コード例 #1
0
        public void RunJob(string xmlFile, string jobName, UnityLoader loader, bool shouldFail)
        {
            // Flush output file
            GetFileNamesOut().ForEach(s => { if (File.Exists(s))
                                             {
                                                 File.Delete(s);
                                             }
                                      });

            // Prerequisites
            GetFileNamesIn().ForEach(s => Assert.IsTrue(new FileInfo(s).Exists, "Job input file " + s + " does not exist, job can't be run"));
            GetFileNamesOut().ForEach(s => Assert.IsFalse(new FileInfo(s).Exists, "Job output file " + s + " should have been deleted before test"));

            XmlJob       job         = XmlJobParser.LoadJob(xmlFile);
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(loader, job);

            Assert.IsNotNull(jobOperator);
            long?executionId = jobOperator.StartNextInstance(jobName);

            Assert.IsNotNull(executionId);

            JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution((long)executionId);

            //job SHOULD BE FAILED because of rollback having occured
            if (shouldFail)
            {
                Assert.IsTrue(jobExecution.Status.IsUnsuccessful());
            }
            else
            {
                Assert.IsFalse(jobExecution.Status.IsUnsuccessful());
            }
            Assert.IsFalse(jobExecution.Status.IsRunning());
        }
コード例 #2
0
        public void RunJobWithTaskletMergeCopy()
        {
            //prepare stuff
            if (!Directory.Exists(TestDataDirectoryToMerge))
            {
                Directory.CreateDirectory(TestDataDirectoryToMerge);
            }

            FileInfo ofi = new FileInfo(Path.Combine(TestDataDirectoryToMerge, "report1_merged_copy.txt"));

            if (!ofi.Exists)
            {
                using (FileStream fs = File.OpenRead(Path.Combine(TestDataDirectoryIn, "report0.txt")))
                    using (FileStream ofs = File.OpenWrite(Path.Combine(TestDataDirectoryToMerge, "report1_merged_copy.txt")))
                    {
                        fs.CopyTo(ofs);
                    }
            }

            XmlJob       job         = XmlJobParser.LoadJob("Job1.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderJob1MergeCopy(), job);

            Assert.IsNotNull(jobOperator);
            long?executionId = jobOperator.StartNextInstance(job.Id);

            Assert.IsNotNull(executionId);

            JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution((long)executionId);

            Assert.IsFalse(jobExecution.Status.IsUnsuccessful());
            Assert.IsFalse(jobExecution.Status.IsRunning());
        }
コード例 #3
0
        public void RunJobWithTasklet()
        {
            XmlJob       job         = XmlJobParser.LoadJob("Job1.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderJob1(), job);

            Assert.IsNotNull(jobOperator);
            Assert.AreEqual(1, jobOperator.StartNextInstance(job.Id));
        }
コード例 #4
0
        public void RunJobWithTasklet()
        {
            XmlJob       job         = XmlJobParser.LoadJob("JobSqlScript.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderJob1(), job);

            Assert.IsNotNull(jobOperator);
            Assert.AreEqual(1, jobOperator.StartNextInstance(job.Id));
            JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution(1);

            Assert.IsFalse(jobExecution.Status.IsUnsuccessful());
        }
コード例 #5
0
        public void PowerShellExitStatus()
        {
            XmlJob       job         = XmlJobParser.LoadJob("JobPowerShellExitStatus.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderPowerShellExitStatus(), job);

            Assert.IsNotNull(jobOperator);
            long?executionId = jobOperator.StartNextInstance(job.Id);

            Assert.IsNotNull(executionId);
            JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution((long)executionId);

            Assert.IsFalse(jobExecution.Status.IsUnsuccessful());
            Assert.IsFalse(jobExecution.Status.IsRunning());
        }
コード例 #6
0
        public void RunJobWithTaskletReset()
        {
            FileUtils.CopyDir(TestDataDirectoryIn, TestDataDirectoryToReset);

            XmlJob       job         = XmlJobParser.LoadJob("Job1.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderJob1Reset(), job);

            Assert.IsNotNull(jobOperator);
            long?executionId = jobOperator.StartNextInstance(job.Id);

            Assert.IsNotNull(executionId);

            JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution((long)executionId);

            Assert.IsFalse(jobExecution.Status.IsUnsuccessful());
            Assert.IsFalse(jobExecution.Status.IsRunning());
        }
コード例 #7
0
        public void RunJobWithTaskletMerge()
        {
            if (!Directory.Exists(TestDataDirectoryToMerge))
            {
                Directory.CreateDirectory(TestDataDirectoryToMerge);
            }

            XmlJob       job         = XmlJobParser.LoadJob("Job1.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderJob1Merge(), job);

            Assert.IsNotNull(jobOperator);
            long?executionId = jobOperator.StartNextInstance(job.Id);

            Assert.IsNotNull(executionId);

            JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution((long)executionId);

            Assert.IsFalse(jobExecution.Status.IsUnsuccessful());
            Assert.IsFalse(jobExecution.Status.IsRunning());
        }
コード例 #8
0
        public void RunJobWithTasklet()
        {
            //Delete any prior existing output file
            FileInfo priorOutputFile = new FileInfo(TestPathOut);

            if (priorOutputFile.Exists)
            {
                priorOutputFile.Delete();
            }

            XmlJob       job         = XmlJobParser.LoadJob("Job1.xml");
            IJobOperator jobOperator = BatchRuntime.GetJobOperator(new MyUnityLoaderJob1(), job);

            Assert.IsNotNull(jobOperator);
            Assert.AreEqual(1, jobOperator.StartNextInstance(job.Id));

            // Post controls
            FileInfo outputFile = new FileInfo(TestPathOut);

            Assert.IsTrue(outputFile.Exists, "Job output file does not exist, job was not successful");
            Assert.IsTrue(outputFile.Length > 0, "Job output file is empty, job was not successful");
        }