Search in sources :

Example 6 with CxfEndpoint

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

the class CxfEndpointBeanBusSettingTest method testBusInjectionOnURI.

@Test
public void testBusInjectionOnURI() throws Exception {
    CamelContext camelContext = (CamelContext) ctx.getBean("camel");
    CxfEndpoint endpoint = camelContext.getEndpoint("cxf:bean:serviceEndpoint?bus=#cxf1", CxfEndpoint.class);
    assertEquals(ctx.getBean("cxf1"), endpoint.getBus());
    endpoint = camelContext.getEndpoint("cxf:http://localhost:" + port1 + "/CxfEndpointBeanBusSettingTest/router1?bus=#cxf1", CxfEndpoint.class);
    assertEquals(ctx.getBean("cxf1"), endpoint.getBus());
}
Also used : CamelContext(org.apache.camel.CamelContext) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 7 with CxfEndpoint

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

the class CxfEndpointBeanTest method testCxfEndpointBeanDefinitionParser.

@Test
public void testCxfEndpointBeanDefinitionParser() {
    CxfEndpoint routerEndpoint = ctx.getBean("routerEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpoint address", "http://localhost:" + port1 + "/CxfEndpointBeanTest/router", routerEndpoint.getAddress());
    assertEquals("Got the wrong endpont service class", "org.apache.camel.component.cxf.HelloService", routerEndpoint.getServiceClass().getName());
    assertEquals("loggingFeatureEnabled should be false", false, routerEndpoint.isLoggingFeatureEnabled());
    assertEquals("loggingSizeLimit should not be set", 0, routerEndpoint.getLoggingSizeLimit());
    assertEquals("Got the wrong handlers size", 1, routerEndpoint.getHandlers().size());
    assertEquals("Got the wrong schemalocations size", 1, routerEndpoint.getSchemaLocations().size());
    assertEquals("Got the wrong schemalocation", "classpath:wsdl/Message.xsd", routerEndpoint.getSchemaLocations().get(0));
    assertEquals("Got the wrong continuationTimeout", 60000, routerEndpoint.getContinuationTimeout());
    CxfEndpoint myEndpoint = ctx.getBean("myEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpointName", endpointName, myEndpoint.getPortName());
    assertEquals("Got the wrong serviceName", serviceName, myEndpoint.getServiceName());
    assertEquals("loggingFeatureEnabled should be true", true, myEndpoint.isLoggingFeatureEnabled());
    assertEquals("loggingSizeLimit should be set", 200, myEndpoint.getLoggingSizeLimit());
    assertTrue("We should get a soap binding", myEndpoint.getBindingConfig() instanceof SoapBindingConfiguration);
    SoapBindingConfiguration configuration = (SoapBindingConfiguration) myEndpoint.getBindingConfig();
    assertEquals("We should get a right soap version", "1.2", String.valueOf(configuration.getVersion().getVersion()));
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 8 with CxfEndpoint

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

the class CxfEndpointBeanTest method testCxfEndpointsWithCamelContext.

@Test
public void testCxfEndpointsWithCamelContext() {
    CamelContext context = ctx.getBean("myCamelContext", CamelContext.class);
    // try to create a new CxfEndpoint which could override the old bean's setting
    CxfEndpoint myLocalCxfEndpoint = (CxfEndpoint) context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:" + port1 + "/CxfEndpointBeanTest/myCamelContext/");
    assertEquals("Got the wrong endpoint address", "http://localhost:" + port1 + "/CxfEndpointBeanTest/myCamelContext/", myLocalCxfEndpoint.getAddress());
    CxfEndpoint routerEndpoint = ctx.getBean("routerEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpoint address", "http://localhost:" + port1 + "/CxfEndpointBeanTest/router", routerEndpoint.getAddress());
}
Also used : CamelContext(org.apache.camel.CamelContext) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 9 with CxfEndpoint

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

the class CxfEndpointBeanWithBusTest method testBusInjectedBySpring.

@Test
public void testBusInjectedBySpring() throws Exception {
    CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
    CxfEndpoint endpoint = camelContext.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
    // verify the interceptor that is added by the logging feature
    // Spring 3.0.0 has an issue of SPR-6589 which will call the BusApplicationListener twice for the same event,
    // so we will get more one InInterceptors here
    assertTrue(endpoint.getBus().getInInterceptors().size() >= 1);
    for (Interceptor<?> i : endpoint.getBus().getInInterceptors()) {
        if (i instanceof LoggingInInterceptor) {
            return;
        }
    }
    fail("Could not find the LoggingInInterceptor on the bus. " + endpoint.getBus().getInInterceptors());
}
Also used : CamelContext(org.apache.camel.CamelContext) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) Test(org.junit.Test)

Example 10 with CxfEndpoint

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

the class CxfEndpointBeansRouterTest method testCreateCxfEndpointFromURI.

@Test
public void testCreateCxfEndpointFromURI() throws Exception {
    CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
    CxfEndpoint endpoint1 = camelContext.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:9000/test1", CxfEndpoint.class);
    CxfEndpoint endpoint2 = camelContext.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 : CamelContext(org.apache.camel.CamelContext) 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