use of org.apache.camel.spi.Language in project camel by apache.
the class JsonPathLanguageTest method testExpressionField.
@Test
public void testExpressionField() throws Exception {
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new File("src/test/resources/type.json"));
Language lan = context.resolveLanguage("jsonpath");
Expression exp = lan.createExpression("$.kind");
String kind = exp.evaluate(exchange, String.class);
assertNotNull(kind);
assertEquals("full", kind);
exp = lan.createExpression("$.type");
String type = exp.evaluate(exchange, String.class);
assertNotNull(type);
assertEquals("customer", type);
}
use of org.apache.camel.spi.Language in project camel by apache.
the class SqlLanguageTest method testPredicateWithHeaderVariable.
@Test
public void testPredicateWithHeaderVariable() throws Exception {
Language language = assertResolveLanguage(getLanguageName());
assertPredicate(language.createPredicate("SELECT * FROM org.apache.camel.builder.sql.Person where name = :fooHeader"), exchange, true);
}
use of org.apache.camel.spi.Language in project camel by apache.
the class SqlLanguageTest method testExpressionWithHeaderVariable.
@Test
public void testExpressionWithHeaderVariable() throws Exception {
Language language = assertResolveLanguage(getLanguageName());
Expression expression = language.createExpression("SELECT * FROM org.apache.camel.builder.sql.Person where name = :fooHeader");
List<?> value = expression.evaluate(exchange, List.class);
assertEquals("List size", 1, value.size());
for (Object person : value) {
log.info("Found: " + person);
assertEquals("name", "James", ((Person) person).getName());
}
}
use of org.apache.camel.spi.Language in project camel by apache.
the class SqlLanguageTest method testPredicates.
@Test
public void testPredicates() throws Exception {
Language language = assertResolveLanguage(getLanguageName());
assertPredicate(language.createPredicate("SELECT * FROM org.apache.camel.builder.sql.Person where city = 'London'"), exchange, true);
assertPredicate(language.createPredicate("SELECT * FROM org.apache.camel.builder.sql.Person where city = 'Manchester'"), exchange, false);
}
use of org.apache.camel.spi.Language in project camel by apache.
the class FileProcessStrategyFactory method getDefaultCommitRenamer.
private static GenericFileExpressionRenamer<File> getDefaultCommitRenamer(CamelContext context) {
// use context to lookup language to let it be loose coupled
Language language = context.resolveLanguage("file");
Expression expression = language.createExpression("${file:parent}/.camel/${file:onlyname}");
return new GenericFileExpressionRenamer<File>(expression);
}
Aggregations