use of org.apache.camel.ExpressionIllegalSyntaxException in project camel by apache.
the class BeanLanguageInvalidOGNLTest method testBeanLanguageInvalidOGNL.
public void testBeanLanguageInvalidOGNL() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").transform().method(MyReallyCoolBean.class, "getOther[xx");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, rce.getCause());
assertEquals("getOther[xx", mnfe.getMethodName());
ExpressionIllegalSyntaxException cause = assertIsInstanceOf(ExpressionIllegalSyntaxException.class, mnfe.getCause());
assertEquals("Illegal syntax: getOther[xx", cause.getMessage());
assertEquals("getOther[xx", cause.getExpression());
}
}
use of org.apache.camel.ExpressionIllegalSyntaxException in project camel by apache.
the class JsonPathExpression method init.
public void init() {
String exp = expression;
if (predicate && isAllowEasyPredicate()) {
EasyPredicateParser parser = new EasyPredicateParser();
exp = parser.parse(expression);
if (!exp.equals(expression)) {
LOG.debug("EasyPredicateParser parsed {} -> {}", expression, exp);
}
}
LOG.debug("Initializing {} using: {}", predicate ? "predicate" : "expression", exp);
try {
engine = new JsonPathEngine(exp, suppressExceptions, allowSimple, options);
} catch (Exception e) {
throw new ExpressionIllegalSyntaxException(exp, e);
}
}
use of org.apache.camel.ExpressionIllegalSyntaxException in project camel by apache.
the class LanguageSupport method loadResource.
/**
* Loads the resource if the given expression is referring to an external resource by using
* the syntax <tt>resource:scheme:uri<tt>.
* If the expression is not referring to a resource, then its returned as is.
* <p/>
* For example <tt>resource:classpath:mygroovy.groovy</tt> to refer to a groovy script on the classpath.
*
* @param expression the expression
* @return the expression
* @throws ExpressionIllegalSyntaxException is thrown if error loading the resource
*/
protected String loadResource(String expression) throws ExpressionIllegalSyntaxException {
if (camelContext != null && expression.startsWith(RESOURCE)) {
String uri = expression.substring(RESOURCE.length());
InputStream is = null;
try {
is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri);
expression = camelContext.getTypeConverter().mandatoryConvertTo(String.class, is);
} catch (Exception e) {
throw new ExpressionIllegalSyntaxException(expression, e);
} finally {
IOHelper.close(is);
}
}
return expression;
}
Aggregations