From 9268abc215c57e5469dc4138ca653d77e49a607f Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sun, 8 Nov 2020 16:16:26 +0100 Subject: [PATCH] Don't call wrapper constructors directly The constructors of the wrapper classes for primitives (Double, Integer, Long) have been deprecated since JDK 9 and should no longer be called. Instead the static factory #valueOf should be used. --- .../football/FootballJobIntegrationTests.java | 4 ++-- ...SplitJobMapRepositoryIntegrationTests.java | 4 ++-- .../launch/support/CommandLineJobRunner.java | 2 +- .../repository/dao/JdbcJobExecutionDao.java | 4 ++-- .../dao/MapExecutionContextDao.java | 2 +- .../batch/core/EntityTests.java | 8 ++++---- .../batch/core/JobExecutionTests.java | 8 ++++---- .../batch/core/JobInstanceTests.java | 8 ++++---- .../batch/core/JobParametersBuilderTests.java | 16 +++++++-------- .../batch/core/JobParametersTests.java | 4 ++-- .../batch/core/StepExecutionTests.java | 20 +++++++++---------- .../xml/StepParserStepFactoryBeanTests.java | 4 ++-- .../configuration/xml/StepParserTests.java | 4 ++-- .../DefaultJobParametersConverterTests.java | 4 ++-- .../support/CommandLineJobRunnerTests.java | 4 ++-- ...MaxValueJobParametersIncrementerTests.java | 6 +++--- .../support/SimpleJvmExitCodeMapperTests.java | 12 +++++------ .../CompositeJobExecutionListenerTests.java | 4 ++-- .../listener/JobListenerFactoryBeanTests.java | 6 +++--- .../dao/AbstractExecutionContextDaoTests.java | 4 ++-- ...stractExecutionContextSerializerTests.java | 2 +- .../dao/AbstractStepExecutionDaoTests.java | 6 +++--- .../repository/dao/JdbcJobDaoQueryTests.java | 4 ++-- ...pExecutionSimpleCompletionPolicyTests.java | 4 ++-- ...erantStepFactoryBeanNonBufferingTests.java | 4 ++-- .../StepExecutorInterruptionTests.java | 4 ++-- .../JdbcPagingRestartIntegrationTests.java | 4 ++-- .../item/adapter/AbstractDelegatorTests.java | 4 ++-- .../builder/KafkaItemReaderBuilderTests.java | 4 ++-- .../integration/chunk/ChunkResponseTests.java | 6 +++--- .../sample/SkipSampleFunctionalTests.java | 8 ++++---- 31 files changed, 89 insertions(+), 89 deletions(-) diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobIntegrationTests.java index d3d56d1e80..2e7fdb520d 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2020 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,7 +67,7 @@ public void testLaunchJob() throws Exception { logger.info("Processed: " + stepExecution); if (stepExecution.getStepName().equals("playerload")) { // The effect of the retries - assertEquals(new Double(Math.ceil(stepExecution.getReadCount() / 10. + 1)).intValue(), + assertEquals((int) Math.ceil(stepExecution.getReadCount() / 10. + 1), stepExecution.getCommitCount()); } } diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java index 7e59b9bdb4..b6889444bc 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2020 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. @@ -69,7 +69,7 @@ public void testMultithreadedSplit() throws Throwable { } try { - JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addLong("count", new Long(i)) + JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addLong("count", (long) i) .toJobParameters()); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java index e7b77844c1..5da1d9820e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java @@ -475,7 +475,7 @@ private List getRunningJobExecutions(String jobIdentifier) { private Long getLongIdentifier(String jobIdentifier) { try { - return new Long(jobIdentifier); + return Long.parseLong(jobIdentifier); } catch (NumberFormatException e) { // Not an ID - must be a name diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java index d7ba625944..f31f969712 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2020 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. @@ -348,7 +348,7 @@ private void insertParameter(Long executionId, ParameterType type, String key, 0L, 0D, identifyingFlag}; } else if (type == ParameterType.LONG) { args = new Object[] { executionId, key, type, "", new Timestamp(0L), - value, new Double(0), identifyingFlag}; + value, 0.0d, identifyingFlag}; } else if (type == ParameterType.DOUBLE) { args = new Object[] { executionId, key, type, "", new Timestamp(0L), 0L, value, identifyingFlag}; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java index 39b36eada7..091ccdd705 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java @@ -65,7 +65,7 @@ public int compareTo(ContextKey them) { if(them == null) { return 1; } - final int idCompare = new Long(this.id).compareTo(new Long(them.id)); // JDK6 Make this Long.compare(x,y) + final int idCompare = Long.compare(this.id, them.id); if(idCompare != 0) { return idCompare; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/EntityTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/EntityTests.java index 79ba98752c..e7719c9f14 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/EntityTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/EntityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2020 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. @@ -23,7 +23,7 @@ */ public class EntityTests extends TestCase { - Entity entity = new Entity(new Long(11)); + Entity entity = new Entity(11L); /** * Test method for {@link org.springframework.batch.core.Entity#hashCode()}. @@ -54,7 +54,7 @@ public void testGetVersion() { */ public void testIncrementVersion() { entity.incrementVersion(); - assertEquals(new Integer(0), entity.getVersion()); + assertEquals(Integer.valueOf(0), entity.getVersion()); } /** @@ -63,7 +63,7 @@ public void testIncrementVersion() { public void testIncrementVersionTwice() { entity.incrementVersion(); entity.incrementVersion(); - assertEquals(new Integer(1), entity.getVersion()); + assertEquals(Integer.valueOf(1), entity.getVersion()); } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java index a81ccbe783..fe3d7a59fe 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2020 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. @@ -35,8 +35,8 @@ */ public class JobExecutionTests { - private JobExecution execution = new JobExecution(new JobInstance(new Long(11), "foo"), - new Long(12), new JobParameters(), null); + private JobExecution execution = new JobExecution(new JobInstance(11L, "foo"), + 12L, new JobParameters(), null); @Test public void testJobExecution() { @@ -135,7 +135,7 @@ public void testDowngradeStatus() { @Test public void testGetJobId() { assertEquals(11, execution.getJobId().longValue()); - execution = new JobExecution(new JobInstance(new Long(23), "testJob"), null, new JobParameters(), null); + execution = new JobExecution(new JobInstance(23L, "testJob"), null, new JobParameters(), null); assertEquals(23, execution.getJobId().longValue()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java index fb9be52eba..32e25fc766 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2020 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. @@ -27,7 +27,7 @@ */ public class JobInstanceTests { - private JobInstance instance = new JobInstance(new Long(11), "job"); + private JobInstance instance = new JobInstance(11L, "job"); /** * Test method for @@ -35,7 +35,7 @@ public class JobInstanceTests { */ @Test public void testGetName() { - instance = new JobInstance(new Long(1), "foo"); + instance = new JobInstance(1L, "foo"); assertEquals("foo", instance.getJobName()); } @@ -59,7 +59,7 @@ public void testCreateWithNulls() { @Test public void testSerialization() { - instance = new JobInstance(new Long(1), "jobName"); + instance = new JobInstance(1L, "jobName"); byte[] serialized = SerializationUtils.serialize(instance); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java index 0b66037dbb..acac1a3cde 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2018 the original author or authors. + * Copyright 2008-2020 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. @@ -96,9 +96,9 @@ public void testAddingExistingJobParameters() { @Test public void testNonIdentifyingParameters() { this.parametersBuilder.addDate("SCHEDULE_DATE", date, false); - this.parametersBuilder.addLong("LONG", new Long(1), false); + this.parametersBuilder.addLong("LONG", 1L, false); this.parametersBuilder.addString("STRING", "string value", false); - this.parametersBuilder.addDouble("DOUBLE", new Double(1), false); + this.parametersBuilder.addDouble("DOUBLE", 1.0d, false); JobParameters parameters = this.parametersBuilder.toJobParameters(); assertEquals(date, parameters.getDate("SCHEDULE_DATE")); @@ -114,9 +114,9 @@ public void testNonIdentifyingParameters() { @Test public void testToJobRuntimeParameters(){ this.parametersBuilder.addDate("SCHEDULE_DATE", date); - this.parametersBuilder.addLong("LONG", new Long(1)); + this.parametersBuilder.addLong("LONG", 1L); this.parametersBuilder.addString("STRING", "string value"); - this.parametersBuilder.addDouble("DOUBLE", new Double(1)); + this.parametersBuilder.addDouble("DOUBLE", 1.0d); JobParameters parameters = this.parametersBuilder.toJobParameters(); assertEquals(date, parameters.getDate("SCHEDULE_DATE")); assertEquals(1L, parameters.getLong("LONG").longValue()); @@ -149,7 +149,7 @@ public void testCopy(){ @Test public void testOrderedTypes(){ this.parametersBuilder.addDate("SCHEDULE_DATE", date); - this.parametersBuilder.addLong("LONG", new Long(1)); + this.parametersBuilder.addLong("LONG", 1L); this.parametersBuilder.addString("STRING", "string value"); Iterator parameters = this.parametersBuilder.toJobParameters().getParameters().keySet().iterator(); assertEquals("SCHEDULE_DATE", parameters.next()); @@ -231,7 +231,7 @@ public void testGetNextJobParametersRestartable(){ when(this.jobExplorer.getJobInstances("simpleJob",0,1)).thenReturn(this.jobInstanceList); when(this.jobExplorer.getJobExecutions(any())).thenReturn(this.jobExecutionList); initializeForNextJobParameters(); - this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", new Long(1), false); + this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", 1L, false); this.parametersBuilder.getNextJobParameters(this.job); baseJobParametersVerify(this.parametersBuilder.toJobParameters(), 5); } @@ -255,7 +255,7 @@ public void testMissingJobExplorer() { private void initializeForNextJobParameters() { this.parametersBuilder.addDate("SCHEDULE_DATE", date); - this.parametersBuilder.addLong("LONG", new Long(1)); + this.parametersBuilder.addLong("LONG", 1L); this.parametersBuilder.addString("STRING", "string value"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java index 68fa481fc4..15fca89632 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java @@ -86,8 +86,8 @@ public void testGetLong() { @Test public void testGetDouble() { - assertEquals(new Double(1.1), new Double(parameters.getDouble("double.key1"))); - assertEquals(new Double(2.2), new Double(parameters.getDouble("double.key2"))); + assertEquals(Double.valueOf(1.1d), parameters.getDouble("double.key1")); + assertEquals(Double.valueOf(2.2d), parameters.getDouble("double.key2")); } @Test 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 d83869f8d4..b18b41c1fd 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2020 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. @@ -38,7 +38,7 @@ */ public class StepExecutionTests { - private StepExecution execution = newStepExecution(new StepSupport("stepName"), new Long(23)); + private StepExecution execution = newStepExecution(new StepSupport("stepName"), 23L); private StepExecution blankExecution = newStepExecution(new StepSupport("blank"), null); @@ -199,26 +199,26 @@ public void testEqualsWithSameName() throws Exception { @Test public void testEqualsWithSameIdentifier() throws Exception { Step step = new StepSupport("stepName"); - Entity stepExecution1 = newStepExecution(step, new Long(11)); - Entity stepExecution2 = newStepExecution(step, new Long(11)); + Entity stepExecution1 = newStepExecution(step, 11L); + Entity stepExecution2 = newStepExecution(step, 11L); assertEquals(stepExecution1, stepExecution2); } @Test public void testEqualsWithNull() throws Exception { - Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11)); + Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L); assertFalse(stepExecution.equals(null)); } @Test public void testEqualsWithNullIdentifiers() throws Exception { - Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11)); + Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L); assertFalse(stepExecution.equals(blankExecution)); } @Test public void testEqualsWithNullJob() throws Exception { - Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11)); + Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L); assertFalse(stepExecution.equals(blankExecution)); } @@ -229,16 +229,16 @@ public void testEqualsWithSelf() throws Exception { @Test public void testEqualsWithDifferent() throws Exception { - Entity stepExecution = newStepExecution(new StepSupport("foo"), new Long(13)); + Entity stepExecution = newStepExecution(new StepSupport("foo"), 13L); assertFalse(execution.equals(stepExecution)); } @Test public void testEqualsWithNullStepId() throws Exception { Step step = new StepSupport("name"); - execution = newStepExecution(step, new Long(31)); + execution = newStepExecution(step, 31L); assertEquals("name", execution.getStepName()); - StepExecution stepExecution = newStepExecution(step, new Long(31)); + StepExecution stepExecution = newStepExecution(step, 31L); assertEquals(stepExecution.getJobExecutionId(), execution.getJobExecutionId()); assertTrue(execution.equals(stepExecution)); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java index c7e047d770..7090026b63 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2020 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. @@ -247,7 +247,7 @@ public void testFaultTolerantStep() throws Exception { Object step = fb.getObject(); assertTrue(step instanceof TaskletStep); Object throttleLimit = ReflectionTestUtils.getField(ReflectionTestUtils.getField(step, "stepOperations"), "throttleLimit"); - assertEquals(new Integer(10), throttleLimit); + assertEquals(Integer.valueOf(10), throttleLimit); Object tasklet = ReflectionTestUtils.getField(step, "tasklet"); assertTrue(tasklet instanceof ChunkOrientedTasklet); assertFalse((Boolean) ReflectionTestUtils.getField(tasklet, "buffering")); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java index c322587302..6c3e762def 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2020 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. @@ -89,7 +89,7 @@ public void testTaskletStepAttributes() throws Exception { TaskletStep bean = (TaskletStep) factory.getObject(); assertEquals("wrong start-limit:", 25, bean.getStartLimit()); Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit"); - assertEquals(new Integer(10), throttleLimit); + assertEquals(Integer.valueOf(10), throttleLimit); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java index 7b6ef08721..b741b9176e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2020 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. @@ -254,7 +254,7 @@ public void testGetParametersWithVeryRoundDouble() throws Exception { public void testGetProperties() throws Exception { JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008")) - .addString("job.key", "myKey").addLong("vendor.id", new Long(33243243)).addDouble("double.key", 1.23) + .addString("job.key", "myKey").addLong("vendor.id", 33243243L).addDouble("double.key", 1.23) .toJobParameters(); Properties props = factory.getProperties(parameters); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java index 8b068fc2bf..39d5cc9834 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2020 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. @@ -76,7 +76,7 @@ public class CommandLineJobRunnerTests { @Before public void setUp() throws Exception { - JobExecution jobExecution = new JobExecution(null, new Long(1), null, null); + JobExecution jobExecution = new JobExecution(null, 1L, null, null); ExitStatus exitStatus = ExitStatus.COMPLETED; jobExecution.setExitStatus(exitStatus); StubJobLauncher.jobExecution = jobExecution; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/DataFieldMaxValueJobParametersIncrementerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/DataFieldMaxValueJobParametersIncrementerTests.java index 23c7b21772..34e5c55db3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/DataFieldMaxValueJobParametersIncrementerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/DataFieldMaxValueJobParametersIncrementerTests.java @@ -70,7 +70,7 @@ public void testGetNext() { // then Long runId = nextParameters.getLong("run.id"); - Assert.assertEquals(new Long(10) ,runId); + Assert.assertEquals(Long.valueOf(10L) ,runId); } @Test @@ -89,7 +89,7 @@ public void testGetNextAppend() { // then Long runId = nextParameters.getLong("run.id"); String foo = nextParameters.getString("foo"); - Assert.assertEquals(new Long(10) ,runId); + Assert.assertEquals(Long.valueOf(10L) ,runId); Assert.assertEquals("bar" ,foo); } @@ -108,6 +108,6 @@ public void testGetNextOverride() { // then Long runId = nextParameters.getLong("run.id"); - Assert.assertEquals(new Long(10) ,runId); + Assert.assertEquals(Long.valueOf(10L) ,runId); } } \ No newline at end of file diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java index cbf37cc002..f08e8c4733 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2020 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. @@ -32,15 +32,15 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { protected void setUp() throws Exception { ecm = new SimpleJvmExitCodeMapper(); Map ecmMap = new HashMap<>(); - ecmMap.put("MY_CUSTOM_CODE", new Integer(3)); + ecmMap.put("MY_CUSTOM_CODE", 3); ecm.setMapping(ecmMap); ecm2 = new SimpleJvmExitCodeMapper(); Map ecm2Map = new HashMap<>(); - ecm2Map.put(ExitStatus.COMPLETED.getExitCode(), new Integer(-1)); - ecm2Map.put(ExitStatus.FAILED.getExitCode(), new Integer(-2)); - ecm2Map.put(ExitCodeMapper.JOB_NOT_PROVIDED, new Integer(-3)); - ecm2Map.put(ExitCodeMapper.NO_SUCH_JOB, new Integer(-3)); + ecm2Map.put(ExitStatus.COMPLETED.getExitCode(), -1); + ecm2Map.put(ExitStatus.FAILED.getExitCode(), -2); + ecm2Map.put(ExitCodeMapper.JOB_NOT_PROVIDED, -3); + ecm2Map.put(ExitCodeMapper.NO_SUCH_JOB, -3); ecm2.setMapping(ecm2Map); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java index 30580fed7e..9640b709d1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2020 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. @@ -82,7 +82,7 @@ public void beforeJob(JobExecution stepExecution) { list.add("foo"); } }); - listener.beforeJob(new JobExecution(new JobInstance(new Long(11L), "testOpenJob"), null)); + listener.beforeJob(new JobExecution(new JobInstance(11L, "testOpenJob"), null)); assertEquals(1, list.size()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java index e1d4628686..c6e1806235 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2020 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. @@ -161,7 +161,7 @@ public void testRightSignatureAnnotation() { @AfterJob public void aMethod(JobExecution jobExecution) { executed = true; - assertEquals(new Long(25), jobExecution.getId()); + assertEquals(Long.valueOf(25L), jobExecution.getId()); } }; factoryBean.setDelegate(delegate); @@ -205,7 +205,7 @@ public void testRightSignatureNamedMethod() { @SuppressWarnings("unused") public void aMethod(JobExecution jobExecution) { executed = true; - assertEquals(new Long(25), jobExecution.getId()); + assertEquals(Long.valueOf(25L), jobExecution.getId()); } }; factoryBean.setDelegate(delegate); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java index 7aae0704d8..0ebf399270 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2013 the original author or authors. + * Copyright 2008-2020 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. @@ -218,7 +218,7 @@ public void testUpdateStepContext() { public void testStoreInteger() { ExecutionContext ec = new ExecutionContext(); - ec.put("intValue", new Integer(343232)); + ec.put("intValue", 343232); stepExecution.setExecutionContext(ec); contextDao.saveExecutionContext(stepExecution); ExecutionContext restoredEc = contextDao.getExecutionContext(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java index 5d2a8b61bc..01c14fd4f1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java @@ -48,7 +48,7 @@ public void testSerializeAMap() throws Exception { m1.put("object2", "OBJECT TWO"); // Use a date after 1971 (otherwise daylight saving screws up)... m1.put("object3", new Date(123456790123L)); - m1.put("object4", new Double(1234567.1234D)); + m1.put("object4", 1234567.1234D); Map m2 = serializationRoundTrip(m1); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java index fbcaba3d80..f671f1a4cc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2020 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. @@ -295,11 +295,11 @@ public void testConcurrentModificationException() { exec2.setId(exec1.getId()); exec2.incrementVersion(); - assertEquals(new Integer(0), exec1.getVersion()); + assertEquals(Integer.valueOf(0), exec1.getVersion()); assertEquals(exec1.getVersion(), exec2.getVersion()); dao.updateStepExecution(exec1); - assertEquals(new Integer(1), exec1.getVersion()); + assertEquals(Integer.valueOf(1), exec1.getVersion()); try { dao.updateStepExecution(exec2); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java index 9c2bdc5d5b..2b504dcafd 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2020 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. @@ -74,7 +74,7 @@ public int update(String sql, Object[] args, int[] argTypes) throws DataAccessEx return 1; } }); - JobExecution jobExecution = new JobExecution(new JobInstance(new Long(11), "testJob"), new JobParameters()); + JobExecution jobExecution = new JobExecution(new JobInstance(11L, "testJob"), new JobParameters()); jobExecutionDao.saveJobExecution(jobExecution); assertEquals(1, list.size()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java index 13199b75bc..a9273f0179 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2020 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. @@ -53,7 +53,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { protected void setUp() throws Exception { JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters(); - jobInstance = new JobInstance(new Long(0), "testJob"); + jobInstance = new JobInstance(0L, "testJob"); JobExecution jobExecution = new JobExecution(jobInstance, jobParameters); Step step = new StepSupport("bar"); stepExecution = jobExecution.createStepExecution(step.getName()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java index d0eade3308..651f65f86f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2020 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. @@ -79,7 +79,7 @@ public void setUp() throws Exception { factory.setSkipLimit(2); factory.setIsReaderTransactionalQueue(true); - JobInstance jobInstance = new JobInstance(new Long(1), "skipJob"); + JobInstance jobInstance = new JobInstance(1L, "skipJob"); jobExecution = new JobExecution(jobInstance, new JobParameters()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index 8f1908c2e9..5890265de7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2020 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. @@ -104,7 +104,7 @@ public Object read() throws Exception { } if (foo != 1) { - return new Double(foo); + return foo; } else { return null; diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java index 185549ce12..10f2f08c2d 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2020 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. @@ -129,7 +129,7 @@ public void testReaderOnRestart() throws Exception { List> ids = jdbcTemplate .queryForList("SELECT ID,NAME FROM T_FOOS ORDER BY ID ASC"); logger.debug("Ids: "+ids); - int startAfterValue = (new Long(ids.get(count - 1).get("ID").toString())).intValue(); + int startAfterValue = Integer.parseInt(ids.get(count - 1).get("ID").toString()); logger.debug("Start after: " + startAfterValue); Map startAfterValues = new LinkedHashMap<>(); startAfterValues.put("ID", startAfterValue); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java index 44ee06b121..de180d352f 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/AbstractDelegatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2020 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. @@ -296,7 +296,7 @@ public void processNameValuePair(String name, int value) { @SuppressWarnings("unused") public void processNameValuePair(String name, String value) { - processedFooNameValuePairs.add(new Foo(name, new Integer(value))); + processedFooNameValuePairs.add(new Foo(name, Integer.parseInt(value))); } public List getProcessedFooNameValuePairs() { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/builder/KafkaItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/builder/KafkaItemReaderBuilderTests.java index 4d725f6d70..6819fb93aa 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/builder/KafkaItemReaderBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/builder/KafkaItemReaderBuilderTests.java @@ -242,7 +242,7 @@ public void testKafkaItemReaderCreation() { assertEquals(partitions.get(1).intValue(), topicPartitions.get(1).partition()); Map partitionOffsetsMap = (Map) ReflectionTestUtils.getField(reader, "partitionOffsets"); assertEquals(2, partitionOffsetsMap.size()); - assertEquals(new Long(10), partitionOffsetsMap.get(new TopicPartition(topic, partitions.get(0)))); - assertEquals(new Long(15), partitionOffsetsMap.get(new TopicPartition(topic, partitions.get(1)))); + assertEquals(Long.valueOf(10L), partitionOffsetsMap.get(new TopicPartition(topic, partitions.get(0)))); + assertEquals(Long.valueOf(15L), partitionOffsetsMap.get(new TopicPartition(topic, partitions.get(1)))); } } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkResponseTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkResponseTests.java index 0cd39c3ee1..238e376d79 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkResponseTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/ChunkResponseTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2020 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. @@ -33,7 +33,7 @@ public class ChunkResponseTests { @Test public void testGetJobId() { - assertEquals(new Long(111L), response.getJobId()); + assertEquals(Long.valueOf(111L), response.getJobId()); } @Test @@ -50,7 +50,7 @@ public void testToString() { public void testSerializable() throws Exception { ChunkResponse result = (ChunkResponse) SerializationUtils.deserialize(SerializationUtils.serialize(response)); assertNotNull(result.getStepContribution()); - assertEquals(new Long(111L), result.getJobId()); + assertEquals(Long.valueOf(111L), result.getJobId()); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java index 587afc2896..6493ff7ff5 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2019 the original author or authors. + * Copyright 2008-2020 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. @@ -285,9 +285,9 @@ private void validateLaunchWithSkips(JobExecution jobExecution) { assertEquals(new BigDecimal("340.45"), jobExecution.getExecutionContext().get(TradeWriter.TOTAL_AMOUNT_KEY)); Map step1Execution = getStepExecutionAsMap(jobExecution, "step1"); - assertEquals(new Long(4), step1Execution.get("COMMIT_COUNT")); - assertEquals(new Long(8), step1Execution.get("READ_COUNT")); - assertEquals(new Long(7), step1Execution.get("WRITE_COUNT")); + assertEquals(Long.valueOf(4L), step1Execution.get("COMMIT_COUNT")); + assertEquals(Long.valueOf(8L), step1Execution.get("READ_COUNT")); + assertEquals(Long.valueOf(7L), step1Execution.get("WRITE_COUNT")); } private void validateLaunchWithoutSkips(JobExecution jobExecution) {