public void Initialize() { _jobInstance = new JobInstance(1, "testJob"); _jobExecution = new JobExecution(_jobInstance, new JobParameters()); _stepExecution1 = new StepExecution("testStep1", _jobExecution, 1); _stepExecution2 = new StepExecution("testStep2", _jobExecution, 2); }
public void Initialize() { _jobExecutionDao = new MapJobExecutionDao(); _instance = new JobInstance(1, "testJob"); _parameters = new JobParameters(); _execution = new JobExecution(_instance, _parameters); }
/// <summary> /// Constructor with mandatory properties. /// </summary> /// <param name="stepName"></param> /// <param name="jobExecution"></param> /// <param name="id"></param> public StepExecution(string stepName, JobExecution jobExecution, long id) : this(stepName, jobExecution) { Assert.NotNull(jobExecution, "JobExecution must be provided to re-hydrate an existing StepExecution"); Assert.NotNull(id, "The entity Id must be provided to re-hydrate an existing StepExecution"); Id = id; jobExecution.AddStepExecution(this); }
public void TestClear() { var execution = new JobExecution(1); var originalContext = new ExecutionContext(); execution.ExecutionContext = originalContext; _executionContextDao.SaveExecutionContext(execution); _executionContextDao.Clear(); _executionContextDao.GetExecutionContext(execution); }
/// <summary> /// Launched before the job. Fills the job context with the injected properties. /// </summary> /// <param name="jobExecution"></param> public void BeforeJob(JobExecution jobExecution) { ExecutionContext context = jobExecution.ExecutionContext; if (Properties != null) { foreach (KeyValuePair<string,string> entry in Properties) { context.PutString(entry.Key,entry.Value); } } }
public void TestSaveExecutionContextJob1() { var execution = new JobExecution(1); var originalContext = new ExecutionContext(); execution.ExecutionContext = originalContext; _executionContextDao.SaveExecutionContext(execution); var context = _executionContextDao.GetExecutionContext(execution); Assert.AreEqual(originalContext, context); }
public void TestSaveExecutionContextStep1() { Insert(@"TestData\DbDao\ExecutionContextTestData.xml"); var jobExecution = new JobExecution(1); var execution = new StepExecution("TestStep", jobExecution, 1); var originalContext = new ExecutionContext(); execution.ExecutionContext = originalContext; _executionContextDao.SaveExecutionContext(execution); var context = _executionContextDao.GetExecutionContext(execution); Assert.AreEqual(originalContext, context); }
public void TestSaveExecutionContextJob2() { var execution = new JobExecution(1); var originalContext = new ExecutionContext(); execution.ExecutionContext = originalContext; originalContext.PutString("test1", "test1"); originalContext.PutLong("test2", 2L); _executionContextDao.SaveExecutionContext(execution); var context = _executionContextDao.GetExecutionContext(execution); Assert.AreEqual(originalContext, context); }
public void TestFindJobExecutions() { var execution2 = new JobExecution(_instance, _parameters); var instance2 = new JobInstance(2, "testJob2"); var execution3 = new JobExecution(instance2, _parameters); _jobExecutionDao.SaveJobExecution(_execution); _jobExecutionDao.SaveJobExecution(execution2); _jobExecutionDao.SaveJobExecution(execution3); var executions = _jobExecutionDao.FindJobExecutions(_instance); Assert.AreEqual(2, executions.Count); Assert.IsTrue(executions.Contains(_execution)); Assert.IsTrue(executions.Contains(execution2)); }
public new void Initialize() { base.Initialize(); _stepExecutionDao = new DbStepExecutionDao { DbOperator = DbOperator, PlaceholderGetter = new PlaceholderGetter(name => "@" + name, true), StepIncrementer = new SqlServerIncrementer { ConnectionStringSettings = ConnectionStringSettings, IncrementerName = "BATCH_STEP_EXECUTION_SEQ", ColumnName = "ID" } }; _jobExecution = new JobExecution(1); }
/// <summary> /// Custom constructor using JobExecution. /// </summary> /// <param name="original"></param> public JobExecution(JobExecution original) { JobParameters = original.JobParameters; JobInstance = original.JobInstance; _stepExecutions = original._stepExecutions; _status = original.Status; StartTime = original.StartTime; CreateTime = original.CreateTime; EndTime = original.EndTime; LastUpdated = original.LastUpdated; _exitStatus = original.ExitStatus; _executionContext = original.ExecutionContext; _failureExceptions = original.FailureExceptions; _jobConfigurationName = original.JobConfigurationName; Id = original.Id; Version = original.Version; }
public void TestSaveJobExecution() { ResetSequence("BATCH_JOB_EXECUTION_SEQ"); Insert(@"TestData\DbDao\JobExecutionTestData1.xml"); var dictionary = new Dictionary<string, JobParameter>(); dictionary["string"] = new JobParameter("string"); dictionary["long"] = new JobParameter(3); dictionary["double"] = new JobParameter(4.3); dictionary["date"] = new JobParameter(DateTime.Now); _parameters = new JobParameters(dictionary); _execution = new JobExecution(_instance, _parameters); _jobExecutionDao.SaveJobExecution(_execution); Assert.AreEqual(1L, _execution.Id); Assert.AreEqual(_execution, _jobExecutionDao.GetJobExecution(1L)); }
public new void Initialize() { base.Initialize(); _jobExecutionDao = new DbJobExecutionDao { DbOperator = DbOperator, PlaceholderGetter = new PlaceholderGetter(name => "@" + name, true), JobIncrementer = new SqlServerIncrementer { IncrementerName = "BATCH_JOB_EXECUTION_SEQ", ConnectionStringSettings = ConnectionStringSettings, ColumnName = "ID" } }; _instance = new JobInstance(1, "TestJob"); _parameters = new JobParameters(); _execution = new JobExecution(_instance, _parameters); }
/// <summary> /// Retrieves all job executions for a given minimal status /// </summary> /// <param name="jobIdentifier"></param> /// <param name="minStatus"></param> /// <param name="jobExplorer"></param> /// <returns></returns> private static List <JobExecution> GetJobExecutionsWithStatusGreaterThan(string jobIdentifier, BatchStatus minStatus, IJobExplorer jobExplorer) { long?executionId = GetLongIdentifier(jobIdentifier); if (executionId != null) { JobExecution jobExecution = jobExplorer.GetJobExecution(executionId.Value); if (jobExecution.Status.IsGreaterThan(minStatus)) { return(new List <JobExecution> { jobExecution }); } //empmty list return(new List <JobExecution>()); } int start = 0; int count = 100; List <JobExecution> executions = new List <JobExecution>(); IList <JobInstance> lastInstances = jobExplorer.GetJobInstances(jobIdentifier, start, count); while (lastInstances.Any()) { foreach (JobInstance jobInstance in lastInstances) { IList <JobExecution> jobExecutions = jobExplorer.GetJobExecutions(jobInstance); if (jobExecutions == null || !jobExecutions.Any()) { continue; } executions.AddRange( jobExecutions.Where(jobExecution => jobExecution.Status.IsGreaterThan(minStatus))); } start += count; lastInstances = jobExplorer.GetJobInstances(jobIdentifier, start, count); } return(executions); }
/// <summary> /// Custom constructor used for serialize/deserialize /// </summary> /// <param name="original"></param> /// <param name="stepExecutions"></param> public JobExecution(JobExecution original, ICollection <StepExecution> stepExecutions) { JobParameters = original.JobParameters; JobInstance = original.JobInstance; _status = original.Status; StartTime = original.StartTime; CreateTime = original.CreateTime; EndTime = original.EndTime; LastUpdated = original.LastUpdated; _exitStatus = original.ExitStatus; _executionContext = original.ExecutionContext; _failureExceptions = original.FailureExceptions; _jobConfigurationName = original.JobConfigurationName; Id = original.Id; Version = original.Version; _stepExecutions = new ConcurrentBag <StepExecution>(); if (stepExecutions != null) { foreach (StepExecution item in stepExecutions) { _stepExecutions.TryAdd(item); } } }
public void TestGetJobInstanceJobExecution() { Insert(@"TestData\DbDao\JobInstanceTestData1.xml"); var jobExecution = new JobExecution(1L); var instance = _jobInstanceDao.GetJobInstance(jobExecution); Assert.IsNotNull(instance); Assert.AreEqual("TestJob", instance.JobName); }
public void Initialize() { _stepExecutionDao = new MapStepExecutionDao(); _jobExecution = new JobExecution(1L); }
public void TestGetLastJobExecution() { var execution2 = new JobExecution(_instance, _parameters); _execution.CreateTime = DateTime.Now; _jobExecutionDao.SaveJobExecution(_execution); execution2.CreateTime = DateTime.Now.AddMinutes(1); _jobExecutionDao.SaveJobExecution(execution2); var lastExecution = _jobExecutionDao.GetLastJobExecution(_instance); Assert.AreEqual(execution2, lastExecution); }
/// <summary> /// Constructor that substitues in null for execution id. /// </summary> /// <param name="stepName"></param> /// <param name="jobExecution"></param> public StepExecution(string stepName, JobExecution jobExecution) { Assert.HasLength(stepName); _stepName = stepName; _jobExecution = jobExecution; }
public void TestSynchronizeStatus() { _jobExecutionDao.SaveJobExecution(_execution); var execution2 = new JobExecution(_execution); _execution.Status = BatchStatus.Completed; _execution.EndTime = DateTime.Now; _jobExecutionDao.UpdateJobExecution(_execution); _jobExecutionDao.SynchronizeStatus(execution2); Assert.AreEqual(BatchStatus.Completed, execution2.Status); Assert.AreEqual(_execution.Version, execution2.Version); Assert.AreNotEqual(_execution.EndTime, execution2.EndTime); }
public void TestFindRunningJobExecutions() { var instance2 = new JobInstance(2, "testJob2"); var execution2 = new JobExecution(instance2, _parameters); _jobExecutionDao.SaveJobExecution(_execution); _jobExecutionDao.SaveJobExecution(execution2); var runningExecutions = _jobExecutionDao.FindRunningJobExecutions("testJob"); Assert.AreEqual(1, runningExecutions.Count); Assert.IsTrue(runningExecutions.Contains(_execution)); }
/// <summary> /// Launched after the job. Not used, thus does nothing. /// </summary> /// <param name="jobExecution"></param> public void AfterJob(JobExecution jobExecution) { //do nothing, on purpose. }
public void TestSaveExecutionContexts() { Insert(@"TestData\DbDao\ExecutionContextTestData.xml"); var jobExecution = new JobExecution(1); var execution1 = new StepExecution("TestStep", jobExecution, 1); var execution2 = new StepExecution("TestStep", jobExecution, 2); execution1.ExecutionContext = new ExecutionContext(); execution2.ExecutionContext = new ExecutionContext(); execution2.ExecutionContext.PutString("test1", "test1"); execution2.ExecutionContext.PutLong("test2", 2L); IList<StepExecution> executions = new List<StepExecution>(); executions.Add(execution1); executions.Add(execution2); _executionContextDao.SaveExecutionContexts(executions); var context1 = _executionContextDao.GetExecutionContext(execution1); var context2 = _executionContextDao.GetExecutionContext(execution2); Assert.AreEqual(execution1.ExecutionContext, context1); Assert.AreEqual(execution2.ExecutionContext, context2); }