Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged revisions 773193 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk ........ r773193 | ningjiang | 2009-05-09 18:34:27 +0800 (Sat, 09 May 2009) | 1 line Added an unitest of SplitterWithXqueryTest ........ git-svn-id: https://svn.apache.org/repos/asf/camel/branches/camel-1.x@773195 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
1 parent
57ff412
commit 257eab3
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* 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.processor; | ||
|
||
import org.apache.camel.ContextTestSupport; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.builder.xml.Namespaces; | ||
import org.apache.camel.component.mock.MockEndpoint; | ||
|
||
public class SplitterWithXqureyTest extends ContextTestSupport { | ||
private static String xmlData = "<workflow id=\"12345\" xmlns=\"http://camel.apache.org/schema/one\" " | ||
+ "xmlns:two=\"http://camel.apache.org/schema/two\">" | ||
+ "<person><name>Willem</name></person> " | ||
+ "<other><two:test>One</two:test></other>" | ||
+ "<other><two:test>Two</two:test></other>" | ||
+ "<other><test>Three</test></other>" | ||
+ "<other><test>Foure</test></other></workflow>"; | ||
|
||
protected RouteBuilder createRouteBuilder() { | ||
return new RouteBuilder() { | ||
public void configure() { | ||
// split the message with namespaces defined | ||
Namespaces namespaces = new Namespaces("one", "http://camel.apache.org/schema/one"); | ||
from("direct:endpoint").splitter().xpath("//one:other", namespaces).to("mock:result"); | ||
} | ||
}; | ||
} | ||
|
||
public void testSenderXmlData() throws Exception { | ||
MockEndpoint result = getMockEndpoint("mock:result"); | ||
result.reset(); | ||
result.expectedMessageCount(4); | ||
template.sendBody("direct:endpoint", xmlData); | ||
assertMockEndpointsSatisfied(); | ||
for (Exchange exchange : result.getExchanges()) { | ||
String message = exchange.getIn().getBody(String.class); | ||
log.debug("The message is " + message); | ||
assertTrue("The splitted message should start with <other", message.indexOf("<other") == 0); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} |