Search in sources :

Example 16 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class CxfEndpointTest method testSettingContinucationTimout.

@Test
public void testSettingContinucationTimout() throws Exception {
    CamelContext context = new DefaultCamelContext();
    CxfEndpoint endpoint = context.getEndpoint(routerEndpointURI + "&continuationTimeout=800000", CxfEndpoint.class);
    assertEquals("Get a wrong continucationTimeout value", 800000, endpoint.getContinuationTimeout());
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 17 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class CxfCustomerStartStopTest method startAndStopService.

@Test
public void startAndStopService() throws Exception {
    CamelContext context = new DefaultCamelContext();
    // start a server    
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("cxf:http://localhost:" + PORT1 + "/test?serviceClass=org.apache.camel.component.cxf.HelloService").to("log:endpoint");
        }
    });
    context.start();
    Thread.sleep(300);
    context.stop();
    Bus bus = BusFactory.getDefaultBus();
    JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
    JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT1);
    assertNotNull("Jetty engine should be found there", engine);
    // Need to call the bus shutdown ourselves.
    String orig = System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "false");
    bus.shutdown(true);
    System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", orig == null ? "true" : "false");
    engine = factory.retrieveJettyHTTPServerEngine(PORT1);
    assertNull("Jetty engine should be removed", engine);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Bus(org.apache.cxf.Bus) RouteBuilder(org.apache.camel.builder.RouteBuilder) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 18 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class ConverterTest method testFallbackConverter.

@Test
public void testFallbackConverter() throws Exception {
    CamelContext context = new DefaultCamelContext();
    Exchange exchange = new DefaultExchange(context);
    MessageContentsList list = new MessageContentsList();
    NodeListWrapper nl = new NodeListWrapper(new ArrayList<Element>());
    list.add(nl);
    exchange.getIn().setBody(list);
    Node node = exchange.getIn().getBody(Node.class);
    assertNull(node);
    File file = new File("src/test/resources/org/apache/camel/component/cxf/converter/test.xml");
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.parse(file);
    document.getDocumentElement().normalize();
    List<Element> elements = new ArrayList<Element>();
    elements.add(document.getDocumentElement());
    nl = new NodeListWrapper(elements);
    list.clear();
    list.add(nl);
    exchange.getIn().setBody(list);
    node = exchange.getIn().getBody(Node.class);
    assertNotNull(node);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) MessageContentsList(org.apache.cxf.message.MessageContentsList) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DocumentBuilder(javax.xml.parsers.DocumentBuilder) File(java.io.File) Test(org.junit.Test)

Example 19 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class ConverterTest method testToInputStream.

@Test
public void testToInputStream() throws Exception {
    CamelContext context = new DefaultCamelContext();
    Exchange exchange = new DefaultExchange(context);
    Response response = EasyMock.createMock(Response.class);
    InputStream is = EasyMock.createMock(InputStream.class);
    response.getEntity();
    EasyMock.expectLastCall().andReturn(is);
    EasyMock.replay(response);
    InputStream result = CxfConverter.toInputStream(response, exchange);
    assertEquals("We should get the inputStream here ", is, result);
    EasyMock.verify(response);
    EasyMock.reset(response);
    response.getEntity();
    EasyMock.expectLastCall().andReturn("Hello World");
    EasyMock.replay(response);
    result = CxfConverter.toInputStream(response, exchange);
    assertTrue("We should get the inputStream here ", result instanceof ByteArrayInputStream);
    EasyMock.verify(response);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Response(javax.ws.rs.core.Response) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 20 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class CxfProducerSoapFaultTest method setUp.

@Before
public void setUp() throws Exception {
    camelContext = new DefaultCamelContext();
    camelContext.start();
    template = camelContext.createProducerTemplate();
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Aggregations

DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)474 CamelContext (org.apache.camel.CamelContext)206 Test (org.junit.Test)183 DefaultExchange (org.apache.camel.impl.DefaultExchange)128 RouteBuilder (org.apache.camel.builder.RouteBuilder)101 Exchange (org.apache.camel.Exchange)91 Before (org.junit.Before)70 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)61 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)38 ESMClass (org.jsmpp.bean.ESMClass)30 ProducerTemplate (org.apache.camel.ProducerTemplate)27 CountDownLatch (java.util.concurrent.CountDownLatch)15 Endpoint (org.apache.camel.Endpoint)13 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)13 Processor (org.apache.camel.Processor)12 RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)12 Address (org.jsmpp.bean.Address)11 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)11 Date (java.util.Date)10