Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 55087 invoked from network); 22 Sep 2010 05:38:30 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Sep 2010 05:38:30 -0000 Received: (qmail 13657 invoked by uid 500); 22 Sep 2010 05:38:30 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 13603 invoked by uid 500); 22 Sep 2010 05:38:28 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 13596 invoked by uid 99); 22 Sep 2010 05:38:27 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Sep 2010 05:38:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Sep 2010 05:38:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 72ED123888FD; Wed, 22 Sep 2010 05:37:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r999763 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml: XPathTransformRouteTest.java XPathTransformTest.java Date: Wed, 22 Sep 2010 05:37:48 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100922053748.72ED123888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Wed Sep 22 05:37:48 2010 New Revision: 999763 URL: http://svn.apache.org/viewvc?rev=999763&view=rev Log: Added xpath transform unit test. Added: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformRouteTest.java camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java Added: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformRouteTest.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformRouteTest.java?rev=999763&view=auto ============================================================================== --- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformRouteTest.java (added) +++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformRouteTest.java Wed Sep 22 05:37:48 2010 @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.xml; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; + +/** + * @version $Revision$ + */ +public class XPathTransformRouteTest extends ContextTestSupport { + + public Document replaceMe(Document doc) throws Exception { + // replace firstname to contain Servicemix + NodeList list = doc.getElementsByTagName("firstname"); + list.item(0).setTextContent("Servicemix"); + // return the changed document + return doc; + } + + public void testXPathTransform() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedBodiesReceived("ServicemixCamel"); + + template.sendBody("direct:start", "ApacheCamel"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start").bean(XPathTransformRouteTest.class, "replaceMe").to("log:result", "mock:result"); + } + }; + } +} Added: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java?rev=999763&view=auto ============================================================================== --- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java (added) +++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTransformTest.java Wed Sep 22 05:37:48 2010 @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.xml; + +import org.apache.camel.ContextTestSupport; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; + +/** + * @version $Revision$ + */ +public class XPathTransformTest extends ContextTestSupport { + + @Override + public boolean isUseRouteBuilder() { + return false; + } + + public void testXPathTransform() throws Exception { + Document doc = context.getTypeConverter().convertTo(Document.class, "ApacheCamel"); + NodeList list = XPathBuilder.xpath("/root/firstname", NodeList.class).evaluate(context, doc, NodeList.class); + assertNotNull(list); + list.item(0).setTextContent("Servicemix"); + + String out = context.getTypeConverter().convertTo(String.class, doc); + assertEquals("ServicemixCamel", out); + } +}