You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2007/12/24 20:56:26 UTC

svn commit: r606733 - in /commons/proper/jxpath/trunk/src: java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java

Author: mbenson
Date: Mon Dec 24 11:56:25 2007
New Revision: 606733

URL: http://svn.apache.org/viewvc?rev=606733&view=rev
Log:
[JXPATH-111] ClassCastException in PrecedingOrFollowingContext

Modified:
    commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java
    commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java

Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java?rev=606733&r1=606732&r2=606733&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java (original)
+++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java Mon Dec 24 11:56:25 2007
@@ -22,7 +22,6 @@
 import org.apache.commons.jxpath.ri.compiler.NodeTest;
 import org.apache.commons.jxpath.ri.model.NodeIterator;
 import org.apache.commons.jxpath.ri.model.NodePointer;
-import org.apache.commons.jxpath.ri.model.beans.PropertyIterator;
 
 /**
  * EvalContext that walks the "preceding::" and "following::" axes.
@@ -148,7 +147,7 @@
                     else {
                         stack.pop();
                         if (!stack.isEmpty()) {
-                            it = (PropertyIterator) stack.peek();
+                            it = (NodeIterator) stack.peek();
                             currentNodePointer = it.getNodePointer();
                             if (currentNodePointer.testNode(nodeTest)) {
                                 super.setPosition(getCurrentPosition() + 1);

Modified: commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java?rev=606733&r1=606732&r2=606733&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java (original)
+++ commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Mon Dec 24 11:56:25 2007
@@ -464,6 +464,15 @@
             "/vendor[1]/location[1]/address[1]/street[1]");
     }
 
+    public void testAxisPreceding() {
+        // preceding::
+        assertXPathPointer(
+                context,
+                "//location[2]/preceding-sibling::location//street",
+        "/vendor[1]/location[1]/address[1]/street[1]");
+        assertXPathPointer(context, "//location[2]/preceding::node()[1]", "/vendor[1]/location[1]/employeeCount[1]");
+    }
+
     public void testAxisAttribute() {
         // attribute::
         assertXPathValue(context, "vendor/location/@id", "100");
@@ -630,6 +639,7 @@
             context,
             "//location/following::price:sale/saleEnds",
             "never");
+        assertXPathPointer(context, "//location[2]/following::node()[1]", "/vendor[1]/product[1]");
     }
 
     public void testAxisSelf() {