package camelinaction;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.CamelSpringTestSupport;
import org.junit.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* The XML example for using the Aggregator EIP.
* <p/>
* This example have XML messages send to the aggregator to demonstrate
* using XPath for correlation expression. And we have two completion
* conditions which is based on size and timeout
* <p/>
* See the class {@link MyAggregationStrategy} for how the messages
* are actually aggregated together.
*
* @see camelinaction.MyAggregationStrategy
*/
public class SpringAggregateXMLTest extends CamelSpringTestSupport {
@Override
protected AbstractXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("META-INF/spring/aggregate-xml.xml");
}
@Test
public void testXML() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
template.sendBody("direct:start", "<order name=\"motor\" amount=\"1000\" customer=\"honda\"/>");
template.sendBody("direct:start", "<order name=\"motor\" amount=\"500\" customer=\"toyota\"/>");
template.sendBody("direct:start", "<order name=\"gearbox\" amount=\"200\" customer=\"toyota\"/>");
assertMockEndpointsSatisfied();
}
}