Tweak the JobOperator slightly and add Javadocs.

This commit is contained in:
dsyer
2008-12-31 16:23:11 +00:00
parent d8c3020176
commit bd3ab51c60
11 changed files with 230 additions and 43 deletions

View File

@@ -16,7 +16,10 @@
package org.springframework.batch.core.exlore.support;
import static org.easymock.EasyMock.*;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import java.util.Collections;
@@ -106,7 +109,7 @@ public class SimpleJobExplorerTests extends TestCase {
expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(jobInstance);
expect(stepExecutionDao.getStepExecutions(jobExecution)).andReturn(null);
replay(jobExecutionDao, jobInstanceDao, stepExecutionDao);
jobExplorer.findJobExecutions(jobInstance);
jobExplorer.getJobExecutions(jobInstance);
verify(jobExecutionDao, jobInstanceDao, stepExecutionDao);
}
@@ -124,7 +127,7 @@ public class SimpleJobExplorerTests extends TestCase {
jobInstanceDao.getLastJobInstances("foo", 1);
EasyMock.expectLastCall().andReturn(Collections.singletonList(jobInstance));
replay(jobExecutionDao, jobInstanceDao, stepExecutionDao);
jobExplorer.getLastJobInstances("foo", 1);
jobExplorer.getJobInstances("foo", 0, 1);
verify(jobExecutionDao, jobInstanceDao, stepExecutionDao);
}

View File

@@ -0,0 +1,34 @@
/*
* 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.launch;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* @author Dave Syer
*
*/
public class JobExecutionNotRunningExceptionTests {
@Test
public void testExceptionString() throws Exception {
Exception exception = new JobExecutionNotFailedException("foo");
assertEquals("foo", exception.getMessage());
}
}

View File

@@ -157,7 +157,7 @@ public class SimpleJobOperatorTests {
@Test
public void testStartNextInstanceSunnyDay() throws Exception {
final JobParameters jobParameters = new JobParameters();
jobExplorer.getLastJobInstances("foo", 1);
jobExplorer.getJobInstances("foo", 0, 1);
EasyMock.expectLastCall().andReturn(Collections.singletonList(new JobInstance(321L, jobParameters, "foo")));
EasyMock.replay(jobExplorer);
Long value = jobOperator.startNextInstance("foo");
@@ -199,7 +199,7 @@ public class SimpleJobOperatorTests {
EasyMock.expectLastCall()
.andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
EasyMock.replay(jobExplorer);
Long value = jobOperator.resume(111L);
Long value = jobOperator.restart(111L);
assertEquals(999, value.longValue());
EasyMock.verify(jobExplorer);
}
@@ -317,11 +317,11 @@ public class SimpleJobOperatorTests {
@Test
public void testGetLastInstancesSunnyDay() throws Exception {
jobParameters = new JobParameters();
jobExplorer.getLastJobInstances("foo", 2);
jobExplorer.getJobInstances("foo", 0, 2);
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
EasyMock.expectLastCall().andReturn(Collections.singletonList(jobInstance));
EasyMock.replay(jobExplorer);
List<Long> value = jobOperator.getLastInstances("foo", 2);
List<Long> value = jobOperator.getJobInstances("foo", 0, 2);
assertEquals(123L, value.get(0).longValue());
EasyMock.verify(jobExplorer);
}
@@ -329,11 +329,11 @@ public class SimpleJobOperatorTests {
@Test
public void testGetLastInstancesNoSuchJob() throws Exception {
jobParameters = new JobParameters();
jobExplorer.getLastJobInstances("no-such-job", 2);
jobExplorer.getJobInstances("no-such-job", 0, 2);
EasyMock.expectLastCall().andReturn(Collections.emptyList());
EasyMock.replay(jobExplorer);
try {
jobOperator.getLastInstances("no-such-job", 2);
jobOperator.getJobInstances("no-such-job", 0, 2);
fail("Expected NoSuchJobException");
}
catch (NoSuchJobException e) {
@@ -355,7 +355,7 @@ public class SimpleJobOperatorTests {
jobExplorer.getJobInstance(123L);
EasyMock.expectLastCall().andReturn(jobInstance);
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
jobExplorer.findJobExecutions(jobInstance);
jobExplorer.getJobExecutions(jobInstance);
EasyMock.expectLastCall().andReturn(Collections.singletonList(jobExecution));
EasyMock.replay(jobExplorer);
List<Long> value = jobOperator.getExecutions(123L);