Search in sources :

Example 1 with OutParameter

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

the class ParserTest method shouldParseOk.

@Test
public void shouldParseOk() {
    Template template = parser.parseTemplate("addnumbers(INTEGER ${header.header1}," + "VARCHAR ${property.property1},BIGINT ${header.header2},OUT INTEGER header1)");
    Assert.assertEquals("addnumbers", template.getProcedureName());
    Assert.assertEquals(4, template.getParameterList().size());
    Exchange exchange = createExchangeWithBody(null);
    exchange.getIn().setHeader("header1", 1);
    exchange.setProperty("property1", "constant string");
    exchange.getIn().setHeader("header2", BigInteger.valueOf(2));
    InputParameter param1 = (InputParameter) template.getParameterList().get(0);
    Assert.assertEquals("_0", param1.getName());
    Assert.assertEquals(Types.INTEGER, param1.getSqlType());
    Assert.assertEquals(1, param1.getValueExtractor().eval(exchange, null));
    InputParameter param2 = (InputParameter) template.getParameterList().get(1);
    Assert.assertEquals("_1", param2.getName());
    Assert.assertEquals(Types.VARCHAR, param2.getSqlType());
    Assert.assertEquals("constant string", param2.getValueExtractor().eval(exchange, null));
    InputParameter param3 = (InputParameter) template.getParameterList().get(2);
    Assert.assertEquals("_2", param3.getName());
    Assert.assertEquals(Types.BIGINT, param3.getSqlType());
    Assert.assertEquals(BigInteger.valueOf(2L), param3.getValueExtractor().eval(exchange, null));
    OutParameter sptpOutputNode = (OutParameter) template.getParameterList().get(3);
    Assert.assertEquals("_3", sptpOutputNode.getName());
    Assert.assertEquals(Types.INTEGER, sptpOutputNode.getSqlType());
    Assert.assertEquals("header1", sptpOutputNode.getOutValueMapKey());
}
Also used : Exchange(org.apache.camel.Exchange) OutParameter(org.apache.camel.component.sql.stored.template.ast.OutParameter) 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

Exchange (org.apache.camel.Exchange)1 InputParameter (org.apache.camel.component.sql.stored.template.ast.InputParameter)1 OutParameter (org.apache.camel.component.sql.stored.template.ast.OutParameter)1 Template (org.apache.camel.component.sql.stored.template.ast.Template)1 Test (org.junit.Test)1