summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/assembly-xml/src/test
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
commit5f3869c451e46aadc943d00087d6847877dd1c50 (patch)
treee22baaff1fb9ea42606b7d04af52e032e3bc03bc /java/sca/modules/assembly-xml/src/test
parent60744a36aae604ac3c4499ed54f1082ab8f5947d (diff)
Merging the 1.x delta on top of the equinox based modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly-xml/src/test')
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java83
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java86
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java2
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java40
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java94
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite14
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType4
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType6
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite30
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite42
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite27
11 files changed, 371 insertions, 57 deletions
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
index 9300731007..abf0269c0f 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
@@ -25,48 +25,71 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.Assert;
+import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.junit.BeforeClass;
import org.junit.Test;
-public class AnyElementReadWriteTestCase {
+public class AnyElementReadWriteTestCase extends TestCase {
- private static XMLInputFactory inputFactory;
- //private static 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 static 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\" /><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\" /></composite>";
- private static ExtensibleStAXArtifactProcessor staxProcessor;
+ 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 interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" multiplicity=\"0..1\" 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\"><y:subUnknownElement1 xmlns:y=\"http://y\" uknAttr1=\"attribute2\" /><x:subUnknownElement2 /></x:unknownElement></composite>";
+ private ExtensibleStAXArtifactProcessor staxProcessor;
- @BeforeClass
- public static 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 setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints
+ .getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors,
+ inputFactory, XMLOutputFactory.newInstance(), null);
+ }
- @Test
- public void testReadWriteComposite() throws Exception {
- InputStream is = getClass().getResourceAsStream("Calculator.composite");
- XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
- Composite composite = (Composite)staxProcessor.read(reader);
- Assert.assertNotNull(composite);
+ @Override
+ public void tearDown() throws Exception {
+ }
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- staxProcessor.write(composite, bos);
- System.out.println(bos.toString());
- Assert.assertEquals(XML, bos.toString());
- bos.close();
+ /*
+ @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);
- is.close();
- }
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ //System.out.println(bos.toString());
+ assertEquals(XML, bos.toString());
+ bos.close();
+
+ is.close();
+ }
+ */
+
+ @Test
+ public void testReadWriteUnknownElementComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("UnknownElement.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/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..f34ff1f8bc
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.sca.assembly.xml;
+
+import static junit.framework.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+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.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * TUSCANY-2662
+ *
+ * @version $Rev$ $Date$
+ */
+public class MultiplicityReadWriteTestCase {
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
+ }
+
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Multiplicity.composite");
+ Composite composite = staxProcessor.read(is, Composite.class);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class);
+
+ verifyComposite(composite);
+
+ }
+
+
+ private void verifyComposite(Composite composite) {
+ assertEquals(composite.getComponents().get(0).getReferences().get(0).getMultiplicity(), Multiplicity.ZERO_N);
+ assertEquals(composite.getReferences().get(0).getMultiplicity(), Multiplicity.ONE_N);
+ }
+
+}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
index 4918271b1f..9409a1bfee 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -193,7 +193,7 @@ public class ReadDocumentTestCase {
documentProcessor.resolve(composite, resolver);
- assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
index 10012282fc..6105b4a86a 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
@@ -51,20 +51,33 @@ public class ReadWriteAttributeTestCase {
private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
+ // implementation.java for CalculatorServiceComponent appears in a strange place as the
+ // java implementation extension is not loaded and hence they are loaded as any elements
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\" />"+
- "<component name=\"CalculatorServiceComponent\" customAttribute=\"customValue\">"+
- "<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\" />"+
- "</composite>";
+ "<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 interface=\"calculator.CalculatorService\" />"+
+ "</service>"+
+ "<component name=\"CalculatorServiceComponent\" customAttribute=\"customValue\">"+
+ "<implementation.java class=\"calculator.CalculatorServiceImpl\" />"+
+ "<reference name=\"addService\" target=\"AddServiceComponent\" />"+
+ "<reference name=\"subtractService\" target=\"SubtractServiceComponent\" />"+
+ "<reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" />"+
+ "<reference name=\"divideService\" target=\"DivideServiceComponent\" />"+
+ "</component>"+
+ "<component name=\"AddServiceComponent\">"+
+ "<implementation.java class=\"calculator.AddServiceImpl\" />"+
+ "</component>"+
+ "<component name=\"SubtractServiceComponent\">"+
+ "<implementation.java class=\"calculator.SubtractServiceImpl\" />"+
+ "</component>"+
+ "<component name=\"MultiplyServiceComponent\">"+
+ "<implementation.java class=\"calculator.MultiplyServiceImpl\" />"+
+ "</component>"+
+ "<component name=\"DivideServiceComponent\">"+
+ "<implementation.java class=\"calculator.DivideServiceImpl\" />"+
+ "</component>"+
+ "</composite>";
@BeforeClass
public static void setUp() throws Exception {
@@ -75,7 +88,6 @@ public class ReadWriteAttributeTestCase {
StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
staxAttributeProcessors.addArtifactProcessor(new TestAttributeProcessor());
-
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..312b5c8fab
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.sca.assembly.xml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+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.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev: 711584 $ $Date: 2008-11-05 15:07:03 +0000 (Wed, 05 Nov 2008) $
+ */
+public class ReadWriteLocalCompositeTestCase extends TestCase {
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ private static final String LOCAL_COMPOSITE_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://localcalc\" name=\"LocalCalculator\" local=\"true\">"+
+ "</composite>";
+
+ @Override
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ staxAttributeProcessors.addArtifactProcessor(new TestAttributeProcessor());
+
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+
+ }
+
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+ }
+
+ public void testWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ System.out.println(bos.toString());
+
+ assertEquals(LOCAL_COMPOSITE_XML, bos.toString());
+ }
+}
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
index 85f6a39243..602d42a06a 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
@@ -22,13 +22,14 @@
xmlns:calc="http://calc"
targetNamespace="http://calc"
name="Calculator">
-
- <service name="CalculatorService" promote="CalculatorServiceComponent">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
<interface.java interface="calculator.CalculatorService"/>
</service>
+
<component name="CalculatorServiceComponent">
<implementation.java class="calculator.CalculatorServiceImpl"/>
- <reference name="addService" target="AddServiceComponent"/>
+ <reference name="addService" multiplicity="0..1" target="AddServiceComponent"/>
<reference name="subtractService" target="SubtractServiceComponent"/>
<reference name="multiplyService" target="MultiplyServiceComponent"/>
<reference name="divideService" target="DivideServiceComponent"/>
@@ -51,9 +52,8 @@
</component>
<x:unknownElement uknAttr="attribute1">
- <x:subUnknownElement1 uknAttr1="attribute1"/>
- <x:subUnknownElement2/>
+ <y:subUnknownElement1 xmlns:y="http://y" uknAttr1="attribute2"/>
+ <x:subUnknownElement2 />
</x:unknownElement>
-
-
+
</composite>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
index 072fe8fde1..d6ec9b0ff0 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
@@ -26,9 +26,9 @@
<interface.java class="calculator.CalculatorService" />
</service>
- <reference name="divideService">
+ <reference name="divideService" multiplicity="1..1">
<interface.java class="calculator.DivideService" />
</reference>
</constrainingType>
- \ No newline at end of file
+
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
index d67ba3ec2b..299eb8c197 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
@@ -20,12 +20,12 @@
<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
<service name="CalculatorService">
- <interface.java class="calculator.CalculatorService" />
+ <interface.java interface="calculator.CalculatorService" />
</service>
<reference name="divideService">
- <interface.java class="calculator.DivideService" />
+ <interface.java interface="calculator.DivideService" />
</reference>
</componentType>
- \ No newline at end of file
+
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
new file mode 100644
index 0000000000..a221c23eec
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="composite1" targetNamespace="http://temp">
+ <component name="data7">
+ <implementation.java class="temp.EchoImpl"/>
+ <service name="Echo">
+ <interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"/>
+ </service>
+ <reference multiplicity="0..n" name="reference" requires=""/>
+ </component>
+
+ <reference multiplicity="1..n" name="reference" promote="" requires=""/>
+</composite>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
new file mode 100644
index 0000000000..f8c0c5ea36
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:ns1="http://temp" xmlns:ns1_1="adfsaf" name="composite1" targetNamespace="http://temp">
+ <unknown>Test unknown</unknown>
+ <component name="data7">
+ <implementation.java class="temp.EchoImpl"/>
+ <unknownImpl abc="cde"/>
+ <service>
+ <interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"/>
+ </service>
+ </component>
+</composite>
+
+And I got this:
+<?xml version="1.0" encoding="UTF-8"?>
+<composite targetNamespace="http://temp" name="composite1"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <component name="data7">
+ <implementation.java class="temp.EchoImpl"></implementation.java>
+ <service>
+ <interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"></interface.wsdl>
+ </service>
+ </component>
+ <component name="empty"></component>
+</composite>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
new file mode 100644
index 0000000000..3bda9ac31c
--- /dev/null
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>