Search in sources :

Example 1 with CxfEndpoint

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

the class CxfEndpointBeansTest method testCxfEndpointBeanDefinitionParser.

@Test
public void testCxfEndpointBeanDefinitionParser() {
    CxfEndpoint routerEndpoint = context.getEndpoint("routerEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpoint address", routerEndpoint.getAddress(), "http://localhost:" + CXFTestSupport.getPort1() + "/CxfEndpointBeansRouterTest/router");
    assertEquals("Got the wrong endpont service class", "org.apache.camel.component.cxf.HelloService", routerEndpoint.getServiceClass().getName());
}
Also used : CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 2 with CxfEndpoint

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

the class CxfEndpointBeansTest method testCreateCxfEndpointFromURI.

@Test
public void testCreateCxfEndpointFromURI() throws Exception {
    CxfEndpoint endpoint1 = context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:9000/test1", CxfEndpoint.class);
    CxfEndpoint endpoint2 = context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:8000/test2", CxfEndpoint.class);
    assertEquals("Get a wrong endpoint address.", "http://localhost:9000/test1", endpoint1.getAddress());
    assertEquals("Get a wrong endpoint address.", "http://localhost:8000/test2", endpoint2.getAddress());
    // the uri will always be normalized
    String uri1 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:9000/test1");
    String uri2 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:8000/test2");
    assertEquals("Get a wrong endpoint key.", uri1, endpoint1.getEndpointKey());
    assertEquals("Get a wrong endpoint key.", uri2, endpoint2.getEndpointKey());
}
Also used : CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 3 with CxfEndpoint

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

the class CxfEndpointUtilsTest method testGetProperties.

@Test
public void testGetProperties() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getEndpointURI());
    QName service = endpoint.getServiceName();
    assertEquals("We should get the right service name", service, SERVICE_NAME);
}
Also used : QName(javax.xml.namespace.QName) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 4 with CxfEndpoint

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

the class CxfEndpointUtilsTest method testCheckServiceClassConsumer.

@Test
public void testCheckServiceClassConsumer() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI());
    try {
        endpoint.createConsumer(new Processor() {

            @Override
            public void process(Exchange exchange) throws Exception {
            // noop
            }
        });
        fail("Should have thrown exception");
    } catch (IllegalArgumentException exception) {
        assertNotNull("Should get a CamelException here", exception);
        assertTrue(exception.getMessage().startsWith("serviceClass must be specified"));
    }
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 5 with CxfEndpoint

use of org.apache.camel.component.cxf.CxfEndpoint 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)

Aggregations

CxfEndpoint (org.apache.camel.component.cxf.CxfEndpoint)32 Test (org.junit.Test)30 CamelContext (org.apache.camel.CamelContext)10 QName (javax.xml.namespace.QName)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 CxfComponent (org.apache.camel.component.cxf.CxfComponent)4 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)4 Endpoint (org.wildfly.camel.test.common.types.Endpoint)3 Exchange (org.apache.camel.Exchange)2 Processor (org.apache.camel.Processor)2 ProducerTemplate (org.apache.camel.ProducerTemplate)2 CxfProducer (org.apache.camel.component.cxf.CxfProducer)2 SoapBindingConfiguration (org.apache.cxf.binding.soap.SoapBindingConfiguration)2 Interceptor (org.apache.cxf.interceptor.Interceptor)2 Message (org.apache.cxf.message.Message)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1