summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test')
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java140
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java86
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java151
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java207
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java91
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java132
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java147
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java100
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java171
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java103
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java61
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java82
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java40
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java186
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java148
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java158
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java95
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite59
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType34
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType31
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite32
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite29
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite44
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite127
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite56
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite125
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml96
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite27
-rw-r--r--tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml206
29 files changed, 2964 insertions, 0 deletions
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
new file mode 100644
index 0000000000..fa0e9bdf5b
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
@@ -0,0 +1,140 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
+ */
+public class BuildPolicyTestCase {
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static Composite composite;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder =
+ extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class)
+ .getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ List<Definitions> policyDefinitions = new ArrayList<Definitions>();
+ resolver = new DefaultModelResolver();
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ monitor = monitorFactory.createMonitor();
+
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml");
+ uri = URI.create("another_test_definitions.xml");
+ Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(definitions);
+ policyDefinitions.add(definitions);
+
+ documentProcessor.resolve(definitions, resolver);
+ documentProcessor.resolve(composite, resolver);
+
+ compositeBuilder.build(composite, definitions, monitor);
+ }
+
+ @Test
+ // @Ignore("The inheritance will be calculated differently in OASIS SCA")
+ public void testPolicyIntentInheritance() throws Exception {
+ String namespaceUri = "http://test";
+
+ PolicySubject policiedComposite = composite;
+ assertEquals(policiedComposite.getRequiredIntents().size(), 1);
+ assertEquals(policiedComposite.getRequiredIntents().get(0).getName(),
+ new QName(namespaceUri, "tuscanyIntent_1"));
+
+ Component component = composite.getComponents().get(0);
+ Endpoint ep = component.getServices().get(0).getEndpoints().get(0);
+ EndpointReference epr = component.getReferences().get(0).getEndpointReferences().get(0);
+
+ System.out.println(ep.getRequiredIntents());
+ System.out.println(epr.getRequiredIntents());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..4e74c55949
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/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 org.junit.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/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
new file mode 100644
index 0000000000..54d8f3d260
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
@@ -0,0 +1,151 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Property;
+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.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadAllTestCase {
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is));
+ assertNotNull(composite);
+ assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
+ assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "CalculatorComponent"));
+ assertTrue(composite.isLocal());
+ assertFalse(composite.getAutowire() == Boolean.TRUE);
+ assertEquals(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
+ "confidentiality"));
+ assertEquals(((PolicySubject)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+
+ Composite include = composite.getIncludes().get(0);
+ assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));
+
+ CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);
+ assertEquals(calcCompositeService.getName(), "CalculatorService");
+ assertTrue(calcCompositeService.getPromotedService().isUnresolved());
+ assertEquals(calcCompositeService.getPromotedService().getName(),
+ "CalculatorService");
+ assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+ Callback calcServiceCallback = calcCompositeService.getCallback();
+ assertNotNull(calcServiceCallback);
+ assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ Component calcComponent = composite.getComponents().get(0);
+ assertEquals(calcComponent.getName(), "CalculatorServiceComponent");
+ assertEquals(calcComponent.getAutowire(), Boolean.FALSE);
+ assertEquals(calcComponent.getConstrainingType().getName(), new QName("http://calc",
+ "CalculatorComponent"));
+ assertEquals(calcComponent.getRequiredIntents().get(0).getName(), new QName("http://test",
+ "confidentiality"));
+ assertEquals(calcComponent.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+
+ ComponentService calcComponentService = calcComponent.getServices().get(0);
+ assertEquals(calcComponentService.getName(), "CalculatorService");
+ assertEquals(calcComponentService.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcComponentService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ ComponentReference calcComponentReference = calcComponent.getReferences().get(0);
+ assertEquals(calcComponentReference.getName(), "addService");
+ assertEquals(calcComponentReference.getAutowire(), Boolean.FALSE);
+ assertEquals(calcComponentReference.isWiredByImpl(), false);
+ assertEquals(calcComponentReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcComponentReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ Property property = calcComponent.getProperties().get(0);
+ assertEquals(property.getName(), "round");
+ Document doc = (Document) property.getValue();
+ Element element = doc.getDocumentElement();
+ String value = element.getTextContent();
+ assertEquals(value, "true");
+ assertEquals(property.getXSDType(), new QName("http://www.w3.org/2001/XMLSchema", "boolean"));
+ assertEquals(property.isMany(), false);
+
+ CompositeReference calcCompositeReference = (CompositeReference)composite.getReferences().get(0);
+ assertEquals(calcCompositeReference.getName(), "MultiplyService");
+ assertTrue(calcCompositeReference.getPromotedReferences().get(0).isUnresolved());
+ assertEquals(calcCompositeReference.getPromotedReferences().get(0).getName(),
+ "CalculatorServiceComponent/multiplyService");
+ assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+ Callback calcCallback = calcCompositeReference.getCallback();
+ assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ assertNotNull(calcCallback);
+ // TODO test operations
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..463e6fec82
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -0,0 +1,207 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.ValidatorHandler;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+ private static final String TUSCANY_11_XSD = "tuscany-sca-1.1.xsd";
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ValidatorHandler handler;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+
+ resolver = new DefaultModelResolver();
+ handler = getValidationHandler();
+
+ }
+
+ @Test
+ public void testValidateAssembly() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("Calculator.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+
+ }
+
+ private static ValidatorHandler getValidationHandler() throws SAXException {
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ schemaFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return null;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return null;
+ }
+ Schema schema = schemaFactory.newSchema(ReadDocumentTestCase.class.getClassLoader().getResource(TUSCANY_11_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+ return handler;
+ }
+
+ @Test
+ public void testValidateImplementation() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("Calculator.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+ }
+
+ @Test
+ public void testReadImplementation() throws Exception {
+
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ factories.addFactory(validatingInputFactory);
+
+ CompositeDocumentProcessor compositeDocumentProcessor =
+ new CompositeDocumentProcessor(factories, staxProcessor, null);
+
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testValidateBinding() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+ }
+
+ @Test
+ public void testReadBinding() throws Exception {
+
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
+ factories.addFactory(validatingInputFactory);
+ CompositeDocumentProcessor compositeDocumentProcessor =
+ new CompositeDocumentProcessor(factories, staxProcessor, null);
+
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ URI uri = URI.create("RMIBindingTest.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+
+ URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
new file mode 100644
index 0000000000..beeb6feaea
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
@@ -0,0 +1,91 @@
+/*
+ * 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 org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+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.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> 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);
+ }
+
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+ }
+
+ @Test
+ public void testReadConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadCompositeAndWireIt() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader));
+ is.close();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
new file mode 100644
index 0000000000..a4f0da5ae9
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
@@ -0,0 +1,132 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+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.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteAnyAttributeTestCase {
+
+ private static final QName EXTENDED_ATTRIBUTE = new QName("http://test", "customAttribute");
+
+ private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" " +
+ "xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" " +
+ "targetNamespace=\"http://calc\" " +
+ "name=\"Calculator\">"+
+ "<component name=\"AddServiceComponent\" xmlns:test=\"http://test\" test:customAttribute=\"customValue\">"+
+ "<implementation.java class=\"calculator.AddServiceImpl\" />"+
+ "</component>"+
+ "</composite>";
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+
+ /**
+ * Initialize the test environment
+ * This takes care to register attribute processors when provided
+ *
+ * @param attributeProcessor
+ * @throws Exception
+ */
+ private void init(StAXAttributeProcessor<?> attributeProcessor) throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ if(attributeProcessor != null) {
+ StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ staxAttributeProcessors.addArtifactProcessor(attributeProcessor);
+ }
+
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * and a particular attribute processor
+ * @throws Exception
+ */
+ @Test
+ public void testReadWriteCompositeWithAttributeProcessor() throws Exception {
+ init(new TestAttributeProcessor());
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // used for debug comparison
+ // System.out.println(XML);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML, bos.toString());
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * but no particular processor for it
+ * @throws Exception
+ */
+ @Test
+ public void testDefaultReadWriteComposite() throws Exception {
+ init(null);
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // used for debug comparison
+ // System.out.println(XML);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML, bos.toString());
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
new file mode 100644
index 0000000000..256c706035
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
@@ -0,0 +1,147 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+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.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ReadWriteAnyElementTestCase {
+ private static final String XML_RECURSIVE_EXTENDED_ELEMENT =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" targetNamespace=\"http://temp\" name=\"RecursiveExtendedElement\">" +
+ "<unknownElement>" +
+ "<subUnknownElement1 attribute=\"anyAttribute\" />" +
+ "<subUnknownElement2 />" +
+ "</unknownElement>" +
+ "</composite>";
+
+ private static final String XML_UNKNOWN_IMPL =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+ private static final String XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\" requires=\"\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance(), null);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testReadWriteExtendedRecursiveElement() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT));
+ Composite composite = (Composite)staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // used for debug comparison
+ // System.out.println(XML_RECURSIVE_EXTENDED_ELEMENT);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_RECURSIVE_EXTENDED_ELEMENT, bos.toString());
+ bos.close();
+ }
+
+ @Test
+ public void testReadWriteUnknwonImpl() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL));
+ Composite composite = (Composite)staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // used for debug comparison
+ // System.out.println(XML_UNKNOWN_IMPL);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_UNKNOWN_IMPL, bos.toString());
+ bos.close();
+ }
+
+ // @Test
+ @Ignore()
+ public void testReadWriteInvalidAttribute() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE));
+ Composite composite = (Composite)staxProcessor.read(reader);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+
+ // used for debug comparison
+ // System.out.println(XML_UNKNOWN_IMPL);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_UNKNOWN_IMPL, bos.toString());
+ bos.close();
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..6c8aa9acc9
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+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.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev: 711584 $ $Date: 2008-11-05 15:07:03 +0000 (Wed, 05 Nov 2008) $
+ */
+public class ReadWriteLocalCompositeTestCase {
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+
+ private static final String LOCAL_COMPOSITE_XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns1=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" targetNamespace=\"http://localcalc\" name=\"LocalCalculator\" local=\"true\">"+
+ "</composite>";
+
+ @Before
+ 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);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ 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();
+ }
+
+ @Test
+ 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/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
new file mode 100644
index 0000000000..d9be1dff90
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
@@ -0,0 +1,171 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
+ */
+public class ResolvePolicyTestCase {
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ resolver = new DefaultModelResolver();
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+
+ URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URI uri = URI.create("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(composite);
+
+ url = getClass().getResource("test_definitions.xml");
+ uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ preResolvePolicyTests(composite);
+ documentProcessor.resolve(scaDefns, resolver);
+ documentProcessor.resolve(composite, resolver);
+
+ // Comment out the post resolving test
+ // postResolvePolicyTests(composite);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ private void preResolvePolicyTests(Composite composite) {
+ assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertTrue(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ }
+
+ private void postResolvePolicyTests(Composite composite) {
+ assertNotNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url);
+
+ documentProcessor.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
new file mode 100644
index 0000000000..cc8a88f3d5
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test resolving SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResolveTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessorExtensionPoint staxProcessors;
+ private static ModelResolver resolver;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ StAXArtifactProcessor<ConstrainingType> constrainingTypeReader = staxProcessors.getProcessor(ConstrainingType.class);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = constrainingTypeReader.read(reader);
+ is.close();
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader);
+ is.close();
+ assertNotNull(composite);
+
+ compositeReader.resolve(composite, resolver);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = compositeReader.read(reader);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader);
+ is.close();
+
+ compositeReader.resolve(composite, resolver);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
new file mode 100644
index 0000000000..1a100c25b1
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * 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 javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A Policy Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<String> {
+ private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
+
+ public QName getArtifactType() {
+ return ATTRIBUTE;
+ }
+
+ public String read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
+ }
+
+ public void write(String value, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+ writer.setPrefix(ATTRIBUTE.getPrefix(), ATTRIBUTE.getNamespaceURI());
+ writer.writeAttribute(ATTRIBUTE.getLocalPart(), value);
+ }
+
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ public void resolve(String arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..e1a149494d
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
@@ -0,0 +1,82 @@
+/*
+ * 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 javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+/**
+ * A PolicyExpression Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
+
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public PolicyExpression read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1) throws ContributionResolveException {
+ }
+
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ }
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
new file mode 100644
index 0000000000..cbfec53f65
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
@@ -0,0 +1,40 @@
+/*
+ * 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 org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSCABindingFactoryImpl implements SCABindingFactory {
+ public SCABinding createSCABinding() {
+ return new TestSCABindingImpl();
+ }
+
+ public DistributedSCABinding createDistributedSCABinding() {
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
new file mode 100644
index 0000000000..d41881dc37
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
@@ -0,0 +1,186 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A test cheel for the SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private Component targetComponent;
+ private ComponentService targetComponentService;
+ private Binding targetBinding;
+
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ExtensionType bindingType = new TestSCABindingType();
+
+ /**
+ * Constructs a new SCA binding.
+ */
+ protected TestSCABindingImpl() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /**
+ * @return the targetComponent
+ */
+ public Component getTargetComponent() {
+ return targetComponent;
+ }
+
+ /**
+ * @param targetComponent the targetComponent to set
+ */
+ public void setTargetComponent(Component targetComponent) {
+ this.targetComponent = targetComponent;
+ }
+
+ /**
+ * @return the targetComponentService
+ */
+ public ComponentService getTargetComponentService() {
+ return targetComponentService;
+ }
+
+ /**
+ * @param targetComponentService the targetComponentService to set
+ */
+ public void setTargetComponentService(ComponentService targetComponentService) {
+ this.targetComponentService = targetComponentService;
+ }
+
+ /**
+ * @return the targetBinding
+ */
+ public Binding getTargetBinding() {
+ return targetBinding;
+ }
+
+ /**
+ * @param targetBinding the targetBinding to set
+ */
+ public void setTargetBinding(Binding targetBinding) {
+ this.targetBinding = targetBinding;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return requiredIntents;
+ }
+
+ public ExtensionType getType() {
+ // TODO Auto-generated method stub
+ return bindingType;
+ }
+
+ public void setType(ExtensionType type) {
+ this.bindingType = type;
+ }
+
+ private class TestSCABindingType implements ExtensionType {
+ private QName name = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903","binding");
+ public QName getBaseType() {
+ return BINDING_BASE;
+ }
+
+ public QName getType() {
+ return name;
+ }
+
+ public void setType(QName type) {
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return Collections.emptyList();
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return Collections.emptyList();
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
new file mode 100644
index 0000000000..5235df5037
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
@@ -0,0 +1,148 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+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.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test the wiring of SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static CompositeBuilder compositeBuilder;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
+ resolver = new DefaultModelResolver();
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testResolveConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(constrainingType);
+ resolver.addModel(constrainingType);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(composite);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+
+ assertEquals(composite.getConstrainingType(), constrainingType);
+ assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = (Composite)staxProcessor.read(reader);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ is.close();
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
new file mode 100644
index 0000000000..cf86aec6f4
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
@@ -0,0 +1,158 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteAllTestCase {
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static 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);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+ compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ monitor = monitorFactory.createMonitor();
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.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);
+
+ }
+
+ @Test
+ public void testReadWireWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
+ assertNotNull(scaDefns);
+ policyDefinitionsProcessor.resolve(scaDefns, resolver);
+
+ staxProcessor.resolve(composite, resolver);
+ compositeBuilder.build(composite, null, monitor);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = staxProcessor.read(is, ComponentType.class);
+ staxProcessor.resolve(componentType, resolver);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, bos);
+ }
+
+ @Test
+ public void testReadWriteConstrainingType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
+ ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
+ staxProcessor.resolve(constrainingType, resolver);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(constrainingType, bos);
+ }
+
+ private void verifyComposite(Composite composite) {
+ assertEquals(composite.getProperties().get(0).getName(),"prop1");
+ assertEquals(composite.getProperties().get(0).isMany(), true);
+ assertEquals(composite.getProperties().get(1).getName(),"prop2");
+ assertEquals(composite.getProperties().get(1).isMustSupply(), true);
+ assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType"));
+ assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://foo", "MyComplexPropertyValue1"));
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
new file mode 100644
index 0000000000..dedd0d0660
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * 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 org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+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 javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteNamespacesTestCase {
+ private static StAXArtifactProcessor<Composite> compositeProcessor;
+ private static XMLOutputFactory outputFactory;
+ private static XMLInputFactory inputFactory;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ //outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ compositeProcessor = artifactProcessors.getProcessor(Composite.class);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+
+ // Read
+ InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader);
+ Component component = composite.getComponents().get(0);
+ Composite implementation = (Composite)component.getImplementation();
+ QName qname = implementation.getName();
+
+ // Write
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
+ compositeProcessor.write(composite, writer);
+ System.out.println(bos);
+
+ // Read again
+ is = new ByteArrayInputStream(bos.toByteArray());
+ reader = inputFactory.createXMLStreamReader(is);
+ composite = compositeProcessor.read(reader);
+
+ // Compare
+ component = composite.getComponents().get(0);
+ implementation = (Composite)component.getImplementation();
+
+ assertEquals(qname, implementation.getName());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
new file mode 100644
index 0000000000..961a40b841
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
@@ -0,0 +1,59 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:x="http://x"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <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">
+ <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>
+
+ <x:unknownElement uknAttr="attribute1">
+ <y:subUnknownElement1 xmlns:y="http://y" uknAttr1="attribute2"/>
+ <x:subUnknownElement2 />
+ </x:unknownElement>
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
new file mode 100644
index 0000000000..9a43d44377
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
@@ -0,0 +1,34 @@
+<?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.
+-->
+<constrainingType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="CalculatorComponent">
+
+ <service name="CalculatorService">
+ <interface.java class="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService" multiplicity="1..1">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</constrainingType>
+
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..2f4518a42c
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
@@ -0,0 +1,31 @@
+<?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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
new file mode 100644
index 0000000000..d713a381f9
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://temp"
+ name="composite1">
+ <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/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
new file mode 100644
index 0000000000..bf3676c585
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
@@ -0,0 +1,29 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.composite xmlns:n="http://inner" name="n:InnerCalculator"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
new file mode 100644
index 0000000000..9f40faa806
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
@@ -0,0 +1,44 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://helloWorldRMI"
+ name="HelloWorldRmiComposite">
+
+ <service name="HelloWorldRmiService" promote="HelloWorldServiceComponent">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+ <component name="HelloWorldRmiServiceComponent">
+ <implementation.java class="helloworld.HelloWorldRmiImpl"/>
+ <reference name="extService"></reference>
+ </component>
+
+ <reference name="HelloWorldRmiReference" promote="HelloWorldRmiServiceComponent/extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </reference>
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
new file mode 100644
index 0000000000..65e709f9b1
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
@@ -0,0 +1,127 @@
+<?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 autowire="false" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 "
+ xmlns:ext="http://extension"
+ xmlns:cns="http://test" xmlns:sns="http://test">
+
+ <include name="tns:TestAllDivide"/>
+ <ext:testExtension/>
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:confidentiality"
+ policySets="sns:SecureReliablePolicy">
+ <ext:testExtension/>
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
+
+ <binding.ws name="CalculatorWS" policySets="sns:SecureReliablePolicy" port="" requires="cns:confidentiality" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <ext:testExtension/>
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorServiceComponent" autowire="false" constrainingType="tns:CalculatorComponent"
+ policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <ext:testExtension/>
+ <service name="CalculatorService" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ </service>
+
+ <reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
+ policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" wiredByImpl="false">
+ <ext:testExtension/>
+ <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" />
+ <reference name="divideService" target="DivideServiceComponent" />
+
+ <property name="round" type="xsd:boolean" many="false">true</property>
+
+ <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+ <component name="NestedCompositeComponent">
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+ <implementation.composite name="tns:Calculator" />
+ </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>
+
+ <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality">
+ <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
+
+ <binding.ws name="MultiplyWS" port="" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality">
+ </binding.ws>
+ </callback>
+ </reference>
+
+ <property name="prop1" xmlns:foo="http://foo" many="true" type="foo:MyComplexType">
+ <value xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </value>
+ </property>
+
+ <property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="foo:MyComplexPropertyValue1">
+ <foo:MyComplexPropertyValue1>123</foo:MyComplexPropertyValue1>
+ </property>
+ <property name="prop3" xmlns:foo="http://foo" mustSupply="true" value="123"/>
+ <property name="prop4">123</property>
+ <property name="prop5"><value>123</value></property>
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
new file mode 100644
index 0000000000..998a49226b
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
@@ -0,0 +1,56 @@
+<?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 autowire="false"
+ constrainingType="tns:Calculator"
+ local="true"
+ name="TestAllDivide"
+ policySets="" requires=""
+ targetNamespace="http://calc"
+ xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 ">
+
+ <include name="tns:CompleteDivide"/>
+
+ <service name="DivideService" policySets="" promote="CalculatorDivideComponent/DivideService" requires="">
+ <interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
+ <operation name="divide" policySets="" requires=""/>
+
+ <binding.ws name="CalculatorWS" policySets="" port="" requires="" uri="http://calc/ws">
+ <operation name="divide" policySets="" requires=""/>
+ </binding.ws>
+
+ <callback policySets="" requires="">
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
+ <operation name="divideCallback" policySets="" requires=""/>
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorDivideComponent" autowire="false" constrainingType="tns:CalculatorServiceComponent" policySets="" requires="">
+ <service name="DivideService" policySets="" requires="">
+ <interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
+ </service>
+ <implementation.java class="calculator.DivideImpl" policySets="" requires=""/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
new file mode 100644
index 0000000000..661270d341
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
@@ -0,0 +1,125 @@
+<?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 autowire="false" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator"
+ requires="cns:tuscanyIntent_1" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 "
+ xmlns:ext="http://extension"
+ xmlns:cns="http://test" xmlns:sns="http://test">
+
+ <include name="tns:TestAllDivide"/>
+ <ext:testExtension/>
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:tuscanyIntent_2 cns:tuscanyIntent_1">
+ <ext:testExtension/>
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <operation name="add" requires="cns:tuscanyIntent_6"/>
+
+ <binding.ws name="CalculatorWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback requires="cns:tuscanyIntent_4">
+ <ext:testExtension/>
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_5" uri="http://calc/callback/ws">
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorServiceComponent" autowire="false" constrainingType="tns:CalculatorComponent"
+ requires="cns:tuscanyIntent_2 cns:tuscanyIntent_3">
+ <ext:testExtension/>
+ <service name="CalculatorService" requires="cns:tuscanyIntent_3">
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
+ </binding.ws>
+ <callback>
+ </callback>
+ </service>
+
+ <reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
+ requires="cns:tuscanyIntent_3 cns:tuscanyIntent_2.qualified" wiredByImpl="false">
+ <ext:testExtension/>
+ <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
+ <binding.ws name="addServiceWSRef" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
+ </binding.ws>
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" />
+ <reference name="divideService" target="DivideServiceComponent" />
+
+ <property name="round" type="xsd:boolean" many="false">true</property>
+
+ <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="cns:tuscanyIntent_4" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+ <component name="NestedCompositeComponent">
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+ <implementation.composite name="tns:Calculator" />
+ </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>
+
+ <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
+ requires="cns:tuscanyIntent_2">
+ <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
+
+ <binding.ws name="MultiplyWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:tuscanyIntent_3">
+ <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws"
+ requires="cns:tuscanyIntent_4">
+ </binding.ws>
+ </callback>
+ </reference>
+
+ <property name="prop1" xmlns:foo="http://foo">
+ <value xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </value>
+ </property>
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
new file mode 100644
index 0000000000..bb1f3118ce
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
@@ -0,0 +1,96 @@
+<?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.
+-->
+<sca:definitions xmlns="http://test"
+ targetNamespace="http://test"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+<!-- simple intent -->
+ <sca:intent name="tuscanyIntent_1"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_2"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_3"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_4"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+<sca:intent name="tuscanyIntent_5"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_6"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_7"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_8"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_9"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_10"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+</sca:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
new file mode 100644
index 0000000000..6aa2ab4979
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>
diff --git a/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
new file mode 100644
index 0000000000..c59fb3537b
--- /dev/null
+++ b/tags/java/sca/2.0-M3-RC5/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
@@ -0,0 +1,206 @@
+<?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.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="message">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file