OPEN - issue BATCH-304: BatchCommandLineLauncher simplified and rename

http://jira.springframework.org/browse/BATCH-304

Allow BatchStatus to be null in Dao (why not?)
This commit is contained in:
dsyer
2008-01-24 08:11:23 +00:00
parent 5a8635a32e
commit 13bce7b1e1
2 changed files with 27 additions and 29 deletions

View File

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