[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Tue Feb 3 16:39:42 UTC 2009


kawas
Tue Feb  3 11:39:41 EST 2009
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory dev.open-bio.org:/tmp/cvs-serv24729/src/main/org/biomoby/shared

Modified Files:
	MobyUnitTest.java 
Log Message:
added some documentation (mainly to make the javadoc look better when referring to it from biomoby.org doc)
moby-live/Java/src/main/org/biomoby/shared MobyUnitTest.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyUnitTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyUnitTest.java	2009/01/29 19:12:01	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyUnitTest.java	2009/02/03 16:39:41	1.3
@@ -48,7 +48,7 @@
     private String validXPath;
 
     /**
-     * Default Constructor
+     * Default Constructor - creates a blank MobyUnitTest object
      */
     public MobyUnitTest() {
 	setExampleInput("");
@@ -58,6 +58,15 @@
 	init();
     }
 
+    /*
+     * set up XMLUnit for doing our comparisons
+     * 
+     * we would like to: -> ignore attribute order because it doesnt matter ->
+     * ignore XML comments, because they are irrelevant in moby -> ignore
+     * element whitespace because it doesnt change semantics -> treat CDATA
+     * sections and text nodes alike
+     * 
+     */
     private void init() {
 	// for comparing dom trees
 	XMLUnit.setIgnoreAttributeOrder(true);
@@ -67,6 +76,7 @@
     }
 
     /**
+     * Getter: get the example input that you can use to invoke this service
      * 
      * @return a string of XML representing a services example input
      */
@@ -75,6 +85,8 @@
     }
 
     /**
+     * Setter: set the example input that can be passed to the service to invoke
+     * it
      * 
      * @param exampleInput
      *                a string of XML representing a services example input
@@ -85,6 +97,8 @@
     }
 
     /**
+     * Getter: get the expected XML output for this service (usually by sending
+     * it the input from <code>getExampleInput()</code>
      * 
      * @return a string of XML representing a services expected output
      */
@@ -93,6 +107,7 @@
     }
 
     /**
+     * Setter: set the expected XML output for this serivce
      * 
      * @param validOutputXML
      *                a string of XML representing a services expected output
@@ -103,6 +118,7 @@
     }
 
     /**
+     * Getter: get the Regular Expression for this unit test
      * 
      * @return a regular expression that can be used on a services output to
      *         determine validity
@@ -112,6 +128,7 @@
     }
 
     /**
+     * Setter: set the regular expression for this unit test
      * 
      * @param validREGEX
      *                a regular expression that can be used on a services output
@@ -123,6 +140,7 @@
     }
 
     /**
+     * Getter: get the xpath expression for this unit test
      * 
      * @return an xpath expression that can be used to drill into a services
      *         output
@@ -132,6 +150,7 @@
     }
 
     /**
+     * Setter: set the xpath expression for this unit test
      * 
      * @param validXPath
      *                an xpath expression that can be used to drill into a
@@ -150,12 +169,16 @@
     public String toString() {
 	StringBuffer buf = new StringBuffer();
 	buf.append("Unit Test:\n");
-	buf.append("   Input       \n" + Utils.format (getExampleInput(), 2) + "\n");
-	buf.append("   Output      \n" + Utils.format(getValidOutputXML(),2) + "\n");
-	buf.append("   XPath       \n" + Utils.format(getValidXPath(),2) + "\n");
-	buf.append("   REGEX       \n" + Utils.format(getValidREGEX(),2) + "\n");
-	//return buf.toString();
-	return Utils.format (buf.toString(), 1);
+	buf.append("   Input       \n" + Utils.format(getExampleInput(), 2)
+		+ "\n");
+	buf.append("   Output      \n" + Utils.format(getValidOutputXML(), 2)
+		+ "\n");
+	buf.append("   XPath       \n" + Utils.format(getValidXPath(), 2)
+		+ "\n");
+	buf.append("   REGEX       \n" + Utils.format(getValidREGEX(), 2)
+		+ "\n");
+	// return buf.toString();
+	return Utils.format(buf.toString(), 1);
     }
 
     /**
@@ -166,6 +189,9 @@
      *                the XML that you would like to compare to XML obtained
      *                from <code>getValidOutputXML()</code>
      * @return true if the documents are semantically similar, false otherwise
+     * 
+     * @throws MobyException
+     *                 if there is a problem reading/parsing the testXML
      */
     public boolean compareOutputXML(String testXML) throws MobyException {
 	if (!getValidOutputXML().trim().equals(""))
@@ -191,6 +217,9 @@
      *                <code>getValidXPath()</code>, expression against
      * @return true if the XPath expression matches at least one node in the
      *         testXML
+     * @throws MobyException
+     *                 if there is a problem compiling the XPATH expression, or
+     *                 reading/parsing the textXML
      */
     public boolean compareXmlWithXpath(String testXML) throws MobyException {
 	if (!getValidXPath().trim().equals(""))
@@ -267,7 +296,8 @@
 
     /**
      * This inner class implements a 'Qualifier' used to compare XML documents
-     * using the XMLUnit engine. It used both RecursiveElementNameAndTextQualifier and
+     * using the XMLUnit engine. It used both
+     * RecursiveElementNameAndTextQualifier and
      * MultiLevelElementNameAndTextQualifier as a template.
      * 
      * @author Eddie Kawas
@@ -275,40 +305,36 @@
      */
     protected class MobyQualifier extends ElementNameQualifier {
 	/*
-	******************************************************************
-	Copyright (c) 2008, Jeff Martin, Tim Bacon
-	All rights reserved.
-
-	Redistribution and use in source and binary forms, with or without
-	modification, are permitted provided that the following conditions
-	are met:
-
-	        * Redistributions of source code must retain the above copyright
-	          notice, this list of conditions and the following disclaimer.
-	        * Redistributions in binary form must reproduce the above
-	          copyright notice, this list of conditions and the following
-	          disclaimer in the documentation and/or other materials provided
-	          with the distribution.
-	        * Neither the name of the xmlunit.sourceforge.net nor the names
-	          of its contributors may be used to endorse or promote products
-	          derived from this software without specific prior written
-	          permission.
-
-	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-	LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-	FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-	COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-	BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-	CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-	LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-	ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-	POSSIBILITY OF SUCH DAMAGE.
-
-	******************************************************************
-	*/
+	 * *****************************************************************
+	 * Copyright (c) 2008, Jeff Martin, Tim Bacon All rights reserved.
+	 * 
+	 * Redistribution and use in source and binary forms, with or without
+	 * modification, are permitted provided that the following conditions
+	 * are met:
+	 * 
+	 * Redistributions of source code must retain the above copyright
+	 * notice, this list of conditions and the following disclaimer.
+	 * Redistributions in binary form must reproduce the above copyright
+	 * notice, this list of conditions and the following disclaimer in the
+	 * documentation and/or other materials provided with the distribution.
+	 * Neither the name of the xmlunit.sourceforge.net nor the names of its
+	 * contributors may be used to endorse or promote products derived from
+	 * this software without specific prior written permission.
+	 * 
+	 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+	 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+	 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+	 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+	 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+	 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+	 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+	 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+	 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+	 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+	 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+	 * 
+	 * *****************************************************************
+	 */
 	private final String[] qualifyingAttrNames;
 
 	private final ElementNameQualifier NAME_QUALIFIER = new ElementNameQualifier();
@@ -373,7 +399,8 @@
 	    Element currentControl = control;
 	    Element currentTest = test;
 
-	    // we dont try to compare the Collection node because they have unordered children
+	    // we dont try to compare the Collection node because they have
+	    // unordered children
 	    if (!control.getLocalName().equals("Collection")) {
 		// not a collection, match name and attributes
 		stillSimilar = NAME_QUALIFIER.qualifyForComparison(




More information about the MOBY-guts mailing list