BATCH-746:Removed easymock warnings in core
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.batch.core.job;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -23,7 +25,6 @@ import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobExecutionException;
|
||||
@@ -354,13 +355,10 @@ public class SimpleJobTests extends TestCase {
|
||||
public void testInterruptWithListener() throws Exception {
|
||||
step1.setProcessException(new JobInterruptedException("job interrupted!"));
|
||||
|
||||
MockControl<JobExecutionListener> control = MockControl.createStrictControl(JobExecutionListener.class);
|
||||
JobExecutionListener listener = control.getMock();
|
||||
JobExecutionListener listener = createMock(JobExecutionListener.class);
|
||||
listener.beforeJob(jobExecution);
|
||||
control.setVoidCallable();
|
||||
listener.onInterrupt(jobExecution);
|
||||
control.setVoidCallable();
|
||||
control.replay();
|
||||
replay(listener);
|
||||
|
||||
job.setJobExecutionListeners(new JobExecutionListener[] { listener });
|
||||
|
||||
@@ -372,7 +370,7 @@ public class SimpleJobTests extends TestCase {
|
||||
// expected
|
||||
}
|
||||
|
||||
control.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
|
||||
package org.springframework.batch.core.launch;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -35,12 +37,10 @@ import org.springframework.core.task.TaskExecutor;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class SimpleJobLauncherTests extends TestCase {
|
||||
public class SimpleJobLauncherTests {
|
||||
|
||||
private SimpleJobLauncher jobLauncher;
|
||||
|
||||
private MockControl<JobRepository> repositoryControl = MockControl.createControl(JobRepository.class);
|
||||
|
||||
private Job job = new JobSupport("foo") {
|
||||
public void execute(JobExecution execution) {
|
||||
execution.setExitStatus(ExitStatus.FINISHED);
|
||||
@@ -52,31 +52,32 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
jobLauncher = new SimpleJobLauncher();
|
||||
jobRepository = repositoryControl.getMock();
|
||||
jobRepository = createMock(JobRepository.class);
|
||||
jobLauncher.setJobRepository(jobRepository);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun() throws Exception {
|
||||
|
||||
JobExecution jobExecution = new JobExecution(null);
|
||||
|
||||
jobRepository.createJobExecution(job, jobParameters);
|
||||
repositoryControl.setReturnValue(jobExecution);
|
||||
expect(jobRepository.createJobExecution(job, jobParameters)).andReturn(jobExecution);
|
||||
|
||||
repositoryControl.replay();
|
||||
replay(jobRepository);
|
||||
|
||||
jobLauncher.afterPropertiesSet();
|
||||
jobLauncher.run(job, jobParameters);
|
||||
assertEquals(ExitStatus.FINISHED, jobExecution.getExitStatus());
|
||||
|
||||
repositoryControl.verify();
|
||||
verify(jobRepository);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskExecutor() throws Exception {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
jobLauncher.setTaskExecutor(new TaskExecutor() {
|
||||
@@ -89,6 +90,7 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRunWithException() throws Exception {
|
||||
job = new JobSupport() {
|
||||
public void execute(JobExecution execution) {
|
||||
@@ -104,6 +106,7 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRunWithError() throws Exception {
|
||||
job = new JobSupport() {
|
||||
public void execute(JobExecution execution) {
|
||||
@@ -119,6 +122,7 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialiseWithoutRepository() throws Exception {
|
||||
try {
|
||||
new SimpleJobLauncher().afterPropertiesSet();
|
||||
@@ -130,6 +134,7 @@ public class SimpleJobLauncherTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialiseWithRepository() throws Exception {
|
||||
jobLauncher = new SimpleJobLauncher();
|
||||
jobLauncher.setJobRepository(jobRepository);
|
||||
|
||||
@@ -15,44 +15,44 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.listener.CompositeChunkListener;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CompositeChunkListenerTests extends TestCase {
|
||||
public class CompositeChunkListenerTests {
|
||||
|
||||
MockControl<ChunkListener> listenerControl = MockControl.createControl(ChunkListener.class);
|
||||
|
||||
ChunkListener listener;
|
||||
CompositeChunkListener compositeListener;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
listener = listenerControl.getMock();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
listener = createMock(ChunkListener.class);
|
||||
compositeListener = new CompositeChunkListener();
|
||||
compositeListener.register(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeforeChunk(){
|
||||
|
||||
listener.beforeChunk();
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.beforeChunk();
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterChunk(){
|
||||
|
||||
listener.afterChunk();
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.afterChunk();
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ItemReadListener;
|
||||
import org.springframework.batch.core.listener.CompositeItemReadListener;
|
||||
|
||||
@@ -25,52 +26,54 @@ import org.springframework.batch.core.listener.CompositeItemReadListener;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CompositeItemReadListenerTests extends TestCase {
|
||||
|
||||
MockControl<ItemReadListener> listenerControl = MockControl.createControl(ItemReadListener.class);
|
||||
public class CompositeItemReadListenerTests {
|
||||
|
||||
ItemReadListener listener;
|
||||
CompositeItemReadListener compositeListener;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
listener = listenerControl.getMock();
|
||||
listener = createMock(ItemReadListener.class);
|
||||
compositeListener = new CompositeItemReadListener();
|
||||
compositeListener.register(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeforeRead(){
|
||||
|
||||
listener.beforeRead();
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.beforeRead();
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterRead(){
|
||||
Object item = new Object();
|
||||
listener.afterRead(item);
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.afterRead(item);
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnReadError(){
|
||||
|
||||
Exception ex = new Exception();
|
||||
listener.onReadError(ex);
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.onReadError(ex);
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetListners() throws Exception {
|
||||
compositeListener.setListeners(new ItemReadListener[] {listener});
|
||||
listener.beforeRead();
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.beforeRead();
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,62 +15,65 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ItemWriteListener;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class CompositeItemWriteListenerTests extends TestCase {
|
||||
public class CompositeItemWriteListenerTests {
|
||||
|
||||
MockControl<ItemWriteListener> listenerControl = MockControl.createControl(ItemWriteListener.class);
|
||||
|
||||
ItemWriteListener listener;
|
||||
CompositeItemWriteListener compositeListener;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
listener = listenerControl.getMock();
|
||||
listener = createMock(ItemWriteListener.class);
|
||||
compositeListener = new CompositeItemWriteListener();
|
||||
compositeListener.register(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeforeWrite(){
|
||||
Object item = new Object();
|
||||
listener.beforeWrite(item);
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.beforeWrite(item);
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterWrite(){
|
||||
Object item = new Object();
|
||||
listener.afterWrite(item);
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.afterWrite(item);
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnWriteError(){
|
||||
Object item = new Object();
|
||||
Exception ex = new Exception();
|
||||
listener.onWriteError(ex, item);
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.onWriteError(ex, item);
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetListners() throws Exception {
|
||||
compositeListener.setListeners(new ItemWriteListener[] {listener});
|
||||
Object item = new Object();
|
||||
listener.beforeWrite(item);
|
||||
listenerControl.replay();
|
||||
replay(listener);
|
||||
compositeListener.beforeWrite(item);
|
||||
listenerControl.verify();
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.springframework.batch.core.repository.support;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -53,12 +54,6 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
Step stepConfiguration1;
|
||||
|
||||
Step stepConfiguration2;
|
||||
|
||||
MockControl jobExecutionDaoControl = MockControl.createControl(JobExecutionDao.class);
|
||||
|
||||
MockControl jobInstanceDaoControl = MockControl.createControl(JobInstanceDao.class);
|
||||
|
||||
MockControl stepExecutionDaoControl = MockControl.createControl(StepExecutionDao.class);
|
||||
|
||||
JobExecutionDao jobExecutionDao;
|
||||
|
||||
@@ -77,9 +72,9 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
|
||||
jobExecutionDao = (JobExecutionDao) jobExecutionDaoControl.getMock();
|
||||
jobInstanceDao = (JobInstanceDao) jobInstanceDaoControl.getMock();
|
||||
stepExecutionDao = (StepExecutionDao) stepExecutionDaoControl.getMock();
|
||||
jobExecutionDao = createMock(JobExecutionDao.class);
|
||||
jobInstanceDao = createMock(JobInstanceDao.class);
|
||||
stepExecutionDao = createMock(StepExecutionDao.class);
|
||||
|
||||
jobRepository = new SimpleJobRepository(jobInstanceDao, jobExecutionDao, stepExecutionDao);
|
||||
|
||||
@@ -130,10 +125,9 @@ public class SimpleJobRepositoryTests extends TestCase {
|
||||
|
||||
// new execution - call update on job dao
|
||||
jobExecutionDao.updateJobExecution(jobExecution);
|
||||
jobExecutionDaoControl.replay();
|
||||
replay(jobExecutionDao);
|
||||
jobRepository.update(jobExecution);
|
||||
jobExecutionDaoControl.verify();
|
||||
|
||||
verify(jobExecutionDao);
|
||||
}
|
||||
|
||||
public void testSaveOrUpdateStepExecutionException() {
|
||||
|
||||
Reference in New Issue
Block a user