diff --git a/execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java b/execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java index 26c345095..6f24fadd5 100644 --- a/execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java +++ b/execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java @@ -84,7 +84,7 @@ public class ScheduledJobIdentifier extends SimpleJobIdentifier implements JobId * stream, run, and schedule date. */ public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other); + return EqualsBuilder.reflectionEquals(this, other) || EqualsBuilder.reflectionEquals(other, this); } public int hashCode() { diff --git a/execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierTests.java b/execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierTests.java index 73e3b194f..e54843366 100644 --- a/execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierTests.java @@ -16,6 +16,7 @@ package org.springframework.batch.execution.runtime; import java.sql.Date; +import java.sql.Timestamp; import junit.framework.TestCase; @@ -62,5 +63,31 @@ public class ScheduledJobIdentifierTests extends TestCase { instance.setJobRun(1); assertEquals(1, instance.getJobRun()); } + + public void testEqualsSelf() throws Exception { + assertEquals(instance, instance); + } + public void testEqualsInstanceWithSameProperties() throws Exception { + ScheduledJobIdentifier other = new ScheduledJobIdentifier(instance.getName()); + other.setJobRun(instance.getJobRun()); + other.setJobStream(instance.getJobStream()); + other.setScheduleDate(instance.getScheduleDate()); + assertEquals(instance, other); + assertEquals(instance.hashCode(), other.hashCode()); + } + + public void testEqualsInstanceWithTimestamp() throws Exception { + ScheduledJobIdentifier other = new ScheduledJobIdentifier(instance.getName()); + other.setJobRun(instance.getJobRun()); + other.setJobStream(instance.getJobStream()); + other.setScheduleDate(new Timestamp(instance.getScheduleDate().getTime())); + assertEquals(instance, other); + assertEquals(other, instance); + assertEquals(instance.hashCode(), other.hashCode()); + } + + public void testEqualsNull() throws Exception { + assertNotSame(null, instance); + } } diff --git a/execution/src/test/java/org/springframework/batch/execution/step/DefaultStepExecutorFactoryTests.java b/execution/src/test/java/org/springframework/batch/execution/step/PrototypeBeanStepExecutorFactoryTests.java similarity index 96% rename from execution/src/test/java/org/springframework/batch/execution/step/DefaultStepExecutorFactoryTests.java rename to execution/src/test/java/org/springframework/batch/execution/step/PrototypeBeanStepExecutorFactoryTests.java index 48dcd7cb0..ae7e9d5df 100644 --- a/execution/src/test/java/org/springframework/batch/execution/step/DefaultStepExecutorFactoryTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/step/PrototypeBeanStepExecutorFactoryTests.java @@ -34,7 +34,7 @@ import org.springframework.context.support.StaticApplicationContext; * @author Dave Syer * */ -public class DefaultStepExecutorFactoryTests extends TestCase { +public class PrototypeBeanStepExecutorFactoryTests extends TestCase { private PrototypeBeanStepExecutorFactory factory = new PrototypeBeanStepExecutorFactory(); private StaticApplicationContext applicationContext = new StaticApplicationContext();