From 5559ef5edbf8d3616f7a4b497b2a459b0ee4082b Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:07 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835122 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/assembly/xml/BuildPolicyTestCase.java | 155 ------------- .../sca/assembly/xml/MockPolicyProcessor.java | 72 ------ .../tuscany/sca/assembly/xml/ReadAllTestCase.java | 165 -------------- .../sca/assembly/xml/ReadDocumentTestCase.java | 241 --------------------- .../tuscany/sca/assembly/xml/ReadTestCase.java | 103 --------- .../sca/assembly/xml/ResolvePolicyTestCase.java | 198 ----------------- .../tuscany/sca/assembly/xml/ResolveTestCase.java | 115 ---------- .../sca/assembly/xml/TestModelResolver.java | 63 ------ .../assembly/xml/TestSCABindingFactoryImpl.java | 35 --- .../sca/assembly/xml/TestSCABindingImpl.java | 189 ---------------- .../tuscany/sca/assembly/xml/WireTestCase.java | 123 ----------- .../tuscany/sca/assembly/xml/WriteAllTestCase.java | 134 ------------ .../sca/assembly/xml/AnotherDefinitions.xml | 84 ------- .../tuscany/sca/assembly/xml/Calculator.composite | 53 ----- .../xml/CalculatorComponent.constrainingType | 34 --- .../sca/assembly/xml/CalculatorImpl.componentType | 31 --- .../sca/assembly/xml/JavaScriptReference.composite | 37 ---- .../sca/assembly/xml/RMIBindingTest.composite | 43 ---- .../sca/assembly/xml/TestAllCalculator.composite | 128 ----------- .../sca/assembly/xml/TestAllDivide.composite | 56 ----- .../assembly/xml/TestAllPolicyCalculator.composite | 131 ----------- .../tuscany/sca/assembly/xml/definitions.xml | 175 --------------- 22 files changed, 2365 deletions(-) delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/AnotherDefinitions.xml delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite delete mode 100644 branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/definitions.xml (limited to 'branches/sca-java-1.0/modules/assembly-xml/src/test') diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java deleted file mode 100644 index 17069783b2..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java +++ /dev/null @@ -1,155 +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.net.URI; -import java.net.URL; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.SCADefinitionsDocumentProcessor; -import org.apache.tuscany.sca.definitions.SCADefinitionsProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.IntentAttachPoint; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.xml.PolicySetProcessor; -import org.apache.tuscany.sca.policy.xml.ProfileIntentProcessor; -import org.apache.tuscany.sca.policy.xml.QualifiedIntentProcessor; -import org.apache.tuscany.sca.policy.xml.SimpleIntentProcessor; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $ - */ -public class BuildPolicyTestCase extends TestCase { - - private ExtensibleURLArtifactProcessor documentProcessor; - private TestModelResolver resolver; - SCADefinitionsDocumentProcessor scaDefnDocProcessor; - CompositeBuilder compositeBuilder; - Composite composite = null; - - @Override - public void setUp() throws Exception { - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - InterfaceContractMapper mapper = new InterfaceContractMapperImpl(); - resolver = new TestModelResolver(); - compositeBuilder = new CompositeBuilderImpl(factory, new TestSCABindingFactoryImpl(), new InterfaceContractMapperImpl(), null, null); - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - // Create Stax processors - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new SCADefinitionsProcessor(policyFactory, staxProcessor, resolver)); - staxProcessors.addArtifactProcessor(new SimpleIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ProfileIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new QualifiedIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new PolicySetProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new MockPolicyProcessor()); - - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - - // Create document processors - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory, null)); - scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, staxProcessor, inputFactory, policyFactory, null); - documentProcessors.addArtifactProcessor(scaDefnDocProcessor); - - 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("TestAllPolicyCalculator.composite"); - uri = URI.create("TestAllCalculator.constrainingType"); - composite = (Composite)documentProcessor.read(null, uri, url); - assertNotNull(composite); - - url = getClass().getResource("AnotherDefinitions.xml"); - uri = URI.create("AnotherDefinitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.read(null, uri, url); - assertNotNull(scaDefns); - - //preResolvePolicyTests(composite); - documentProcessor.resolve(scaDefns, resolver); - documentProcessor.resolve(composite, resolver); - //postResolvePolicyTests(composite); - - compositeBuilder.build(composite); - } - - @Override - public void tearDown() throws Exception { - documentProcessor = null; - resolver = null; - } - - 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 for the promoted service (4) - assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 4); - 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(composite.getReferences().get(0).getRequiredIntents().size(), 2); - 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(), 2); - - 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).getReferences().get(0).getRequiredIntents().size(), 5); - - } -} diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.java deleted file mode 100644 index e435f7ce0a..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MockPolicyProcessor.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 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.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.policy.Policy; - -/** - * @author administrator - * - */ -public class MockPolicyProcessor 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-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java deleted file mode 100644 index 8b42bd03db..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java +++ /dev/null @@ -1,165 +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.InputStream; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -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.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadAllTestCase extends TestCase { - private ExtensibleStAXArtifactProcessor staxProcessor; - - @Override - public void setUp() throws Exception { - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - InterfaceContractMapper mapper = new InterfaceContractMapperImpl(); - ContributionFactory contributionFactory = new ContributionFactoryImpl(); - - StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - - staxProcessors.addArtifactProcessor(new CompositeProcessor(contributionFactory, factory, policyFactory, mapper, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - } - - @Override - public void tearDown() throws Exception { - } - - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = (Composite)staxProcessor.read(is, Composite.class); - 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 - - //new PrintUtil(System.out).print(composite); - } - -} diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java deleted file mode 100644 index de2452fde8..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java +++ /dev/null @@ -1,241 +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.net.URI; -import java.net.URL; - -import javax.xml.XMLConstants; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.ValidatorHandler; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class ReadDocumentTestCase extends TestCase { - - private ExtensibleURLArtifactProcessor documentProcessor; - private TestModelResolver resolver; - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - - @Override - public void setUp() throws Exception { - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - InterfaceContractMapper mapper = new InterfaceContractMapperImpl(); - - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - // Create Stax processors - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - - inputFactory = XMLInputFactory.newInstance(); - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory, null)); - - resolver = new TestModelResolver(); - } - - @Override - public void tearDown() throws Exception { - } - - 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())); - } - - 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())); - } - - public void testReadImplementation() 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")); - - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, inputFactory, schema); - - URL url = getClass().getResource("JavaScriptReference.composite"); - URI uri = URI.create("JavaScriptReference.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - 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())); - } - - public void testReadBinding() 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")); - - CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, inputFactory, schema); - - URL url = getClass().getResource("RMIBindingTest.composite"); - URI uri = URI.create("RMIBindingTest.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url); - assertNotNull(composite); - } - - 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); - } - - 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-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java deleted file mode 100644 index 81c244a6d5..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.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 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.AssemblyFactory; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadTestCase extends TestCase { - - private XMLInputFactory inputFactory; - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private AssemblyFactory factory; - private PolicyFactory policyFactory; - private InterfaceContractMapper mapper; - - @Override - public void setUp() throws Exception { - factory = new DefaultAssemblyFactory(); - policyFactory = new DefaultPolicyFactory(); - mapper = new InterfaceContractMapperImpl(); - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - } - - @Override - public void tearDown() throws Exception { - } - - public void testReadComponentType() throws Exception { - ComponentTypeProcessor componentTypeReader = new ComponentTypeProcessor(factory, policyFactory, staxProcessor); - InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(componentTypeReader.read(reader)); - is.close(); - } - - public void testReadConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(constrainingTypeReader.read(reader)); - is.close(); - - } - - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(compositeReader.read(reader)); - is.close(); - - } - - public void testReadCompositeAndWireIt() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(compositeReader.read(reader)); - is.close(); - } - -} diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java deleted file mode 100644 index 0c2b686016..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java +++ /dev/null @@ -1,198 +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.net.URI; -import java.net.URL; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.SCADefinitionsDocumentProcessor; -import org.apache.tuscany.sca.definitions.SCADefinitionsProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.xml.PolicySetProcessor; -import org.apache.tuscany.sca.policy.xml.ProfileIntentProcessor; -import org.apache.tuscany.sca.policy.xml.QualifiedIntentProcessor; -import org.apache.tuscany.sca.policy.xml.SimpleIntentProcessor; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $ - */ -public class ResolvePolicyTestCase extends TestCase { - - private ExtensibleURLArtifactProcessor documentProcessor; - private TestModelResolver resolver; - SCADefinitionsDocumentProcessor scaDefnDocProcessor; - - @Override - public void setUp() throws Exception { - AssemblyFactory factory = new DefaultAssemblyFactory(); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - InterfaceContractMapper mapper = new InterfaceContractMapperImpl(); - resolver = new TestModelResolver(); - - URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - // Create Stax processors - DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new SCADefinitionsProcessor(policyFactory, staxProcessor, resolver)); - staxProcessors.addArtifactProcessor(new SimpleIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ProfileIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new QualifiedIntentProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new PolicySetProcessor(policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new MockPolicyProcessor()); - - // Create document processors - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxProcessor, inputFactory, null)); - documentProcessors.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxProcessor, inputFactory, null)); - scaDefnDocProcessor = new SCADefinitionsDocumentProcessor(staxProcessors, staxProcessor, inputFactory, policyFactory, null); - documentProcessors.addArtifactProcessor(scaDefnDocProcessor); - } - - @Override - public void tearDown() throws Exception { - } - - 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("definitions.xml"); - uri = URI.create("definitions.xml"); - SCADefinitions scaDefns = (SCADefinitions)scaDefnDocProcessor.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()); - - - } - - 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-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java deleted file mode 100644 index ddd26169e8..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java +++ /dev/null @@ -1,115 +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.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.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test resolving SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ResolveTestCase extends TestCase { - - private XMLInputFactory inputFactory; - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private TestModelResolver resolver; - private AssemblyFactory factory; - private PolicyFactory policyFactory; - private InterfaceContractMapper mapper; - - @Override - public void setUp() throws Exception { - factory = new DefaultAssemblyFactory(); - policyFactory = new DefaultPolicyFactory(); - mapper = new InterfaceContractMapperImpl(); - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - resolver = new TestModelResolver(); - } - - @Override - public void tearDown() throws Exception { - } - - public void testResolveConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - ConstrainingType constrainingType = constrainingTypeReader.read(reader); - is.close(); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor); - 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); - } - - public void testResolveComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite nestedComposite = compositeReader.read(reader); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), factory, policyFactory, mapper, staxProcessor); - 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-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java deleted file mode 100644 index 3224176d6e..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestModelResolver.java +++ /dev/null @@ -1,63 +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.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * A default implementation of an artifact resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map map = new HashMap(); - - public TestModelResolver() { - } - - public T resolveModel(Class modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved) { - return map.remove(resolved); - } - -} diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java deleted file mode 100644 index c423df6f7d..0000000000 --- a/branches/sca-java-1.0/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-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java deleted file mode 100644 index 6ecf387da9..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java +++ /dev/null @@ -1,189 +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.SCABinding; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -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 { - private String name; - private String uri; - private List extensions = new ArrayList(); - - private Component targetComponent; - private ComponentService targetComponentService; - private Binding targetBinding; - - List requiredIntents = new ArrayList(); - List policySets = new ArrayList(); - IntentAttachPointType 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 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 - - } - - } -} diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java deleted file mode 100644 index 7bf412e4b6..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java +++ /dev/null @@ -1,123 +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.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.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test the wiring of SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class WireTestCase extends TestCase { - - private XMLInputFactory inputFactory; - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private TestModelResolver resolver; - private AssemblyFactory assemblyFactory; - private SCABindingFactory scaBindingFactory; - private PolicyFactory policyFactory; - private InterfaceContractMapper mapper; - - @Override - public void setUp() throws Exception { - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - resolver = new TestModelResolver(); - assemblyFactory = new DefaultAssemblyFactory(); - scaBindingFactory = new TestSCABindingFactoryImpl(); - policyFactory = new DefaultPolicyFactory(); - mapper = new InterfaceContractMapperImpl(); - } - - @Override - public void tearDown() throws Exception { - } - - public void testResolveConstrainingType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); - ConstrainingTypeProcessor constrainingTypeReader = new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - ConstrainingType constrainingType = constrainingTypeReader.read(reader); - is.close(); - assertNotNull(constrainingType); - resolver.addModel(constrainingType); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader); - is.close(); - assertNotNull(composite); - - compositeReader.resolve(composite, resolver); - CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null, null); - compositeUtil.build(composite); - - assertEquals(composite.getConstrainingType(), constrainingType); - assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType); - } - - public void testResolveComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - CompositeProcessor compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite nestedComposite = compositeReader.read(reader); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - compositeReader = new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader); - is.close(); - - compositeReader.resolve(composite, resolver); - CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null, null); - compositeUtil.build(composite); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java deleted file mode 100644 index 202d3d7f13..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java +++ /dev/null @@ -1,134 +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.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 junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -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.DefaultAssemblyFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * Test writing SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class WriteAllTestCase extends TestCase { - private DefaultStAXArtifactProcessorExtensionPoint staxProcessors; - private ExtensibleStAXArtifactProcessor staxProcessor; - private TestModelResolver resolver; - private AssemblyFactory assemblyFactory; - private SCABindingFactory scaBindingFactory; - private PolicyFactory policyFactory; - private InterfaceContractMapper mapper; - private CompositeBuilderImpl compositeUtil; - - - @Override - public void setUp() throws Exception { - assemblyFactory = new DefaultAssemblyFactory(); - scaBindingFactory = new TestSCABindingFactoryImpl(); - policyFactory = new DefaultPolicyFactory(); - mapper = new InterfaceContractMapperImpl(); - compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null, null); - staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - staxProcessors.addArtifactProcessor(new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor)); - staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor)); - staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor)); - resolver = new TestModelResolver(); - } - - @Override - public void tearDown() throws Exception { - } - - 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); - - } - - public void testReadWireWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = staxProcessor.read(is, Composite.class); - staxProcessor.resolve(composite, resolver); - compositeUtil.build(composite); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos); - } - - 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); - } - - 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-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/AnotherDefinitions.xml b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/AnotherDefinitions.xml deleted file mode 100644 index b99287d57e..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/AnotherDefinitions.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - Sample Intent - - - - - - - \ No newline at end of file diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite deleted file mode 100644 index 4546fddb2d..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType deleted file mode 100644 index 072fe8fde1..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType deleted file mode 100644 index d67ba3ec2b..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite deleted file mode 100644 index a313dd1e6d..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/JavaScriptReference.composite +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite deleted file mode 100644 index d29fe85586..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite deleted file mode 100644 index 5091ff700b..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AValue - InterestingURI - - - BValue - BoringURI - - - - - - diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite deleted file mode 100644 index d59e69209d..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite deleted file mode 100644 index 59f832d6df..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AValue - InterestingURI - - - BValue - BoringURI - - - - diff --git a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/definitions.xml b/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/definitions.xml deleted file mode 100644 index 3c268f18e0..0000000000 --- a/branches/sca-java-1.0/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/definitions.xml +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - - - ... - - - - - - - - - Protect messages from unauthorized reading or modification - - - - - - Protect messages from unauthorized reading or modification - - - - - - - Communitcation thro this binding must prevent - unauthorized users from reading the messages. - - - - - - Communitcation thro this binding must prevent - unauthorized modification of the messages. - - - - - - Communitcation thro this binding required - Authentication. - - - - \ No newline at end of file -- cgit v1.2.3