public void TestStringToPropertiesEmpty() { string s = ""; NameValueCollection props = PropertiesConverter.StringToProperties(s); Assert.AreEqual(0, props.Count); }
/// <summary> /// @see IJobOperator#Start . /// </summary> /// <param name="jobName"></param> /// <param name="parameters"></param> /// <returns></returns> /// <exception cref="NoSuchJobException"> </exception> /// <exception cref="JobInstanceAlreadyExistsException"> </exception> /// <exception cref="JobParametersInvalidException"> </exception> public long?Start(string jobName, string parameters) { _logger.Info("Checking status of job with name= {0}", jobName); JobParameters jobParameters = _jobParametersConverter.GetJobParameters(PropertiesConverter.StringToProperties(parameters)); if (JobRepository.IsJobInstanceExists(jobName, jobParameters)) { throw new JobInstanceAlreadyExistsException(string.Format("Cannot start a job instance that already exists with name={0} and parameters={1}", jobName, parameters)); } IJob job = JobRegistry.GetJob(jobName); _logger.Info("Attempting to launch job with name={0} and parameters={1}", jobName, parameters); try { return(JobLauncher.Run(job, jobParameters).Id); } catch (JobExecutionAlreadyRunningException e) { throw new UnexpectedJobExecutionException(string.Format(IllegalStateMsg, "job execution already running", jobName, parameters), e); } catch (JobRestartException e) { throw new UnexpectedJobExecutionException(string.Format(IllegalStateMsg, "job not restartable", jobName, parameters), e); } catch (JobInstanceAlreadyCompleteException e) { throw new UnexpectedJobExecutionException(string.Format(IllegalStateMsg, "job already complete", jobName, parameters), e); } }
public void TestStringToProperties() { string s = "prop1=val1,prop2=val2"; NameValueCollection props = PropertiesConverter.StringToProperties(s); Assert.AreEqual(props.Count, 2); Assert.AreEqual("val1", props.Get("prop1")); Assert.AreEqual("val2", props.Get("prop2")); }
public void TestPropertiesToStringId1() { NameValueCollection props = new NameValueCollection { { "aa", "bb" }, { "bb", "aa" } }; NameValueCollection props2 = PropertiesConverter.StringToProperties(PropertiesConverter.PropertiesToString(props)); Assert.AreEqual(2, props2.Count); Assert.AreEqual("bb", props2.Get("aa")); Assert.AreEqual("aa", props2.Get("bb")); }
public void TestPropertiesToString() { string s1 = "prop1=val1,prop2=val2"; string s2 = "prop2=val2,prop1=val1"; NameValueCollection props = new NameValueCollection { { "prop1", "val1" }, { "prop2", "val2" } }; string result = PropertiesConverter.PropertiesToString(props); Assert.IsTrue(result.Equals(s1) || result.Equals(s2)); }
public void TestPropertiesToStringId2() { // Warning: = in the key is not handled properly, = in the value is OK NameValueCollection props = new NameValueCollection { { "a=a", "bb" }, { "bb", "a=a" } }; NameValueCollection props2 = PropertiesConverter.StringToProperties(PropertiesConverter.PropertiesToString(props)); Assert.AreEqual(2, props2.Count); Assert.AreEqual("a=bb", props2.Get("a")); Assert.AreEqual("a=a", props2.Get("bb")); }
public void TestPropertiesToStringEmpty() { NameValueCollection props = new NameValueCollection(); Assert.AreEqual("", PropertiesConverter.PropertiesToString(props)); }
/// <summary> /// @see IJobOperator#GetParameters . /// </summary> /// <param name="executionId"></param> /// <returns></returns> /// <exception cref="NoSuchJobExecutionException"> </exception> public string GetParameters(long executionId) { JobExecution jobExecution = FindExecutionById(executionId); return(PropertiesConverter.PropertiesToString(_jobParametersConverter.GetProperties(jobExecution.JobParameters))); }