Search in sources :

Example 1 with Main

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());
    }
}
Also used : CamelException(org.apache.camel.CamelException) Main(org.apache.camel.spring.Main) CamelException(org.apache.camel.CamelException)

Example 2 with Main

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();
}
Also used : Main(org.apache.camel.spring.Main)

Example 3 with Main

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();
    }
}
Also used : StringWriter(java.io.StringWriter) InputStreamReader(java.io.InputStreamReader) Main(org.apache.camel.spring.Main) Test(org.junit.Test)

Example 4 with Main

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();
}
Also used : Main(org.apache.camel.spring.Main)

Example 5 with Main

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();
}
Also used : KafkaProducer(org.apache.kafka.clients.producer.KafkaProducer) Properties(java.util.Properties) Main(org.apache.camel.spring.Main)

Aggregations

Main (org.apache.camel.spring.Main)35 BeforeClass (org.junit.BeforeClass)5 InputStreamReader (java.io.InputStreamReader)2 StringWriter (java.io.StringWriter)2 Server (org.apache.coheigea.camel.cxf.proxy.shiro.service.Server)2 Server (org.apache.coheigea.camel.cxf.proxy.spring.security.service.Server)2 Test (org.junit.Test)2 Properties (java.util.Properties)1 CamelException (org.apache.camel.CamelException)1 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)1 Server (org.apache.coheigea.camel.cxf.proxy.service.Server)1 KafkaProducer (org.apache.kafka.clients.producer.KafkaProducer)1