Search in sources :

Example 6 with Template

use of org.apache.camel.component.sql.stored.template.ast.Template in project camel by apache.

the class ParserTest method vendorSpecificNegativeSqlType.

@Test
public void vendorSpecificNegativeSqlType() {
    Template template = parser.parseTemplate("ADDNUMBERS2(-1342 ${header.foo})");
    assertEquals(-1342, ((InputParameter) template.getParameterList().get(0)).getSqlType());
}
Also used : Template(org.apache.camel.component.sql.stored.template.ast.Template) Test(org.junit.Test)

Example 7 with Template

use of org.apache.camel.component.sql.stored.template.ast.Template in project camel by apache.

the class ParserTest method vendorSpecificPositiveSqlTypeOut.

@Test
public void vendorSpecificPositiveSqlTypeOut() {
    Template template = parser.parseTemplate("ADDNUMBERS2(OUT 1342 h1)");
    assertEquals(1342, ((OutParameter) template.getParameterList().get(0)).getSqlType());
}
Also used : Template(org.apache.camel.component.sql.stored.template.ast.Template) Test(org.junit.Test)

Example 8 with Template

use of org.apache.camel.component.sql.stored.template.ast.Template in project camel by apache.

the class ParserTest method nestedSimpleExpression.

@Test
public void nestedSimpleExpression() {
    Exchange exchange = createExchangeWithBody(1);
    exchange.getIn().setHeader("foo", 1);
    exchange.getIn().setHeader("bar", 3);
    Template template = parser.parseTemplate("ADDNUMBERS2(INTEGER ${header.foo},INTEGER ${header.bar})");
    assertEquals(1, ((InputParameter) template.getParameterList().get(0)).getValueExtractor().eval(exchange, null));
    assertEquals(3, ((InputParameter) template.getParameterList().get(1)).getValueExtractor().eval(exchange, null));
}
Also used : Exchange(org.apache.camel.Exchange) InputParameter(org.apache.camel.component.sql.stored.template.ast.InputParameter) Template(org.apache.camel.component.sql.stored.template.ast.Template) Test(org.junit.Test)

Aggregations

Template (org.apache.camel.component.sql.stored.template.ast.Template)8 Test (org.junit.Test)7 InputParameter (org.apache.camel.component.sql.stored.template.ast.InputParameter)3 Exchange (org.apache.camel.Exchange)2 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 OutParameter (org.apache.camel.component.sql.stored.template.ast.OutParameter)1 ParseRuntimeException (org.apache.camel.component.sql.stored.template.ast.ParseRuntimeException)1 ParseException (org.apache.camel.component.sql.stored.template.generated.ParseException)1 SSPTParser (org.apache.camel.component.sql.stored.template.generated.SSPTParser)1