use of org.apache.camel.examples.MultiSteps in project camel by apache.
the class JpaWithNativeQueryWithResultClassTest method assertReceivedResult.
/**
* We receive a MultiSteps object, because we call entityManager.createNativeQuery(nativeQuery, MultiSteps.class)
*/
@Override
protected void assertReceivedResult(Exchange exchange) {
assertNotNull(exchange);
MultiSteps result = (MultiSteps) exchange.getIn().getBody();
assertNotNull("Received an object array", result);
assertEquals("address property", "foo@bar.com", result.getAddress());
}
use of org.apache.camel.examples.MultiSteps in project camel by apache.
the class JpaProducerWithQueryTest method testProducerWithQuery.
@Test
public void testProducerWithQuery() throws Exception {
template.sendBody("direct:deleteMultiSteps", "");
MultiSteps m1 = new MultiSteps();
m1.setStep(1);
template.sendBody("direct:addMultiSteps", m1);
MultiSteps m2 = new MultiSteps();
m2.setStep(2);
template.sendBody("direct:addMultiSteps", m2);
Object answer = template.requestBody("direct:query", "");
List list = (List) answer;
assertEquals(1, list.size());
assertEquals(1, ((MultiSteps) list.get(0)).getStep());
answer = template.requestBody("direct:deleteMultiSteps", "");
assertEquals(2, ((Integer) answer).intValue());
}
use of org.apache.camel.examples.MultiSteps in project camel by apache.
the class JpaProducerWithQueryTest method testProducerWithNativeQueryAndResultClass.
@Test
public void testProducerWithNativeQueryAndResultClass() throws Exception {
template.sendBody("direct:deleteMultiSteps", "");
MultiSteps m1 = new MultiSteps();
m1.setStep(1);
template.sendBody("direct:addMultiSteps", m1);
MultiSteps m2 = new MultiSteps();
m2.setStep(2);
template.sendBody("direct:addMultiSteps", m2);
Object answer = template.requestBody("direct:nativeQueryWithResultClass", "");
List list = (List) answer;
assertEquals(1, list.size());
assertEquals(1, ((MultiSteps) list.get(0)).getStep());
answer = template.requestBody("direct:deleteMultiSteps", "");
assertEquals(2, ((Integer) answer).intValue());
}
use of org.apache.camel.examples.MultiSteps in project camel by apache.
the class JpaProducerWithQueryTest method setUp.
@Before
public void setUp() throws Exception {
camelContext = new DefaultCamelContext();
SimpleRegistry registry = new SimpleRegistry();
Map<String, Object> params = new HashMap<String, Object>();
params.put("custName", "${body}");
// bind the params
registry.put("params", params);
camelContext.setRegistry(registry);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:query").to("jpa://" + MultiSteps.class.getName() + "?query=select o from " + MultiSteps.class.getName() + " o where o.step = 1");
from("direct:namedQuery").to("jpa://" + Customer.class.getName() + "?namedQuery=findAllCustomersWithName¶meters=#params");
from("direct:nativeQuery").to("jpa://" + MultiSteps.class.getName() + "?nativeQuery=select * from MultiSteps where step = 1");
from("direct:nativeQueryWithResultClass").to("jpa://" + MultiSteps.class.getName() + "?resultClass=org.apache.camel.examples.MultiSteps&nativeQuery=select * from MultiSteps where step = 1");
from("direct:addCustomer").to("jpa://" + Customer.class.getName());
from("direct:deleteCustomers").to("jpa://" + Customer.class.getName() + "?query=delete from " + Customer.class.getName());
from("direct:addMultiSteps").to("jpa://" + MultiSteps.class.getName());
from("direct:deleteMultiSteps").to("jpa://" + MultiSteps.class.getName() + "?nativeQuery=delete from MultiSteps");
}
});
template = camelContext.createProducerTemplate();
ServiceHelper.startServices(template, camelContext);
}
use of org.apache.camel.examples.MultiSteps in project camel by apache.
the class JpaProducerWithQueryTest method testProducerWithNativeQuery.
@Test
public void testProducerWithNativeQuery() throws Exception {
template.sendBody("direct:deleteMultiSteps", "");
MultiSteps m1 = new MultiSteps();
m1.setStep(1);
template.sendBody("direct:addMultiSteps", m1);
MultiSteps m2 = new MultiSteps();
m2.setStep(2);
template.sendBody("direct:addMultiSteps", m2);
Object answer = template.requestBody("direct:nativeQuery", "");
List list = (List) answer;
assertEquals(1, list.size());
assertEquals(1, ((Object[]) list.get(0))[2]);
answer = template.requestBody("direct:deleteMultiSteps", "");
assertEquals(2, ((Integer) answer).intValue());
}
Aggregations