You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/02/01 01:07:33 UTC
svn commit: r502055 - in /incubator/tuscany/java/sca/kernel:
core/src/main/java/org/apache/tuscany/core/idl/java/
core/src/main/java/org/apache/tuscany/core/loader/
core/src/test/java/org/apache/tuscany/core/loader/ spi/
spi/src/main/java/org/apache/tu...
Author: meerajk
Date: Wed Jan 31 16:07:32 2007
New Revision: 502055
URL: http://svn.apache.org/viewvc?view=rev&rev=502055
Log:
moved StAXUtil from core to spi
Added:
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java (with props)
incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/
incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java (with props)
incubator/tuscany/java/sca/kernel/spi/src/test/resources/
incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl (with props)
Removed:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java
incubator/tuscany/java/sca/kernel/spi/pom.xml
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java?view=diff&rev=502055&r1=502054&r2=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java Wed Jan 31 16:07:32 2007
@@ -42,8 +42,7 @@
import org.apache.tuscany.spi.model.DataType;
import org.apache.tuscany.spi.model.InteractionScope;
import org.apache.tuscany.spi.model.ModelObject;
-
-import org.apache.tuscany.core.loader.StAXUtil;
+import org.apache.tuscany.spi.util.stax.StaxUtil;
/**
* Loads a Java interface definition from an XML-based assembly file
@@ -72,7 +71,7 @@
throws XMLStreamException, LoaderException {
assert INTERFACE_JAVA.equals(reader.getName());
- InteractionScope interactionScope = StAXUtil.interactionScope(reader.getAttributeValue(null, "scope"));
+ InteractionScope interactionScope = StaxUtil.interactionScope(reader.getAttributeValue(null, "scope"));
String name = reader.getAttributeValue(null, "interface");
if (name == null) {
// allow "class" as well as seems to be a common mistake
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java?view=diff&rev=502055&r1=502054&r2=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java Wed Jan 31 16:07:32 2007
@@ -69,6 +69,7 @@
import org.apache.tuscany.spi.model.ReferenceDefinition;
import org.apache.tuscany.spi.model.ReferenceTarget;
import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.util.stax.StaxUtil;
import org.osoa.sca.annotations.Constructor;
import org.w3c.dom.Document;
@@ -204,7 +205,7 @@
} else {
try {
DocumentBuilder documentBuilder = DOMHelper.newDocumentBuilder();
- Document value = StAXUtil.createPropertyValue(reader, property.getXmlType(), documentBuilder);
+ Document value = StaxUtil.createPropertyValue(reader, property.getXmlType(), documentBuilder);
propertyValue = new PropertyValue<Type>(name, value);
} catch (ParserConfigurationException e) {
throw new LoaderException(e);
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java?view=diff&rev=502055&r1=502054&r2=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java Wed Jan 31 16:07:32 2007
@@ -37,6 +37,7 @@
import org.apache.tuscany.spi.model.OverrideOptions;
import org.apache.tuscany.spi.model.Property;
import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.util.stax.StaxUtil;
import org.apache.tuscany.spi.annotation.Autowire;
/**
@@ -87,7 +88,7 @@
boolean many = Boolean.parseBoolean(reader.getAttributeValue(null, PROPERTY_MANY_ATTR));
String override = reader.getAttributeValue(null, PROPERTY_OVERRIDE_ATTR);
- Document value = StAXUtil.createPropertyValue(reader, xmlType, documentBuilder);
+ Document value = StaxUtil.createPropertyValue(reader, xmlType, documentBuilder);
Property<?> property = new Property();
property.setName(name);
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java?view=diff&rev=502055&r1=502054&r2=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java Wed Jan 31 16:07:32 2007
@@ -39,6 +39,7 @@
import org.apache.tuscany.spi.model.Multiplicity;
import org.apache.tuscany.spi.model.ReferenceDefinition;
import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.util.stax.StaxUtil;
/**
* Loads a reference from an XML-based assembly file
@@ -64,7 +65,7 @@
assert REFERENCE.equals(reader.getName());
String name = reader.getAttributeValue(null, "name");
String multiplicityVal = reader.getAttributeValue(null, "multiplicity");
- Multiplicity multiplicity = StAXUtil.multiplicity(multiplicityVal, Multiplicity.ONE_ONE);
+ Multiplicity multiplicity = StaxUtil.multiplicity(multiplicityVal, Multiplicity.ONE_ONE);
ReferenceDefinition referenceDefinition = new ReferenceDefinition();
referenceDefinition.setMultiplicity(multiplicity);
referenceDefinition.setName(name);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java?view=diff&rev=502055&r1=502054&r2=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java Wed Jan 31 16:07:32 2007
@@ -26,6 +26,8 @@
import javax.xml.parsers.DocumentBuilder;
import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.util.stax.StaxUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -45,7 +47,7 @@
+ "</property>";
XMLStreamReader reader = getReader(xml);
- StAXUtil.loadPropertyValue(reader, root);
+ StaxUtil.loadPropertyValue(reader, root);
NodeList childNodes = root.getChildNodes();
assertEquals(2, childNodes.getLength());
Modified: incubator/tuscany/java/sca/kernel/spi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/pom.xml?view=diff&rev=502055&r1=502054&r2=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/pom.xml (original)
+++ incubator/tuscany/java/sca/kernel/spi/pom.xml Wed Jan 31 16:07:32 2007
@@ -41,18 +41,27 @@
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</dependency>
+
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
</dependency>
+
</dependencies>
</project>
Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java?view=auto&rev=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java Wed Jan 31 16:07:32 2007
@@ -0,0 +1,324 @@
+/*
+ * 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.spi.util.stax;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.Multiplicity;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Utility for stax operations.
+ *
+ * @version $Revision$ $Date$
+ *
+ */
+public abstract class StaxUtil {
+
+ /** XML input factory. */
+ private static final XMLInputFactory xmlFactory =
+ XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", StaxUtil.class.getClassLoader());;
+
+ private static final Map<String, Multiplicity> MULTIPLICITY = new HashMap<String, Multiplicity>(4);
+
+ static {
+ MULTIPLICITY.put("0..1", Multiplicity.ZERO_ONE);
+ MULTIPLICITY.put("1..1", Multiplicity.ONE_ONE);
+ MULTIPLICITY.put("0..n", Multiplicity.ZERO_N);
+ MULTIPLICITY.put("1..n", Multiplicity.ONE_N);
+ }
+
+ private StaxUtil() {
+ }
+
+ /**
+ * Convert a "multiplicity" attribute to the equivalent enum value.
+ *
+ * @param multiplicity the attribute to convert
+ * @param def the default value
+ * @return the enum equivalent
+ */
+ public static Multiplicity multiplicity(String multiplicity, Multiplicity def) {
+ return multiplicity == null ? def : MULTIPLICITY.get(multiplicity);
+ }
+
+ /**
+ * Convert a "scope" attribute to the equivalent enum value. Returns
+ * CONVERSATIONAL if the value equals (ignoring case) "conversational",
+ * otherwise returns NONCONVERSATIONAL.
+ *
+ * @param scope the attribute to convert
+ * @return the enum equivalent
+ */
+ public static InteractionScope interactionScope(String scope) {
+ if ("conversational".equalsIgnoreCase(scope)) {
+ return InteractionScope.CONVERSATIONAL;
+ } else {
+ return InteractionScope.NONCONVERSATIONAL;
+ }
+ }
+
+ public static Document createPropertyValue(XMLStreamReader reader, QName type, DocumentBuilder builder)
+ throws XMLStreamException {
+ Document doc = builder.newDocument();
+
+ // root element has no namespace and local name "value"
+ Element root = doc.createElementNS(null, "value");
+ if (type != null) {
+ Attr xsi = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+ xsi.setValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ root.setAttributeNodeNS(xsi);
+
+ String prefix = type.getPrefix();
+ if (prefix == null || prefix.length() == 0) {
+ prefix = "ns";
+ }
+ Attr typeXmlns = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + prefix);
+ typeXmlns.setValue(type.getNamespaceURI());
+ root.setAttributeNodeNS(typeXmlns);
+
+ Attr xsiType = doc.createAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+ xsiType.setValue(prefix + ":" + type.getLocalPart());
+ root.setAttributeNodeNS(xsiType);
+ }
+ doc.appendChild(root);
+
+ loadPropertyValue(reader, root);
+ return doc;
+ }
+
+ /**
+ * 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
+ */
+ public static void loadPropertyValue(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 = document.createElementNS(name.getNamespaceURI(), name.getLocalPart());
+
+ // add the attributes for this element
+ int count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String localPart = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+ child.setAttributeNS(ns, localPart, value);
+ }
+
+ // push the new element and make it the current one
+ current.appendChild(child);
+ current = child;
+ 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();
+ }
+ }
+ }
+
+ /**
+ * Serializes the infoset in the stream reader.
+ *
+ * @param reader Stream reader.
+ * @return Serialized XML.
+ * @throws XMLStreamException In case of an xml stream error.
+ */
+ public static final String serialize(XMLStreamReader reader) throws XMLStreamException {
+
+ try {
+
+ StringBuffer xml = new StringBuffer();
+
+ int event = reader.getEventType();
+ while (true) {
+
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ onStartElement(reader, xml);
+ onNsMappings(reader, xml);
+ onAttributes(reader, xml);
+ xml.append(">");
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ if (reader.isWhiteSpace()) {
+ break;
+ }
+ xml.append(reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ onEndElement(reader, xml);
+ break;
+ }
+
+ if (!reader.hasNext()) {
+ break;
+ }
+ event = reader.next();
+
+ }
+ return xml.toString();
+
+ } finally {
+ reader.close();
+ }
+
+ }
+
+ /**
+ * Creates a stream reader to the serialized XML.
+ *
+ * @param xml Serialized XML to which reader is to be created.
+ * @return XML stream reader instance.
+ * @throws XMLStreamException In case of an xml stream error.
+ */
+ public static final XMLStreamReader createReader(String xml) throws XMLStreamException {
+
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ return xmlFactory.createXMLStreamReader(in);
+
+ }
+
+ /**
+ * Creates a stream reader to the serialized XML.
+ *
+ * @param xml XML stream to which reader is to be created.
+ * @return XML stream reader instance.
+ * @throws XMLStreamException In case of an xml stream error.
+ */
+ public static final XMLStreamReader createReader(InputStream xml) throws XMLStreamException {
+
+ return xmlFactory.createXMLStreamReader(xml);
+
+ }
+
+ /**
+ * Returns the qualified name of the document element.
+ *
+ * @param xml Serialized xml that needs to be checked.
+ * @return Qualified name of the document element.
+ * @throws XMLStreamException In case of an xml stream error.
+ */
+ public static final QName getDocumentElementQName(String xml) throws XMLStreamException {
+
+ XMLStreamReader reader = null;
+ try {
+ reader = createReader(xml);
+ reader.next();
+ return reader.getName();
+ } finally {
+ reader.close();
+ }
+
+ }
+
+ /*
+ * Renders end element markup.
+ */
+ private static void onEndElement(XMLStreamReader reader, StringBuffer xml) {
+ String name = getName(reader);
+ xml.append("</");
+ xml.append(name);
+ xml.append(">");
+ }
+
+ /*
+ * Gets the fully-qualified name of the element.
+ */
+ private static String getName(XMLStreamReader reader) {
+ QName qname = reader.getName();
+ String namePrefix = qname.getPrefix();
+ String localPart = qname.getLocalPart();
+ String name = namePrefix == null || "".equals(namePrefix) ? localPart : namePrefix + ":" + localPart;
+ return name;
+ }
+
+ /*
+ * Render the attributes.
+ */
+ private static void onAttributes(XMLStreamReader reader, StringBuffer xml) {
+ for (int i = 0, n = reader.getAttributeCount(); i < n; ++i) {
+ xml.append(" ");
+ xml.append(reader.getAttributeLocalName(i));
+ xml.append("=");
+ xml.append("'");
+ xml.append(reader.getAttributeValue(i));
+ xml.append("'");
+ }
+ }
+
+ /*
+ * Renedr namespace mappings.
+ */
+ private static void onNsMappings(XMLStreamReader reader, StringBuffer xml) {
+ for (int i = 0, n = reader.getNamespaceCount(); i < n; ++i) {
+ String prefix = reader.getNamespacePrefix(i);
+ prefix = prefix == null ? prefix = "xmlns" : "xmlns:" + prefix;
+ xml.append(" ");
+ xml.append(prefix);
+ xml.append("=");
+ xml.append("'");
+ xml.append(reader.getNamespaceURI(i));
+ xml.append("'");
+ }
+ }
+
+ /*
+ * Render start element.
+ */
+ private static void onStartElement(XMLStreamReader reader, StringBuffer xml) {
+ xml.append("<");
+ String name = getName(reader);
+ xml.append(name);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java?view=auto&rev=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java Wed Jan 31 16:07:32 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.spi.util.stax;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for StaxHelper
+ *
+ * @version $Revision$ $Date$
+ *
+ */
+public class StaxUtilTestCase extends TestCase {
+
+ public StaxUtilTestCase(String name) {
+ super(name);
+ }
+
+ public void testSerialize() throws XMLStreamException {
+
+ InputStream in = getClass().getClassLoader().getResourceAsStream("test.scdl");
+ XMLStreamReader reader = StaxUtil.createReader(in);
+ StaxUtil.serialize(reader);
+ // TODO Do assertions
+ }
+
+ public void testGetDocumentElementQName() throws XMLStreamException {
+ InputStream in = getClass().getClassLoader().getResourceAsStream("test.scdl");
+ XMLStreamReader reader = StaxUtil.createReader(in);
+ String xml = StaxUtil.serialize(reader);
+ QName qname = StaxUtil.getDocumentElementQName(xml);
+ assertEquals("http://www.osoa.org/xmlns/sca/1.0", qname.getNamespaceURI());
+ assertEquals("composite", qname.getLocalPart());
+ }
+
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/util/stax/StaxUtilTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl?view=auto&rev=502055
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl Wed Jan 31 16:07:32 2007
@@ -0,0 +1,34 @@
+<?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.
+-->
+<!--
+ Test for stax.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="test.scdl">
+
+ <component name="test.component">
+ <system:implementation.system class="test.class"/>
+ <property name="testProperty">123</property>
+ </component>
+
+</composite>
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/resources/test.scdl
------------------------------------------------------------------------------
svn:mime-type = text/xml
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org