use of org.apache.camel.Expression in project camel by apache.
the class TokenizerTest method testTokenizePairIncludeTokens.
public void testTokenizePairIncludeTokens() throws Exception {
Expression exp = TokenizeLanguage.tokenizePair("[START]", "[END]", true);
exchange.getIn().setBody("2011-11-11\n[START]James[END]\n[START]Claus[END]\n2 records");
List<?> names = exp.evaluate(exchange, List.class);
assertEquals(2, names.size());
assertEquals("[START]James[END]", names.get(0));
assertEquals("[START]Claus[END]", names.get(1));
}
use of org.apache.camel.Expression in project camel by apache.
the class TokenizerTest method testTokenizeXMLPairWithLocalAndNotInheritedNamespace.
public void testTokenizeXMLPairWithLocalAndNotInheritedNamespace() throws Exception {
Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);
exchange.getIn().setBody("<?xml version=\"1.0\"?><persons xmlns=\"http:acme.com/persons\">\n<person xmlns:foo=\"http:foo.com\">James</person>\n" + "<person>Claus</person>\n<person>Jonathan</person>\n<person xmlns:bar=\"http:bar.com\">Hadrian</person>\n</persons>\n");
List<?> names = exp.evaluate(exchange, List.class);
assertEquals(4, names.size());
assertEquals("<person xmlns:foo=\"http:foo.com\">James</person>", names.get(0));
assertEquals("<person>Claus</person>", names.get(1));
assertEquals("<person>Jonathan</person>", names.get(2));
assertEquals("<person xmlns:bar=\"http:bar.com\">Hadrian</person>", names.get(3));
}
use of org.apache.camel.Expression in project camel by apache.
the class TokenizerTest method testTokenizeHeader.
public void testTokenizeHeader() throws Exception {
Expression exp = TokenizeLanguage.tokenize("names", ",");
List<?> names = exp.evaluate(exchange, List.class);
assertEquals(3, names.size());
assertEquals("Claus", names.get(0));
assertEquals("James", names.get(1));
assertEquals("Willem", names.get(2));
}
use of org.apache.camel.Expression in project camel by apache.
the class TokenizerTest method testTokenizeXMLPairWithSimilarChildNames.
public void testTokenizeXMLPairWithSimilarChildNames() throws Exception {
Expression exp = TokenizeLanguage.tokenizeXML("Trip", "Trips");
exchange.getIn().setBody("<?xml version='1.0' encoding='UTF-8'?>\n<Trips>\n<Trip>\n<TripType>\n</TripType>\n</Trip>\n</Trips>");
List<?> names = exp.evaluate(exchange, List.class);
assertEquals(1, names.size());
}
use of org.apache.camel.Expression in project camel by apache.
the class TokenizerTest method testTokenizeXMLPairWithDefaultNamespaceNotInherit.
public void testTokenizeXMLPairWithDefaultNamespaceNotInherit() throws Exception {
Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);
exchange.getIn().setBody("<?xml version=\"1.0\"?><persons xmlns=\"http:acme.com/persons\">\n<person>James</person>\n<person>Claus</person>\n" + "<person>Jonathan</person>\n<person>Hadrian</person>\n</persons>\n");
List<?> names = exp.evaluate(exchange, List.class);
assertEquals(4, names.size());
assertEquals("<person>James</person>", names.get(0));
assertEquals("<person>Claus</person>", names.get(1));
assertEquals("<person>Jonathan</person>", names.get(2));
assertEquals("<person>Hadrian</person>", names.get(3));
}
Aggregations