From e019e98df93d7dcb46b6f029848f43e9f1388aa6 Mon Sep 17 00:00:00 2001 From: robokaso Date: Wed, 16 Jul 2008 08:01:56 +0000 Subject: [PATCH] IN PROGRESS - BATCH-709: Change all collections to use generics --- .../.settings/org.eclipse.jdt.core.prefs | 8 +-- .../batch/core/StepExecutionTests.java | 10 +++- .../SimpleExportedJobLauncherTests.java | 54 +++++++++++++------ .../ItemOrientedStepIntegrationTests.java | 6 ++- .../core/step/item/ItemOrientedStepTests.java | 18 ++++--- 5 files changed, 67 insertions(+), 29 deletions(-) diff --git a/spring-batch-core/.settings/org.eclipse.jdt.core.prefs b/spring-batch-core/.settings/org.eclipse.jdt.core.prefs index 964c52679..ad9685860 100644 --- a/spring-batch-core/.settings/org.eclipse.jdt.core.prefs +++ b/spring-batch-core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ -#Tue Apr 22 11:16:17 CEST 2008 +#Wed Jul 16 09:54:03 CEST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -79,4 +79,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.4 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java index bed4665e8..28634cf9b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java @@ -36,6 +36,12 @@ public class StepExecutionTests extends TestCase { private StepExecution execution = newStepExecution(new StepSupport("stepName"), new Long(23)); private StepExecution blankExecution = newStepExecution(new StepSupport("blank"), null); + + private ExecutionContext foobarEc = new ExecutionContext() { + { + put("foo", "bar"); + } + }; public void testStepExecution() { assertNull(new StepExecution("step", null).getId()); @@ -206,7 +212,7 @@ public class StepExecutionTests extends TestCase { Set set = new HashSet(); set.add(execution); assertTrue(set.contains(execution)); - execution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + execution.setExecutionContext(foobarEc); assertTrue(set.contains(execution)); } @@ -214,7 +220,7 @@ public class StepExecutionTests extends TestCase { ExitStatus status = ExitStatus.NOOP; execution.setExitStatus(status); - execution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + execution.setExecutionContext(foobarEc); byte[] serialized = SerializationUtils.serialize(execution); StepExecution deserialized = (StepExecution) SerializationUtils.deserialize(serialized); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleExportedJobLauncherTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleExportedJobLauncherTests.java index 3c35fc9af..5086a31f3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleExportedJobLauncherTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleExportedJobLauncherTests.java @@ -55,8 +55,11 @@ public class SimpleExportedJobLauncherTests extends TestCase { public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException { JobExecution result = new JobExecution(null); StepExecution stepExecution = result.createStepExecution(new StepSupport("stepName")); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter - .stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(new ExecutionContext() { + { + put("foo", "bar"); + } + }); list.add(jobParameters); return result; } @@ -67,7 +70,8 @@ public class SimpleExportedJobLauncherTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#afterPropertiesSet()}. + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#afterPropertiesSet()} + * . * * @throws Exception */ @@ -76,15 +80,18 @@ public class SimpleExportedJobLauncherTests extends TestCase { try { launcher.afterPropertiesSet(); fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException e) { String message = e.getMessage(); - assertTrue("Message does not contain 'launcher': " + message, contains(message.toLowerCase(), "joblauncher")); + assertTrue("Message does not contain 'launcher': " + message, + contains(message.toLowerCase(), "joblauncher")); } } /** * Test method for - * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#afterPropertiesSet()}. + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#afterPropertiesSet()} + * . * * @throws Exception */ @@ -98,14 +105,17 @@ public class SimpleExportedJobLauncherTests extends TestCase { try { launcher.afterPropertiesSet(); fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException e) { String message = e.getMessage(); assertTrue("Message does not contain 'locator': " + message, contains(message.toLowerCase(), "joblocator")); } } /** - * Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()}. + * Test method for + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()} + * . */ public void testGetStatistics() { Properties props = launcher.getStatistics(); @@ -114,7 +124,9 @@ public class SimpleExportedJobLauncherTests extends TestCase { } /** - * Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()}. + * Test method for + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#getStatistics()} + * . * * @throws Exception */ @@ -127,7 +139,9 @@ public class SimpleExportedJobLauncherTests extends TestCase { } /** - * Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()}. + * Test method for + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()} + * . * * @throws Exception */ @@ -138,7 +152,9 @@ public class SimpleExportedJobLauncherTests extends TestCase { } /** - * Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()}. + * Test method for + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#isRunning()} + * . * * @throws Exception */ @@ -150,12 +166,14 @@ public class SimpleExportedJobLauncherTests extends TestCase { } }); String value = launcher.run("foo"); - assertTrue("Return value was not an exception: " + value, contains(value, "JobExecutionAlreadyRunningException")); + assertTrue("Return value was not an exception: " + value, + contains(value, "JobExecutionAlreadyRunningException")); } /** * Test method for - * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)}. + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)} + * . */ public void testRunNonExistentJob() { String value = launcher.run("foo"); @@ -164,7 +182,8 @@ public class SimpleExportedJobLauncherTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)}. + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)} + * . * * @throws Exception */ @@ -177,7 +196,8 @@ public class SimpleExportedJobLauncherTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)}. + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#run(java.lang.String)} + * . * * @throws Exception */ @@ -198,7 +218,9 @@ public class SimpleExportedJobLauncherTests extends TestCase { } /** - * Test method for {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#stop()}. + * Test method for + * {@link org.springframework.batch.core.launch.support.SimpleExportedJobLauncher#stop()} + * . * * @throws Exception */ diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java index e0c13cfef..0c25e7b85 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java @@ -139,7 +139,11 @@ public class ItemOrientedStepIntegrationTests extends AbstractDependencyInjectio JobExecution jobExecution = jobRepository.createJobExecution(job, new JobParameters()); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(new ExecutionContext() { + { + put("foo", "bar"); + } + }); // step.setLastExecution(stepExecution); try { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java index ac20e5cb8..591c5075f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java @@ -80,6 +80,12 @@ public class ItemOrientedStepTests extends TestCase { private JobInstance jobInstance; private ResourcelessTransactionManager transactionManager; + + private ExecutionContext foobarEc = new ExecutionContext() { + { + put("foo", "bar"); + } + }; private ItemReader getReader(String[] args) { return new ListItemReader(Arrays.asList(args)); @@ -529,7 +535,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(foobarEc); try { itemOrientedStep.execute(stepExecution); @@ -556,7 +562,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { @@ -583,7 +589,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { @@ -616,7 +622,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { @@ -644,7 +650,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { @@ -706,7 +712,7 @@ public class ItemOrientedStepTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); - stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try {