diff options
Diffstat (limited to 'branches/sca-equinox')
4 files changed, 55 insertions, 5 deletions
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java index 9b88ad3a3d..69ddbdb3e2 100644 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java +++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java @@ -51,9 +51,7 @@ public class ReadWriteAttributeTestCase extends TestCase { private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+ "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\">"+ - "<service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\">"+ - "<interface.java xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" interface=\"calculator.CalculatorService\" />"+ - "</service>"+ + "<service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\" />"+ "<component name=\"CalculatorServiceComponent\" customAttribute=\"customValue\">"+ "<reference name=\"addService\" target=\"AddServiceComponent\" />"+ "<reference name=\"subtractService\" target=\"SubtractServiceComponent\" />"+ @@ -101,6 +99,7 @@ public class ReadWriteAttributeTestCase extends TestCase { ByteArrayOutputStream bos = new ByteArrayOutputStream(); staxProcessor.write(composite, bos); + System.out.println(XML); System.out.println(bos.toString()); assertEquals(XML, bos.toString()); diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java new file mode 100644 index 0000000000..467b050fff --- /dev/null +++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java @@ -0,0 +1,53 @@ +package org.apache.tuscany.sca.assembly.xml; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.junit.Test; + +public class TestReadWriteUnknownElement extends TestCase { + + private XMLInputFactory inputFactory; + String XML = "<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><interface.java xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" target=\"AddServiceComponent\" /><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\" /><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /><x:unknownElement xmlns:x=\"http://x\" uknAttr=\"attribute1\"><x:subUnknownElement1 uknAttr1=\"attribute1\" /><x:subUnknownElement2 /></x:unknownElement></composite>"; + private ExtensibleStAXArtifactProcessor staxProcessor; + + @Override + public void setUp() throws Exception { + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null); + } + + @Override + public void tearDown() throws Exception { + } + + @Test + public void testReadWriteComposite() throws Exception{ + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = (Composite)staxProcessor.read(reader); + assertNotNull(composite); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, bos); + System.out.println(bos.toString()); + assertEquals(XML,bos.toString()); + bos.close(); + + is.close(); + } + +} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java index 76361d4b70..ed3e7897c0 100644 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java +++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java @@ -46,7 +46,6 @@ import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.definitions.SCADefinitions; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl; diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java index b859779437..cfe218c1e9 100644 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java +++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java @@ -49,7 +49,6 @@ import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.definitions.SCADefinitions; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl; |