Search in sources :

Example 1 with CxfProducer

use of org.apache.camel.component.cxf.CxfProducer in project camel by apache.

the class CamelEndpointSpringConfigureTest method testCreateDestinationFromSpring.

@Test
public void testCreateDestinationFromSpring() throws Exception {
    CxfEndpoint cxfEndpoint = context.getEndpoint("cxf:bean:serviceEndpoint", CxfEndpoint.class);
    CxfProducer producer = (CxfProducer) cxfEndpoint.createProducer();
    assertNotNull("The producer should not be null", producer);
    producer.start();
    CamelConduit conduit = (CamelConduit) producer.getClient().getConduit();
    assertTrue("we should get SpringCamelContext here", conduit.getCamelContext() instanceof SpringCamelContext);
    assertEquals("The context id should be camel_conduit", "camel_conduit", conduit.getCamelContext().getName());
    cxfEndpoint = context.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
    CxfConsumer consumer = (CxfConsumer) cxfEndpoint.createConsumer(new Processor() {

        public void process(Exchange exchange) throws Exception {
        // do nothing here                
        }
    });
    assertNotNull("The consumer should not be null", consumer);
    consumer.start();
    CamelDestination destination = (CamelDestination) consumer.getServer().getDestination();
    assertTrue("we should get SpringCamelContext here", destination.getCamelContext() instanceof SpringCamelContext);
    assertEquals("The context id should be camel_destination", "camel_destination", destination.getCamelContext().getName());
}
Also used : Exchange(org.apache.camel.Exchange) CxfProducer(org.apache.camel.component.cxf.CxfProducer) Processor(org.apache.camel.Processor) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) CxfConsumer(org.apache.camel.component.cxf.CxfConsumer) CamelConduit(org.apache.camel.component.cxf.transport.CamelConduit) CamelDestination(org.apache.camel.component.cxf.transport.CamelDestination) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 2 with CxfProducer

use of org.apache.camel.component.cxf.CxfProducer in project camel by apache.

the class CxfEndpointBeanTest method testPropertiesSettingOnCxfClient.

@Test
public void testPropertiesSettingOnCxfClient() throws Exception {
    CxfEndpoint clientEndpoint = ctx.getBean("clientEndpoint", CxfEndpoint.class);
    CxfProducer producer = (CxfProducer) clientEndpoint.createProducer();
    // need to start the producer to get the client
    producer.start();
    Client client = producer.getClient();
    HTTPConduit conduit = (HTTPConduit) client.getConduit();
    assertEquals("Got the wrong user name", "test", conduit.getAuthorization().getUserName());
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) CxfProducer(org.apache.camel.component.cxf.CxfProducer) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Aggregations

CxfEndpoint (org.apache.camel.component.cxf.CxfEndpoint)2 CxfProducer (org.apache.camel.component.cxf.CxfProducer)2 Test (org.junit.Test)2 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 CxfConsumer (org.apache.camel.component.cxf.CxfConsumer)1 CamelConduit (org.apache.camel.component.cxf.transport.CamelConduit)1 CamelDestination (org.apache.camel.component.cxf.transport.CamelDestination)1 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)1 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1