From cde3d2629677a07aa09e3c7fbe117b680c0f5df7 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:09:08 +0000 Subject: Moving 2.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835133 13f79535-47bb-0310-9956-ffa450edef68 --- .../assembly/xml/AnyElementReadWriteTestCase.java | 72 ------- .../sca/assembly/xml/BuildPolicyTestCase.java | 149 -------------- .../tuscany/sca/assembly/xml/ReadAllTestCase.java | 151 -------------- .../sca/assembly/xml/ReadDocumentTestCase.java | 217 --------------------- .../tuscany/sca/assembly/xml/ReadTestCase.java | 91 --------- .../assembly/xml/ReadWriteAttributeTestCase.java | 106 ---------- .../sca/assembly/xml/ResolvePolicyTestCase.java | 169 ---------------- .../tuscany/sca/assembly/xml/ResolveTestCase.java | 103 ---------- .../sca/assembly/xml/TestAttributeProcessor.java | 61 ------ .../sca/assembly/xml/TestPolicyProcessor.java | 73 ------- .../assembly/xml/TestReadWriteUnknownElement.java | 54 ----- .../assembly/xml/TestSCABindingFactoryImpl.java | 35 ---- .../sca/assembly/xml/TestSCABindingImpl.java | 213 -------------------- .../tuscany/sca/assembly/xml/WireTestCase.java | 148 -------------- .../tuscany/sca/assembly/xml/WriteAllTestCase.java | 158 --------------- .../sca/assembly/xml/WriteNamespacesTestCase.java | 95 --------- 16 files changed, 1895 deletions(-) delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java delete mode 100644 branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java (limited to 'branches/sca-equinox/modules/assembly-xml/src/test/java/org') diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java deleted file mode 100644 index 9300731007..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.xml; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import junit.framework.Assert; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AnyElementReadWriteTestCase { - - private static XMLInputFactory inputFactory; - //private static String XML = ""; - private static String XML = ""; - private static ExtensibleStAXArtifactProcessor staxProcessor; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = - extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = - new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory - .newInstance(), null); - } - - @Test - public void testReadWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader); - Assert.assertNotNull(composite); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - System.out.println(bos.toString()); - Assert.assertEquals(XML, bos.toString()); - bos.close(); - - is.close(); - } - -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java deleted file mode 100644 index 0fc36e6cad..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.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.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -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.DefaultMonitorFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -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 documentProcessor; - private static URLArtifactProcessor 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 policyDefinitions = new ArrayList(); - resolver = new DefaultModelResolver(); - - MonitorFactory monitorFactory = new DefaultMonitorFactory(); - monitor = monitorFactory.createMonitor(); - - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - 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.constrainingType"); - 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, null, monitor); - } - - @Test - public void testPolicyIntentInheritance() throws Exception { - String namespaceUri = "http://test"; - - IntentAttachPoint policiedComposite = (IntentAttachPoint)composite; - assertEquals(policiedComposite.getRequiredIntents().size(), 1); - assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - - //1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4) - assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7); - //1 from the operation defined in this service and 2 from the operation defined in the promoted service - assertEquals(composite.getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3")); - //bindings will have only 2 intents since duplications will be cut out - assertEquals(((IntentAttachPoint)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3); - assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().size(), 1); - assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - - assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getReferences().get(0).getConfiguredOperations().size(), 1); - assertEquals(composite.getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 4); - assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - assertEquals(((IntentAttachPoint)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3); - - assertEquals(composite.getComponents().get(0).getRequiredIntents().size(), 3); - assertEquals(composite.getComponents().get(0).getRequiredIntents().get(2).getName(), new QName(namespaceUri, "tuscanyIntent_1")); - assertEquals(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size(), 4); - assertEquals(composite.getComponents().get(0).getServices().get(0).getCallback().getRequiredIntents().size(), 4); - assertEquals(composite.getComponents().get(0).getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().size(), 5); - assertEquals(composite.getComponents().get(0).getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5); - } -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java deleted file mode 100644 index d7836fbc3b..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.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.PolicySetAttachPoint; -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 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(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getName(), new QName("http://test", - "confidentiality")); - assertEquals(((PolicySetAttachPoint)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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java deleted file mode 100644 index 4918271b1f..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.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.junit.BeforeClass; -import org.junit.Test; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class ReadDocumentTestCase { - - private static URLArtifactProcessor documentProcessor; - private static ModelResolver resolver; - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessor staxProcessor; - - @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(); - } - - @Test - public void testValidateAssembly() throws Exception { - - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return; - } - Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd")); - ValidatorHandler handler = schema.newValidatorHandler(); - - 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 testValidateImplementation() throws Exception { - - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return; - } - Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd")); - ValidatorHandler handler = schema.newValidatorHandler(); - - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("JavaScriptReference.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-sca.xsd").toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null); - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null, null); - - URL url = getClass().getResource("JavaScriptReference.composite"); - URI uri = URI.create("JavaScriptReference.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - @Test - public void testValidateBinding() throws Exception { - - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return; - } - Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd")); - ValidatorHandler handler = schema.newValidatorHandler(); - - 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-sca.xsd").toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null); - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null, 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.constrainingType"); - 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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java deleted file mode 100644 index ba85769728..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static junit.framework.Assert.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 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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java deleted file mode 100644 index 10012282fc..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; - -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 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.BeforeClass; -import org.junit.Test; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadWriteAttributeTestCase { - - private static XMLInputFactory inputFactory; - private static ExtensibleStAXArtifactProcessor staxProcessor; - - private static final QName ATTRIBUTE = new QName("http://test", "customAttribute"); - - private static final String XML = ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""; - - @BeforeClass - public static 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); - } - - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorExtended.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader); - assertNotNull(composite); - is.close(); - } - - @Test - public void testWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorExtended.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader); - assertNotNull(composite); - is.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - System.out.println(bos.toString()); - - assertEquals(XML, bos.toString()); - } -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java deleted file mode 100644 index cc5421cd84..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.PolicySetAttachPoint; -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 documentProcessor; - private static ModelResolver resolver; - private static URLArtifactProcessor 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.constrainingType"); - 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); - postResolvePolicyTests(composite); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - private void preResolvePolicyTests(Composite composite) { - assertNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription()); - assertTrue(((PolicySetAttachPoint)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(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription()); - assertFalse(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(((PolicySetAttachPoint)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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java deleted file mode 100644 index cc8a88f3d5..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 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 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 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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java deleted file mode 100644 index 1a100c25b1..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 { - 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 getModelType() { - return String.class; - } - - public void resolve(String arg0, ModelResolver arg1) throws ContributionResolveException { - - } -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java deleted file mode 100644 index d01e304aad..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.Policy; - -/** - * A Policy Processor used for testing. - * - * @version $Rev$ $Date$ - */ -public class TestPolicyProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); - } - - public Policy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException { - return new MockPolicyImplOne(); - } - - public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException, - XMLStreamException { - } - - public Class getModelType() { - return Policy.class; - } - - public void resolve(Policy arg0, ModelResolver arg1) throws ContributionResolveException { - } - - - public class MockPolicyImplOne implements Policy { - public QName getSchemaName() { - 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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java deleted file mode 100644 index 8dcc3256f4..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestReadWriteUnknownElement.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.tuscany.sca.assembly.xml; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.Test; - -public class TestReadWriteUnknownElement extends TestCase { - - private XMLInputFactory inputFactory; - //String XML = ""; - String XML = ""; - private ExtensibleStAXArtifactProcessor staxProcessor; - - @Override - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null); - } - - @Override - public void tearDown() throws Exception { - } - - @Test - public void testReadWriteComposite() throws Exception{ - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader); - assertNotNull(composite); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - System.out.println(bos.toString()); - assertEquals(XML,bos.toString()); - bos.close(); - - is.close(); - } - -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java deleted file mode 100644 index c423df6f7d..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.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(); - } - -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java deleted file mode 100644 index af25109de1..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * 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.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.ConfiguredOperation; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - -/** - * A test cheel for the SCA binding. - * - * @version $Rev$ $Date$ - */ -public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySetAttachPoint, OperationsConfigurator { - private String name; - private String uri; - private List extensions = new ArrayList(); - - private Component targetComponent; - private ComponentService targetComponentService; - private Binding targetBinding; - - private List requiredIntents = new ArrayList(); - private List policySets = new ArrayList(); - private IntentAttachPointType bindingType = new TestSCABindingType(); - private List configuredOperations = new ArrayList(); - private List applicablePolicySets = new ArrayList(); - - /** - * 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 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 getPolicySets() { - // TODO Auto-generated method stub - return policySets; - } - - public List getRequiredIntents() { - // TODO Auto-generated method stub - return requiredIntents; - } - - public IntentAttachPointType getType() { - // TODO Auto-generated method stub - return bindingType; - } - - public void setType(IntentAttachPointType type) { - this.bindingType = type; - } - - private class TestSCABindingType implements IntentAttachPointType { - private QName name = new QName("http://www.osoa.org/xmlns/sca/1.0","binding"); - - public List getAlwaysProvidedIntents() { - // TODO Auto-generated method stub - return null; - } - - public List getMayProvideIntents() { - // TODO Auto-generated method stub - return null; - } - - public QName getName() { - return name; - } - - public boolean isUnresolved() { - // TODO Auto-generated method stub - return false; - } - - public void setName(QName type) { - // TODO Auto-generated method stub - - } - - public void setUnresolved(boolean unresolved) { - // TODO Auto-generated method stub - - } - - } - - public void setPolicySets(List policySets) { - this.policySets = policySets; - } - - public void setRequiredIntents(List intents) { - this.requiredIntents = intents; - } - - public List getConfiguredOperations() { - return configuredOperations; - } - - public void setConfiguredOperations(List configuredOperations) { - this.configuredOperations = configuredOperations; - } - - public List getApplicablePolicySets() { - return applicablePolicySets; - } -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java deleted file mode 100644 index ee281faa5d..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.assembly.xml; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.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 staxProcessor; - private static ModelResolver resolver; - private static URLArtifactProcessor 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/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java deleted file mode 100644 index df760c1d1f..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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 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://www.osoa.org/xmlns/sca/1.0", "MyComplexPropertyValue1")); - } - -} diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java deleted file mode 100644 index dedd0d0660..0000000000 --- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 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()); - } - -} -- cgit v1.2.3