BATCH-956: remove pause and wait features
This commit is contained in:
@@ -15,7 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -60,8 +64,6 @@ public class BatchStatusTests {
|
||||
assertEquals(BatchStatus.COMPLETED, BatchStatus.COMPLETED.upgradeTo(BatchStatus.STARTING));
|
||||
assertEquals(BatchStatus.STARTED, BatchStatus.STARTING.upgradeTo(BatchStatus.STARTED));
|
||||
assertEquals(BatchStatus.STARTED, BatchStatus.STARTED.upgradeTo(BatchStatus.STARTING));
|
||||
assertEquals(BatchStatus.COMPLETED, BatchStatus.COMPLETED.upgradeTo(BatchStatus.WAITING));
|
||||
assertEquals(BatchStatus.STARTED, BatchStatus.STARTED.upgradeTo(BatchStatus.WAITING));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,7 +72,6 @@ public class BatchStatusTests {
|
||||
assertFalse(BatchStatus.COMPLETED.isRunning());
|
||||
assertTrue(BatchStatus.STARTED.isRunning());
|
||||
assertTrue(BatchStatus.STARTING.isRunning());
|
||||
assertTrue(BatchStatus.WAITING.isRunning());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +80,6 @@ public class BatchStatusTests {
|
||||
assertFalse(BatchStatus.COMPLETED.isUnsuccessful());
|
||||
assertFalse(BatchStatus.STARTED.isUnsuccessful());
|
||||
assertFalse(BatchStatus.STARTING.isUnsuccessful());
|
||||
assertFalse(BatchStatus.WAITING.isUnsuccessful());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -107,38 +107,6 @@ public class JobExecutionTests {
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#pauseAndWait()}.
|
||||
*/
|
||||
@Test
|
||||
public void testPauseAndWait() {
|
||||
execution.pauseAndWait();
|
||||
assertEquals(BatchStatus.WAITING, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#pauseAndWait()}.
|
||||
*/
|
||||
@Test
|
||||
public void testPauseAndWaitWhenFailed() {
|
||||
execution.setStatus(BatchStatus.FAILED);
|
||||
execution.pauseAndWait();
|
||||
assertEquals(BatchStatus.FAILED, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#pauseAndWait()}.
|
||||
*/
|
||||
@Test
|
||||
public void testPauseAndWaitWhenStarted() {
|
||||
execution.setStatus(BatchStatus.STARTED);
|
||||
execution.pauseAndWait();
|
||||
assertEquals(BatchStatus.WAITING, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
|
||||
@@ -15,7 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@@ -275,38 +280,6 @@ public class StepExecutionTests {
|
||||
assertEquals(exception, execution.getFailureExceptions().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#pauseAndWait()}.
|
||||
*/
|
||||
@Test
|
||||
public void testPauseAndWait() {
|
||||
execution.pauseAndWait();
|
||||
assertEquals(BatchStatus.WAITING, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#pauseAndWait()}.
|
||||
*/
|
||||
@Test
|
||||
public void testPauseAndWaitWhenFailed() {
|
||||
execution.setStatus(BatchStatus.FAILED);
|
||||
execution.pauseAndWait();
|
||||
assertEquals(BatchStatus.FAILED, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#pauseAndWait()}.
|
||||
*/
|
||||
@Test
|
||||
public void testPauseAndWaitWhenStarted() {
|
||||
execution.setStatus(BatchStatus.STARTED);
|
||||
execution.pauseAndWait();
|
||||
assertEquals(BatchStatus.WAITING, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.JobExecution#getStatus()}.
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.springframework.batch.core.job.flow.support.StateTransition;
|
||||
import org.springframework.batch.core.job.flow.support.state.DecisionState;
|
||||
import org.springframework.batch.core.job.flow.support.state.EndState;
|
||||
import org.springframework.batch.core.job.flow.support.state.JobExecutionDecider;
|
||||
import org.springframework.batch.core.job.flow.support.state.PauseState;
|
||||
import org.springframework.batch.core.job.flow.support.state.StepState;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
@@ -250,33 +249,6 @@ public class FlowJobTests {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPauseFlow() throws Throwable {
|
||||
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "*", "pause"));
|
||||
transitions.add(StateTransition.createStateTransition(new PauseState("pause"), "*", "step2"));
|
||||
transitions.add(StateTransition.createEndStateTransition(new StepState(new StubStep("step2")), "*"));
|
||||
flow.setStateTransitions(transitions);
|
||||
job.setFlow(flow);
|
||||
|
||||
job.execute(jobExecution);
|
||||
if (!jobExecution.getAllFailureExceptions().isEmpty()) {
|
||||
throw jobExecution.getAllFailureExceptions().get(0);
|
||||
}
|
||||
assertEquals(BatchStatus.WAITING, jobExecution.getStatus());
|
||||
assertEquals(1, jobExecution.getStepExecutions().size());
|
||||
|
||||
job.execute(jobExecution);
|
||||
if (!jobExecution.getAllFailureExceptions().isEmpty()) {
|
||||
throw jobExecution.getAllFailureExceptions().get(0);
|
||||
}
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
assertEquals(2, jobExecution.getStepExecutions().size());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
|
||||
@@ -186,24 +186,6 @@ public class SimpleJobLauncherTests {
|
||||
jobLauncher.setJobRepository(jobRepository);
|
||||
jobLauncher.afterPropertiesSet(); // no error
|
||||
}
|
||||
|
||||
/**
|
||||
* Same execution is used if the last found has PAUSED status.
|
||||
*/
|
||||
@Test
|
||||
public void testResumePausedInstance() throws Exception {
|
||||
long id = 9;
|
||||
JobExecution jobExecution = new JobExecution(null, id);
|
||||
jobExecution.pauseAndWait();
|
||||
expect(jobRepository.getLastJobExecution(job.getName(), jobParameters)).andReturn(jobExecution);
|
||||
replay(jobRepository);
|
||||
|
||||
jobLauncher.afterPropertiesSet();
|
||||
JobExecution returned = jobLauncher.run(job, jobParameters);
|
||||
assertEquals(jobExecution, returned);
|
||||
|
||||
verify(jobRepository);
|
||||
}
|
||||
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
|
||||
@@ -15,10 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.launch.support;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expectLastCall;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -390,19 +393,4 @@ public class SimpleJobOperatorTests {
|
||||
assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPause() throws Exception{
|
||||
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
|
||||
jobExplorer.getJobExecution(111L);
|
||||
expectLastCall().andReturn(jobExecution);
|
||||
jobRepository.update(jobExecution);
|
||||
replay(jobExplorer);
|
||||
replay(jobRepository);
|
||||
jobOperator.pause(111L);
|
||||
verify(jobExplorer);
|
||||
verify(jobRepository);
|
||||
assertEquals(BatchStatus.WAITING, jobExecution.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user