tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r526272 - in /incubator/tuscany/java/sca/modules/assembly-xml/src: main/java/org/apache/tuscany/assembly/xml/impl/ test/java/org/apache/tuscany/assembly/xml/
Date Fri, 06 Apr 2007 20:34:10 GMT
Author: jsdelfino
Date: Fri Apr  6 13:34:09 2007
New Revision: 526272

URL: http://svn.apache.org/viewvc?view=rev&rev=526272
Log:
Added missing call to nextTag in document processors, and a test case testing the reading
and resolution of SCA assembly XML documents.

Added:
    incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java
  (with props)
Modified:
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
    incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java?view=diff&rev=526272&r1=526271&r2=526272
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ComponentTypeDocumentProcessor.java
Fri Apr  6 13:34:09 2007
@@ -74,6 +74,7 @@
         try {
             urlStream = url.openStream();
             XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+            reader.nextTag();
             ComponentType componentType = (ComponentType)registry.read(reader);
             return componentType;
             

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java?view=diff&rev=526272&r1=526271&r2=526272
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/CompositeDocumentProcessor.java
Fri Apr  6 13:34:09 2007
@@ -74,6 +74,7 @@
         try {
             urlStream = url.openStream();
             XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+            reader.nextTag();
             Composite composite = (Composite)registry.read(reader);
             return composite;
             

Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java?view=diff&rev=526272&r1=526271&r2=526272
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/ConstrainingTypeDocumentProcessor.java
Fri Apr  6 13:34:09 2007
@@ -75,6 +75,7 @@
         try {
             urlStream = url.openStream();
             XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+            reader.nextTag();
             ConstrainingType constrainingType = (ConstrainingType)registry.read(reader);
             return constrainingType;
             

Added: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java?view=auto&rev=526272
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java
(added)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java
Fri Apr  6 13:34:09 2007
@@ -0,0 +1,109 @@
+/*
+ * 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.assembly.xml;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.xml.impl.ComponentTypeDocumentProcessor;
+import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.impl.CompositeDocumentProcessor;
+import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeDocumentProcessor;
+import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
+import org.apache.tuscany.services.spi.contribution.DefaultArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.DefaultURLArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.URLArtifactProcessorRegistry;
+
+/**
+ * Test the resolving SCA XML assemblies.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ReadAndResolveDocumentTestCase extends TestCase {
+
+    private XMLInputFactory inputFactory;
+    private URLArtifactProcessorRegistry registry;
+
+    public void setUp() throws Exception {
+        inputFactory = XMLInputFactory.newInstance();
+        registry = new DefaultURLArtifactProcessorRegistry();
+        
+        // Create Stax processors
+        StAXArtifactProcessorRegistry staxRegistry = new DefaultStAXArtifactProcessorRegistry();
+        staxRegistry.addArtifactProcessor(new CompositeProcessor(staxRegistry));
+        staxRegistry.addArtifactProcessor(new ComponentTypeProcessor(staxRegistry));
+        staxRegistry.addArtifactProcessor(new ConstrainingTypeProcessor(staxRegistry));
+        
+        // Create document processors
+        registry.addArtifactProcessor(new CompositeDocumentProcessor(staxRegistry));
+        registry.addArtifactProcessor(new ComponentTypeDocumentProcessor(staxRegistry));
+        registry.addArtifactProcessor(new ConstrainingTypeDocumentProcessor(staxRegistry));
+    }
+
+    public void tearDown() throws Exception {
+        inputFactory = null;
+        registry = null;
+    }
+
+    public void testResolveConstrainingType() throws Exception {
+        DefaultArtifactResolver resolver = new DefaultArtifactResolver();
+        
+        URL url = getClass().getClassLoader().getResource("CalculatorComponent.constrainingType");
+        ConstrainingType constrainingType = (ConstrainingType)registry.read(url);
+        assertNotNull(constrainingType);
+        resolver.put(constrainingType, constrainingType);
+
+        url = getClass().getClassLoader().getResource("TestAllCalculator.composite");
+        Composite composite = (Composite)registry.read(url);
+        assertNotNull(composite);
+        
+        registry.resolve(composite, resolver);
+        
+        assertEquals(composite.getConstrainingType(), constrainingType);
+        assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
+    }
+
+    public void testResolveComposite() throws Exception {
+        DefaultArtifactResolver resolver = new DefaultArtifactResolver();
+        
+        URL url = getClass().getClassLoader().getResource("Calculator.composite");
+        Composite nestedComposite = (Composite)registry.read(url);
+        assertNotNull(nestedComposite);
+        resolver.put(nestedComposite, nestedComposite);
+
+        url = getClass().getClassLoader().getResource("TestAllCalculator.composite");
+        Composite composite = (Composite)registry.read(url);
+        
+        registry.resolve(composite, resolver);
+        
+        assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/ReadAndResolveDocumentTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message