tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r711457 - in /tuscany/branches/sca-java-1.3.3/modules: assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ assembly-xml/src/test/resources/org/apache/tuscany/sca/as...
Date Tue, 04 Nov 2008 22:56:15 GMT
Author: slaws
Date: Tue Nov  4 14:56:14 2008
New Revision: 711457

URL: http://svn.apache.org/viewvc?rev=711457&view=rev
Log:
TUSCANY-2663 unknown element processing didn't write out all the information it read in 

Added:
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
  (with props)
Modified:
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
    tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
    tuscany/branches/sca-java-1.3.3/modules/binding-sca-xml/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java
    tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java

Modified: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?rev=711457&r1=711456&r2=711457&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
(original)
+++ tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
Tue Nov  4 14:56:14 2008
@@ -690,6 +690,10 @@
                 extensionProcessor.write(component.getImplementation(), writer);
             }
             
+            for (Object extension : component.getExtensions()) {
+                extensionProcessor.write(extension, writer);
+            }            
+            
             // Write <service> elements
             for (ComponentService service : component.getServices()) {
                 writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
@@ -808,7 +812,7 @@
 
                 writeEnd(writer);
             }
-    
+ 
             writeEnd(writer);
         }
 
@@ -908,9 +912,9 @@
         }
 
         for (Object extension : composite.getExtensions()) {
-            extensionProcessor.write(extension, writer);
+        		extensionProcessor.write(extension, writer);
         }
-
+        
         writeEndDocument(writer);
     }
 

Modified: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java?rev=711457&r1=711456&r2=711457&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
(original)
+++ tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
Tue Nov  4 14:56:14 2008
@@ -34,6 +34,7 @@
 import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
 import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class AnyElementReadWriteTestCase extends TestCase {
@@ -58,6 +59,7 @@
 	public void tearDown() throws Exception {
 	}
 
+	/*
 	@Test
 	public void testReadWriteComposite() throws Exception {
 		InputStream is = getClass().getResourceAsStream("Calculator.composite");
@@ -73,5 +75,22 @@
 
 		is.close();
 	}
+	*/
+	
+	@Test
+	public void testReadWriteUnknownElementComposite() throws Exception {
+		InputStream is = getClass().getResourceAsStream("UnknownElement.composite");
+		XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+		Composite composite = (Composite) staxProcessor.read(reader);
+		assertNotNull(composite);
+
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		staxProcessor.write(composite, bos);
+		System.out.println(bos.toString());
+		//assertEquals(XML, bos.toString());
+		bos.close();
+
+		is.close();
+	}	
 
 }

Modified: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java?rev=711457&r1=711456&r2=711457&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
(original)
+++ tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
Tue Nov  4 14:56:14 2008
@@ -49,21 +49,32 @@
 
     private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
     
+    // implementation.java for CalculatorServiceComponent appears in a strange place as the
+    // java implementation extension is not loaded and hence they are loaded as any elements
     private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
 		 	 "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\"
targetNamespace=\"http://calc\" name=\"Calculator\">"+
 		 	 "<service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\">"+
 		 	 	"<interface.java interface=\"calculator.CalculatorService\" />"+
 	 	 	 "</service>"+
 	 	 	 "<component name=\"CalculatorServiceComponent\" customAttribute=\"customValue\">"+
+	 	 	    "<implementation.java class=\"calculator.CalculatorServiceImpl\" />"+
 	 	 	 	"<reference name=\"addService\" target=\"AddServiceComponent\" />"+
 	 	 	 	"<reference name=\"subtractService\" target=\"SubtractServiceComponent\" />"+
 	 	 	 	"<reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" />"+
 	 	 	 	"<reference name=\"divideService\" target=\"DivideServiceComponent\" />"+
  	 	 	 "</component>"+
- 	 	 	 "<component name=\"AddServiceComponent\" />"+
- 	 	 	 "<component name=\"SubtractServiceComponent\" />"+
- 	 	 	 "<component name=\"MultiplyServiceComponent\" />"+
- 	 	 	 "<component name=\"DivideServiceComponent\" />"+
+ 	 	 	 "<component name=\"AddServiceComponent\">"+
+ 	 	 	    "<implementation.java class=\"calculator.AddServiceImpl\" />"+
+ 	 	 	 "</component>"+
+ 	 	 	 "<component name=\"SubtractServiceComponent\">"+
+ 	 	 	    "<implementation.java class=\"calculator.SubtractServiceImpl\" />"+
+ 	 	 	 "</component>"+
+ 	 	 	 "<component name=\"MultiplyServiceComponent\">"+
+ 	 	 	    "<implementation.java class=\"calculator.MultiplyServiceImpl\" />"+
+ 	 	 	 "</component>"+
+ 	 	 	 "<component name=\"DivideServiceComponent\">"+
+ 	 	 	    "<implementation.java class=\"calculator.DivideServiceImpl\" />"+
+ 	 	 	 "</component>"+
  	 	 	 "</composite>";
     
     @Override

Added: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite?rev=711457&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
(added)
+++ tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
Tue Nov  4 14:56:14 2008
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:ns1="http://temp" xmlns:ns1_1="adfsaf"
name="composite1" targetNamespace="http://temp">
+	<unknown>Test unknown</unknown>
+  <component name="data7">
+    <implementation.java class="temp.EchoImpl"/>
+    <unknownImpl abc="cde"/>
+    <service>
+      <interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"/>
+    </service>
+  </component>
+</composite>
+
+And I got this:
+<?xml version="1.0" encoding="UTF-8"?>
+<composite targetNamespace="http://temp" name="composite1"
+	xmlns="http://www.osoa.org/xmlns/sca/1.0">
+	<component name="data7">
+		<implementation.java class="temp.EchoImpl"></implementation.java>
+		<service>
+			<interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"></interface.wsdl>
+		</service>
+	</component>
+	<component name="empty"></component>
+</composite>

Propchange: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/branches/sca-java-1.3.3/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/UnknownElement.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: tuscany/branches/sca-java-1.3.3/modules/binding-sca-xml/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/binding-sca-xml/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java?rev=711457&r1=711456&r2=711457&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/binding-sca-xml/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java
(original)
+++ tuscany/branches/sca-java-1.3.3/modules/binding-sca-xml/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java
Tue Nov  4 14:56:14 2008
@@ -70,7 +70,7 @@
         assertNotNull(composite);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos));
-        assertEquals("<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\"
xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service
name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><binding.sca /><interface.java
interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference
name=\"addService\" target=\"AddServiceComponent\"><binding.sca /></reference><reference
name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\"
target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\"
/></component><component name=\"AddServiceComponent\"><service><binding.sca
/><interface.java interface=\"calculator.AddService\" /></service></component><component
name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component
na
 me=\"DivideServiceComponent\" /></composite>",
+        assertEquals("<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\"
xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service
name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><binding.sca /><interface.java
interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><implementation.java
class=\"calculator.CalculatorServiceImpl\" /><reference name=\"addService\" target=\"AddServiceComponent\"><binding.sca
/></reference><reference name=\"subtractService\" target=\"SubtractServiceComponent\"
/><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference
name=\"divideService\" target=\"DivideServiceComponent\" /></component><component
name=\"AddServiceComponent\"><implementation.java class=\"calculator.AddServiceImpl\"
/><service><binding.sca /><interface.java interface=\"calculator.AddService\"
/></se
 rvice></component><component name=\"SubtractServiceComponent\"><implementation.java
class=\"calculator.SubtractServiceImpl\" /></component><component name=\"MultiplyServiceComponent\"><implementation.java
class=\"calculator.MultiplyServiceImpl\" /></component><component name=\"DivideServiceComponent\"><implementation.java
class=\"calculator.DivideServiceImpl\" /></component></composite>",
                  	 bos.toString() );
     }
 

Modified: tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java?rev=711457&r1=711456&r2=711457&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
(original)
+++ tuscany/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
Tue Nov  4 14:56:14 2008
@@ -20,6 +20,9 @@
 
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
+import static javax.xml.stream.XMLStreamConstants.COMMENT;
+import static javax.xml.stream.XMLStreamConstants.CDATA;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -36,6 +39,7 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.Characters;
 import javax.xml.stream.events.XMLEvent;
 
 import org.apache.tuscany.sca.contribution.Constants;
@@ -142,6 +146,14 @@
 							reader.getAttributeLocalName(i), reader.getAttributeValue(i));
 				}
 				break;
+				
+			case CHARACTERS:
+				writer.writeCharacters(reader.getText());	
+				break;
+				
+			case CDATA:				
+				writer.writeCData(reader.getText());
+				break;
 
 			case END_ELEMENT:
 				writer.writeEndElement();



Mime
View raw message