You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dm...@apache.org on 2002/05/15 01:08:26 UTC
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes ChildContext.java
dmitri 02/05/14 16:08:26
Modified: jxpath/src/test/org/apache/commons/jxpath
JXPathTestCase.java
jxpath/src/java/org/apache/commons/jxpath/ri/axes
ChildContext.java
Log:
Fixed bug with default index
Revision Changes Path
1.19 +46 -43 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- JXPathTestCase.java 8 May 2002 23:05:05 -0000 1.18
+++ JXPathTestCase.java 14 May 2002 23:08:25 -0000 1.19
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v 1.18 2002/05/08 23:05:05 dmitri Exp $
- * $Revision: 1.18 $
- * $Date: 2002/05/08 23:05:05 $
+ * $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 $
*
* ====================================================================
* The Apache Software License, Version 1.1
@@ -81,11 +81,6 @@
import org.apache.commons.jxpath.ri.compiler.Expression;
import java.beans.*;
-//import org.apache.xpath.XPath;
-//import org.apache.xpath.XPathContext;
-//import org.apache.xml.utils.PrefixResolver;
-//import org.apache.xml.utils.PrefixResolverDefault;
-
/**
* <p>
* Test Case for the JXPath class. The majority of these tests use
@@ -100,7 +95,7 @@
* </p>
*
* @author Dmitri Plotnikov
- * @version $Revision: 1.18 $ $Date: 2002/05/08 23:05:05 $
+ * @version $Revision: 1.19 $ $Date: 2002/05/14 23:08:25 $
*/
public class JXPathTestCase extends TestCase
@@ -285,6 +280,7 @@
testGetValue(context, "2 + 3", "5.0", String.class);
testGetValue(context, "2 + 3", Boolean.TRUE, boolean.class);
testGetValue(context, "'true'", Boolean.TRUE, Boolean.class);
+
boolean exception = false;
try {
testGetValue(context, "'foo'", null, Date.class);
@@ -430,50 +426,57 @@
* Test JXPath.setValue() with various arguments
*/
public void testSetValue(){
- if (enabled){
- TestBean tBean = new TestBean();
- JXPathContext context = JXPathContext.newContext(tBean);
- context.getVariables().declareVariable("x", null);
+ if (!enabled){
+ return;
+ }
+ TestBean tBean = new TestBean();
+ JXPathContext context = JXPathContext.newContext(tBean);
+ context.getVariables().declareVariable("x", null);
- context.setValue("$x", new Integer(1));
- assertEquals("Modified <" + "$x" + ">", new Integer(1), context.getValue("$x"));
+ context.setValue("$x", new Integer(1));
+ assertEquals("Modified <" + "$x" + ">", new Integer(1), context.getValue("$x"));
- boolean exception = false;
- try {
- context.setValue("$y", new Integer(1));
- }
- catch (Exception ex){
- exception = true;
- }
- assertTrue("Setting '$y = 1', expected exception - did not get it", exception);
+ boolean exception = false;
+ try {
+ context.setValue("$y", new Integer(1));
+ }
+ catch (Exception ex){
+ exception = true;
+ }
+ assertTrue("Setting '$y = 1', expected exception - did not get it", exception);
- context.setValue("int", new Integer(3));
- assertEquals("Modified <" + "int" + ">", new Integer(3), context.getValue("int"));
+ context.setValue("int", new Integer(3));
+ assertEquals("Modified <" + "int" + ">", new Integer(3), context.getValue("int"));
- context.setValue("int", new int[]{4});
- assertEquals("Modified <" + "int" + ">", new Integer(4), context.getValue("int"));
+ context.setValue("int", new int[]{4});
+ assertEquals("Modified <" + "int" + ">", new Integer(4), context.getValue("int"));
- context.setValue("integers[2]", new Integer(5));
- assertEquals("Modified <" + "integers[2]" + ">", new Integer(5), context.getValue("integers[2]"));
+ context.setValue("integers[2]", new Integer(5));
+ assertEquals("Modified <" + "integers[2]" + ">", new Integer(5), context.getValue("integers[2]"));
- context.setValue("integers[2]", new int[]{6});
- assertEquals("Modified <" + "integers[2]" + ">", new Integer(6), context.getValue("integers[2]"));
+ context.setValue("integers[2]", new int[]{6});
+ assertEquals("Modified <" + "integers[2]" + ">", new Integer(6), context.getValue("integers[2]"));
- NestedTestBean nBean = new NestedTestBean("Name 9");
- tBean.getBeans()[1] = null;
- context.setValue("beans[2]", nBean);
- assertEquals("Modified <" + "beans[2]" + ">", nBean, context.getValue("beans[2]"));
+ NestedTestBean nBean = new NestedTestBean("Name 9");
+ tBean.getBeans()[1] = null;
+ context.setValue("beans[2]", nBean);
+ assertEquals("Modified <" + "beans[2]" + ">", nBean, context.getValue("beans[2]"));
- context.setValue("map/Key1", new Integer(6));
- assertEquals("Modified <" + "map/Key1" + ">", new Integer(6), context.getValue("map/Key1"));
+ context.setValue("map/Key1", new Integer(6));
+ assertEquals("Modified <" + "map/Key1" + ">", new Integer(6), context.getValue("map/Key1"));
- context.setValue("map/Key1", new Integer[]{new Integer(7), new Integer(8)});
- context.setValue("map/Key1[1]", new Integer(9));
- assertEquals("Modified <" + "map/Key1[1]" + ">", new Integer(9), context.getValue("map/Key1[1]"));
+ context.setValue("map/Key1", new Integer[]{new Integer(7), new Integer(8)});
+ context.setValue("map/Key1[1]", new Integer(9));
+ assertEquals("Modified <" + "map/Key1[1]" + ">", new Integer(9), context.getValue("map/Key1[1]"));
- context.setValue("map/Key4", new Integer(7));
- assertEquals("Modified <" + "map/Key4" + ">", new Integer(7), context.getValue("map/Key4"));
- }
+ context.setValue("map/Key4", new Integer(7));
+ assertEquals("Modified <" + "map/Key4" + ">", new Integer(7), context.getValue("map/Key4"));
+
+ context.setValue("integers[. = 6]", new Integer(8));
+ assertEquals("Modified <" + "integers[. = 6]" + ">", new Integer(8), context.getValue("integers[2]"));
+
+ context.setValue("beans[name = 'Name 9']/int", new Integer(9));
+ assertEquals("Modified <" + "beans[name = 'Name 9']/int" + ">", new Integer(9), context.getValue("beans[name = 'Name 9']/int"));
}
/**
1.9 +7 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java
Index: ChildContext.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ChildContext.java 28 Apr 2002 04:35:48 -0000 1.8
+++ ChildContext.java 14 May 2002 23:08:26 -0000 1.9
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java,v 1.8 2002/04/28 04:35:48 dmitri Exp $
- * $Revision: 1.8 $
- * $Date: 2002/04/28 04:35:48 $
+ * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java,v 1.9 2002/05/14 23:08:26 dmitri Exp $
+ * $Revision: 1.9 $
+ * $Date: 2002/05/14 23:08:26 $
*
* ====================================================================
* The Apache Software License, Version 1.1
@@ -72,7 +72,7 @@
* "preceding-sibling::" axes.
*
* @author Dmitri Plotnikov
- * @version $Revision: 1.8 $ $Date: 2002/04/28 04:35:48 $
+ * @version $Revision: 1.9 $ $Date: 2002/05/14 23:08:26 $
*/
public class ChildContext extends EvalContext {
private NodeTest nodeTest;
@@ -116,8 +116,9 @@
return null;
}
// See if there is a property there, singular or collection
- if (iterator.getNodePointer() != null){
- break;
+ NodePointer pointer = iterator.getNodePointer();
+ if (pointer != null){
+ return pointer;
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>