Java 类org.apache.camel.component.cxf.CxfEndpoint 实例源码

项目:wildfly-camel-examples    文件:Application.java   
@Named("cxfProducerEndpoint")
@Produces
public CxfEndpoint createCxfProducerEndpoint() {
    CxfComponent cxfProducerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfProducerEndpoint = new CxfEndpoint(CXF_PRODUCER_ENDPOINT_ADDRESS, cxfProducerComponent);
    cxfProducerEndpoint.setBeanId("cxfProducerEndpoint");
    cxfProducerEndpoint.setServiceClass(org.wildfly.camel.examples.cxf.jaxws.GreetingService.class);

    SSLContextParameters producerSslContextParameters = this.createProducerSSLContextParameters();
    cxfProducerEndpoint.setSslContextParameters(producerSslContextParameters);

    // Not for use in production
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    cxfProducerEndpoint.setHostnameVerifier(hostnameVerifier);

    return cxfProducerEndpoint;
}
项目:Camel    文件:CxfEndpointBeanTest.java   
@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()));

}
项目:Camel    文件:CxfEndpointBeanWithBusTest.java   
@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());
}
项目:Camel    文件:CxfEndpointBeanBusSettingTest.java   
@Test
public void testBusInjectedBySpring() throws Exception {
    CamelContext camelContext = (CamelContext) ctx.getBean("camel");

    CxfEndpoint endpoint = camelContext.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
    assertEquals("Get a wrong endpoint uri", "cxf://bean:routerEndpoint", endpoint.getEndpointUri());       
    Bus cxf1 = endpoint.getBus();

    assertEquals(cxf1, ctx.getBean("cxf1"));
    assertEquals(cxf1, endpoint.getBus());
    assertEquals("barf", endpoint.getBus().getProperty("foo"));

    endpoint = camelContext.getEndpoint("cxf:bean:serviceEndpoint", CxfEndpoint.class);
    assertEquals("Get a wrong endpoint uri", "cxf://bean:serviceEndpoint", endpoint.getEndpointUri());
    Bus cxf2 = endpoint.getBus();

    assertEquals(cxf2, ctx.getBean("cxf2"));
    assertEquals(cxf2, endpoint.getBus());
    assertEquals("snarf", endpoint.getBus().getProperty("foo"));


}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@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"));
    }
}
项目:Camel    文件:CamelEndpointSpringConfigureTest.java   
@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());


}
项目:cxf_over_jms_kata    文件:CamelConfig.java   
@Bean(name = "helloEndpoint")
public CxfEndpoint userServiceEndpoint() {
    CxfEndpoint cxfEndpoint = new CxfEndpoint();
    cxfEndpoint.setAddress("http://localhost:8888/services/hello");
    cxfEndpoint.setServiceClass(HelloWorld.class);
    LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
    loggingInInterceptor.setPrettyLogging(true);
    LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
    loggingOutInterceptor.setPrettyLogging(true);
    cxfEndpoint.getOutInterceptors().add(loggingOutInterceptor);
    cxfEndpoint.getInInterceptors().add(loggingInInterceptor);
    cxfEndpoint.setDataFormat(DataFormat.POJO);
    final Map<String, Object> properties = new HashMap<>();
    properties.put("schema-validation-enabled", "true");
    properties.put("bus.jmx.enabled", "true");

    //properties.setProperty("faultStackTraceEnabled", "true");
    //properties.setProperty("exceptionMessageCauseEnabled", "true");
    //properties.setProperty("schema-validation-enabled", "false");

    //properties.put("allowStreaming", true);
    cxfEndpoint.configureProperties(properties);
    return cxfEndpoint;
}
项目:wildfly-camel-examples    文件:Application.java   
@Named("cxfConsumerEndpoint")
@Produces
public CxfEndpoint createCxfConsumerEndpoint() {
    CxfComponent cxfConsumerComponent = new CxfComponent(this.camelContext);
    CxfEndpoint cxfConsumerEndpoint = new CxfEndpoint(CXF_CONSUMER_ENDPOINT_ADDRESS, cxfConsumerComponent);
    cxfConsumerEndpoint.setBeanId("cxfConsumerEndpoint");
    cxfConsumerEndpoint.setServiceClass(org.wildfly.camel.examples.cxf.jaxws.GreetingService.class);

    SSLContextParameters consumerSslContextParameters = this.createConsumerSSLContextParameters();
    cxfConsumerEndpoint.setSslContextParameters(consumerSslContextParameters);

    List<Interceptor<? extends Message>> inInterceptors = cxfConsumerEndpoint.getInInterceptors();

    // Authentication
    JAASLoginInterceptor jaasLoginInterceptor = new JAASLoginInterceptor();
    jaasLoginInterceptor.setContextName(WILDFLY_SECURITY_DOMAIN_NAME);
    jaasLoginInterceptor.setAllowAnonymous(false);
    List<CallbackHandlerProvider> chp = Arrays.asList(new JBossCallbackHandlerTlsCert());
    jaasLoginInterceptor.setCallbackHandlerProviders(chp);
    inInterceptors.add(jaasLoginInterceptor);

    // Authorization
    SimpleAuthorizingInterceptor authorizingInterceptor = new SimpleAuthorizingInterceptor();
    authorizingInterceptor.setAllowAnonymousUsers(false);
    Map<String, String> rolesMap = new HashMap<>(1);
    rolesMap.put("greet", "testRole");
    authorizingInterceptor.setMethodRolesMap(rolesMap);
    inInterceptors.add(authorizingInterceptor);
    return cxfConsumerEndpoint;
}
项目:wildfly-camel-examples    文件:Application.java   
@Named("cxfConsumer")
@Produces
public CxfEndpoint createCxfConsumer() {
    CxfComponent cxfComponent = new CxfComponent(this.context);
    CxfEndpoint cxfFromEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting-cdi-xml", cxfComponent);
    cxfFromEndpoint.setServiceClass(GreetingService.class);
    return cxfFromEndpoint;
}
项目:wildfly-camel-examples    文件:Application.java   
@Named("cxfProducer")
@Produces
public CxfEndpoint createCxfProducer() {
    CxfComponent cxfComponent = new CxfComponent(this.context);
    CxfEndpoint cxfToEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting-cdi-xml", cxfComponent);
    cxfToEndpoint.setServiceClass(GreetingService.class);
    return cxfToEndpoint;
}
项目:Camel    文件:CamelCxfExample.java   
@Override
public void configure() throws Exception {
    // Set system properties for use with Camel property placeholders for running the example tests.
    System.setProperty("routerPort", String.valueOf(AvailablePortFinder.getNextAvailable()));
    System.setProperty("servicePort", String.valueOf(AvailablePortFinder.getNextAvailable()));
    CxfComponent cxfComponent = new CxfComponent(getContext());
    CxfEndpoint serviceEndpoint = new CxfEndpoint(SERVICE_ADDRESS, cxfComponent);
    serviceEndpoint.setServiceClass(Greeter.class); 

    // Here we just pass the exception back, don't need to use errorHandler
    errorHandler(noErrorHandler());
    from(ROUTER_ENDPOINT_URI).to(serviceEndpoint);
}
项目:Camel    文件:CxfEndpointBeansTest.java   
@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());
}
项目:Camel    文件:CxfEndpointBeansTest.java   
@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());
}
项目:Camel    文件:CxfEndpointBeansTest.java   
@Test
public void testCxfBeanWithCamelPropertiesHolder() throws Exception {
    // get the camelContext from application context
    CxfEndpoint testEndpoint = context.getEndpoint("cxf:bean:testEndpoint", CxfEndpoint.class);
    QName endpointName = QName.valueOf("{http://org.apache.camel.component.cxf}myEndpoint");
    QName serviceName = QName.valueOf("{http://org.apache.camel.component.cxf}myService");

    assertEquals("Got a wrong address", 
                 "http://localhost:" + CXFTestSupport.getPort3() + "/testEndpoint", testEndpoint.getAddress());
    assertEquals("Got a wrong bindingId", "http://schemas.xmlsoap.org/wsdl/soap12/", testEndpoint.getBindingId());
    assertEquals("Got a wrong transportId", "http://cxf.apache.org/transports/http", testEndpoint.getTransportId());
    assertEquals("Got a wrong endpointName", endpointName, testEndpoint.getPortName());
    assertEquals("Got a wrong WsdlURL", "wsdl/test.wsdl", testEndpoint.getWsdlURL());
    assertEquals("Got a wrong serviceName", serviceName, testEndpoint.getServiceName());
}
项目:Camel    文件:CxfConsumerSoap12Test.java   
@Test
public void testCxfEndpointBeanDefinitionParser() {
    CxfEndpoint routerEndpoint = context.getEndpoint("routerEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpoint address", routerEndpoint.getAddress(),
                 "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
    assertEquals("Got the wrong endpont service class", 
                 "org.apache.hello_world_soap_http.Greeter", 
                 routerEndpoint.getServiceClass().getName());
    BindingConfiguration binding = routerEndpoint.getBindingConfig();
    assertTrue("Got no soap binding", binding instanceof SoapBindingConfiguration);
    assertEquals("Got the wrong soap version", "http://schemas.xmlsoap.org/wsdl/soap12/",
                 ((SoapBindingConfiguration)binding).getVersion().getBindingId());
    assertTrue("Mtom not enabled", ((SoapBindingConfiguration)binding).isMtomEnabled());
}
项目:Camel    文件:CxfEndpointBeanTest.java   
@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());
}
项目:Camel    文件:CxfEndpointBeanTest.java   
@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());
}
项目:Camel    文件:CxfEndpointBeanWithBusTest.java   
@Test
public void testCxfEndpointBeanDefinitionParser() {
    CxfEndpoint routerEndpoint = ctx.getBean("routerEndpoint", CxfEndpoint.class);
    assertEquals("Got the wrong endpoint address", "http://localhost:" + port1 
                 + "/CxfEndpointBeanWithBusTest/router/", routerEndpoint.getAddress());
    assertEquals("Got the wrong endpont service class", 
                 "org.apache.camel.component.cxf.HelloService",
                 routerEndpoint.getServiceClass().getName());

}
项目:Camel    文件:CxfEndpointBeansRouterTest.java   
@Test
public void testCxfEndpointBeanDefinitionParser() {
    CxfEndpoint routerEndpoint = ctx.getBean("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());
}
项目:Camel    文件:CxfEndpointBeansRouterTest.java   
@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());
}
项目:Camel    文件:CxfEndpointBeansRouterTest.java   
@Test
public void testCxfBeanWithCamelPropertiesHolder() throws Exception {
    // get the camelContext from application context
    CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
    CxfEndpoint testEndpoint = camelContext.getEndpoint("cxf:bean:testEndpoint", CxfEndpoint.class);
    QName endpointName = QName.valueOf("{http://org.apache.camel.component.cxf}myEndpoint");
    QName serviceName = QName.valueOf("{http://org.apache.camel.component.cxf}myService");

    assertEquals("Got a wrong address", "http://localhost:9000/testEndpoint", testEndpoint.getAddress());
    assertEquals("Got a wrong bindingId", "http://schemas.xmlsoap.org/wsdl/soap12/", testEndpoint.getBindingId());
    assertEquals("Got a wrong transportId", "http://cxf.apache.org/transports/http", testEndpoint.getTransportId());
    assertEquals("Got a wrong endpointName", endpointName, testEndpoint.getPortName());
    assertEquals("Got a wrong WsdlURL", "wsdl/test.wsdl", testEndpoint.getWsdlURL());
    assertEquals("Got a wrong serviceName", serviceName, testEndpoint.getServiceName());
}
项目:Camel    文件:CxfEndpointBeanBusSettingTest.java   
@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());
}
项目:Camel    文件:CxfMessageHeadersRelayTest.java   
@Test
public void testMessageHeadersRelaysSpringContext() throws Exception {
    CxfEndpoint endpoint = context.getEndpoint("cxf:bean:serviceExtraRelays?headerFilterStrategy=#customMessageFilterStrategy", CxfEndpoint.class);
    CxfHeaderFilterStrategy strategy = (CxfHeaderFilterStrategy)endpoint.getHeaderFilterStrategy();
    List<MessageHeaderFilter> filters = strategy.getMessageHeaderFilters();
    assertEquals("Expected number of filters ", 2, filters.size());
    Map<String, MessageHeaderFilter> messageHeaderFilterMap = strategy.getMessageHeaderFiltersMap();
    for (String ns : new CustomHeaderFilter().getActivationNamespaces()) {
        assertEquals("Expected a filter class for namespace: " + ns,
                     CustomHeaderFilter.class, messageHeaderFilterMap.get(ns).getClass());
    }
}
项目:cxf_over_jms_kata    文件:CamelConfig.java   
@Bean(name = "wsEndpoint")
public CxfEndpoint wsEndpoint() throws ClassNotFoundException {
    CxfEndpoint cxfEndpoint = new CxfEndpoint();
    cxfEndpoint.setAddress("http://localhost:8888/services/person");
    cxfEndpoint.setServiceClass("pl.java.scalatech.spring_camel.service.impl.PersonServiceImpl");
    cxfEndpoint.setLoggingFeatureEnabled(true);
    return cxfEndpoint;
}
项目:morc    文件:CxfEndpointOverride.java   
@Override
public void overrideEndpoint(Endpoint endpoint) {
    if (endpoint instanceof CxfEndpoint) {
        ((CxfEndpoint) endpoint).setDataFormat(DataFormat.PAYLOAD);
        //Works around issue: https://issues.apache.org/jira/browse/CXF-2775
        System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "true");
    }
}
项目:wildfly-camel    文件:WildFlyCxfComponent.java   
WildflyCxfConsumer(CxfEndpoint endpoint, Processor processor) throws Exception {
    super(endpoint, processor);
    URI uri = new URI(endpoint.getEndpointUri());
    String host = uri.getHost();
    int port = uri.getPort();
    if (!"localhost".equals(host) || port > 0) {
        LOGGER.warn("Ignoring configured host/port: {}", uri);
    }
}
项目:wildfly-camel    文件:CXFWSJAASAuthenticationIntegrationTest.java   
private CamelContext configureCamelContext(String password) throws Exception {
    CamelContext camelctx = new DefaultCamelContext();

    CxfComponent component = new CxfComponent(camelctx);
    CxfEndpoint consumerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
    consumerEndpoint.setServiceClass(Endpoint.class);

    List<Interceptor<? extends Message>> inInterceptors = consumerEndpoint.getInInterceptors();
    JAASLoginInterceptor interceptor =  new JAASLoginInterceptor();
    interceptor.setContextName("other");
    inInterceptors.add(interceptor);

    CxfEndpoint producerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
    producerEndpoint.setServiceClass(Endpoint.class);
    producerEndpoint.setUsername("user1");
    producerEndpoint.setPassword(password);

    Map<String, Object> properties = producerEndpoint.getProperties();
    if (properties == null) {
        producerEndpoint.setProperties(new HashMap<>());
    }

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to(producerEndpoint);

            from(consumerEndpoint)
            .process(exchange -> {
                Object[] args = exchange.getIn().getBody(Object[].class);
                exchange.getOut().setBody("Hello " + args[0]);
            });
        }
    });
    return camelctx;
}
项目:wildfly-camel    文件:CXFWSInterceptorTest.java   
@Test
public void testCXFInterceptor() throws Exception {
    CountDownLatch latch = new CountDownLatch(1);

    CamelContext camelctx = new DefaultCamelContext();

    CxfComponent component = new CxfComponent(camelctx);
    CxfEndpoint cxfEndpoint = new CxfEndpoint("http://localhost:8080/EndpointService/EndpointPort", component);
    cxfEndpoint.setServiceClass(Endpoint.class);

    List<Interceptor<? extends Message>> inInterceptors = cxfEndpoint.getInInterceptors();
    inInterceptors.add(new CountDownInterceptor(latch));

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from(cxfEndpoint)
            .setBody(constant("Hello ${body}"));
        }
    });

    camelctx.start();
    try {
        QName qname = new QName("http://wildfly.camel.test.cxf", "EndpointService");
        Service service = Service.create(new URL("http://localhost:8080/EndpointService/EndpointPort?wsdl"), qname);
        Endpoint endpoint = service.getPort(Endpoint.class);
        endpoint.echo("Kermit");
        Assert.assertTrue("Gave up waiting for CXF interceptor handleMessage", latch.await(5, TimeUnit.SECONDS));
    } finally {
        camelctx.stop();
    }
}
项目:Camel    文件:CamelCxfExample.java   
public static void main(String args[]) throws Exception {

    // Set system properties for use with Camel property placeholders for running the examples.
    System.setProperty("routerPort", "9001");
    System.setProperty("servicePort", "9003");

    // START SNIPPET: e1
    CamelContext context = new DefaultCamelContext();
    // END SNIPPET: e1
    PropertiesComponent pc = new PropertiesComponent();
    context.addComponent("properties", pc);
    // Set up the JMS broker and the CXF SOAP over JMS server
    // START SNIPPET: e2
    JmsBroker broker = new JmsBroker();
    Server server = new Server();
    try {
        broker.start();
        server.start();
        // END SNIPPET: e2
        // Add some configuration by hand ...
        // START SNIPPET: e3
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                CxfComponent cxfComponent = new CxfComponent(getContext());
                CxfEndpoint serviceEndpoint = new CxfEndpoint(SERVICE_ADDRESS, cxfComponent);
                serviceEndpoint.setServiceClass(Greeter.class);
                // Here we just pass the exception back, don't need to use errorHandler
                errorHandler(noErrorHandler());
                from(ROUTER_ENDPOINT_URI).to(serviceEndpoint);
            }
        });
        // END SNIPPET: e3
        String address = ROUTER_ADDRESS.replace("{{routerPort}}", System.getProperty("routerPort"));
        // Starting the routing context
        // Using the CXF Client to kick off the invocations
        // START SNIPPET: e4
        context.start();
        Client client = new Client(address + "?wsdl");
        // END SNIPPET: e4
        // Now everything is set up - let's start the context

        client.invoke();
        Thread.sleep(1000);
        context.stop();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        server.stop();
        broker.stop();
        System.exit(0);
    }

}
项目:Camel    文件:CxfEndpointBeansTest.java   
@Test
public void testCxfBusInjection() {
    CxfEndpoint serviceEndpoint = context.getEndpoint("cxf:bean:serviceEndpoint", CxfEndpoint.class);
    CxfEndpoint routerEndpoint = context.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
    assertEquals("These endpoints don't share the same bus", serviceEndpoint.getBus().getId(), routerEndpoint.getBus().getId());
}
项目:Camel    文件:CxfEndpointBeansTest.java   
@Test
public void testCxfFeatureSetting() {
    CxfEndpoint routerEndpoint = context.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
    assertEquals("Get a wrong size of features.", 1, routerEndpoint.getFeatures().size());
    assertTrue("Get a wrong feature instance.", routerEndpoint.getFeatures().get(0) instanceof FailoverFeature);
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
protected CxfEndpoint createEndpoint(String uri) throws Exception {
    CamelContext context = getCamelContext();
    return (CxfEndpoint)new CxfComponent(context).createEndpoint(uri);
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@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);
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@SuppressWarnings("deprecation")
@Test
public void testGetDataFormatMessage() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + "dataFormat=MESSAGE");
    assertEquals("We should get the Message DataFormat", DataFormat.MESSAGE, endpoint.getDataFormat());
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@Test
public void testGetDataFormatCXF() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + "dataFormat=CXF_MESSAGE");
    assertEquals("We should get the Message DataFormat", DataFormat.CXF_MESSAGE, endpoint.getDataFormat());
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@Test
public void testGetDataFormatRAW() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + "dataFormat=RAW");
    assertEquals("We should get the Message DataFormat", DataFormat.RAW, endpoint.getDataFormat());
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@Test
public void testCheckServiceClassWithTheEndpoint() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI());
    assertNull(endpoint.getServiceClass());
}
项目:Camel    文件:CxfEndpointUtilsTest.java   
@Test
public void testCheckServiceClassProcedure() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI());
    assertNotNull(endpoint.createProducer());
}
项目:Camel    文件:CxfEndpointUtilsWithSpringTest.java   
@Test
public void testGetServiceClass() throws Exception {
    CxfEndpoint endpoint = createEndpoint("cxf:bean:helloServiceEndpoint?serviceClass=#helloServiceImpl");      
    assertEquals("org.apache.camel.component.cxf.HelloServiceImpl",
                 endpoint.getServiceClass().getName());
}
项目:Camel    文件:CxfEndpointUtilsWithSpringTest.java   
@Test
public void testGetDataFormatFromCxfEndpontProperties() throws Exception {
    CxfEndpoint endpoint = createEndpoint(getEndpointURI() + "?dataFormat=PAYLOAD");
    assertEquals("We should get the PAYLOAD DataFormat", DataFormat.PAYLOAD, endpoint.getDataFormat());
}