@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2013 the original author or authors.
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,17 +54,6 @@ public class DefaultJobKeyGeneratorTests {
|
||||
assertEquals(32, key.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateJobKeyWithNullParameter() {
|
||||
JobParameters jobParameters1 = new JobParametersBuilder().addString(
|
||||
"foo", "bar").addString("bar", null).toJobParameters();
|
||||
JobParameters jobParameters2 = new JobParametersBuilder().addString(
|
||||
"foo", "bar").addString("bar", "").toJobParameters();
|
||||
String key1 = jobKeyGenerator.generateKey(jobParameters1);
|
||||
String key2 = jobKeyGenerator.generateKey(jobParameters2);
|
||||
assertEquals(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateJobKeyOrdering() {
|
||||
JobParameters jobParameters1 = new JobParametersBuilder().addString(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2013 the original author or authors.
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,10 +37,9 @@ public class JobParameterTests {
|
||||
assertEquals("test", jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullStringParameter(){
|
||||
jobParameter = new JobParameter((String)null, true);
|
||||
assertEquals(null, jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,10 +61,9 @@ public class JobParameterTests {
|
||||
assertEquals(new Date(0L), jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullDateParameter(){
|
||||
jobParameter = new JobParameter((Date)null, true);
|
||||
assertEquals(null, jobParameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,25 +87,4 @@ public class JobParameterTests {
|
||||
assertEquals(testParameter.hashCode(), jobParameter.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithNull(){
|
||||
jobParameter = new JobParameter((String)null, true);
|
||||
JobParameter testParameter = new JobParameter((String)null, true);
|
||||
assertTrue(jobParameter.equals(testParameter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsWithNullAndDifferentType(){
|
||||
jobParameter = new JobParameter((String)null, true);
|
||||
JobParameter testParameter = new JobParameter((Date)null, true);
|
||||
assertFalse(jobParameter.equals(testParameter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashcodeWithNull(){
|
||||
jobParameter = new JobParameter((String)null, true);
|
||||
JobParameter testParameter = new JobParameter((String)null, true);
|
||||
assertEquals(testParameter.hashCode(), jobParameter.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,20 +120,6 @@ public class JobParametersBuilderTests {
|
||||
assertEquals("string value", parameters.getString("STRING"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullRuntimeParameters(){
|
||||
this.parametersBuilder.addDate("SCHEDULE_DATE", null);
|
||||
this.parametersBuilder.addLong("LONG", null);
|
||||
this.parametersBuilder.addString("STRING", null);
|
||||
this.parametersBuilder.addDouble("DOUBLE", null);
|
||||
|
||||
JobParameters parameters = this.parametersBuilder.toJobParameters();
|
||||
assertNull(parameters.getDate("SCHEDULE_DATE"));
|
||||
assertNull(parameters.getLong("LONG"));
|
||||
assertNull(parameters.getString("STRING"));
|
||||
assertNull(parameters.getLong("DOUBLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopy(){
|
||||
this.parametersBuilder.addString("STRING", "string value");
|
||||
|
||||
@@ -74,12 +74,6 @@ public class JobParametersTests {
|
||||
assertEquals("value2", parameters.getString("string.key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNullString() {
|
||||
parameters = new JobParameters(Collections.singletonMap("string.key1", new JobParameter((String) null, true)));
|
||||
assertNull(parameters.getDate("string.key1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLong() {
|
||||
assertEquals(1L, parameters.getLong("long.key1").longValue());
|
||||
@@ -98,18 +92,6 @@ public class JobParametersTests {
|
||||
assertEquals(date2, parameters.getDate("date.key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNullDate() {
|
||||
parameters = new JobParameters(Collections.singletonMap("date.key1", new JobParameter((Date)null, true)));
|
||||
assertNull(parameters.getDate("date.key1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEmptyLong() {
|
||||
parameters = new JobParameters(Collections.singletonMap("long1", new JobParameter((Long)null, true)));
|
||||
assertNull(parameters.getLong("long1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMissingLong() {
|
||||
assertNull(parameters.getLong("missing.long1"));
|
||||
@@ -231,14 +213,4 @@ public class JobParametersTests {
|
||||
assertNull(new JobParameters().getDate("keythatdoesntexist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToPropertiesWithNullValue() {
|
||||
Map<String, JobParameter> parameterMap = new HashMap<>();
|
||||
Long value = null;
|
||||
parameterMap.put("nullkey", new JobParameter(value));
|
||||
JobParameters jobParameters = new JobParameters(parameterMap);
|
||||
|
||||
Properties properties = jobParameters.toProperties();
|
||||
assertEquals("", properties.get("nullkey"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,21 +331,4 @@ public class DefaultJobParametersConverterTests {
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPropertiesWithNullValues() throws Exception {
|
||||
|
||||
JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", null)
|
||||
.addString("job.key", null).addLong("vendor.id", null).addDouble("double.key", null)
|
||||
.toJobParameters();
|
||||
|
||||
Properties props = factory.getProperties(parameters);
|
||||
assertNotNull(props);
|
||||
|
||||
final String NOT_FOUND = "NOT FOUND";
|
||||
assertEquals(NOT_FOUND, props.getProperty("schedule.date", NOT_FOUND));
|
||||
assertEquals(NOT_FOUND, props.getProperty("job.key", NOT_FOUND));
|
||||
assertEquals(NOT_FOUND, props.getProperty("vendor.id", NOT_FOUND));
|
||||
assertEquals(NOT_FOUND, props.getProperty("double.key", NOT_FOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,29 +411,6 @@ public class SimpleJobTests {
|
||||
assertFalse(step2.passedInStepContext.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestartWithNullParameter() throws Exception {
|
||||
|
||||
JobParameters jobParameters = new JobParametersBuilder().addString("foo", null).toJobParameters();
|
||||
jobExecution = jobRepository.createJobExecution(job.getName(), jobParameters);
|
||||
jobInstance = jobExecution.getJobInstance();
|
||||
|
||||
step1.setAllowStartIfComplete(true);
|
||||
final RuntimeException exception = new RuntimeException("Foo!");
|
||||
step2.setProcessException(exception);
|
||||
|
||||
job.execute(jobExecution);
|
||||
Throwable e = jobExecution.getAllFailureExceptions().get(0);
|
||||
assertSame(exception, e);
|
||||
|
||||
jobExecution = jobRepository.createJobExecution(job.getName(), jobParameters);
|
||||
job.execute(jobExecution);
|
||||
e = jobExecution.getAllFailureExceptions().get(0);
|
||||
assertSame(exception, e);
|
||||
assertTrue(step1.passedInStepContext.isEmpty());
|
||||
assertFalse(step2.passedInStepContext.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterruptWithListener() throws Exception {
|
||||
step1.setProcessException(new JobInterruptedException("job interrupted!"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2019 the original author or authors.
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,24 +67,6 @@ public abstract class AbstractJobInstanceDaoTests {
|
||||
assertEquals(fooJob, retrievedInstance.getJobName());
|
||||
}
|
||||
|
||||
/*
|
||||
* Create and retrieve a job instance.
|
||||
*/
|
||||
@Transactional
|
||||
@Test
|
||||
public void testCreateAndRetrieveWithNullParameter() throws Exception {
|
||||
|
||||
JobParameters jobParameters = new JobParametersBuilder().addString("foo", null).toJobParameters();
|
||||
|
||||
JobInstance fooInstance = dao.createJobInstance(fooJob, jobParameters);
|
||||
assertNotNull(fooInstance.getId());
|
||||
assertEquals(fooJob, fooInstance.getJobName());
|
||||
|
||||
JobInstance retrievedInstance = dao.getJobInstance(fooJob, jobParameters);
|
||||
assertEquals(fooInstance, retrievedInstance);
|
||||
assertEquals(fooJob, retrievedInstance.getJobName());
|
||||
}
|
||||
|
||||
/*
|
||||
* Create and retrieve a job instance.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user