use of org.apache.camel.spring.Main in project camel by apache.
the class MisspelledRouteRefTest method testApplicationContextFailed.
public void testApplicationContextFailed() {
try {
Main main = new Main();
main.setApplicationContextUri("org/apache/camel/spring/issues/MisspelledRouteRefTest.xml");
main.start();
fail("Should have thrown an exception");
} catch (Exception e) {
//expected but want to see what it looks like...
LOG.debug("Exception message : " + e.getMessage());
CamelException cause = (CamelException) e.getCause();
assertEquals("Cannot find any routes with this RouteBuilder reference: RouteBuilderRef[xxxroute]", cause.getMessage());
}
}
use of org.apache.camel.spring.Main in project camel by apache.
the class CamelConsoleMain method main.
public static void main(String[] args) throws Exception {
// Main makes it easier to run a Spring application
Main main = new Main();
// configure the location of the Spring XML file
main.setApplicationContextUri("META-INF/spring/camel-context.xml");
// run and block until Camel is stopped (or JVM terminated)
main.run();
}
use of org.apache.camel.spring.Main in project camel by apache.
the class CxfRsRelayTest method testJaxrsRelayRoute.
/**
* That test builds a route chaining two cxfrs endpoints. It shows a request
* sent to the first one will be correctly transferred and consumed by the
* other one.
*/
@Test
public void testJaxrsRelayRoute() throws Exception {
final Main main = new Main();
try {
main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
main.start();
Thread t = new Thread(new Runnable() {
/**
* Sends a request to the first endpoint in the route
*/
public void run() {
try {
JAXRSClientFactory.create("http://localhost:" + port6 + "/CxfRsRelayTest/rest", UploadService.class).upload(CamelRouteBuilder.class.getResourceAsStream(SAMPLE_CONTENT_PATH), SAMPLE_NAME);
} catch (Exception e) {
log.warn("Error uploading to http://localhost:" + port6 + "/CxfRsRelayTest/rest", e);
}
}
});
t.start();
LATCH.await(10, TimeUnit.SECONDS);
assertEquals(SAMPLE_NAME, name);
StringWriter writer = new StringWriter();
IOUtils.copyAndCloseInput(new InputStreamReader(CamelRouteBuilder.class.getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
assertEquals(writer.toString(), content);
} finally {
main.stop();
}
}
use of org.apache.camel.spring.Main in project testcases by coheigea.
the class HDFSTest method testHDFS.
@org.junit.Test
public void testHDFS() throws Exception {
// Start up the Camel route
Main main = new Main();
main.setApplicationContextUri("camel-hdfs.xml");
main.start();
// Sleep to allow time to copy the files etc.
Thread.sleep(10 * 1000);
main.stop();
}
use of org.apache.camel.spring.Main in project testcases by coheigea.
the class KafkaTest method testKafka.
@org.junit.Test
public void testKafka() throws Exception {
// Set up the Producer
Properties producerProps = new Properties();
producerProps.put("bootstrap.servers", "localhost:" + port);
producerProps.put("acks", "all");
producerProps.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
producerProps.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
Producer<String, String> producer = new KafkaProducer<>(producerProps);
// Send a message
producer.send(new ProducerRecord<String, String>("test", "somekey", "somevalue"));
producer.flush();
// Start up the Camel route
Main main = new Main();
main.setApplicationContextUri("camel-kafka.xml");
main.start();
// Sleep to allow time for the demo to work
Thread.sleep(60 * 1000);
main.stop();
producer.close();
}
Aggregations