From 62eb328f5a3e7f4c170f35f1fecc512c6f83449d Mon Sep 17 00:00:00 2001 From: lucasward Date: Mon, 24 Sep 2007 05:12:58 +0000 Subject: [PATCH] OPEN - issue BATCH-116: Create XML input/output source which will work directly with StAX parser http://opensource.atlassian.com/projects/spring/browse/BATCH-116 --- ...20070918.testStream.xmlFileStep.output.xml | 1 + .../input/20070918.testStream.xmlFileStep.xml | 57 +++++++++++++ .../resources/data/staxJob/input/trade.xsd | 17 ++++ .../src/main/resources/jobs/xmlStaxJob.xml | 80 +++++++++++++++++++ .../sample/XmlStaxJobFunctionalTests.java | 50 ++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 samples/20070918.testStream.xmlFileStep.output.xml create mode 100644 samples/src/main/resources/data/staxJob/input/20070918.testStream.xmlFileStep.xml create mode 100644 samples/src/main/resources/data/staxJob/input/trade.xsd create mode 100644 samples/src/main/resources/jobs/xmlStaxJob.xml create mode 100644 samples/src/test/java/org/springframework/batch/sample/XmlStaxJobFunctionalTests.java diff --git a/samples/20070918.testStream.xmlFileStep.output.xml b/samples/20070918.testStream.xmlFileStep.output.xml new file mode 100644 index 000000000..50a39a9c9 --- /dev/null +++ b/samples/20070918.testStream.xmlFileStep.output.xml @@ -0,0 +1 @@ +XYZ0001511.39Customer1XYZ0002272.99Customer2cXYZ0003999.99Customer3XYZ0001511.39Customer1XYZ0002272.99Customer2cXYZ0003999.99Customer3XYZ0001511.39Customer1XYZ0002272.99Customer2cXYZ0003999.99Customer3 \ No newline at end of file diff --git a/samples/src/main/resources/data/staxJob/input/20070918.testStream.xmlFileStep.xml b/samples/src/main/resources/data/staxJob/input/20070918.testStream.xmlFileStep.xml new file mode 100644 index 000000000..1e4169bf2 --- /dev/null +++ b/samples/src/main/resources/data/staxJob/input/20070918.testStream.xmlFileStep.xml @@ -0,0 +1,57 @@ + + + + XYZ0001 + 5 + 11.39 + Customer1 + + + XYZ0002 + 2 + 72.99 + Customer2c + + + XYZ0003 + 9 + 99.99 + Customer3 + + + XYZ0001 + 5 + 11.39 + Customer1 + + + XYZ0002 + 2 + 72.99 + Customer2c + + + XYZ0003 + 9 + 99.99 + Customer3 + + + XYZ0001 + 5 + 11.39 + Customer1 + + + XYZ0002 + 2 + 72.99 + Customer2c + + + XYZ0003 + 9 + 99.99 + Customer3 + + diff --git a/samples/src/main/resources/data/staxJob/input/trade.xsd b/samples/src/main/resources/data/staxJob/input/trade.xsd new file mode 100644 index 000000000..f4f9b08c6 --- /dev/null +++ b/samples/src/main/resources/data/staxJob/input/trade.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/samples/src/main/resources/jobs/xmlStaxJob.xml b/samples/src/main/resources/jobs/xmlStaxJob.xml new file mode 100644 index 000000000..842998436 --- /dev/null +++ b/samples/src/main/resources/jobs/xmlStaxJob.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/src/test/java/org/springframework/batch/sample/XmlStaxJobFunctionalTests.java b/samples/src/test/java/org/springframework/batch/sample/XmlStaxJobFunctionalTests.java new file mode 100644 index 000000000..4ebed8258 --- /dev/null +++ b/samples/src/test/java/org/springframework/batch/sample/XmlStaxJobFunctionalTests.java @@ -0,0 +1,50 @@ +/* + * 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.sample; + +import org.springframework.batch.sample.AbstractLifecycleSpringContextTests; + +public class XmlStaxJobFunctionalTests extends AbstractLifecycleSpringContextTests { + +// @Override + protected String[] getConfigLocations() { + return new String[]{"jobs/xmlStaxJob.xml"}; + } + + /** + * Output should be the same as input + */ + protected void validatePostConditions() throws Exception { + applicationContext.close(); //make sure the output file is closed + + /* TODO compare DOM to the expected output -> does not work as expected yet, fails on correct output + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document expectedOutput = builder.parse( + new File("src/main/resources/data/staxJob/input/20070918.testStream.xmlFileStep.output.xml")); + + Document actualOutput = builder.parse( + new File("20070918.testStream.xmlFileStep.output.xml")); + + expectedOutput.normalize(); + actualOutput.normalize(); + + assertTrue(expectedOutput.isEqualNode(actualOutput)); + */ + } + +}