コード例 #1
0
  public void testRegexReplaceAll() throws Exception {
    Expression expression = regexReplaceAll(headerExpression("location"), "London", "Westminster");
    assertExpression(expression, exchange, "Islington,Westminster,UK");

    expression = regexReplaceAll(headerExpression("location"), "London", headerExpression("name"));
    assertExpression(expression, exchange, "Islington,James,UK");
  }
コード例 #2
0
 public void testCamelContextPropertiesExpression() throws Exception {
   camelContext.getProperties().put("CamelTestKey", "CamelTestValue");
   Expression expression = camelContextPropertyExpression("CamelTestKey");
   assertExpression(expression, exchange, "CamelTestValue");
   expression = camelContextPropertiesExpression();
   Map<?, ?> properties = expression.evaluate(exchange, Map.class);
   assertEquals("Get a wrong properties size", properties.size(), 1);
 }
コード例 #3
0
  public void testSortLines() throws Exception {
    Expression expression = sortExpression(body().tokenize(",").getExpression(), new SortByName());
    exchange.getIn().setBody("Jonathan,Claus,James,Hadrian");

    List<String> expected =
        new ArrayList<String>(
            Arrays.asList(new String[] {"Claus", "Hadrian", "James", "Jonathan"}));
    assertExpression(expression, exchange, expected);
  }
コード例 #4
0
  public void testTokenizeLines() throws Exception {
    Expression expression = regexTokenizeExpression(bodyExpression(), "[\r|\n]");
    exchange.getIn().setBody("Hello World\nBye World\rSee you again");

    List<String> expected =
        new ArrayList<String>(
            Arrays.asList(new String[] {"Hello World", "Bye World", "See you again"}));
    assertExpression(expression, exchange, expected);
  }
コード例 #5
0
  public void testTokenize() throws Exception {
    Expression expression = tokenizeExpression(headerExpression("location"), ",");

    List<String> expected =
        new ArrayList<String>(Arrays.asList(new String[] {"Islington", "London", "UK"}));
    assertExpression(expression, exchange, expected);

    Predicate predicate =
        contains(
            tokenizeExpression(headerExpression("location"), ","), constantExpression("London"));
    assertPredicate(predicate, exchange, true);

    predicate =
        contains(
            tokenizeExpression(headerExpression("location"), ","),
            constantExpression("Manchester"));
    assertPredicate(predicate, exchange, false);
  }