IN PROGRESS - issue BATCH-366: Do we still need StepInstance?
http://jira.springframework.org/browse/BATCH-366 Killed StepInstance - test coverage temporarily low due to commenting obsolete tests (but sample jobs work fine).
This commit is contained in:
@@ -130,7 +130,7 @@ public class JobExecutionTests extends TestCase {
|
||||
|
||||
public void testAddAndRemoveStepExecution() throws Exception {
|
||||
assertEquals(0, execution.getStepExecutions().size());
|
||||
execution.createStepExecution(new StepInstance(null, null));
|
||||
execution.createStepExecution(null);
|
||||
assertEquals(1, execution.getStepExecutions().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,20 +35,20 @@ public class JobInstanceTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getStepInstances()}.
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getStepNames()}.
|
||||
*/
|
||||
public void testGetSteps() {
|
||||
assertEquals(0, instance.getStepInstances().size());
|
||||
instance.setStepInstances(Collections.singletonList(new StepInstance()));
|
||||
assertEquals(1, instance.getStepInstances().size());
|
||||
assertEquals(0, instance.getStepNames().size());
|
||||
instance.setStepNames(Collections.singletonList(""));
|
||||
assertEquals(1, instance.getStepNames().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#addStepInstance(org.springframework.batch.core.domain.StepInstance)}.
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#addStepName(org.springframework.batch.core.domain.StepInstance)}.
|
||||
*/
|
||||
public void testAddStep() {
|
||||
instance.addStepInstance(new StepInstance());
|
||||
assertEquals(1, instance.getStepInstances().size());
|
||||
instance.addStepName("");
|
||||
assertEquals(1, instance.getStepNames().size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,7 @@ public class JobSupportTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobSupport#setSteps(java.util.List)}.
|
||||
* {@link org.springframework.batch.core.domain.JobSupport#setStepNames(java.util.List)}.
|
||||
*/
|
||||
public void testSetSteps() {
|
||||
job.setSteps(Collections.singletonList(new StepSupport("step")));
|
||||
@@ -70,7 +70,7 @@ public class JobSupportTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobSupport#addStepInstance(org.springframework.batch.core.configuration.StepConfiguration)}.
|
||||
* {@link org.springframework.batch.core.domain.JobSupport#addStepName(org.springframework.batch.core.configuration.StepConfiguration)}.
|
||||
*/
|
||||
public void testAddStep() {
|
||||
job.addStep(new StepSupport("step"));
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.batch.support.PropertiesConverter;
|
||||
*/
|
||||
public class StepExecutionTests extends TestCase {
|
||||
|
||||
private StepExecution execution = newStepExecution(new Long(11),
|
||||
private StepExecution execution = newStepExecution("stepName",
|
||||
new Long(23));
|
||||
|
||||
/**
|
||||
@@ -157,18 +157,6 @@ public class StepExecutionTests extends TestCase {
|
||||
execution.setRollbackCount(123);
|
||||
assertEquals(123, execution.getRollbackCount().intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#getStepId()}.
|
||||
*/
|
||||
public void testGetStepId() {
|
||||
assertEquals(11, execution.getStepId().longValue());
|
||||
}
|
||||
|
||||
public void testGetStep() throws Exception {
|
||||
assertNotNull(execution.getStep());
|
||||
}
|
||||
|
||||
public void testGetJobExecution() throws Exception {
|
||||
assertNotNull(execution.getJobExecution());
|
||||
@@ -210,18 +198,18 @@ public class StepExecutionTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testEqualsWithSameIdentifier() throws Exception {
|
||||
Entity step1 = newStepExecution(new Long(100), new Long(11));
|
||||
Entity step2 = newStepExecution(new Long(100), new Long(11));
|
||||
Entity step1 = newStepExecution("stepName", new Long(11));
|
||||
Entity step2 = newStepExecution("stepName", new Long(11));
|
||||
assertEquals(step1, step2);
|
||||
}
|
||||
|
||||
public void testEqualsWithNull() throws Exception {
|
||||
Entity step = newStepExecution(new Long(100), new Long(11));
|
||||
Entity step = newStepExecution("stepName", new Long(11));
|
||||
assertFalse(step.equals(null));
|
||||
}
|
||||
|
||||
public void testEqualsWithNullIdentifiers() throws Exception {
|
||||
Entity step = newStepExecution(new Long(100), new Long(11));
|
||||
Entity step = newStepExecution("stepName", new Long(11));
|
||||
assertFalse(step.equals(new StepExecution()));
|
||||
}
|
||||
|
||||
@@ -231,7 +219,7 @@ public class StepExecutionTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testEqualsWithNullStep() throws Exception {
|
||||
Entity step = newStepExecution(new Long(11), null);
|
||||
Entity step = newStepExecution("stepName", null);
|
||||
assertFalse(step.equals(new StepExecution()));
|
||||
}
|
||||
|
||||
@@ -240,13 +228,13 @@ public class StepExecutionTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testEqualsWithDifferent() throws Exception {
|
||||
Entity step = newStepExecution(new Long(43), new Long(13));
|
||||
Entity step = newStepExecution("foo", new Long(13));
|
||||
assertFalse(execution.equals(step));
|
||||
}
|
||||
|
||||
public void testEqualsWithNullStepId() throws Exception {
|
||||
execution = newStepExecution(null, new Long(31));
|
||||
assertEquals(null, execution.getStepId());
|
||||
assertEquals(null, execution.getStepName());
|
||||
StepExecution step = newStepExecution(null, new Long(31));
|
||||
assertEquals(step.getJobExecutionId(), execution.getJobExecutionId());
|
||||
assertTrue(execution.equals(step));
|
||||
@@ -271,10 +259,9 @@ public class StepExecutionTests extends TestCase {
|
||||
assertTrue(set.contains(execution));
|
||||
}
|
||||
|
||||
private StepExecution newStepExecution(Long long1, Long long2) {
|
||||
private StepExecution newStepExecution(String stepName, Long long2) {
|
||||
JobInstance job = new JobInstance(new Long(3), new JobParameters());
|
||||
StepInstance step = new StepInstance(job, "foo", long1);
|
||||
StepExecution execution = new StepExecution(step, new JobExecution(job, long2), new Long(4));
|
||||
StepExecution execution = new StepExecution(stepName, new JobExecution(job, long2), new Long(4));
|
||||
return execution;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepInstanceTests extends TestCase {
|
||||
|
||||
StepInstance instance = new StepInstance(new Long(13));
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#StepInstance()}.
|
||||
*/
|
||||
public void testStepInstance() {
|
||||
assertNull(new StepInstance().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getStepExecutionCount()}.
|
||||
*/
|
||||
public void testGetStepExecutionCount() {
|
||||
assertEquals(0, instance.getStepExecutionCount());
|
||||
instance.setStepExecutionCount(23);
|
||||
assertEquals(23, instance.getStepExecutionCount());
|
||||
}
|
||||
|
||||
public void testLastExecution(){
|
||||
StepExecution lastExecution = new StepExecution();
|
||||
assertNull(instance.getLastExecution());
|
||||
instance.setLastExecution(lastExecution);
|
||||
assertEquals(lastExecution, instance.getLastExecution());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getJobInstance()}.
|
||||
*/
|
||||
public void testGetJobInstance() {
|
||||
assertEquals(null, instance.getJobInstance());
|
||||
JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters());
|
||||
instance = new StepInstance(jobInstance, null);
|
||||
assertEquals(jobInstance, instance.getJobInstance());
|
||||
}
|
||||
|
||||
public void testGetJob(){
|
||||
|
||||
Job job = new JobSupport("job");
|
||||
JobInstance jobInstance = new JobInstance(new Long(2), new JobParameters(), job);
|
||||
instance = new StepInstance(jobInstance, null);
|
||||
assertEquals(job, instance.getJobInstance().getJob());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getName()}.
|
||||
*/
|
||||
public void testGetName() {
|
||||
assertEquals(null, instance.getName());
|
||||
instance = new StepInstance(null, "foo");
|
||||
assertEquals("foo", instance.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getJobId()}.
|
||||
*/
|
||||
public void testGetJobId() {
|
||||
assertEquals(null, instance.getJobId());
|
||||
instance = new StepInstance(new JobInstance(new Long(23), new JobParameters()), null);
|
||||
assertEquals(23, instance.getJobId().longValue());
|
||||
}
|
||||
|
||||
public void testEqualsWithSameIdentifier() throws Exception {
|
||||
JobInstance job = new JobInstance(new Long(100), new JobParameters());
|
||||
StepInstance step1 = new StepInstance(job, "foo", new Long(0));
|
||||
StepInstance step2 = new StepInstance(job, "foo", new Long(0));
|
||||
assertEquals(step1, step2);
|
||||
}
|
||||
|
||||
public void testToString() throws Exception {
|
||||
assertTrue("Should contain name", instance.toString().indexOf("name=")>=0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user