Exemplo n.º 1
0
 public void testInvalidSyntax() throws Exception {
   assertExpression("${file:onlyname}", file.getName());
   try {
     assertExpression("${file:onlyName}", file.getName());
     fail("Should have thrown exception");
   } catch (ExpressionIllegalSyntaxException e) {
     assertTrue(e.getMessage().startsWith("Unknown file language syntax: onlyName at location 0"));
   }
 }
 public void testProducerInvalidDoneFileName() throws Exception {
   try {
     template.sendBodyAndHeader(
         "file:target/done?doneFileName=${file:parent}/foo",
         "Hello World",
         Exchange.FILE_NAME,
         "hello.txt");
     fail("Should have thrown exception");
   } catch (CamelExecutionException e) {
     ExpressionIllegalSyntaxException cause =
         assertIsInstanceOf(ExpressionIllegalSyntaxException.class, e.getCause());
     assertTrue(
         cause.getMessage(),
         cause.getMessage().endsWith("Cannot resolve reminder: ${file:parent}/foo"));
   }
 }
Exemplo n.º 3
0
  public void testIllegalSyntax() throws Exception {
    try {
      // it should be with colon
      assertExpression("${file.name}", "");
      fail("Should have thrown an exception");
    } catch (ExpressionIllegalSyntaxException e) {
      assertTrue(e.getMessage().startsWith("Unknown function: file.name at location 0"));
    }

    try {
      assertExpression("hey ${xxx} how are you?", "");
      fail("Should have thrown an exception");
    } catch (ExpressionIllegalSyntaxException e) {
      assertTrue(e.getMessage().startsWith("Unknown function: xxx at location 4"));
    }

    try {
      assertExpression("${xxx}", "");
      fail("Should have thrown an exception");
    } catch (ExpressionIllegalSyntaxException e) {
      assertTrue(e.getMessage().startsWith("Unknown function: xxx at location 0"));
    }
  }