IN PROGRESS - issue BATCH-267: Re-organise I/O (io) packages

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

Rationalize interface locations to minimize chance of cycles in future.
Rename and refactor OXM interfaces a bit to be more consistent
This commit is contained in:
dsyer
2008-01-02 09:21:44 +00:00
parent 03ea1e3826
commit 1be07ec5b2
19 changed files with 84 additions and 94 deletions

View File

@@ -25,6 +25,7 @@ import java.util.Collections;
import junit.framework.TestCase;
import org.springframework.batch.io.file.FlatFileItemWriter;
import org.springframework.batch.io.file.transform.Converter;
import org.springframework.batch.restart.RestartData;
import org.springframework.core.io.FileSystemResource;
import org.springframework.transaction.support.TransactionSynchronization;

View File

@@ -37,7 +37,7 @@ public class StaxEventReaderItemReaderTests extends TestCase {
// test xml input
private String xml = "<root> <fragment> <misc1/> </fragment> <misc2/> <fragment> testString </fragment> </root>";
private FragmentDeserializer deserializer = new MockFragmentDeserializer();
private EventReaderDeserializer deserializer = new MockFragmentDeserializer();
private static final String FRAGMENT_ROOT_ELEMENT = "fragment";
@@ -277,7 +277,7 @@ public class StaxEventReaderItemReaderTests extends TestCase {
* document events for the fragment root & end tags + skips the fragment
* contents.
*/
private static class MockFragmentDeserializer implements FragmentDeserializer {
private static class MockFragmentDeserializer implements EventReaderDeserializer {
/**
* A simple mapFragment implementation checking the
@@ -339,7 +339,7 @@ public class StaxEventReaderItemReaderTests extends TestCase {
/**
* Moves cursor inside the fragment body and causes rollback.
*/
private static class ExceptionFragmentDeserializer implements FragmentDeserializer {
private static class ExceptionFragmentDeserializer implements EventReaderDeserializer {
public Object deserializeFragment(XMLEventReader eventReader) {
eventReader.next();

View File

@@ -12,7 +12,7 @@ import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.springframework.batch.io.xml.StaxEventItemWriter;
import org.springframework.batch.io.xml.oxm.MarshallingObjectToXmlSerializer;
import org.springframework.batch.io.xml.oxm.MarshallingEventWriterSerializer;
import org.springframework.batch.restart.RestartData;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
@@ -55,7 +55,7 @@ public class StaxEventWriterItemWriterTests extends TestCase {
*/
public void testWrite() throws Exception {
Marshaller marshaller = new InputCheckMarshaller();
MarshallingObjectToXmlSerializer serializer = new MarshallingObjectToXmlSerializer(marshaller);
MarshallingEventWriterSerializer serializer = new MarshallingEventWriterSerializer(marshaller);
writer.setSerializer(serializer);
// see asserts in the marshaller
@@ -193,7 +193,7 @@ public class StaxEventWriterItemWriterTests extends TestCase {
source.setResource(resource);
Marshaller marshaller = new SimpleMarshaller();
MarshallingObjectToXmlSerializer serializer = new MarshallingObjectToXmlSerializer(marshaller);
MarshallingEventWriterSerializer serializer = new MarshallingEventWriterSerializer(marshaller);
source.setSerializer(serializer);
source.setEncoding("UTF-8");

View File

@@ -26,7 +26,7 @@ import javax.xml.transform.Result;
import junit.framework.TestCase;
import org.springframework.batch.io.xml.oxm.MarshallingObjectToXmlSerializer;
import org.springframework.batch.io.xml.oxm.MarshallingEventWriterSerializer;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.XmlMappingException;
@@ -39,21 +39,23 @@ import org.springframework.oxm.XmlMappingException;
*/
public class MarshallingObjectToXmlSerializerTests extends TestCase {
MarshallingObjectToXmlSerializer xmlSerializer;
MarshallingEventWriterSerializer xmlSerializer;
MockMarshaller mockMarshaller = new MockMarshaller();
private StubXmlEventWriter writer;
protected void setUp() throws Exception {
super.setUp();
xmlSerializer = new MarshallingObjectToXmlSerializer(mockMarshaller);
xmlSerializer.setEventWriter(new StubXmlEventWriter());
xmlSerializer = new MarshallingEventWriterSerializer(mockMarshaller);
writer = new StubXmlEventWriter();
}
public void testSuccessfulWrite(){
Object objectToOutput = new Object();
xmlSerializer.serializeObject(objectToOutput);
xmlSerializer.serializeObject(writer, objectToOutput);
assertEquals(objectToOutput, mockMarshaller.getMarshalledObject());
}
@@ -61,7 +63,7 @@ public class MarshallingObjectToXmlSerializerTests extends TestCase {
mockMarshaller.setThrowException(true);
try{
xmlSerializer.serializeObject(new Object());
xmlSerializer.serializeObject(writer, new Object());
fail("Exception expected");
}catch(DataAccessResourceFailureException ex){
//expected

View File

@@ -8,21 +8,21 @@ import javax.xml.stream.XMLInputFactory;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.io.xml.oxm.UnmarshallingFragmentDeserializer;
import org.springframework.batch.io.xml.oxm.UnmarshallingEventReaderDeserializer;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.dao.DataAccessException;
import org.springframework.oxm.Unmarshaller;
/**
* Tests for {@link UnmarshallingFragmentDeserializer}
* Tests for {@link UnmarshallingEventReaderDeserializer}
*
* @author Robert Kasanicky
*/
public class UnmarshallingFragmentDeserializerTests extends TestCase {
// object under test
private UnmarshallingFragmentDeserializer deserializer;
private UnmarshallingEventReaderDeserializer deserializer;
private XMLEventReader eventReader;
private String xml = "<root> </root>";
@@ -37,7 +37,7 @@ public class UnmarshallingFragmentDeserializerTests extends TestCase {
eventReader = XMLInputFactory.newInstance().createXMLEventReader(input.getInputStream());
unmarshaller = (Unmarshaller) unmarshallerControl.getMock();
unmarshallerControl.setDefaultMatcher(MockControl.ALWAYS_MATCHER);
deserializer = new UnmarshallingFragmentDeserializer(unmarshaller);
deserializer = new UnmarshallingEventReaderDeserializer(unmarshaller);
}
/**
@@ -81,7 +81,7 @@ public class UnmarshallingFragmentDeserializerTests extends TestCase {
*/
public void testExceptionOnNullUnmarshaller() {
try {
deserializer = new UnmarshallingFragmentDeserializer(null);
deserializer = new UnmarshallingEventReaderDeserializer(null);
fail("Exception expected");
}
catch (IllegalArgumentException e) {