From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/topology/xml/ReadDocumentTestCase.java | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 branches/sca-java-1.0/modules/topology-xml/src/test/java/org/apache/tuscany/sca/topology/xml/ReadDocumentTestCase.java (limited to 'branches/sca-java-1.0/modules/topology-xml/src/test/java/org/apache/tuscany/sca/topology/xml/ReadDocumentTestCase.java') diff --git a/branches/sca-java-1.0/modules/topology-xml/src/test/java/org/apache/tuscany/sca/topology/xml/ReadDocumentTestCase.java b/branches/sca-java-1.0/modules/topology-xml/src/test/java/org/apache/tuscany/sca/topology/xml/ReadDocumentTestCase.java new file mode 100644 index 0000000000..ad7b2c5d37 --- /dev/null +++ b/branches/sca-java-1.0/modules/topology-xml/src/test/java/org/apache/tuscany/sca/topology/xml/ReadDocumentTestCase.java @@ -0,0 +1,89 @@ +/* + * 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.topology.xml; + +import java.net.URL; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.topology.Component; +import org.apache.tuscany.sca.topology.DefaultTopologyFactory; +import org.apache.tuscany.sca.topology.Node; +import org.apache.tuscany.sca.topology.Runtime; +import org.apache.tuscany.sca.topology.Scheme; +import org.apache.tuscany.sca.topology.TopologyFactory; + +/** + * Test reading SCA XML assembly documents. + * + * @version $Rev$ $Date$ + */ +public class ReadDocumentTestCase extends TestCase { + + private ExtensibleURLArtifactProcessor documentProcessor; + + @Override + public void setUp() throws Exception { + AssemblyFactory factory = new DefaultAssemblyFactory(); + TopologyFactory topologyFactory = new DefaultTopologyFactory(); + + URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); + documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); + + // Create Stax processors + DefaultStAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(new DefaultModelFactoryExtensionPoint()); + ExtensibleStAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); + staxProcessors.addArtifactProcessor(new TopologyProcessor(topologyFactory, factory, staxProcessor)); + + // Create document processors + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + documentProcessors.addArtifactProcessor(new TopologyDocumentProcessor(staxProcessor, inputFactory)); + } + + @Override + public void tearDown() throws Exception { + documentProcessor = null; + } + + public void testReadTopology() throws Exception { + URL url = getClass().getResource("runtime.topology"); + Runtime runtime = (Runtime)documentProcessor.read(null, null, url); + assertNotNull(runtime); + + Node node0 = runtime.getNodes().get(0); + Scheme scheme0 = node0.getSchemes("nodomain").get(0); + assertEquals(scheme0.getName(), "http"); + + Node node1 = runtime.getNodes().get(1); + Component component0 = node1.getComponents("domainA").get(0); + assertEquals(component0.getName(), "AddServiceComponent"); + } +} -- cgit v1.2.3