Quantcast

Unit test fails after upgrading to 2.7.1. Cannot use xquery expression after xpath

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unit test fails after upgrading to 2.7.1. Cannot use xquery expression after xpath

ltsallas
This post was updated on .
Hi,
After upgrading from version 2.5.0 to 2.7.1the following unit test throws

Caused by: java.lang.ClassCastException: net.sf.saxon.tinytree.TinyElementImpl cannot be cast to net.sf.saxon.om.DocumentInfo
I cannot use xquery(neither @XQuery in beans) after xpath expression

//works in 2.5.0
public class XqueryTest extends CamelTestSupport {
       
        protected static final transient Log log = LogFactory
        .getLog(XqueryTest.class);
       
        @EndpointInject(uri = "mock:result")
    protected MockEndpoint resultEndpoint;
 
    @Produce(uri = "direct:xpath")
    protected ProducerTemplate template;
   
   
   
    public void testXpathSplitter() throws Exception {
    resultEndpoint.expectedMessageCount(1);
        template.sendBody("<records><record><type>1</type></record><record><type>2</type></record></records>");
        resultEndpoint.assertIsSatisfied();
    }

   
    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
               
            XPathBuilder splitter = new XPathBuilder("//records/record");
            XPathBuilder type1 = new XPathBuilder("//record[type=2]");
           
            from("direct:xpath")
                .split(splitter)
                .to("log:reply")
                .filter().xquery("//record[type=2]") // works filter(type1)
                .to("mock:result");    
           
            }
        };
    }
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit test fails after upgrading to 2.9.0. Cannot use xquery expression after xpath

ltsallas
Hi,

After a long time  I tried this unit test in the newest camel 2.9.0 version. and it still fails.

Am I missing something? I cound use .convertBodyTo(Document.class) just after the splitter but

1. this is not required  in the 2.5 version, unit test succeeds  using camel 2.5.0.
3. I made the test ony  to reproduce the issue, and major refactoring is needed in order to apply this change in all parts of the existing code.

I want to upgrade my existing camel 2.5.0 application to the newest version to use some of the  new features.

Should I create a jira ticket for this?

BR,
 
ltsall
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit test fails after upgrading to 2.9.0. Cannot use xquery expression after xpath

Claus Ibsen-2
Hi

Can you post snippets of the route what you are doing?
And where you have a problem?


On Tue, Jan 31, 2012 at 5:47 PM, ltsall <[hidden email]> wrote:

> Hi,
>
> After a long time  I tried this unit test in the newest camel 2.9.0 version.
> and it still fails.
>
> Am I missing something? I cound use .convertBodyTo(Document.class) just
> after the splitter but
>
> 1. this is not required  in the 2.5 version, unit test succeeds  using camel
> 2.5.0.
> 3. I made the test ony  to reproduce the issue, and major refactoring is
> needed in order to apply this change in all parts of the existing code.
>
> I want to upgrade my existing camel 2.5.0 application to the newest version
> to use some of the  new features.
>
> Should I create a jira ticket for this?
>
> BR,
>
> ltsall
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unit-test-fails-after-upgrading-to-2-7-1-Cannot-use-xquery-expression-after-xpath-tp4422582p5445078.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit test fails after upgrading to 2.9.0. Cannot use xquery expression after xpath

ltsallas
Hi Claus,

I created a unit test for this. See my first post.
 
The problem is when i use an xquery  predicate just after an xpath splitter.

from("direct:xpath")
.split(xpathsplitter)
.filter().xquery("//record[type=2]")
.to("mock:result");    

This route  works in 2.5.0 but fails in 2.9.0 with  
java.lang.ClassCastException: net.sf.saxon.tinytree.TinyElementImpl cannot be cast to net.sf.saxon.om.DocumentInfo


If i replace xquery predicate with an xpath one ,   the route works in both 2.5.0 and 2.9.0

from("direct:xpath")
.split(xpathsplitter)
.filter().xpath("//record[type=2]")
.to("mock:result");    



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit test fails after upgrading to 2.9.0. Cannot use xquery expression after xpath

Claus Ibsen-2
Hi

Can you post the full stack trace?


Yeah if you have a small unit test that can go into camel-saxon, then
fell free to open a JIRA.



On Thu, Feb 2, 2012 at 11:51 AM, ltsall <[hidden email]> wrote:

> Hi Claus,
>
> I created a unit test for this. See my first post.
>
> The problem is when i use an xquery  predicate just after an xpath splitter.
>
> from("direct:xpath")
> .split(xpathsplitter)
> .filter().xquery("//record[type=2]")
> .to("mock:result");
>
> This route  works in 2.5.0 but fails in 2.9.0 with
> java.lang.ClassCastException: net.sf.saxon.tinytree.TinyElementImpl cannot
> be cast to net.sf.saxon.om.DocumentInfo
>
>
> If i replace xquery predicate with an xpath one ,   the route works in both
> 2.5.0 and 2.9.0
>
> from("direct:xpath")
> .split(xpathsplitter)
> .filter().xpath("//record[type=2]")
> .to("mock:result");
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unit-test-fails-after-upgrading-to-2-7-1-Cannot-use-xquery-expression-after-xpath-tp4422582p5450318.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit test fails after upgrading to 2.9.0. Cannot use xquery expression after xpath

ltsallas
Hi

I created a jira and attached a unit test

 https://issues.apache.org/jira/browse/CAMEL-4970



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit test fails after upgrading to 2.9.0. Cannot use xquery expression after xpath

Willem.Jiang
I did a quick fix of issue on the trunk.
The patch was merged into Camel-2.9.x and Camel 2.8.x branches.

On Thu Feb  2 21:21:51 2012, ltsall wrote:

> Hi
>
> I created a jira and attached a unit test
>
>   https://issues.apache.org/jira/browse/CAMEL-4970
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unit-test-fails-after-upgrading-to-2-7-1-Cannot-use-xquery-expression-after-xpath-tp4422582p5450621.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Loading...