[addressing-devel] SF.net SVN: addressing:[12] trunk
Brought to you by:
nodens2k
|
From: <Nod...@us...> - 2008-09-04 12:59:58
|
Revision: 12
http://addressing.svn.sourceforge.net/addressing/?rev=12&view=rev
Author: Nodens2k
Date: 2008-09-04 13:00:07 +0000 (Thu, 04 Sep 2008)
Log Message:
-----------
- Fixed some minor bugs
Modified Paths:
--------------
trunk/pom.xml
trunk/src/main/java/org/apache/axis/message/addressing/AnyContentTypeList.java
trunk/src/main/java/org/apache/axis/message/addressing/EndpointReference.java
trunk/src/main/java/org/apache/axis/message/addressing/EndpointReferenceType.java
trunk/src/main/java/org/apache/axis/message/addressing/MetaDataType.java
trunk/src/main/java/org/apache/axis/message/addressing/ReferenceParametersType.java
trunk/src/main/java/org/apache/axis/message/addressing/ReferencePropertiesType.java
trunk/src/site/site.xml
Added Paths:
-----------
trunk/src/test/java/org/apache/ws/addressing/EprParsingTest.java
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Added: svn:ignore
+ target
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/pom.xml 2008-09-04 13:00:07 UTC (rev 12)
@@ -98,14 +98,14 @@
<!-- Assembly configuration -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptorRefs>
- <descriptorRef>project</descriptorRef>
- </descriptorRefs>
- <descriptors>
- <descriptor>src/main/assembly/bin.xml</descriptor>
- </descriptors>
- </configuration>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>project</descriptorRef>
+ </descriptorRefs>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ </descriptors>
+ </configuration>
</plugin>
<!-- Ensure Java 5 is used on all modules -->
<plugin>
@@ -147,11 +147,11 @@
<mkdir dir="target/generated-sources/test/stubs"/>
<java classname="org.apache.axis.message.addressing.tools.wsdl.WSDL2Java"
- failonerror="true"
- fork="yes">
- <classpath>
- <path refid="maven.test.classpath"/>
- </classpath>
+ failonerror="true"
+ fork="yes">
+ <classpath>
+ <path refid="maven.test.classpath"/>
+ </classpath>
<arg value="-o"/>
<arg value="target/generated-sources/test/stubs"/>
<arg value="-Nhttp://schemas.xmlsoap.org/ws/2004/08/addressing=org.apache.axis.message.addressing"/>
Modified: trunk/src/main/java/org/apache/axis/message/addressing/AnyContentTypeList.java
===================================================================
--- trunk/src/main/java/org/apache/axis/message/addressing/AnyContentTypeList.java 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/main/java/org/apache/axis/message/addressing/AnyContentTypeList.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -52,6 +52,7 @@
* </pre>
*
* @author Rodrigo Ruiz
+ * @version $Revision$
*/
public abstract class AnyContentTypeList extends ArrayList<MessageElement>
implements AnyContentType, DOMAppendable {
@@ -189,21 +190,8 @@
Element elem = doc.createElementNS(ns, elementName);
try {
- // Optimize execution depending on the number of elements
- if (size == 1) {
- elem.appendChild(doc.importNode(this.get(0).getAsDOM(), true));
- } else {
- MessageElement dummy = new MessageElement(new QName("", "a"));
-
- for (MessageElement item : this) {
- dummy.addChild(item);
- }
-
- NodeList list = doc.importNode(dummy.getAsDOM(), true).getChildNodes();
- final int count = list.getLength();
- for (int i = 0; i < count; i++) {
- elem.appendChild(list.item(i));
- }
+ for (MessageElement item : this) {
+ elem.appendChild(doc.importNode(item.getAsDOM(), true));
}
} catch (Exception e) {
LOG.warn("Error appending child element", e);
@@ -257,16 +245,18 @@
*/
protected String toString(String itemName) {
StringBuffer buf = new StringBuffer();
+ buf.append(itemName);
+
for (int i = 0; i < this.size(); i++) {
+ buf.append(i == 0 ? ": { " : ", ");
MessageElement item = this.get(i);
- buf.append(itemName).append("[").append(i).append("]:\n");
try {
buf.append(item.getAsString());
} catch (Exception e) {
buf.append("<error converting: " + e.getMessage() + ">");
}
- buf.append("\n");
}
+ buf.append(" }");
return buf.toString();
}
Modified: trunk/src/main/java/org/apache/axis/message/addressing/EndpointReference.java
===================================================================
--- trunk/src/main/java/org/apache/axis/message/addressing/EndpointReference.java 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/main/java/org/apache/axis/message/addressing/EndpointReference.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -52,6 +52,7 @@
*
* @author Davanum Srinivas
* @author Rodrigo Ruiz
+ * @version $Revision$
*/
public class EndpointReference extends EndpointReferenceType
implements AddressingHeaderItem {
Modified: trunk/src/main/java/org/apache/axis/message/addressing/EndpointReferenceType.java
===================================================================
--- trunk/src/main/java/org/apache/axis/message/addressing/EndpointReferenceType.java 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/main/java/org/apache/axis/message/addressing/EndpointReferenceType.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -66,6 +66,7 @@
*
* @author Davanum Srinivas
* @author Rodrigo Ruiz
+ * @version $Revision$
*/
public class EndpointReferenceType implements AnyContentType, Serializable {
/**
@@ -491,7 +492,17 @@
}
if (this.properties != null) {
buf.append(this.properties);
+ buf.append("\n");
}
+ if (this.parameters != null) {
+ buf.append(this.parameters);
+ buf.append("\n");
+ }
+ if (this.metaData != null) {
+ buf.append(this.metaData);
+ buf.append("\n");
+ }
+
if (this.any != null) {
for (int i = 0; i < this.any.length; i++) {
buf.append("Extensibility Element[").append(i).append("]:\n");
Modified: trunk/src/main/java/org/apache/axis/message/addressing/MetaDataType.java
===================================================================
--- trunk/src/main/java/org/apache/axis/message/addressing/MetaDataType.java 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/main/java/org/apache/axis/message/addressing/MetaDataType.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -47,6 +47,7 @@
*
* @author Davanum Srinivas
* @author Rodrigo Ruiz
+ * @version $Revision$
*/
public class MetaDataType extends AnyContentTypeList {
@@ -170,7 +171,7 @@
*/
@Override
public String toString() {
- return super.toString("MetaData");
+ return super.toString("Metadata");
}
}
Modified: trunk/src/main/java/org/apache/axis/message/addressing/ReferenceParametersType.java
===================================================================
--- trunk/src/main/java/org/apache/axis/message/addressing/ReferenceParametersType.java 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/main/java/org/apache/axis/message/addressing/ReferenceParametersType.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -47,6 +47,7 @@
*
* @author Davanum Srinivas
* @author Rodrigo Ruiz
+ * @version $Revision$
*/
public class ReferenceParametersType extends AnyContentTypeList {
@@ -169,6 +170,6 @@
*/
@Override
public String toString() {
- return this.toString("Reference parameter");
+ return this.toString("Reference parameters");
}
}
Modified: trunk/src/main/java/org/apache/axis/message/addressing/ReferencePropertiesType.java
===================================================================
--- trunk/src/main/java/org/apache/axis/message/addressing/ReferencePropertiesType.java 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/main/java/org/apache/axis/message/addressing/ReferencePropertiesType.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -47,6 +47,7 @@
*
* @author Davanum Srinivas
* @author Rodrigo Ruiz
+ * @version $Revision$
*/
public class ReferencePropertiesType extends AnyContentTypeList {
@@ -169,7 +170,7 @@
*/
@Override
public String toString() {
- return super.toString("Reference property");
+ return super.toString("Reference properties");
}
}
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2008-09-02 05:49:13 UTC (rev 11)
+++ trunk/src/site/site.xml 2008-09-04 13:00:07 UTC (rev 12)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2008 Rodrigo Ruiz
@@ -13,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<?xml version="1.0" encoding="UTF-8"?>
<project name="Addressing">
<bannerLeft>
<name>Addressing</name>
@@ -48,8 +48,8 @@
<menu name="Get Addressing">
<item name="Download" href="http://sf.net/project/showfiles.php?group_id=237365"/>
<item name="License" href="license.html"/>
- <item name="Releases Repository" href="maven2-releases"/>
- <item name="Snapshots Repository" href="maven2-snapshots"/>
+ <item name="Releases Repository" href="maven2-releases"/>
+ <item name="Snapshots Repository" href="maven2-snapshots"/>
</menu>
<menu ref="reports"/>
Added: trunk/src/test/java/org/apache/ws/addressing/EprParsingTest.java
===================================================================
--- trunk/src/test/java/org/apache/ws/addressing/EprParsingTest.java (rev 0)
+++ trunk/src/test/java/org/apache/ws/addressing/EprParsingTest.java 2008-09-04 13:00:07 UTC (rev 12)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2008 Rodrigo Ruiz
+ *
+ * Licensed 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.ws.addressing;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+import org.apache.axis.message.addressing.EndpointReference;
+import org.apache.axis.utils.DOM2Writer;
+import org.apache.axis.utils.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+/**
+ * EPR Parsing Unit Test.
+ *
+ * @author Rodrigo Ruiz
+ * @version $Revision$
+ */
+public class EprParsingTest extends TestCase {
+
+ /**
+ * Creates a new instance.
+ *
+ * @param name Test name
+ */
+ public EprParsingTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Test method for parsing an end-point reference.
+ *
+ * @throws Exception If an unexpected error occurs
+ */
+ public void testParseReference() throws Exception {
+ String xmlFragment = "<wsa:EndpointReference"
+ + " xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'"
+ + " xmlns:fura='http://www.gridsystems.com/tools'>\n"
+ + " <wsa:Address>http://localhost:8080/kernel/api/ApiFileSystem</wsa:Address>\n"
+ + "</wsa:EndpointReference>";
+ EndpointReference ref = parseReference(xmlFragment);
+
+ assertNotNull(ref);
+ assertEquals(0, ref.getParameters().size());
+ assertEquals(0, ref.getProperties().size());
+ }
+
+ /**
+ * Test method for converting an end-point reference to a string.
+ *
+ * @throws Exception If an unexpected error occurs
+ */
+ public void testToString() throws Exception {
+ String xmlFragment = "<wsa:EndpointReference"
+ + " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">"
+ + "<wsa:Address>http://localhost:8080/kernel/api/ApiFileSystem</wsa:Address>"
+ + "<wsa:ReferenceProperties><type>dummy</type></wsa:ReferenceProperties>"
+ + "<wsa:ReferenceParameters><p1>Hello</p1><p2>World</p2></wsa:ReferenceParameters>"
+ + "</wsa:EndpointReference>";
+
+ EndpointReference ref = parseReference(xmlFragment);
+ System.out.println(ref);
+ String converted = toString(ref, false);
+ assertEquals(xmlFragment, converted);
+ }
+
+ /**
+ * Parses a string containing an End-point reference in XML format, and
+ * translates it into an {@link EndpointReference} bean.
+ *
+ * @param epr End-point reference in XML format
+ * @return Bean instance
+ * @throws Exception If the XML parser fails to initialize, a syntax error
+ * is detected in the input string, or a general error
+ * occurs while constructing the bean
+ */
+ private static EndpointReference parseReference(String epr) throws Exception {
+ Document doc = XMLUtils.newDocument(new InputSource(new StringReader(epr)));
+ Element elem = doc.getDocumentElement();
+ return new EndpointReference(elem);
+ }
+
+ /**
+ * Converts an End-Point Reference into an XML String.
+ *
+ * @param epr End-point reference
+ * @param prettyPrint Whether to beautify the generated XML text
+ * @return XML String
+ * @throws Exception If an error occurs
+ */
+ private static String toString(EndpointReference epr, boolean prettyPrint)
+ throws Exception {
+
+ if (epr == null) {
+ return null;
+ } else {
+ Document doc = XMLUtils.newDocument();
+ Element elem = epr.toDOM(doc, "wsa:EndpointReference");
+
+ StringWriter writer = new StringWriter();
+ DOM2Writer.serializeAsXML(elem, writer, true, prettyPrint);
+ return writer.toString();
+ }
+ }
+}
Property changes on: trunk/src/test/java/org/apache/ws/addressing/EprParsingTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ "Date Author Revision"
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|