diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java index ce32d79e0..3a450aa99 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -16,7 +16,8 @@ package org.springframework.batch.core; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -71,7 +72,7 @@ class ExitStatusTests { @Test void testEqualsWithNull() { - assertFalse(ExitStatus.EXECUTING.equals(null)); + assertNotEquals(null, ExitStatus.EXECUTING); } @Test @@ -119,35 +120,35 @@ class ExitStatusTests { @Test void testAddExitCode() { ExitStatus status = ExitStatus.EXECUTING.replaceExitCode("FOO"); - assertTrue(ExitStatus.EXECUTING != status); + assertNotSame(ExitStatus.EXECUTING, status); assertEquals("FOO", status.getExitCode()); } @Test void testAddExitCodeToExistingStatus() { ExitStatus status = ExitStatus.EXECUTING.replaceExitCode("FOO").replaceExitCode("BAR"); - assertTrue(ExitStatus.EXECUTING != status); + assertNotSame(ExitStatus.EXECUTING, status); assertEquals("BAR", status.getExitCode()); } @Test void testAddExitCodeToSameStatus() { ExitStatus status = ExitStatus.EXECUTING.replaceExitCode(ExitStatus.EXECUTING.getExitCode()); - assertTrue(ExitStatus.EXECUTING != status); + assertNotSame(ExitStatus.EXECUTING, status); assertEquals(ExitStatus.EXECUTING.getExitCode(), status.getExitCode()); } @Test void testAddExitDescription() { ExitStatus status = ExitStatus.EXECUTING.addExitDescription("Foo"); - assertTrue(ExitStatus.EXECUTING != status); + assertNotSame(ExitStatus.EXECUTING, status); assertEquals("Foo", status.getExitDescription()); } @Test void testAddExitDescriptionWIthStacktrace() { ExitStatus status = ExitStatus.EXECUTING.addExitDescription(new RuntimeException("Foo")); - assertTrue(ExitStatus.EXECUTING != status); + assertNotSame(ExitStatus.EXECUTING, status); String description = status.getExitDescription(); assertTrue(description.contains("Foo"), "Wrong description: " + description); assertTrue(description.contains("RuntimeException"), "Wrong description: " + description); @@ -156,7 +157,7 @@ class ExitStatusTests { @Test void testAddExitDescriptionToSameStatus() { ExitStatus status = ExitStatus.EXECUTING.addExitDescription("Foo").addExitDescription("Foo"); - assertTrue(ExitStatus.EXECUTING != status); + assertNotSame(ExitStatus.EXECUTING, status); assertEquals("Foo", status.getExitDescription()); } 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 1a790045d..07f4d8a26 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-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -128,7 +128,7 @@ class JobExecutionTests { @Test void testGetJobIdForNullJob() { execution = new JobExecution((JobInstance) null, (JobParameters) null); - assertEquals(null, execution.getJobId()); + assertNull(execution.getJobId()); } /** 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 247732f5d..2445c00a9 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-2023 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. @@ -17,6 +17,7 @@ package org.springframework.batch.core; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -112,27 +113,27 @@ class JobParametersTests { @Test void testEquals() { JobParameters testParameters = getNewParameters(); - assertTrue(testParameters.equals(parameters)); + assertEquals(testParameters, parameters); } @Test void testEqualsSelf() { - assertTrue(parameters.equals(parameters)); + assertEquals(parameters, parameters); } @Test void testEqualsDifferent() { - assertFalse(parameters.equals(new JobParameters())); + assertNotEquals(parameters, new JobParameters()); } @Test void testEqualsWrongType() { - assertFalse(parameters.equals("foo")); + assertNotEquals("foo", parameters); } @Test void testEqualsNull() { - assertFalse(parameters.equals(null)); + assertNotEquals(null, parameters); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java index 0b2aa8781..fc26f91ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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,7 +96,7 @@ class ExtendedAbstractJobTests { @Test void testSetBeanNameWithNullName() { job = new StubJob(null, null); - assertEquals(null, job.getName()); + assertNull(job.getName()); job.setBeanName("foo"); assertEquals("foo", job.getName()); } 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 91430257e..c71471841 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-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -50,6 +50,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -333,7 +334,7 @@ class CommandLineJobRunnerTests { StubJobExplorer.jobExecution = jobExecution; CommandLineJobRunner.main(args); assertEquals(1, StubSystemExiter.status); - assertEquals(null, StubJobLauncher.jobParameters); + assertNull(StubJobLauncher.jobParameters); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java index 1c494ed32..2ebbee0fa 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-2023 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. @@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -329,13 +330,13 @@ public abstract class AbstractJobExecutionDaoTests { dao.saveJobExecution(exec1); JobExecution exec2 = new JobExecution(jobInstance, jobParameters); - assertTrue(exec1.getId() != null); + assertNotNull(exec1.getId()); exec2.setId(exec1.getId()); exec2.setStatus(BatchStatus.STARTED); exec2.setVersion(7); - assertTrue(exec1.getVersion() != exec2.getVersion()); - assertTrue(exec1.getStatus() != exec2.getStatus()); + assertNotSame(exec1.getVersion(), exec2.getVersion()); + assertNotSame(exec1.getStatus(), exec2.getStatus()); dao.synchronizeStatus(exec2); @@ -356,12 +357,12 @@ public abstract class AbstractJobExecutionDaoTests { dao.saveJobExecution(exec1); JobExecution exec2 = new JobExecution(jobInstance, jobParameters); - assertTrue(exec1.getId() != null); + assertNotNull(exec1.getId()); exec2.setId(exec1.getId()); exec2.setStatus(BatchStatus.UNKNOWN); exec2.setVersion(7); - assertTrue(exec1.getVersion() != exec2.getVersion()); + assertNotSame(exec1.getVersion(), exec2.getVersion()); assertTrue(exec1.getStatus().isLessThan(exec2.getStatus())); dao.synchronizeStatus(exec2); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/JobContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/JobContextTests.java index 430377f20..ca9acf69a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/JobContextTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/JobContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -16,7 +16,7 @@ package org.springframework.batch.core.scope.context; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -35,6 +35,7 @@ import org.springframework.batch.item.ExecutionContext; /** * @author Dave Syer * @author Jimmy Praet + * @author Mahmoud Ben Hassine */ class JobContextTests { @@ -71,7 +72,7 @@ class JobContextTests { @Test void testNotEqualsNull() { - assertFalse(context.equals(null)); + assertNotEquals(null, context); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java index a451112c8..a0448a96a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -16,7 +16,7 @@ package org.springframework.batch.core.scope.context; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -65,7 +65,7 @@ class StepContextTests { @Test void testNotEqualsNull() { - assertFalse(context.equals(null)); + assertNotEquals(null, context); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java index 979f24a5b..78a8fd89e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java @@ -140,7 +140,7 @@ class FaultTolerantStepFactoryBeanRollbackTests { step.execute(stepExecution); assertEquals(FAILED, stepExecution.getStatus()); assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); - assertTrue(stepExecution.getCommitCount() == 0);// Make sure exception was thrown + assertEquals(0, stepExecution.getCommitCount());// Make sure exception was thrown // in after, not before Throwable e = stepExecution.getFailureExceptions().get(0); assertThat(e, instanceOf(FatalStepExecutionException.class)); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index a2b379ac7..8eec8e814 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -446,7 +446,7 @@ class TaskletStepTests { JobExecution jobExecution = new JobExecution(jobInstance, jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); + assertFalse(stepExecution.getExecutionContext().containsKey("foo")); step.execute(stepExecution); @@ -467,7 +467,7 @@ class TaskletStepTests { JobExecution jobExecution = new JobExecution(jobInstance, jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); + assertFalse(stepExecution.getExecutionContext().containsKey("foo")); step.execute(stepExecution); @@ -587,7 +587,7 @@ class TaskletStepTests { JobExecution jobExecution = new JobExecution(jobInstance, jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); + assertFalse(stepExecution.getExecutionContext().containsKey("foo")); step.execute(stepExecution); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java index 4115f6452..fe4fd5bb7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ExecutionContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -17,6 +17,7 @@ package org.springframework.batch.item; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -107,9 +108,9 @@ class ExecutionContextTests { void testEquals() { context.putString("1", "testString"); ExecutionContext tempContext = new ExecutionContext(); - assertFalse(tempContext.equals(context)); + assertNotEquals(tempContext, context); tempContext.putString("1", "testString"); - assertTrue(tempContext.equals(context)); + assertEquals(tempContext, context); } /** diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperTests.java index f9445abda..c31f025bf 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -97,7 +97,7 @@ class BeanWrapperFieldSetMapperTests { new String[] { "varString", "varBoolean", "varChar" }); TestObject result = mapper.mapFieldSet(fieldSet); assertEquals("This is some dummy string", result.getVarString()); - assertEquals(true, result.isVarBoolean()); + assertTrue(result.isVarBoolean()); assertEquals('C', result.getVarChar()); } @@ -125,7 +125,7 @@ class BeanWrapperFieldSetMapperTests { new String[] { "varString", "varBoolean", "varChar" }); TestObject result = mapper.mapFieldSet(fieldSet); assertEquals("This is some dummy string", result.getVarString()); - assertEquals(true, result.isVarBoolean()); + assertTrue(result.isVarBoolean()); assertEquals('C', result.getVarChar()); } @@ -142,7 +142,7 @@ class BeanWrapperFieldSetMapperTests { new String[] { "VarString", "VAR_BOOLEAN", "VAR_CHAR" }); TestObject result = mapper.mapFieldSet(fieldSet); assertEquals("This is some dummy string", result.getVarString()); - assertEquals(true, result.isVarBoolean()); + assertTrue(result.isVarBoolean()); assertEquals('C', result.getVarChar()); } @@ -158,7 +158,7 @@ class BeanWrapperFieldSetMapperTests { new String[] { "varString", "varBoolean", "varChar" }); TestObject result = mapper.mapFieldSet(fieldSet); assertEquals("This is some dummy string", result.getVarString()); - assertEquals(true, result.isVarBoolean()); + assertTrue(result.isVarBoolean()); assertEquals('C', result.getVarChar()); } @@ -292,7 +292,7 @@ class BeanWrapperFieldSetMapperTests { Properties props = (Properties) editor.getValue(); wrapper.setPropertyValues(props); assertEquals("This is some dummy string", result.getVarString()); - assertEquals(true, result.isVarBoolean()); + assertTrue(result.isVarBoolean()); assertEquals('C', result.getVarChar()); } @@ -452,7 +452,7 @@ class BeanWrapperFieldSetMapperTests { assertEquals(bean.getVarInt(), 12, "Expected 12 for varInt"); assertEquals(bean.getVarLong(), 12345L, "Expected 12345 for varLong"); - assertEquals(bean.isVarBoolean(), true, "Expected true for varBoolean"); + assertTrue(bean.isVarBoolean(), "Expected true for varBoolean"); assertEquals(bean.getVarChar(), 'Z', "Expected Z for varChar"); assertEquals(bean.getVarByte(), 123, "Expected A for varByte"); assertEquals(bean.getVarFloat(), 12345F, 1F, "Expected 12345 for varFloat"); @@ -556,7 +556,7 @@ class BeanWrapperFieldSetMapperTests { new String[] { "varString", "illegalPropertyName", "varBoolean", "varChar" }); TestObject result = mapper.mapFieldSet(fieldSet); assertEquals("This is some dummy string", result.getVarString()); - assertEquals(true, result.isVarBoolean()); + assertTrue(result.isVarBoolean()); assertEquals('C', result.getVarChar()); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DefaultFieldSetTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DefaultFieldSetTests.java index e4b9b8277..2c4d09c58 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DefaultFieldSetTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DefaultFieldSetTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -18,6 +18,7 @@ package org.springframework.batch.item.file.transform; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -406,12 +407,12 @@ class DefaultFieldSetTests { @Test void testEqualsNull() { - assertFalse(fieldSet.equals(null)); + assertNotEquals(null, fieldSet); } @Test void testEqualsNullTokens() { - assertFalse(new DefaultFieldSet(null).equals(fieldSet)); + assertNotEquals(new DefaultFieldSet(null), fieldSet); } @Test @@ -421,7 +422,7 @@ class DefaultFieldSetTests { String[] tokens2 = new String[] { "token1", "token2" }; FieldSet fs1 = new DefaultFieldSet(tokens1); FieldSet fs2 = new DefaultFieldSet(tokens2); - assertFalse(fs1.equals(fs2)); + assertNotEquals(fs1, fs2); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizerTests.java index 4696559dc..b9e095caa 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; class DelimitedLineTokenizerTests { @@ -32,29 +31,29 @@ class DelimitedLineTokenizerTests { void testTokenizeRegularUse() { FieldSet tokens = tokenizer.tokenize("sfd,\"Well,I have no idea what to do in the afternoon\",sFj, asdf,,as\n"); assertEquals(6, tokens.getFieldCount()); - assertTrue(tokens.readString(0).equals("sfd"), TOKEN_MATCHES); - assertTrue(tokens.readString(1).equals("Well,I have no idea what to do in the afternoon"), TOKEN_MATCHES); - assertTrue(tokens.readString(2).equals("sFj"), TOKEN_MATCHES); - assertTrue(tokens.readString(3).equals("asdf"), TOKEN_MATCHES); - assertTrue(tokens.readString(4).equals(""), TOKEN_MATCHES); - assertTrue(tokens.readString(5).equals("as"), TOKEN_MATCHES); + assertEquals("sfd", tokens.readString(0), TOKEN_MATCHES); + assertEquals("Well,I have no idea what to do in the afternoon", tokens.readString(1), TOKEN_MATCHES); + assertEquals("sFj", tokens.readString(2), TOKEN_MATCHES); + assertEquals("asdf", tokens.readString(3), TOKEN_MATCHES); + assertEquals("", tokens.readString(4), TOKEN_MATCHES); + assertEquals("as", tokens.readString(5), TOKEN_MATCHES); tokens = tokenizer.tokenize("First string,"); assertEquals(2, tokens.getFieldCount()); - assertTrue(tokens.readString(0).equals("First string"), TOKEN_MATCHES); - assertTrue(tokens.readString(1).equals(""), TOKEN_MATCHES); + assertEquals("First string", tokens.readString(0), TOKEN_MATCHES); + assertEquals("", tokens.readString(1), TOKEN_MATCHES); } @Test void testBlankString() { FieldSet tokens = tokenizer.tokenize(" "); - assertTrue(tokens.readString(0).equals(""), TOKEN_MATCHES); + assertEquals("", tokens.readString(0), TOKEN_MATCHES); } @Test void testEmptyString() { FieldSet tokens = tokenizer.tokenize("\"\""); - assertTrue(tokens.readString(0).equals(""), TOKEN_MATCHES); + assertEquals("", tokens.readString(0), TOKEN_MATCHES); } @Test @@ -93,8 +92,8 @@ class DelimitedLineTokenizerTests { FieldSet tokens = tokenizer.tokenize("a,b,c"); - assertTrue(tokens.readString(0).equals("a"), TOKEN_MATCHES); - assertTrue(tokens.readString(1).equals("b"), TOKEN_MATCHES); + assertEquals("a", tokens.readString(0), TOKEN_MATCHES); + assertEquals("b", tokens.readString(1), TOKEN_MATCHES); } @Test @@ -118,11 +117,11 @@ class DelimitedLineTokenizerTests { FieldSet tokens = tokenizer.tokenize("a,b,c"); - assertTrue(tokens.readString(0).equals("a"), TOKEN_MATCHES); - assertTrue(tokens.readString(1).equals("b"), TOKEN_MATCHES); - assertTrue(tokens.readString(2).equals("c"), TOKEN_MATCHES); - assertTrue(tokens.readString(3).equals(""), TOKEN_MATCHES); - assertTrue(tokens.readString(4).equals(""), TOKEN_MATCHES); + assertEquals("a", tokens.readString(0), TOKEN_MATCHES); + assertEquals("b", tokens.readString(1), TOKEN_MATCHES); + assertEquals("c", tokens.readString(2), TOKEN_MATCHES); + assertEquals("", tokens.readString(3), TOKEN_MATCHES); + assertEquals("", tokens.readString(4), TOKEN_MATCHES); } @Test diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessorTests.java index de28df0eb..15de4fd96 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.springframework.core.AttributeAccessorSupport; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -84,7 +84,7 @@ class SynchronizedAttributeAccessorTests { Map another = Collections.singletonMap("foo", "bar"); // Accessor and another are instances of unrelated classes, they should // never be equal... - assertFalse(accessor.equals(another)); + assertNotEquals(accessor, another); } @Test