From 3b7a9c51b93925c567b6b84450410b2737cc565e Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 16 Feb 2012 15:41:20 +0000 Subject: Delete old RC tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1245037 13f79535-47bb-0310-9956-ffa450edef68 --- .../assembly/xml/CompositeProcessorTestCase.java | 108 ------------ .../xml/MultiplicityReadWriteTestCase.java | 88 ---------- .../tuscany/sca/assembly/xml/ReadAllTestCase.java | 151 ---------------- .../sca/assembly/xml/ReadDocumentTestCase.java | 192 --------------------- .../tuscany/sca/assembly/xml/ReadTestCase.java | 85 --------- .../xml/ReadWriteAnyAttributeTestCase.java | 130 -------------- .../assembly/xml/ReadWriteAnyElementTestCase.java | 151 ---------------- .../xml/ReadWriteLocalCompositeTestCase.java | 103 ----------- .../sca/assembly/xml/ResolvePolicyTestCase.java | 143 --------------- .../tuscany/sca/assembly/xml/ResolveTestCase.java | 82 --------- .../sca/assembly/xml/StripURISpacesTestCase.java | 78 --------- .../sca/assembly/xml/TestAttributeProcessor.java | 62 ------- .../sca/assembly/xml/TestPolicyProcessor.java | 83 --------- .../assembly/xml/TestSCABindingFactoryImpl.java | 35 ---- .../sca/assembly/xml/TestSCABindingImpl.java | 162 ----------------- .../tuscany/sca/assembly/xml/WireTestCase.java | 109 ------------ .../tuscany/sca/assembly/xml/WriteAllTestCase.java | 136 --------------- .../sca/assembly/xml/WriteNamespacesTestCase.java | 99 ----------- 18 files changed, 1997 deletions(-) delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java delete mode 100644 sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java (limited to 'sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly') diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java deleted file mode 100644 index 3f4a74ba03..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java +++ /dev/null @@ -1,108 +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.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -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.monitor.Monitor; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CompositeProcessorTestCase { - private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912"; - - private static final String OASIS_COMPOSITE = - " " - + "" - + "" - + " " - + "" - + ""; - - private static final String OSOA_COMPOSITE = - "" - + "" - + "" - + " " - + "" - + ""; - - private static XMLInputFactory inputFactory; - private static XMLOutputFactory outputFactory; - private static StAXArtifactProcessor staxProcessor; - private static Monitor monitor; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - monitor = context.getMonitor(); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE); - StAXArtifactProcessorExtensionPoint staxProcessors = - extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory); - } - - @Test - public void testReadOASISSpecVersion() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OASIS_COMPOSITE)); - Object result = staxProcessor.read(reader, context); - assertNotNull(result); - if( result instanceof Composite) { - Composite composite = (Composite) result; - assertEquals(SCA11_NS, composite.getSpecVersion()); - } - reader.close(); - } - - @Test - public void testReadOSOASpecVersion() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OSOA_COMPOSITE)); - Object result = staxProcessor.read(reader, context); - assertNotNull(result); - if( result instanceof Composite) { - throw new Exception("Error, unsupported OSOA namespace being parsed as valid !"); - } - reader.close(); - } -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java deleted file mode 100644 index 0d5e69bd61..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java +++ /dev/null @@ -1,88 +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.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.Multiplicity; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.junit.Before; -import org.junit.Test; - -/** - * Test writing SCA XML assemblies. - * - * TUSCANY-2662 - * - * @version $Rev$ $Date$ - */ -public class MultiplicityReadWriteTestCase { - private XMLInputFactory inputFactory; - private XMLOutputFactory outputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - private ProcessorContext context; - - @Before - public void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory); - } - - - @Test - public void testReadWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Multiplicity.composite"); - Composite composite = staxProcessor.read(is, Composite.class, context); - - verifyComposite(composite); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - bos.close(); - - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - composite = staxProcessor.read(bis, Composite.class, context); - - verifyComposite(composite); - - } - - - private void verifyComposite(Composite composite) { - assertEquals(composite.getComponents().get(0).getReferences().get(0).getMultiplicity(), Multiplicity.ZERO_N); - assertEquals(composite.getReferences().get(0).getMultiplicity(), Multiplicity.ONE_N); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java deleted file mode 100644 index 155c0c5a47..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/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 org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.InputStream; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; - -import org.apache.tuscany.sca.assembly.Callback; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeReference; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.junit.BeforeClass; -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadAllTestCase { - private static StAXArtifactProcessor staxProcessor; - private static XMLInputFactory inputFactory; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - inputFactory = XMLInputFactory.newInstance(); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null); - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context); - assertNotNull(composite); - assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator")); - assertTrue(composite.isLocal()); - assertFalse(composite.getAutowire() == Boolean.TRUE); - assertEquals(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test", - "confidentiality")); - assertEquals(((PolicySubject)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - - Composite include = composite.getIncludes().get(0); - assertEquals(include.getName(), new QName("http://calc", "TestAllDivide")); - - CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0); - assertEquals(calcCompositeService.getName(), "CalculatorService"); - assertTrue(calcCompositeService.getPromotedService().isUnresolved()); - assertEquals(calcCompositeService.getPromotedService().getName(), - "CalculatorService"); - assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - Callback calcServiceCallback = calcCompositeService.getCallback(); - assertNotNull(calcServiceCallback); - assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(), - new QName("http://test", "confidentiality")); - assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy")); - // TODO test operations - - Component calcComponent = composite.getComponents().get(0); - assertEquals(calcComponent.getName(), "CalculatorServiceComponent"); - assertEquals(calcComponent.getAutowire(), Boolean.FALSE); - assertEquals(calcComponent.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/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java deleted file mode 100644 index 473e483d31..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java +++ /dev/null @@ -1,192 +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.net.URI; -import java.net.URL; -import java.util.HashMap; - -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.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.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.BeforeClass; -import org.junit.Test; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class ReadDocumentTestCase { - private static final String TUSCANY_11_XSD = "tuscany-sca-1.1.xsd"; - - private static URLArtifactProcessor documentProcessor; - private static ModelResolver resolver; - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessor staxProcessor; - private static ValidatorHandler handler; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - URLArtifactProcessorExtensionPoint documentProcessors = - extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - - StAXArtifactProcessorExtensionPoint staxProcessors = - extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - inputFactory = XMLInputFactory.newInstance(); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null); - - resolver = new DefaultModelResolver(); - handler = getValidationHandler(); - - } - - @Test - public void testValidateAssembly() throws Exception { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("Calculator.composite"); - XMLReader reader = parserFactory.newSAXParser().getXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setContentHandler(handler); - reader.parse(new InputSource(url.openStream())); - - } - - private static ValidatorHandler getValidationHandler() throws SAXException { - SchemaFactory schemaFactory; - try { - schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - schemaFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - } catch (Error e) { - // Some old JDKs don't support XMLSchema validation - return null; - } catch (Exception e) { - // Some old JDKs don't support XMLSchema validation - return null; - } - Schema schema = schemaFactory.newSchema(ReadDocumentTestCase.class.getClassLoader().getResource(TUSCANY_11_XSD)); - ValidatorHandler handler = schema.newValidatorHandler(); - return handler; - } - - @Test - public void testValidateImplementation() throws Exception { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("Calculator.composite"); - XMLReader reader = parserFactory.newSAXParser().getXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setContentHandler(handler); - reader.parse(new InputSource(url.openStream())); - } - - @Test - public void testReadImplementation() throws Exception { - ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry, new HashMap()); - schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas); - DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry); - factories.addFactory(validatingInputFactory); - - CompositeDocumentProcessor compositeDocumentProcessor = - new CompositeDocumentProcessor(factories, staxProcessor); - - URL url = getClass().getResource("Calculator.composite"); - URI uri = URI.create("Calculator.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url, context); - assertNotNull(composite); - } - - @Test - public void testValidateBinding() throws Exception { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - URL url = getClass().getResource("RMIBindingTest.composite"); - XMLReader reader = parserFactory.newSAXParser().getXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setContentHandler(handler); - reader.parse(new InputSource(url.openStream())); - } - - @Test - public void testReadBinding() throws Exception { - - ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry, new HashMap()); - schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString()); - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas); - DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry); - factories.addFactory(validatingInputFactory); - CompositeDocumentProcessor compositeDocumentProcessor = - new CompositeDocumentProcessor(factories, staxProcessor); - - URL url = getClass().getResource("RMIBindingTest.composite"); - URI uri = URI.create("RMIBindingTest.composite"); - Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url, context); - assertNotNull(composite); - } - - @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, context); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite, context); - - url = getClass().getResource("TestAllCalculator.composite"); - uri = URI.create("TestAllCalculator.composite"); - Composite composite = (Composite)documentProcessor.read(null, uri, url, context); - - documentProcessor.resolve(composite, resolver, context); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java deleted file mode 100644 index 05d320b211..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java +++ /dev/null @@ -1,85 +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.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.ProcessorContext; -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; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - } - - - @Test - public void testReadComponentType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader, context)); - is.close(); - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader, context)); - is.close(); - - } - - @Test - public void testReadCompositeAndWireIt() throws Exception { - InputStream is = getClass().getResourceAsStream("Calculator.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - assertNotNull(staxProcessor.read(reader, context)); - is.close(); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java deleted file mode 100644 index 28a2bb6851..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java +++ /dev/null @@ -1,130 +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.ByteArrayOutputStream; -import java.io.StringReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.Test; - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadWriteAnyAttributeTestCase { - - private static final String XML = ""+ - ""+ - ""+ - ""+ - ""+ - ""; - - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - private ProcessorContext context; - - /** - * Initialize the test environment - * This takes care to register attribute processors when provided - * - * @param attributeProcessor - * @throws Exception - */ - private void init(StAXAttributeProcessor attributeProcessor) throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - - if(attributeProcessor != null) { - StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class); - staxAttributeProcessors.addArtifactProcessor(attributeProcessor); - } - - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - } - - /** - * Read and Write a composite that has a extended attribute - * and a particular attribute processor - * @throws Exception - */ - @Test - public void testReadWriteCompositeWithAttributeProcessor() throws Exception { - init(new TestAttributeProcessor()); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML)); - Composite composite = (Composite) staxProcessor.read(reader, context); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - - // used for debug comparison - // System.out.println(XML); - // System.out.println(bos.toString()); - - assertEquals(XML, bos.toString()); - } - - /** - * Read and Write a composite that has a extended attribute - * but no particular processor for it - * @throws Exception - */ - @Test - public void testDefaultReadWriteComposite() throws Exception { - init(null); - - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML)); - Composite composite = (Composite) staxProcessor.read(reader, context); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - - // used for debug comparison - // System.out.println(XML); - // System.out.println(bos.toString()); - - assertEquals(XML, bos.toString()); - } -} \ No newline at end of file diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java deleted file mode 100644 index 7a36c1d97d..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.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 org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; - -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.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -public class ReadWriteAnyElementTestCase { - private static final String XML_RECURSIVE_EXTENDED_ELEMENT = - "" + - "" + - "" + - "" + - "" + - "" + - ""; - - private static final String XML_UNKNOWN_IMPL = - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - ""; - - private static final String XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE = - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - ""; - - - private ValidatingXMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - private ProcessorContext context; - - @Before - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); - - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance()); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testReadWriteExtendedRecursiveElement() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT)); - ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor()); - Composite composite = (Composite)staxProcessor.read(reader, context); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - - // used for debug comparison - // System.out.println(XML_RECURSIVE_EXTENDED_ELEMENT); - // System.out.println(bos.toString()); - - assertEquals(XML_RECURSIVE_EXTENDED_ELEMENT, bos.toString()); - bos.close(); - } - - @Test - public void testReadWriteUnknwonImpl() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL)); - Composite composite = (Composite)staxProcessor.read(reader, context); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - - // used for debug comparison - // System.out.println(XML_UNKNOWN_IMPL); - // System.out.println(bos.toString()); - - assertEquals(XML_UNKNOWN_IMPL, bos.toString()); - bos.close(); - } - - // @Test - @Ignore() - public void testReadWriteInvalidAttribute() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE)); - Composite composite = (Composite)staxProcessor.read(reader, context); - assertNotNull(composite); - reader.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - - // used for debug comparison - // System.out.println(XML_UNKNOWN_IMPL); - // System.out.println(bos.toString()); - - assertEquals(XML_UNKNOWN_IMPL, bos.toString()); - bos.close(); - } -} \ No newline at end of file diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java deleted file mode 100644 index fc675dcdce..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.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 static org.junit.Assert.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -/** - * Test reading SCA XML assemblies. - * - * @version $Rev$ $Date$ - */ -public class ReadWriteLocalCompositeTestCase { - - private XMLInputFactory inputFactory; - private ExtensibleStAXArtifactProcessor staxProcessor; - private ProcessorContext context; - - private static final String LOCAL_COMPOSITE_XML = ""+ - ""+ - ""; - - @Before - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - 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()); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("local.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader, context); - assertNotNull(composite); - assertTrue(composite.isLocal()); - is.close(); - } - - @Test - public void testWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("local.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader, context); - assertNotNull(composite); - assertTrue(composite.isLocal()); - is.close(); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - System.out.println(bos.toString()); - - assertEquals(LOCAL_COMPOSITE_XML, bos.toString()); - } -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java deleted file mode 100644 index df588e3504..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java +++ /dev/null @@ -1,143 +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.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.definitions.Definitions; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test reading SCA XML assembly documents. - * - * @version $Rev$ $Date$ - */ -public class ResolvePolicyTestCase { - - private static URLArtifactProcessor documentProcessor; - private static ModelResolver resolver; - private static URLArtifactProcessor policyDefinitionsProcessor; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - resolver = new DefaultModelResolver(); - - URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); - policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class); - - // Create StAX processors - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessors.addArtifactProcessor(new TestPolicyProcessor()); - } - - private void preResolvePolicyTests(Composite composite) { - assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription()); - assertTrue(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty()); - - assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - - assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - - assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - } - - private void postResolvePolicyTests(Composite composite) { - assertNotNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription()); - assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription()); - assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty()); - assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription()); - - - } - - @Test - public void testResolveComposite() throws Exception { - URL url = getClass().getResource("Calculator.composite"); - URI uri = URI.create("Calculator.composite"); - Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url, context); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite, context); - - url = getClass().getResource("TestAllCalculator.composite"); - uri = URI.create("TestAllCalculator.composite"); - Composite composite = (Composite)documentProcessor.read(null, uri, url, context); - - documentProcessor.resolve(composite, resolver, context); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java deleted file mode 100644 index 28e679da4a..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java +++ /dev/null @@ -1,82 +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.contribution.processor.ProcessorContext; -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; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - resolver = new DefaultModelResolver(); - } - - @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, context); - is.close(); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite, context); - - is = getClass().getResourceAsStream("TestAllCalculator.composite"); - reader = inputFactory.createXMLStreamReader(is); - Composite composite = compositeReader.read(reader, context); - is.close(); - - compositeReader.resolve(composite, resolver, context); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java deleted file mode 100644 index 8d9bc72389..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java +++ /dev/null @@ -1,78 +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.assertNotNull; -import static org.junit.Assert.assertEquals; - -import java.io.InputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -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 StripURISpacesTestCase { - - private static XMLInputFactory inputFactory; - private static StAXArtifactProcessor staxProcessor; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); - } - - - - @Test - public void testReadComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorURISpaces.composite"); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader, context); - assertNotNull(composite); - is.close(); - - CompositeService compositeService = (CompositeService)composite.getServices().get(0); - assertNotNull(compositeService); - - // Promoted component name with leading and training spaces removed - assertEquals("CalculatorServiceComponent", compositeService.getPromotedComponent().getName()); - } -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java deleted file mode 100644 index b6f4c11ac2..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java +++ /dev/null @@ -1,62 +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.ProcessorContext; -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, ProcessorContext context) throws ContributionReadException, XMLStreamException { - return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart()); - } - - public void write(String value, XMLStreamWriter writer, ProcessorContext context) 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, ProcessorContext context) throws ContributionResolveException { - - } -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java deleted file mode 100644 index cfec8dee7a..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java +++ /dev/null @@ -1,83 +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.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.policy.PolicyExpression; - -/** - * A PolicyExpression Processor used for testing. - * - * @version $Rev$ $Date$ - */ -public class TestPolicyProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); - } - - public PolicyExpression read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException { - return new MockPolicyImplOne(); - } - - public void write(PolicyExpression arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - } - - public Class getModelType() { - return PolicyExpression.class; - } - - public void resolve(PolicyExpression arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { - } - - public class MockPolicyImplOne implements PolicyExpression { - public T getPolicy() { - return null; - } - - public void setName(QName name) { - } - - public void setPolicy(T policy) { - } - - public QName getName() { - return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - - } -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java deleted file mode 100644 index 5e3fa15b69..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/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/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java deleted file mode 100644 index f83a2ebd14..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java +++ /dev/null @@ -1,162 +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.Collections; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.OperationSelector; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.WireFormat; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * A test cheel for the SCA binding. - * - * @version $Rev$ $Date$ - */ -public class TestSCABindingImpl implements SCABinding, PolicySubject { - private String name; - private String uri; - private List extensions = new ArrayList(); - - private List requiredIntents = new ArrayList(); - private List policySets = new ArrayList(); - private ExtensionType bindingType = new TestSCABindingType(); - - /** - * Constructs a new SCA binding. - */ - protected TestSCABindingImpl() { - } - - public String getName() { - return name; - } - - public String getURI() { - return uri; - } - - public void setName(String name) { - this.name = name; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public List 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(); - } - - public List getPolicySets() { - // TODO Auto-generated method stub - return policySets; - } - - public List getRequiredIntents() { - // TODO Auto-generated method stub - return requiredIntents; - } - - public ExtensionType getExtensionType() { - // TODO Auto-generated method stub - return bindingType; - } - - public void setExtensionType(ExtensionType type) { - this.bindingType = type; - } - - public QName getType() { - return TYPE; - } - - private class TestSCABindingType implements ExtensionType { - private QName name = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912","binding"); - public QName getBaseType() { - return BINDING_BASE; - } - - public QName getType() { - return name; - } - - public void setType(QName type) { - } - - public List getAlwaysProvidedIntents() { - return Collections.emptyList(); - } - - public List getMayProvidedIntents() { - return Collections.emptyList(); - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - } - - public WireFormat getRequestWireFormat() { - return null; - } - - public void setRequestWireFormat(WireFormat wireFormat) { - } - - public WireFormat getResponseWireFormat() { - return null; - } - - public void setResponseWireFormat(WireFormat wireFormat) { - } - - public OperationSelector getOperationSelector() { - return null; - } - - public void setOperationSelector(OperationSelector operationSelector) { - } -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java deleted file mode 100644 index 543aaf9893..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java +++ /dev/null @@ -1,109 +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.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -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.definitions.Definitions; -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 ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null); - resolver = new DefaultModelResolver(); - - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl(); - modelFactories.addFactory(scaBindingFactory); - - URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class); - } - - @Test - public void testResolveComposite() throws Exception { - Composite nestedComposite = readComposite("Calculator.composite"); - assertNotNull(nestedComposite); - resolver.addModel(nestedComposite, context); - - Composite composite = readComposite("TestAllCalculator.composite"); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context); - assertNotNull(scaDefns); - - policyDefinitionsProcessor.resolve(scaDefns, resolver, context); - - staxProcessor.resolve(composite, resolver, context); - - assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite); - } - - private Composite readComposite(String resource) throws XMLStreamException, ContributionReadException, IOException { - InputStream is = getClass().getResourceAsStream(resource); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite)staxProcessor.read(reader, context); - is.close(); - return composite; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java deleted file mode 100644 index a19ce79490..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java +++ /dev/null @@ -1,136 +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.SCABindingFactory; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -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.definitions.Definitions; -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 URLArtifactProcessor policyDefinitionsProcessor; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory); - resolver = new DefaultModelResolver(); - - FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); - SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl(); - modelFactories.addFactory(scaBindingFactory); - - 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, context); - - verifyComposite(composite); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - bos.close(); - - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - composite = staxProcessor.read(bis, Composite.class, context); - - verifyComposite(composite); - - } - - @Test - public void testReadWireWriteComposite() throws Exception { - InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite"); - Composite composite = staxProcessor.read(is, Composite.class, context); - - URL url = getClass().getResource("test_definitions.xml"); - URI uri = URI.create("test_definitions.xml"); - Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context); - assertNotNull(scaDefns); - policyDefinitionsProcessor.resolve(scaDefns, resolver, context); - - staxProcessor.resolve(composite, resolver, context); - // compositeBuilder.build(composite, null, monitor); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, bos, context); - } - - @Test - public void testReadWriteComponentType() throws Exception { - InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); - ComponentType componentType = staxProcessor.read(is, ComponentType.class, context); - staxProcessor.resolve(componentType, resolver, context); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(componentType, bos, context); - } - - - private void verifyComposite(Composite composite) { - assertEquals(composite.getProperties().get(0).getName(),"prop1"); - assertEquals(composite.getProperties().get(0).isMany(), true); - assertEquals(composite.getProperties().get(1).getName(),"prop2"); - assertEquals(composite.getProperties().get(1).isMustSupply(), true); - assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType")); - assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://foo", "MyComplexPropertyValue1")); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java deleted file mode 100644 index f50cd5811f..0000000000 --- a/sca-java-2.x/tags/2.0-Beta1-RC1/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java +++ /dev/null @@ -1,99 +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.ProcessorContext; -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; - private static ProcessorContext context; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - context = new ProcessorContext(extensionPoints); - - 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, context); - 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, context); - System.out.println(bos); - - // Read again - is = new ByteArrayInputStream(bos.toByteArray()); - reader = inputFactory.createXMLStreamReader(is); - composite = compositeProcessor.read(reader, context); - - // Compare - component = composite.getComponents().get(0); - implementation = (Composite)component.getImplementation(); - - assertEquals(qname, implementation.getName()); - } - -} -- cgit v1.2.3