[jboss-svn-commits] JBL Code SVN: r17015 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP: product/rosetta/tests/src/org/jboss/soa/esb/testutils and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 4 09:52:58 EST 2007
Author: kevin.conner at jboss.com
Date: 2007-12-04 09:52:58 -0500 (Tue, 04 Dec 2007)
New Revision: 17015
Added:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java
Removed:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soap/build.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java
Log:
Compare XML output, fix soap classpath
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java 2007-12-04 13:59:29 UTC (rev 17014)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -26,6 +26,8 @@
import javax.xml.stream.XMLStreamReader;
+import org.jboss.soa.esb.testutils.StringUtils;
+
import junit.framework.TestCase;
/**
@@ -55,10 +57,11 @@
XMLHelper.replaceSystemProperties(streamReader,
XMLHelper.getXMLStreamWriter(sw)) ;
- final String contents = sw.toString().trim() ;
+ final String contents = sw.toString() ;
- final String expectedContents = StreamUtils.getResourceAsString("replaceSystemProperties_expected.xml", encoding).trim() ;
+ final String expectedContents = StreamUtils.getResourceAsString("replaceSystemProperties_expected.xml", encoding) ;
- assertEquals("System property replacement", expectedContents, contents) ;
+ final boolean match = StringUtils.compareXMLContent(expectedContents, contents) ;
+ assertTrue("System property replacement", match) ;
}
}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java (from rev 16898, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Element.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.xml.namespace.QName;
+
+import org.xml.sax.Attributes;
+
+/**
+ * Simple class representing an element.
+ * This is used to compare XML documents.
+ *
+ * @author Kevin Conner
+ */
+public class Element implements Node
+{
+ /**
+ * The QName comparator.
+ */
+ private static final Comparator<QName> QNAME_COMPARATOR = new QNameComparator() ;
+
+ /**
+ * The name of the element.
+ */
+ private final QName name ;
+ /**
+ * Associated attributes.
+ */
+ private final Map<QName, String> attributes = new TreeMap<QName, String>(QNAME_COMPARATOR) ;
+ /**
+ * Children.
+ */
+ private final List<Node> children = new ArrayList<Node>() ;
+
+ /**
+ * Construct the element.
+ * @param namespaceURI The namespace for the element.
+ * @param localName The local name of the element.
+ * @param attributes The associated attributes.
+ */
+ Element(final String namespaceURI, final String localName, final Attributes attributes)
+ {
+ name = new QName(namespaceURI, localName) ;
+ final int numAttributes = attributes.getLength() ;
+ for(int count = 0 ; count < numAttributes ; count++)
+ {
+ final String attrNamespaceURI = attributes.getURI(count) ;
+ final String attrLocalName = attributes.getLocalName(count) ;
+ final String attrValue = attributes.getValue(count) ;
+
+ this.attributes.put(new QName(attrNamespaceURI, attrLocalName), attrValue) ;
+ }
+ }
+
+ /**
+ * Add a child node.
+ * @param child The child node.
+ */
+ void addChild(final Node child)
+ {
+ children.add(child) ;
+ }
+
+ /**
+ * Check for equality.
+ * @param obj the object to test against.
+ */
+ @Override
+ public boolean equals(final Object obj)
+ {
+ if (obj == null)
+ {
+ return false ;
+ }
+
+ if (obj == this)
+ {
+ return true ;
+ }
+
+ if (obj instanceof Element)
+ {
+ final Element rhs = (Element)obj ;
+ return (name.equals(rhs.name) && attributes.equals(rhs.attributes) &&
+ children.equals(rhs.children)) ;
+ }
+
+ return false ;
+ }
+
+ /**
+ * The QName comparator class.
+ * @author kevin
+ */
+ private static final class QNameComparator implements Comparator<QName>
+ {
+ /**
+ * Compare the QNames.
+ * @param name1 The first QName.
+ * @param name2 The second QName.
+ * @return
+ */
+ public int compare(final QName name1, final QName name2)
+ {
+ final int uriComparator = name1.getNamespaceURI().compareTo(name2.getNamespaceURI()) ;
+ if (uriComparator != 0)
+ {
+ return uriComparator ;
+ }
+ return name1.getLocalPart().compareTo(name2.getLocalPart());
+ }
+ }
+}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java (from rev 16898, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/IdentitySAXHandler.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Simple SAX parser creating an identity document for the incoming XML.
+ * Any leading and trailing whitespace is ignored in the document as are
+ * namespace prefixes.
+ *
+ * @author Kevin Conner
+ */
+public class IdentitySAXHandler extends DefaultHandler
+{
+ /**
+ * The root element.
+ */
+ private Element rootElement ;
+ /**
+ * The current element.
+ */
+ private Element currentElement ;
+ /**
+ * The stack of working elements.
+ */
+ private List<Element> stack = new ArrayList<Element>() ;
+ /**
+ * The current text value.
+ */
+ private StringBuilder currentText = new StringBuilder() ;
+
+ @Override
+ public void startElement(final String uri, final String localName,
+ final String name, final Attributes attributes)
+ throws SAXException
+ {
+ checkText() ;
+
+ final Element element = new Element(uri, localName, attributes) ;
+ if (rootElement == null)
+ {
+ rootElement = element ;
+ }
+
+ if (currentElement != null)
+ {
+ currentElement.addChild(element) ;
+ stack.add(currentElement) ;
+ }
+ currentElement = element ;
+ }
+
+ @Override
+ public void endElement(final String uri, final String localName,
+ final String name)
+ throws SAXException
+ {
+ checkText() ;
+
+ final int lastIndex = (stack.size() - 1) ;
+ if (lastIndex < 0)
+ {
+ currentElement = null ;
+ }
+ else
+ {
+ currentElement = stack.remove(lastIndex) ;
+ }
+ }
+
+ @Override
+ public void characters(final char[] ch, final int start, final int length)
+ throws SAXException
+ {
+ currentText.append(ch, start, length) ;
+ }
+
+ private void checkText()
+ {
+ final int textLength = currentText.length() ;
+ if (textLength > 0)
+ {
+ int start = 0 ;
+ while((start < textLength) && isXMLWhitespace(currentText.charAt(start)))
+ {
+ start++ ;
+ }
+
+ int end = textLength-1 ;
+ while((end >= start) && isXMLWhitespace(currentText.charAt(end)))
+ {
+ end-- ;
+ }
+
+ if (start <= end)
+ {
+ currentElement.addChild(new Text(currentText.substring(start, end+1))) ;
+ }
+ currentText.setLength(0) ;
+ currentText.trimToSize() ;
+ }
+ }
+
+ private boolean isXMLWhitespace(final char ch)
+ {
+ return ((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n')) ;
+ }
+
+ public Element getRootElement()
+ {
+ return rootElement ;
+ }
+}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java (from rev 16898, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Node.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+/**
+ * Simple Node tagging XML nodes.
+ *
+ * @author Kevin Conner
+ */
+public interface Node
+{
+}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java 2007-12-04 13:59:29 UTC (rev 17014)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -21,6 +21,16 @@
*/
package org.jboss.soa.esb.testutils;
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
/**
* Utility methods for string manipulation and testing.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
@@ -67,4 +77,47 @@
return stringBuf.toString();
}
+
+ /**
+ * Compare the specified contents as XML.
+ * @param content1 The first content.
+ * @param content2 The second content.
+ * @return true if equals, false otherwise.
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public static boolean compareXMLContent(final String content1, final String content2)
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ try {
+ final SAXParserFactory parserFactory = SAXParserFactory.newInstance() ;
+ parserFactory.setNamespaceAware(true) ;
+
+ final SAXParser parser = parserFactory.newSAXParser() ;
+ final IdentitySAXHandler handler1;
+ final IdentitySAXHandler handler2;
+
+ try {
+ handler1 = new IdentitySAXHandler() ;
+ parser.parse(new InputSource(new StringReader(content1)), handler1) ;
+ } catch(SAXException e) {
+ System.out.println("Failed to parse content1 [" + content1 + "].");
+ throw e;
+ }
+
+ try {
+ handler2 = new IdentitySAXHandler() ;
+ parser.parse(new InputSource(new StringReader(content2)), handler2) ;
+ } catch(SAXException e) {
+ System.out.println("Failed to parse content2 [" + content2 + "].");
+ throw e;
+ }
+
+ return (handler1.getRootElement().equals(handler2.getRootElement())) ;
+ } catch(IOException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java (from rev 16898, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Text.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+
+/**
+ * Simple class representing a text element.
+ * This is used to compare XML documents.
+ *
+ * @author Kevin Conner
+ */
+public class Text implements Node
+{
+ /**
+ * The text content.
+ */
+ private final String text ;
+
+ /**
+ * Construct the text element.
+ * @param text The text value.
+ */
+ Text(final String text)
+ {
+ this.text = text ;
+ }
+
+ /**
+ * Check for equality.
+ * @param obj the object to test against.
+ */
+ @Override
+ public boolean equals(final Object obj)
+ {
+ if (obj == null)
+ {
+ return false ;
+ }
+
+ if (obj == this)
+ {
+ return true ;
+ }
+
+ if (obj instanceof Text)
+ {
+ final Text rhs = (Text)obj ;
+ return (text.equals(rhs.text)) ;
+ }
+
+ return false ;
+ }
+}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soap/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soap/build.xml 2007-12-04 13:59:29 UTC (rev 17014)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soap/build.xml 2007-12-04 14:52:58 UTC (rev 17015)
@@ -12,7 +12,7 @@
<fileset dir="../../lib/ext" includes="jboss-jaxb-intros.jar"/>
<!-- StAX jars ... -->
- <fileset dir="../../lib/ext" includes="xbean.jar stax-api-1.0.1.jar xstream-1.1.3.jar"/>
+ <fileset dir="../../lib/ext" includes="xbean.jar stax-api-1.0.1.jar xstream-1.1.3.jar wstx-lgpl-3.2.1.jar ognl-2.6.9.jar"/>
<!-- Adding the Smooks jars... -->
<fileset dir="../smooks/lib/ext" includes="*.jar"/>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java 2007-12-04 13:59:29 UTC (rev 17014)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java 2007-12-04 14:52:58 UTC (rev 17015)
@@ -32,7 +32,7 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.jboss.soa.esb.quickstart.test.util.IdentitySAXHandler;
+import org.jboss.soa.esb.testutils.IdentitySAXHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
More information about the jboss-svn-commits
mailing list