tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r524731 - in /incubator/tuscany/java/sca/scdl4j/stax/src: main/java/org/apache/tuscany/scdl/stax/impl/ test/java/org/apache/tuscany/scdl/stax/impl/ test/resources/
Date Mon, 02 Apr 2007 06:27:28 GMT
Author: rfeng
Date: Sun Apr  1 23:27:27 2007
New Revision: 524731

URL: http://svn.apache.org/viewvc?view=rev&rev=524731
Log:
Add the DOM-based property value loading 

Added:
    incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java
  (with props)
Modified:
    incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/BaseLoader.java
    incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/CompositeLoader.java
    incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/ConstrainingTypeLoader.java
    incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/ReadAllTestCase.java
    incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllCalculator.composite
    incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllDivide.composite

Modified: incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/BaseLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/BaseLoader.java?view=diff&rev=524731&r1=524730&r2=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/BaseLoader.java
(original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/BaseLoader.java
Sun Apr  1 23:27:27 2007
@@ -19,11 +19,17 @@
 
 package org.apache.tuscany.scdl.stax.impl;
 
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -42,6 +48,10 @@
 import org.apache.tuscany.policy.model.PolicySetAttachPoint;
 import org.apache.tuscany.sca.idl.Operation;
 import org.apache.tuscany.scdl.stax.Constants;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 /**
  * A test handler to test the usability of the assembly model API when loading
@@ -53,10 +63,10 @@
 
     private AssemblyFactory factory;
     private PolicyFactory policyFactory;
-    
+
     BaseLoader() {
     }
-    
+
     BaseLoader(AssemblyFactory factory, PolicyFactory policyFactory) {
         this.factory = factory;
         this.policyFactory = policyFactory;
@@ -71,6 +81,18 @@
         return getQNameValue(reader, qname);
     }
 
+    /**
+     * Get the value of xsi:type attribute
+     * 
+     * @param reader The XML stream reader
+     * @return The QName of the type, if the attribute is not present, null is
+     *         returned.
+     */
+    protected QName getXSIType(XMLStreamReader reader) {
+        String qname = reader.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,
"type");
+        return getQNameValue(reader, qname);
+    }
+
     protected QName getQNameValue(XMLStreamReader reader, String value) {
         if (value != null) {
             int index = value.indexOf(':');
@@ -105,9 +127,9 @@
     }
 
     protected void readIntents(IntentAttachPoint attachPoint, XMLStreamReader reader) {
-    	readIntents(attachPoint, null, reader);
+        readIntents(attachPoint, null, reader);
     }
-    
+
     protected void readIntents(IntentAttachPoint attachPoint, Operation operation, XMLStreamReader
reader) {
         String value = reader.getAttributeValue(null, Constants.REQUIRES);
         if (value != null) {
@@ -116,18 +138,18 @@
                 QName qname = getQNameValue(reader, tokens.nextToken());
                 Intent intent = policyFactory.createIntent();
                 intent.setName(qname);
-    			if (operation != null) {
-    				intent.getOperations().add(operation);
-    			}
+                if (operation != null) {
+                    intent.getOperations().add(operation);
+                }
                 requiredIntents.add(intent);
             }
         }
     }
 
     protected void readPolicies(PolicySetAttachPoint attachPoint, XMLStreamReader reader)
{
-    	readPolicies(attachPoint, null, reader);
+        readPolicies(attachPoint, null, reader);
     }
-    
+
     protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader)
{
         String value = reader.getAttributeValue(null, MULTIPLICITY);
         if (ZERO_ONE.equals(value)) {
@@ -140,8 +162,8 @@
     }
 
     protected void readPolicies(PolicySetAttachPoint attachPoint, Operation operation, XMLStreamReader
reader) {
-    	readIntents(attachPoint, operation, reader);
-    	
+        readIntents(attachPoint, operation, reader);
+
         String value = reader.getAttributeValue(null, Constants.POLICY_SETS);
         if (value != null) {
             List<PolicySet> policySets = attachPoint.getPolicySets();
@@ -149,9 +171,9 @@
                 QName qname = getQNameValue(reader, tokens.nextToken());
                 PolicySet policySet = policyFactory.createPolicySet();
                 policySet.setName(qname);
-    			if (operation != null) {
-    				policySet.getOperations().add(operation);
-    			}
+                if (operation != null) {
+                    policySet.getOperations().add(operation);
+                }
                 policySets.add(policySet);
             }
         }
@@ -169,25 +191,27 @@
         }
     }
 
-    protected void readAbstractProperty(AbstractProperty prop, XMLStreamReader reader) {
+    protected void readAbstractProperty(AbstractProperty prop, XMLStreamReader reader) throws
XMLStreamException {
         prop.setName(getString(reader, "name"));
         prop.setMany(getBoolean(reader, "many"));
         prop.setMustSupply(getBoolean(reader, "mustSupply"));
         prop.setXSDElement(getQName(reader, "element"));
         prop.setXSDType(getQName(reader, "type"));
+        Node value = readPropertyValue(reader, prop.getXSDType());
+        prop.setDefaultValue(value);
     }
 
-    protected void readProperty(Property prop, XMLStreamReader reader) {
+    protected void readProperty(Property prop, XMLStreamReader reader) throws XMLStreamException
{
         readAbstractProperty(prop, reader);
     }
 
     protected boolean nextChildElement(XMLStreamReader reader) throws XMLStreamException
{
         while (reader.hasNext()) {
             int event = reader.next();
-            if (event == XMLStreamConstants.END_ELEMENT) {
+            if (event == END_ELEMENT) {
                 return false;
             }
-            if (event == XMLStreamConstants.START_ELEMENT) {
+            if (event == START_ELEMENT) {
                 return true;
             }
         }
@@ -215,5 +239,34 @@
             }
         }
     }
+
+    public static Document readPropertyValue(XMLStreamReader reader, QName type)
+        throws XMLStreamException {
+        Document doc = DOMUtil.newDocument();
+
+        // root element has no namespace and local name "value"
+        Element root = doc.createElementNS(null, "value");
+        if (type != null) {
+            Attr xsi = doc.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+            xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
+            root.setAttributeNodeNS(xsi);
+
+            String prefix = type.getPrefix();
+            if (prefix == null || prefix.length() == 0) {
+                prefix = "ns";
+            }
+
+            DOMUtil.declareNamespace(root, prefix, type.getNamespaceURI());
+
+            Attr xsiType = doc.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+            xsiType.setValue(prefix + ":" + type.getLocalPart());
+            root.setAttributeNodeNS(xsiType);
+        }
+        doc.appendChild(root);
+
+        DOMUtil.loadDOM(reader, root);
+        return doc;
+    }
+
 
 }

Modified: incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/CompositeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/CompositeLoader.java?view=diff&rev=524731&r1=524730&r2=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/CompositeLoader.java
(original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/CompositeLoader.java
Sun Apr  1 23:27:27 2007
@@ -58,7 +58,8 @@
 
     /**
      * Construct a new composite loader
-     * @param assemblyFactory 
+     * 
+     * @param assemblyFactory
      * @param policyFactory
      * @param registry
      */
@@ -89,36 +90,36 @@
             switch (event) {
                 case START_ELEMENT:
                     name = reader.getName();
-                    
+
                     if (COMPOSITE_QNAME.equals(name)) {
-                    	
-                    	// Read a <composite>
+
+                        // Read a <composite>
                         composite = factory.createComposite();
                         composite.setName(getQName(reader, NAME));
                         composite.setAutowire(getBoolean(reader, AUTOWIRE));
                         composite.setLocal(getBoolean(reader, LOCAL));
                         composite.setConstrainingType(getConstrainingType(reader));
                         readPolicies(composite, reader);
-                        
+
                     } else if (INCLUDE_QNAME.equals(name)) {
-                    	
-                    	// Read an <include> 
+
+                        // Read an <include>
                         include = factory.createComposite();
                         include.setUnresolved(true);
                         composite.getIncludes().add(include);
-                        
+
                     } else if (SERVICE_QNAME.equals(name)) {
                         if (component != null) {
-                        	
-                        	// Read a <component><service>
+
+                            // Read a <component><service>
                             componentService = factory.createComponentService();
                             contract = componentService;
                             componentService.setName(getString(reader, NAME));
                             component.getServices().add(componentService);
                             readPolicies(contract, reader);
                         } else {
-                        	
-                        	// Read a <composite><service>
+
+                            // Read a <composite><service>
                             compositeService = factory.createCompositeService();
                             contract = compositeService;
                             compositeService.setName(getString(reader, NAME));
@@ -134,8 +135,8 @@
 
                     } else if (REFERENCE_QNAME.equals(name)) {
                         if (component != null) {
-                        	
-                        	// Read a <component><reference>
+
+                            // Read a <component><reference>
                             componentReference = factory.createComponentReference();
                             contract = componentReference;
                             componentReference.setName(getString(reader, NAME));
@@ -150,8 +151,8 @@
                             component.getReferences().add(componentReference);
                             readPolicies(contract, reader);
                         } else {
-                        	
-                        	// Read a <composite><reference>
+
+                            // Read a <composite><reference>
                             compositeReference = factory.createCompositeReference();
                             contract = compositeReference;
                             compositeReference.setName(getString(reader, NAME));
@@ -166,36 +167,37 @@
                             composite.getReferences().add(compositeReference);
                             readPolicies(contract, reader);
                         }
-                        
+
                     } else if (PROPERTY_QNAME.equals(name)) {
                         if (component != null) {
-                        	
-                        	// Read a <component><property>
+
+                            // Read a <component><property>
                             componentProperty = factory.createComponentProperty();
                             property = componentProperty;
+                            readPolicies(property, reader);
                             readProperty(componentProperty, reader);
                             component.getProperties().add(componentProperty);
                         } else {
-                        	
-                        	// Read a <composite><property>
+
+                            // Read a <composite><property>
                             property = factory.createProperty();
+                            readPolicies(property, reader);
                             readProperty(property, reader);
                             composite.getProperties().add(property);
                         }
-                        readPolicies(property, reader);
-                        
+
                     } else if (COMPONENT_QNAME.equals(name)) {
-                    	
-                    	// Read a <component>
+
+                        // Read a <component>
                         component = factory.createComponent();
                         component.setName(getString(reader, NAME));
                         component.setConstrainingType(getConstrainingType(reader));
                         composite.getComponents().add(component);
                         readPolicies(component, reader);
-                        
+
                     } else if (WIRE_QNAME.equals(name)) {
-                    	
-                    	// Read a <wire>
+
+                        // Read a <wire>
                         wire = factory.createWire();
                         ComponentReference source = factory.createComponentReference();
                         source.setUnresolved(true);
@@ -209,41 +211,42 @@
 
                         composite.getWires().add(wire);
                         readPolicies(wire, reader);
-                        
+
                     } else if (CALLBACK_QNAME.equals(name)) {
-                    	
-                    	// Read a <callback> 
+
+                        // Read a <callback>
                         callback = factory.createCallback();
                         contract.setCallback(callback);
                         readPolicies(callback, reader);
-                        
+
                     } else if (OPERATION.equals(name)) {
-    	        	
-    	        	// Read an <operation>
-            		Operation operation = factory.createOperation();
-            		operation.setName(getString(reader, NAME));
-            		operation.setUnresolved(true);
-            		if (callback != null) {
-            			readPolicies(callback, operation, reader);
-            		} else {
-            			readPolicies(contract, operation, reader);
-            		}
+
+                        // Read an <operation>
+                        Operation operation = factory.createOperation();
+                        operation.setName(getString(reader, NAME));
+                        operation.setUnresolved(true);
+                        if (callback != null) {
+                            readPolicies(callback, operation, reader);
+                        } else {
+                            readPolicies(contract, operation, reader);
+                        }
                     } else {
-                    	
+
                         // Read an extension element
                         Object extension = registry.load(reader);
                         if (extension != null) {
                             if (extension instanceof Interface) {
 
-                                // <service><interface> and <reference><interface>
+                                // <service><interface> and
+                                // <reference><interface>
                                 contract.setInterface((Interface)extension);
-                                
+
                             } else if (extension instanceof Binding) {
                                 // <service><binding> and <reference><binding>
                                 contract.getBindings().add((Binding)extension);
-                                
+
                             } else if (extension instanceof Implementation) {
-                                
+
                                 // <component><implementation>
                                 component.setImplementation((Implementation)extension);
                             }
@@ -252,21 +255,17 @@
                     break;
 
                 case XMLStreamConstants.CHARACTERS:
-                	
-                	// Read an <include>qname</include>
+
+                    // Read an <include>qname</include>
                     if (include != null && INCLUDE_QNAME.equals(name)) {
                         include.setName(getQNameValue(reader, reader.getText().trim()));
                     }
-                    
-                    // Read a <property>value</property>
-                    else if (property != null && PROPERTY_QNAME.equals(name)) {
-                        property.setDefaultValue(reader.getText().trim());
-                    }
+
                     break;
-                
+
                 case END_ELEMENT:
                     name = reader.getName();
-                	
+
                     // Clear current state when reading reaching end element
                     if (SERVICE_QNAME.equals(name)) {
                         componentService = null;
@@ -290,7 +289,7 @@
                     }
                     break;
             }
-            
+
             // Read the next element
             if (reader.hasNext()) {
                 reader.next();

Modified: incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/ConstrainingTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/ConstrainingTypeLoader.java?view=diff&rev=524731&r1=524730&r2=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/ConstrainingTypeLoader.java
(original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/ConstrainingTypeLoader.java
Sun Apr  1 23:27:27 2007
@@ -121,12 +121,9 @@
 
                         // Read an extension element
                         Object extension = registry.load(reader);
-                        if (extension != null) {
-                            if (extension instanceof Interface) {
-
-                                // <service><interface> and <reference><interface>
-                                abstractContract.setInterface((Interface)extension);
-                            }
+                        if (extension instanceof Interface) {
+                            // <service><interface> and <reference><interface>
+                            abstractContract.setInterface((Interface)extension);
                         }
                     }
                     break;

Added: incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java?view=auto&rev=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java
(added)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java
Sun Apr  1 23:27:27 2007
@@ -0,0 +1,169 @@
+/*
+ * 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.scdl.stax.impl;
+
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.scdl.stax.LoaderException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class DOMUtil {
+    private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();
+    static {
+        FACTORY.setNamespaceAware(true);
+    }
+
+    private DOMUtil() {
+    }
+
+    public static Document newDocument() {
+        try {
+            return newDocumentBuilder().newDocument();
+        } catch (ParserConfigurationException e) {
+            throw new LoaderException(e);
+        }
+    }
+
+    public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
{
+        return FACTORY.newDocumentBuilder();
+    }
+
+    public static QName getQName(Node node) {
+        String ns = node.getNamespaceURI();
+        if (ns == null) {
+            ns = "";
+        }
+        // node.getLocalName() will return null if it is created using DOM Level
+        // 1 method
+        // such as createElement()
+        return new QName(ns, node.getNodeName());
+    }
+
+    public static Element createElement(Document document, QName name) {
+        String prefix = name.getPrefix();
+        String qname = (prefix != null && prefix.length() > 0) ? prefix + ":"
+ name.getLocalPart() : name
+            .getLocalPart();
+        return document.createElementNS(name.getNamespaceURI(), qname);
+    }
+
+    public static void declareNamespace(Element element, String prefix, String ns) {
+        String qname = null;
+        if ("".equals(prefix)) {
+            qname = "xmlns";
+        } else {
+            qname = "xmlns:" + prefix;
+        }
+        Node node = element;
+        boolean declared = false;
+        while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+            NamedNodeMap attrs = node.getAttributes();
+            if (attrs == null) {
+                break;
+            }
+            Node attr = attrs.getNamedItem(qname);
+            if (attr != null) {
+                declared = ns.equals(attr.getNodeValue());
+                break;
+            }
+            node = node.getParentNode();
+        }
+        if (!declared) {
+            Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI,
qname);
+            attr.setValue(ns);
+            element.setAttributeNodeNS(attr);
+        }
+    }
+
+    /**
+     * Load a property value specification from an StAX stream into a DOM
+     * Document. Only elements, text and attributes are processed; all comments
+     * and other whitespace are ignored.
+     * 
+     * @param reader the stream to read from
+     * @param root the DOM node to load
+     * @throws javax.xml.stream.XMLStreamException
+     */
+    public static void loadDOM(XMLStreamReader reader, Node root) throws XMLStreamException
{
+        Document document = root.getOwnerDocument();
+        Node current = root;
+        while (true) {
+            switch (reader.next()) {
+                case XMLStreamConstants.START_ELEMENT:
+                    QName name = reader.getName();
+                    Element child = createElement(document, name);
+
+                    // push the new element and make it the current one
+                    current.appendChild(child);
+                    current = child;
+
+                    declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
+
+                    int count = reader.getNamespaceCount();
+                    for (int i = 0; i < count; i++) {
+                        String prefix = reader.getNamespacePrefix(i);
+                        String ns = reader.getNamespaceURI(i);
+                        declareNamespace(child, prefix, ns);
+                    }
+
+                    // add the attributes for this element
+                    count = reader.getAttributeCount();
+                    for (int i = 0; i < count; i++) {
+                        String ns = reader.getAttributeNamespace(i);
+                        String prefix = reader.getAttributePrefix(i);
+                        String localPart = reader.getAttributeLocalName(i);
+                        String value = reader.getAttributeValue(i);
+                        child.setAttributeNS(ns, localPart, value);
+                        declareNamespace(child, prefix, ns);
+                    }
+
+                    break;
+                case XMLStreamConstants.CDATA:
+                    current.appendChild(document.createCDATASection(reader.getText()));
+                    break;
+                case XMLStreamConstants.CHARACTERS:
+                    current.appendChild(document.createTextNode(reader.getText()));
+                    break;
+                case XMLStreamConstants.END_ELEMENT:
+                    // if we are back at the root then we are done
+                    if (current == root) {
+                        return;
+                    }
+
+                    // pop the element off the stack
+                    current = current.getParentNode();
+            }
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/scdl4j/stax/src/main/java/org/apache/tuscany/scdl/stax/impl/DOMUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/ReadAllTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/ReadAllTestCase.java?view=diff&rev=524731&r1=524730&r2=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/ReadAllTestCase.java
(original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/ReadAllTestCase.java
Sun Apr  1 23:27:27 2007
@@ -37,6 +37,8 @@
 import org.apache.tuscany.assembly.util.CompositeUtil;
 import org.apache.tuscany.assembly.util.PrintUtil;
 import org.apache.tuscany.scdl.stax.Constants;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 /**
  * Test the usability of the assembly model API when loading SCDL
@@ -113,7 +115,10 @@
 
         Property property = calcComponent.getProperties().get(0);
         assertEquals(property.getName(), "round");
-        assertEquals(property.getDefaultValue(), "true");
+        Document doc = (Document) property.getDefaultValue();
+        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);
 

Modified: incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllCalculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllCalculator.composite?view=diff&rev=524731&r1=524730&r2=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllCalculator.composite
(original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllCalculator.composite
Sun Apr  1 23:27:27 2007
@@ -1,85 +1,93 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<composite autowire="false"
-	constrainingType="tns:Calculator"
-	local="true"
-	name="tns:TestAllCalculator"
-	policySets="sns:secure" requires="cns:confidentiality"
-	targetNamespace="http://calc"
-	xmlns:tns="http://calc"
-	xmlns="http://www.osoa.org/xmlns/sca/1.0"
-	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0
"
-	xmlns:cns="http://test/confidentiality"
-	xmlns:sns="http://test/secure">
-	
-  <include>tns:TestAllDivide</include>
-  
-  <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService"
-	requires="cns:confidentiality" policySets="sns:secure">
-    <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback"/>
-    <operation name="add" policySets="sns:secure" requires="cns:confidentiality"/>
-
-    <binding.ws name="CalculatorWS" policySets="sns:secure" port="" requires="cns:confidentiality"
uri="http://calc/ws">
-      <operation name="add" policySets="sns:secure" requires="cns:confidentiality"/>
-    </binding.ws>
-
-    <callback policySets="sns:secure" requires="cns:confidentiality">
-      <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
-        <operation name="addCallback" policySets="sns:secure" requires="cns:confidentiality"/>
-      </binding.ws>
-    </callback>
-  </service>
-  
-   <component name="CalculatorServiceComponent" autowire="false" constrainingType="tns:CalculatorServiceComponent"
policySets="sns:secure" requires="cns:confidentiality">
-   		<service name="CalculatorService" policySets="sns:secure" requires="cns:confidentiality">
-   			<interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback"/>
-   		</service>
-
-   		<reference name="addService" target="AddServiceComponent/AddService" autowire="false"
multiplicity="1..1" policySets="sns:secure" requires="cns:confidentiality" wiredByImpl="false">
-   			<interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback"/>
-   		</reference>
-   		<reference name="subtractService" target="SubtractServiceComponent"/>
-   		<reference name="multiplyService"/>
-   		<reference name="divideService" target="DivideServiceComponent"/>
-
-   		<property name="round" type="xsd:boolean" many="false">true</property>
-
-		<implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires=""/>
-   </component>
-
-   <component name="AddServiceComponent">
-   		<service name="AddService">
-   			<interface.java interface="calculator.AddService"/>
-   		</service>
-       <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>
-
-  <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
policySets="sns:secure" requires="cns:confidentiality" >
-    <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback"/>
-    <operation name="multiply" policySets="sns:secure" requires="cns:confidentiality"
/>
-
-    <binding.ws name="MultiplyWS" port="" policySets="sns:secure" requires="cns:confidentiality"
uri="http://calc/ws">
-      <operation name="multiply" policySets="sns:secure" requires="cns:confidentiality"
/>
-    </binding.ws>
-
-    <callback policySets="sns:secure" requires="cns:confidentiality" >
-      <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws" policySets="sns:secure"
requires="cns:confidentiality" >
-        <operation name="multiplyCallback" policySets="sns:secure" requires="cns:confidentiality"
/>
-      </binding.ws>
-    </callback>
-  </reference>
-  
+<composite autowire="false" constrainingType="tns:Calculator" local="true" name="tns:TestAllCalculator"
policySets="sns:secure"
+    requires="cns:confidentiality" targetNamespace="http://calc" xmlns:tns="http://calc"
+    xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0
"
+    xmlns:cns="http://test/confidentiality" xmlns:sns="http://test/secure">
+
+    <include>tns:TestAllDivide</include>
+
+    <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService"
requires="cns:confidentiality"
+        policySets="sns:secure">
+        <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback"
/>
+        <operation name="add" policySets="sns:secure" requires="cns:confidentiality" />
+
+        <binding.ws name="CalculatorWS" policySets="sns:secure" port="" requires="cns:confidentiality"
uri="http://calc/ws">
+            <operation name="add" policySets="sns:secure" requires="cns:confidentiality"
/>
+        </binding.ws>
+
+        <callback policySets="sns:secure" requires="cns:confidentiality">
+            <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires=""
uri="http://calc/callback/ws">
+                <operation name="addCallback" policySets="sns:secure" requires="cns:confidentiality"
/>
+            </binding.ws>
+        </callback>
+    </service>
+
+    <component name="CalculatorServiceComponent" autowire="false" constrainingType="tns:CalculatorServiceComponent"
+        policySets="sns:secure" requires="cns:confidentiality">
+        <service name="CalculatorService" policySets="sns:secure" requires="cns:confidentiality">
+            <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback"
/>
+        </service>
+
+        <reference name="addService" target="AddServiceComponent/AddService" autowire="false"
multiplicity="1..1"
+            policySets="sns:secure" requires="cns:confidentiality" wiredByImpl="false">
+            <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback"
/>
+        </reference>
+        <reference name="subtractService" target="SubtractServiceComponent" />
+        <reference name="multiplyService" />
+        <reference name="divideService" target="DivideServiceComponent" />
+
+        <property name="round" type="xsd:boolean" many="false">true</property>
+
+        <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires=""
/>
+    </component>
+
+    <component name="AddServiceComponent">
+        <service name="AddService">
+            <interface.java interface="calculator.AddService" />
+        </service>
+        <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>
+
+    <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
policySets="sns:secure"
+        requires="cns:confidentiality">
+        <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback"
/>
+        <operation name="multiply" policySets="sns:secure" requires="cns:confidentiality"
/>
+
+        <binding.ws name="MultiplyWS" port="" policySets="sns:secure" requires="cns:confidentiality"
uri="http://calc/ws">
+            <operation name="multiply" policySets="sns:secure" requires="cns:confidentiality"
/>
+        </binding.ws>
+
+        <callback policySets="sns:secure" requires="cns:confidentiality">
+            <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws"
policySets="sns:secure"
+                requires="cns:confidentiality">
+                <operation name="multiplyCallback" policySets="sns:secure" requires="cns:confidentiality"
/>
+            </binding.ws>
+        </callback>
+    </reference>
+
+    <property name="prop1" xmlns:foo="http://foo">
+        <MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
+            <foo:a>AValue</foo:a>
+            <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+        </MyComplexPropertyValue1>
+        <MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
+            <foo:a>BValue</foo:a>
+            <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+        </MyComplexPropertyValue2>
+    </property>
+
 </composite>

Modified: incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllDivide.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllDivide.composite?view=diff&rev=524731&r1=524730&r2=524731
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllDivide.composite (original)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/test/resources/TestAllDivide.composite Sun
Apr  1 23:27:27 2007
@@ -74,6 +74,6 @@
         <operation name="multiplyCallback" policySets="" requires=""/>
       </binding.ws>
     </callback>
-  </service>
+  </reference>
   
 </composite>



---------------------------------------------------------------------
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