Change svn:eol-style to LF

This commit is contained in:
dsyer
2008-03-06 21:59:13 +00:00
parent ee5746a860
commit f5e85d5f63
372 changed files with 33472 additions and 33470 deletions

View File

@@ -1,83 +1,83 @@
/*
* 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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class BatchStatusTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#toString()}.
*/
public void testToString() {
assertEquals("FAILED", BatchStatus.FAILED.toString());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.FAILED, BatchStatus.getStatus(BatchStatus.FAILED.toString()));
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatusWrongCode() {
try {
BatchStatus.getStatus("foo");
fail();
}
catch (IllegalArgumentException ex) {
// expected
}
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatusNullCode() {
assertNull(BatchStatus.getStatus(null));
}
public void testSerialization() throws Exception {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject(BatchStatus.COMPLETED);
out.flush();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream in = new ObjectInputStream(bin);
BatchStatus status = (BatchStatus) in.readObject();
assertEquals(BatchStatus.COMPLETED, status);
}
}
/*
* 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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class BatchStatusTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#toString()}.
*/
public void testToString() {
assertEquals("FAILED", BatchStatus.FAILED.toString());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.FAILED, BatchStatus.getStatus(BatchStatus.FAILED.toString()));
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatusWrongCode() {
try {
BatchStatus.getStatus("foo");
fail();
}
catch (IllegalArgumentException ex) {
// expected
}
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatusNullCode() {
assertNull(BatchStatus.getStatus(null));
}
public void testSerialization() throws Exception {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject(BatchStatus.COMPLETED);
out.flush();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream in = new ObjectInputStream(bin);
BatchStatus status = (BatchStatus) in.readObject();
assertEquals(BatchStatus.COMPLETED, status);
}
}

View File

@@ -1,128 +1,128 @@
/*
* 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 EntityTests extends TestCase {
Entity entity = new Entity(new Long(11));
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
*/
public void testHashCode() {
assertEquals(entity.hashCode(), new Entity(entity.getId()).hashCode());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
*/
public void testHashCodeNullId() {
int withoutNull = entity.hashCode();
entity.setId(null);
int withNull = entity.hashCode();
assertTrue(withoutNull!=withNull);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testGetVersion() {
assertEquals(null, entity.getVersion());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testIncrementVersion() {
entity.incrementVersion();
assertEquals(new Integer(0), entity.getVersion());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testIncrementVersionTwice() {
entity.incrementVersion();
entity.incrementVersion();
assertEquals(new Integer(1), entity.getVersion());
}
/**
* @throws Exception
*/
public void testToString() throws Exception {
Entity job = new Entity();
assertTrue(job.toString().indexOf("id=null") >= 0);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsSelf() {
assertEquals(entity, entity);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsSelfWithNullId() {
entity = new Entity(null);
assertEquals(entity, entity);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntityWithNullId() {
entity = new Entity(null);
assertNotSame(entity, new Entity(null));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntity() {
assertEquals(entity, new Entity(entity.getId()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntityWrongId() {
assertFalse(entity.equals(new Entity()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsObject() {
assertFalse(entity.equals(new Object()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsNull() {
assertFalse(entity.equals(null));
}
}
/*
* 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 EntityTests extends TestCase {
Entity entity = new Entity(new Long(11));
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
*/
public void testHashCode() {
assertEquals(entity.hashCode(), new Entity(entity.getId()).hashCode());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
*/
public void testHashCodeNullId() {
int withoutNull = entity.hashCode();
entity.setId(null);
int withNull = entity.hashCode();
assertTrue(withoutNull!=withNull);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testGetVersion() {
assertEquals(null, entity.getVersion());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testIncrementVersion() {
entity.incrementVersion();
assertEquals(new Integer(0), entity.getVersion());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testIncrementVersionTwice() {
entity.incrementVersion();
entity.incrementVersion();
assertEquals(new Integer(1), entity.getVersion());
}
/**
* @throws Exception
*/
public void testToString() throws Exception {
Entity job = new Entity();
assertTrue(job.toString().indexOf("id=null") >= 0);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsSelf() {
assertEquals(entity, entity);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsSelfWithNullId() {
entity = new Entity(null);
assertEquals(entity, entity);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntityWithNullId() {
entity = new Entity(null);
assertNotSame(entity, new Entity(null));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntity() {
assertEquals(entity, new Entity(entity.getId()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntityWrongId() {
assertFalse(entity.equals(new Entity()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsObject() {
assertFalse(entity.equals(new Object()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsNull() {
assertFalse(entity.equals(null));
}
}

View File

@@ -1,41 +1,41 @@
/*
* 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 org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.domain.JobExecutionException;
/**
* @author Dave Syer
*
*/
public class JobExecutionExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobExecutionException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobExecutionException(msg, t);
}
}
/*
* 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 org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.domain.JobExecutionException;
/**
* @author Dave Syer
*
*/
public class JobExecutionExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobExecutionException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobExecutionException(msg, t);
}
}

View File

@@ -1,155 +1,155 @@
/*
* 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 java.util.Date;
import junit.framework.TestCase;
import org.springframework.batch.repeat.ExitStatus;
/**
* @author Dave Syer
*
*/
public class JobExecutionTests extends TestCase {
private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), new JobSupport("foo")), new Long(12));
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testJobExecution() {
assertNull(new JobExecution().getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testGetEndTime() {
assertNull(execution.getEndTime());
execution.setEndTime(new Date(100L));
assertEquals(100L, execution.getEndTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testIsRunning() {
assertTrue(execution.isRunning());
execution.setEndTime(new Date(100L));
assertFalse(execution.isRunning());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testIsRunningWithStoppedExecution() {
assertTrue(execution.isRunning());
execution.stop();
assertTrue(execution.isRunning());
assertTrue(execution.isStopping());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
*/
public void testGetStartTime() {
assertNull(execution.getStartTime());
execution.setStartTime(new Date(0L));
assertEquals(0L, execution.getStartTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.STARTING, execution.getStatus());
execution.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobId() {
assertEquals(11, execution.getJobId().longValue());
execution = new JobExecution(new JobInstance(new Long(23), new JobParameters(), new JobSupport("testJob")), null);
assertEquals(23, execution.getJobId().longValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobIdForNullJob() {
execution = new JobExecution(null);
assertEquals(null, execution.getJobId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJob() {
assertNotNull(execution.getJobInstance());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
*/
public void testGetExitCode() {
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
execution.setExitStatus(new ExitStatus(true, "23"));
assertEquals("23", execution.getExitStatus().getExitCode());
}
public void testContextContainsInfo() throws Exception {
assertEquals("foo", execution.getJobInstance().getJobName());
}
public void testAddAndRemoveStepExecution() throws Exception {
assertEquals(0, execution.getStepExecutions().size());
execution.createStepExecution(new StepSupport("stepName"));
assertEquals(1, execution.getStepExecutions().size());
}
public void testStop() throws Exception {
StepExecution stepExecution = execution.createStepExecution(new StepSupport("stepName"));
assertFalse(stepExecution.isTerminateOnly());
execution.stop();
assertTrue(stepExecution.isTerminateOnly());
}
public void testToString() throws Exception {
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
assertTrue("JobExecution string does not contain name: " + execution, execution.toString().indexOf("foo") >= 0);
}
public void testToStringWithNullJob() throws Exception {
execution = new JobExecution();
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
assertTrue("JobExecution string does not contain job: " + execution, execution.toString().indexOf("job=") >= 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 java.util.Date;
import junit.framework.TestCase;
import org.springframework.batch.repeat.ExitStatus;
/**
* @author Dave Syer
*
*/
public class JobExecutionTests extends TestCase {
private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), new JobSupport("foo")), new Long(12));
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testJobExecution() {
assertNull(new JobExecution().getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testGetEndTime() {
assertNull(execution.getEndTime());
execution.setEndTime(new Date(100L));
assertEquals(100L, execution.getEndTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testIsRunning() {
assertTrue(execution.isRunning());
execution.setEndTime(new Date(100L));
assertFalse(execution.isRunning());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testIsRunningWithStoppedExecution() {
assertTrue(execution.isRunning());
execution.stop();
assertTrue(execution.isRunning());
assertTrue(execution.isStopping());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
*/
public void testGetStartTime() {
assertNull(execution.getStartTime());
execution.setStartTime(new Date(0L));
assertEquals(0L, execution.getStartTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.STARTING, execution.getStatus());
execution.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobId() {
assertEquals(11, execution.getJobId().longValue());
execution = new JobExecution(new JobInstance(new Long(23), new JobParameters(), new JobSupport("testJob")), null);
assertEquals(23, execution.getJobId().longValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobIdForNullJob() {
execution = new JobExecution(null);
assertEquals(null, execution.getJobId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJob() {
assertNotNull(execution.getJobInstance());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
*/
public void testGetExitCode() {
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
execution.setExitStatus(new ExitStatus(true, "23"));
assertEquals("23", execution.getExitStatus().getExitCode());
}
public void testContextContainsInfo() throws Exception {
assertEquals("foo", execution.getJobInstance().getJobName());
}
public void testAddAndRemoveStepExecution() throws Exception {
assertEquals(0, execution.getStepExecutions().size());
execution.createStepExecution(new StepSupport("stepName"));
assertEquals(1, execution.getStepExecutions().size());
}
public void testStop() throws Exception {
StepExecution stepExecution = execution.createStepExecution(new StepSupport("stepName"));
assertFalse(stepExecution.isTerminateOnly());
execution.stop();
assertTrue(stepExecution.isTerminateOnly());
}
public void testToString() throws Exception {
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
assertTrue("JobExecution string does not contain name: " + execution, execution.toString().indexOf("foo") >= 0);
}
public void testToStringWithNullJob() throws Exception {
execution = new JobExecution();
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
assertTrue("JobExecution string does not contain job: " + execution, execution.toString().indexOf("job=") >= 0);
}
}

View File

@@ -1,52 +1,52 @@
/*
* 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 dsyer
*
*/
public class JobInstanceTests extends TestCase {
private JobInstance instance = new JobInstance(new Long(11), new JobParameters(), new JobSupport("job"));
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}.
*/
public void testGetName() {
instance = new JobInstance(new Long(1), new JobParameters(), new JobSupport("foo"));
assertEquals("foo", instance.getJobName());
}
public void testGetJob(){
assertEquals("job", instance.getJob().getName());
}
public void testCreateWithNulls(){
try {
new JobInstance(null, null, null);
fail("job instance can't exist without job specified");
}
catch (IllegalArgumentException e) {
// expected
}
instance = new JobInstance(null, null, new JobSupport("testJob"));
assertEquals("testJob", instance.getJobName());
assertEquals(0, instance.getJobParameters().getParameters().size());
}
}
/*
* 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 dsyer
*
*/
public class JobInstanceTests extends TestCase {
private JobInstance instance = new JobInstance(new Long(11), new JobParameters(), new JobSupport("job"));
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}.
*/
public void testGetName() {
instance = new JobInstance(new Long(1), new JobParameters(), new JobSupport("foo"));
assertEquals("foo", instance.getJobName());
}
public void testGetJob(){
assertEquals("job", instance.getJob().getName());
}
public void testCreateWithNulls(){
try {
new JobInstance(null, null, null);
fail("job instance can't exist without job specified");
}
catch (IllegalArgumentException e) {
// expected
}
instance = new JobInstance(null, null, new JobSupport("testJob"));
assertEquals("testJob", instance.getJobName());
assertEquals(0, instance.getJobParameters().getParameters().size());
}
}

View File

@@ -1,41 +1,41 @@
/*
* 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 org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.domain.JobInterruptedException;
/**
* @author Dave Syer
*
*/
public class JobInterruptedExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobInterruptedException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new RuntimeException(msg, t);
}
}
/*
* 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 org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.domain.JobInterruptedException;
/**
* @author Dave Syer
*
*/
public class JobInterruptedExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobInterruptedException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new RuntimeException(msg, t);
}
}

View File

@@ -1,271 +1,271 @@
/*
* 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 java.util.Date;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.support.PropertiesConverter;
/**
* @author Dave Syer
*
*/
public class StepExecutionTests extends TestCase {
private StepExecution execution = newStepExecution(new StepSupport("stepName"),
new Long(23));
private StepExecution blankExecution = new StepExecution(new StepSupport("blank"), new JobExecution());
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testStepExecution() {
assertNull(new StepExecution().getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testStepExecutionWithNullId() {
assertNull(new StepExecution(new StepSupport("stepName"), new JobExecution()).getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testGetEndTime() {
assertNull(execution.getEndTime());
execution.setEndTime(new Date(0L));
assertEquals(0L, execution.getEndTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
*/
public void testGetStartTime() {
assertNotNull(execution.getStartTime());
execution.setStartTime(new Date(10L));
assertEquals(10L, execution.getStartTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.STARTING, execution.getStatus());
execution.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobId() {
assertEquals(23, execution.getJobExecutionId().longValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
*/
public void testGetExitCode() {
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
execution.setExitStatus(ExitStatus.FINISHED);
assertEquals(ExitStatus.FINISHED, execution.getExitStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementCommitCount()}.
*/
public void testIncrementCommitCount() {
int before = execution.getCommitCount().intValue();
execution.incrementCommitCount();
int after = execution.getCommitCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementTaskCount()}.
*/
public void testIncrementLuwCount() {
int before = execution.getTaskCount().intValue();
execution.incrementTaskCount();
int after = execution.getTaskCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#rollback()}.
*/
public void testIncrementRollbackCount() {
int before = execution.getRollbackCount().intValue();
execution.rollback();
int after = execution.getRollbackCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getCommitCount()}.
*/
public void testGetCommitCount() {
execution.setCommitCount(123);
assertEquals(123, execution.getCommitCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getTaskCount()}.
*/
public void testGetTaskCount() {
execution.setTaskCount(123);
assertEquals(123, execution.getTaskCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getRollbackCount()}.
*/
public void testGetRollbackCount() {
execution.setRollbackCount(123);
assertEquals(123, execution.getRollbackCount().intValue());
}
public void testGetJobExecution() throws Exception {
assertNotNull(execution.getJobExecution());
}
public void testApplyContribution() throws Exception {
StepContribution contribution = execution.createStepContribution();
contribution.incrementCommitCount();
execution.apply(contribution);
assertEquals(new Integer(1), execution.getCommitCount());
}
public void testTerminateOnly() throws Exception {
assertFalse(execution.isTerminateOnly());
execution.setTerminateOnly();
assertTrue(execution.isTerminateOnly());
}
public void testToStringWithNullName() throws Exception {
String value = new StepExecution(new StepSupport(null), new JobExecution()).toString();
assertTrue("Should contain name=null: "+value, value.indexOf("name=null")>=0);
}
public void testToString() throws Exception {
assertTrue("Should contain task count: " + execution.toString(),
execution.toString().indexOf("task") >= 0);
assertTrue("Should contain commit count: " + execution.toString(),
execution.toString().indexOf("commit") >= 0);
assertTrue("Should contain rollback count: " + execution.toString(),
execution.toString().indexOf("rollback") >= 0);
}
public void testExecutionContext() throws Exception {
assertNotNull(execution.getExecutionContext());
ExecutionContext context = new ExecutionContext();
context.putString("foo", "bar");
execution.setExecutionContext(context );
assertEquals("bar", execution.getExecutionContext().getString("foo"));
}
public void testEqualsWithSameIdentifier() throws Exception {
Step step = new StepSupport("stepName");
Entity stepExecution1 = newStepExecution(step, new Long(11));
Entity stepExecution2 = newStepExecution(step, new Long(11));
assertEquals(stepExecution1, stepExecution2);
}
public void testEqualsWithNull() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
assertFalse(stepExecution.equals(null));
}
public void testEqualsWithNullIdentifiers() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
assertFalse(stepExecution.equals(blankExecution));
}
public void testEqualsWithNullJob() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
assertFalse(stepExecution.equals(blankExecution));
}
public void testEqualsWithNullStep() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), null);
assertFalse(stepExecution.equals(blankExecution));
}
public void testEqualsWithSelf() throws Exception {
assertTrue(execution.equals(execution));
}
public void testEqualsWithDifferent() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("foo"), new Long(13));
assertFalse(execution.equals(stepExecution));
}
public void testEqualsWithNullStepId() throws Exception {
Step step = new StepSupport("name");
execution = newStepExecution(step, new Long(31));
assertEquals("name", execution.getStepName());
StepExecution stepExecution = newStepExecution(step, new Long(31));
assertEquals(stepExecution.getJobExecutionId(), execution.getJobExecutionId());
assertTrue(execution.equals(stepExecution));
}
public void testHashCode() throws Exception {
assertTrue("Hash code same as parent", new Entity(execution.getId())
.hashCode() != execution.hashCode());
}
public void testHashCodeWithNullIds() throws Exception {
assertTrue("Hash code not same as parent",
new Entity(execution.getId()).hashCode() != blankExecution
.hashCode());
}
public void testHashCodeViaHashSet() throws Exception {
Set set = new HashSet();
set.add(execution);
assertTrue(set.contains(execution));
execution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar")));
assertTrue(set.contains(execution));
}
private StepExecution newStepExecution(Step step, Long long2) {
JobInstance job = new JobInstance(new Long(3), new JobParameters(), new JobSupport("testJob"));
StepExecution execution = new StepExecution(step, new JobExecution(job, long2), new Long(4));
return execution;
}
}
/*
* 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 java.util.Date;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.support.PropertiesConverter;
/**
* @author Dave Syer
*
*/
public class StepExecutionTests extends TestCase {
private StepExecution execution = newStepExecution(new StepSupport("stepName"),
new Long(23));
private StepExecution blankExecution = new StepExecution(new StepSupport("blank"), new JobExecution());
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testStepExecution() {
assertNull(new StepExecution().getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testStepExecutionWithNullId() {
assertNull(new StepExecution(new StepSupport("stepName"), new JobExecution()).getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testGetEndTime() {
assertNull(execution.getEndTime());
execution.setEndTime(new Date(0L));
assertEquals(0L, execution.getEndTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
*/
public void testGetStartTime() {
assertNotNull(execution.getStartTime());
execution.setStartTime(new Date(10L));
assertEquals(10L, execution.getStartTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.STARTING, execution.getStatus());
execution.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobId() {
assertEquals(23, execution.getJobExecutionId().longValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
*/
public void testGetExitCode() {
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
execution.setExitStatus(ExitStatus.FINISHED);
assertEquals(ExitStatus.FINISHED, execution.getExitStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementCommitCount()}.
*/
public void testIncrementCommitCount() {
int before = execution.getCommitCount().intValue();
execution.incrementCommitCount();
int after = execution.getCommitCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementTaskCount()}.
*/
public void testIncrementLuwCount() {
int before = execution.getTaskCount().intValue();
execution.incrementTaskCount();
int after = execution.getTaskCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#rollback()}.
*/
public void testIncrementRollbackCount() {
int before = execution.getRollbackCount().intValue();
execution.rollback();
int after = execution.getRollbackCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getCommitCount()}.
*/
public void testGetCommitCount() {
execution.setCommitCount(123);
assertEquals(123, execution.getCommitCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getTaskCount()}.
*/
public void testGetTaskCount() {
execution.setTaskCount(123);
assertEquals(123, execution.getTaskCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getRollbackCount()}.
*/
public void testGetRollbackCount() {
execution.setRollbackCount(123);
assertEquals(123, execution.getRollbackCount().intValue());
}
public void testGetJobExecution() throws Exception {
assertNotNull(execution.getJobExecution());
}
public void testApplyContribution() throws Exception {
StepContribution contribution = execution.createStepContribution();
contribution.incrementCommitCount();
execution.apply(contribution);
assertEquals(new Integer(1), execution.getCommitCount());
}
public void testTerminateOnly() throws Exception {
assertFalse(execution.isTerminateOnly());
execution.setTerminateOnly();
assertTrue(execution.isTerminateOnly());
}
public void testToStringWithNullName() throws Exception {
String value = new StepExecution(new StepSupport(null), new JobExecution()).toString();
assertTrue("Should contain name=null: "+value, value.indexOf("name=null")>=0);
}
public void testToString() throws Exception {
assertTrue("Should contain task count: " + execution.toString(),
execution.toString().indexOf("task") >= 0);
assertTrue("Should contain commit count: " + execution.toString(),
execution.toString().indexOf("commit") >= 0);
assertTrue("Should contain rollback count: " + execution.toString(),
execution.toString().indexOf("rollback") >= 0);
}
public void testExecutionContext() throws Exception {
assertNotNull(execution.getExecutionContext());
ExecutionContext context = new ExecutionContext();
context.putString("foo", "bar");
execution.setExecutionContext(context );
assertEquals("bar", execution.getExecutionContext().getString("foo"));
}
public void testEqualsWithSameIdentifier() throws Exception {
Step step = new StepSupport("stepName");
Entity stepExecution1 = newStepExecution(step, new Long(11));
Entity stepExecution2 = newStepExecution(step, new Long(11));
assertEquals(stepExecution1, stepExecution2);
}
public void testEqualsWithNull() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
assertFalse(stepExecution.equals(null));
}
public void testEqualsWithNullIdentifiers() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
assertFalse(stepExecution.equals(blankExecution));
}
public void testEqualsWithNullJob() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
assertFalse(stepExecution.equals(blankExecution));
}
public void testEqualsWithNullStep() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), null);
assertFalse(stepExecution.equals(blankExecution));
}
public void testEqualsWithSelf() throws Exception {
assertTrue(execution.equals(execution));
}
public void testEqualsWithDifferent() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("foo"), new Long(13));
assertFalse(execution.equals(stepExecution));
}
public void testEqualsWithNullStepId() throws Exception {
Step step = new StepSupport("name");
execution = newStepExecution(step, new Long(31));
assertEquals("name", execution.getStepName());
StepExecution stepExecution = newStepExecution(step, new Long(31));
assertEquals(stepExecution.getJobExecutionId(), execution.getJobExecutionId());
assertTrue(execution.equals(stepExecution));
}
public void testHashCode() throws Exception {
assertTrue("Hash code same as parent", new Entity(execution.getId())
.hashCode() != execution.hashCode());
}
public void testHashCodeWithNullIds() throws Exception {
assertTrue("Hash code not same as parent",
new Entity(execution.getId()).hashCode() != blankExecution
.hashCode());
}
public void testHashCodeViaHashSet() throws Exception {
Set set = new HashSet();
set.add(execution);
assertTrue(set.contains(execution));
execution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar")));
assertTrue(set.contains(execution));
}
private StepExecution newStepExecution(Step step, Long long2) {
JobInstance job = new JobInstance(new Long(3), new JobParameters(), new JobSupport("testJob"));
StepExecution execution = new StepExecution(step, new JobExecution(job, long2), new Long(4));
return execution;
}
}

View File

@@ -1,117 +1,117 @@
/*
* 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 org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
/**
* Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that
* if no name is provided explicitly it will be inferred from the bean definition in Spring configuration.
*
* @author Dave Syer
*
*/
public class StepSupport implements Step, BeanNameAware {
private String name;
private int startLimit = Integer.MAX_VALUE;
private boolean allowStartIfComplete;
/**
* Default constructor for {@link StepSupport}.
*/
public StepSupport() {
super();
}
/**
* @param string
*/
public StepSupport(String string) {
super();
this.name = string;
}
public String getName() {
return this.name;
}
/**
* Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the
* name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent
* bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
public void setBeanName(String name) {
if (this.name == null) {
this.name = name;
}
}
/**
* Set the name property. Always overrides the default value if this object is a Spring bean.
*
* @see #setBeanName(java.lang.String)
*/
public void setName(String name) {
this.name = name;
}
public int getStartLimit() {
return this.startLimit;
}
/**
* Public setter for the startLimit.
*
* @param startLimit the startLimit to set
*/
public void setStartLimit(int startLimit) {
this.startLimit = startLimit;
}
public boolean isAllowStartIfComplete() {
return this.allowStartIfComplete;
}
/**
* Public setter for the shouldAllowStartIfComplete.
*
* @param allowStartIfComplete the shouldAllowStartIfComplete to set
*/
public void setAllowStartIfComplete(boolean allowStartIfComplete) {
this.allowStartIfComplete = allowStartIfComplete;
}
/**
* Not supported but provided so that tests can easily create a step.
*
* @throws UnsupportedOperationException always
*
* @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution)
*/
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
throw new UnsupportedOperationException(
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
}
}
/*
* 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 org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.domain.Step;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
/**
* Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that
* if no name is provided explicitly it will be inferred from the bean definition in Spring configuration.
*
* @author Dave Syer
*
*/
public class StepSupport implements Step, BeanNameAware {
private String name;
private int startLimit = Integer.MAX_VALUE;
private boolean allowStartIfComplete;
/**
* Default constructor for {@link StepSupport}.
*/
public StepSupport() {
super();
}
/**
* @param string
*/
public StepSupport(String string) {
super();
this.name = string;
}
public String getName() {
return this.name;
}
/**
* Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the
* name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent
* bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
public void setBeanName(String name) {
if (this.name == null) {
this.name = name;
}
}
/**
* Set the name property. Always overrides the default value if this object is a Spring bean.
*
* @see #setBeanName(java.lang.String)
*/
public void setName(String name) {
this.name = name;
}
public int getStartLimit() {
return this.startLimit;
}
/**
* Public setter for the startLimit.
*
* @param startLimit the startLimit to set
*/
public void setStartLimit(int startLimit) {
this.startLimit = startLimit;
}
public boolean isAllowStartIfComplete() {
return this.allowStartIfComplete;
}
/**
* Public setter for the shouldAllowStartIfComplete.
*
* @param allowStartIfComplete the shouldAllowStartIfComplete to set
*/
public void setAllowStartIfComplete(boolean allowStartIfComplete) {
this.allowStartIfComplete = allowStartIfComplete;
}
/**
* Not supported but provided so that tests can easily create a step.
*
* @throws UnsupportedOperationException always
*
* @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution)
*/
public void execute(StepExecution stepExecution) throws JobInterruptedException, InfrastructureException {
throw new UnsupportedOperationException(
"Cannot process a StepExecution. Use a smarter subclass of StepSupport.");
}
}

View File

@@ -1,44 +1,44 @@
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.repository.DuplicateJobException;
/**
* @author Dave Syer
*
*/
public class DuplicateJobExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new DuplicateJobException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new DuplicateJobException(msg, t);
}
}
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.repository.DuplicateJobException;
/**
* @author Dave Syer
*
*/
public class DuplicateJobExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new DuplicateJobException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new DuplicateJobException(msg, t);
}
}

View File

@@ -1,44 +1,44 @@
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.repository.JobException;
/**
* @author Dave Syer
*
*/
public class JobExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobException(msg, t);
}
}
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.repository.JobException;
/**
* @author Dave Syer
*
*/
public class JobExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobException(msg, t);
}
}

View File

@@ -1,40 +1,40 @@
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobExecutionAlreadyRunningException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobExecutionAlreadyRunningException(msg, t);
}
}
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobExecutionAlreadyRunningException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobExecutionAlreadyRunningException(msg, t);
}
}

View File

@@ -1,43 +1,43 @@
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class JobRestartExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobRestartException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobRestartException(msg, t);
}
}
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class JobRestartExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobRestartException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobRestartException(msg, t);
}
}

View File

@@ -1,44 +1,44 @@
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.repository.NoSuchJobException;
/**
* @author Dave Syer
*
*/
public class NoSuchJobExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new NoSuchJobException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new NoSuchJobException(msg, t);
}
}
/*
* 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.repository;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.repository.NoSuchJobException;
/**
* @author Dave Syer
*
*/
public class NoSuchJobExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new NoSuchJobException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new NoSuchJobException(msg, t);
}
}