dmitri 02/05/28 17:42:08
Modified: jxpath/src/test/org/apache/commons/jxpath
JXPathTestCase.java Vendor.xml
Log:
Tested changes
Revision Changes Path
1.20 +43 -8
jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java
Index: JXPathTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- JXPathTestCase.java 14 May 2002 23:08:25 -0000 1.19
+++ JXPathTestCase.java 29 May 2002 00:42:06 -0000 1.20
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v
1.19 2002/05/14 23:08:25 dmitri Exp $
- * $Revision: 1.19 $
- * $Date: 2002/05/14 23:08:25 $
+ * $Header:
/home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v
1.20 2002/05/29 00:42:06 dmitri Exp $
+ * $Revision: 1.20 $
+ * $Date: 2002/05/29 00:42:06 $
*
* ====================================================================
* The Apache Software License, Version 1.1
@@ -95,7 +95,7 @@
* </p>
*
* @author Dmitri Plotnikov
- * @version $Revision: 1.19 $ $Date: 2002/05/14 23:08:25 $
+ * @version $Revision: 1.20 $ $Date: 2002/05/29 00:42:06 $
*/
public class JXPathTestCase extends TestCase
@@ -281,6 +281,11 @@
testGetValue(context, "2 + 3", Boolean.TRUE,
boolean.class);
testGetValue(context, "'true'", Boolean.TRUE,
Boolean.class);
+ Map tm = new HashMap();
+ tm.put("bar", "zz");
+ bean.getMap().put("foo", new Map[]{tm, tm});
+ testGetValue(context, "map/foo[2]/bar/../bar", "zz");
+
boolean exception = false;
try {
testGetValue(context, "'foo'", null, Date.class);
@@ -292,6 +297,32 @@
}
/**
+ * Test JXPath.iterate() with various arguments
+ */
+ public void testIterate(){
+ if (!enabled){
+ return;
+ }
+ Map map = new HashMap();
+ map.put("foo", new String[]{"a", "b", "c"});
+ JXPathContext context = JXPathContext.newContext(map);
+ testIterate(context, "foo", list("a", "b", "c"));
+
+// context = JXPathContext.newContext(bean);
+// testIterate(context, "nestedBean/strings[2]/following::node()", null);
+ }
+
+ private void testIterate(JXPathContext context, String xpath, List expected) {
+ Iterator it = context.iterate(xpath);
+ List actual = new ArrayList();
+ while (it.hasNext()){
+ actual.add(it.next());
+ }
+ assertEquals("Iterating <" + xpath + ">", expected, actual);
+ }
+
+
+ /**
* Test JXPath.getValue() with variables
*/
public void testVariables(){
@@ -973,7 +1004,7 @@
}
static final XP[] xpath_tests = new XP[]{
-/*
+
// Numbers
test("1", new Double(1.0)),
testEval("1", list(new Double(1.0))),
@@ -1094,9 +1125,10 @@
test("self::node() = /", Boolean.TRUE),
test("self::root = /", Boolean.TRUE),
- // Union
+ // Union - note corrected document order
testEval("integers | beans[1]/strings",
- list(new Integer(1), new Integer(2), new Integer(3), new Integer(4),
"String 1", "String 2", "String 3")),
+ list("String 1", "String 2", "String 3",
+ new Integer(1), new Integer(2), new Integer(3), new Integer(4))),
test("count((integers | beans[1]/strings)[contains(., '1')])", new
Double(2)),
test("count((integers | beans[1]/strings)[name(.) = 'strings'])", new
Double(3)),
@@ -1113,7 +1145,7 @@
test("name(integers)", "integers"),
testEval("*[name(.) = 'integers']", list(new Integer(1), new Integer(2),
new Integer(3), new Integer(4))),
-*/
+
// Dynamic properties
test("nestedBean[@name = 'int']", new Integer(1)), // Not implemented in
Xalan
testPath("nestedBean[@name = 'int']", "/nestedBean/int"),
@@ -1373,6 +1405,9 @@
testPath("$test/object/vendor/location[1]//street",
"$test/object/vendor[1]/location[1]/address[1]/street[1]"),
test("$object//street", "Orchard Road"),
testPath("$object//street",
"$object/vendor[1]/location[1]/address[1]/street[1]"),
+
+ testEval("vendor/contact/following::location//street",
+ list("Orchard Road", "Tangerine Drive")),
};
public void testTypeConversions(){
1.2 +2 -0
jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/Vendor.xml
Index: Vendor.xml
===================================================================
RCS file:
/home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/Vendor.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Vendor.xml 11 Apr 2002 02:57:41 -0000 1.1
+++ Vendor.xml 29 May 2002 00:42:07 -0000 1.2
@@ -1,5 +1,7 @@
<?xml version="1.0" ?>
<vendor>
+ <contact>John</contact>
+ <contact>Jack</contact>
<location id="100" name="local" manager="">
<address>
<street>Orchard Road</street>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>