Search in sources :

Example 6 with Bus

use of org.apache.cxf.Bus 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 7 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class CxfProducerSessionTest method startServer.

@BeforeClass
public static void startServer() throws Exception {
    // start a simple front service
    JaxWsServiceFactoryBean svrFBean = new JaxWsServiceFactoryBean();
    svrFBean.setServiceClass(EchoService.class);
    JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean(svrFBean);
    svrBean.setAddress(SIMPLE_SERVER_ADDRESS);
    svrBean.setServiceClass(EchoService.class);
    svrBean.setServiceBean(new EchoServiceSessionImpl());
    // make the Jetty server support sessions
    Bus bus = BusFactory.newInstance().createBus();
    JettyHTTPServerEngineFactory jettyFactory = bus.getExtension(JettyHTTPServerEngineFactory.class);
    jettyFactory.createJettyHTTPServerEngine(PORT, "http").setSessionSupport(true);
    svrBean.setBus(bus);
    svrBean.create();
}
Also used : Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) BeforeClass(org.junit.BeforeClass)

Example 8 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class WSSecurityRouteTest method testSignature.

@Test
public void testSignature() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterSignaturePort();
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterSignaturePort");
    assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.camel.hello_world_soap_http.Greeter) GreeterService(org.apache.camel.hello_world_soap_http.GreeterService) URL(java.net.URL) Test(org.junit.Test)

Example 9 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class WSSecurityRouteTest method testEncryption.

@Test
public void testEncryption() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterEncryptionPort();
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterEncryptionPort");
    assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.camel.hello_world_soap_http.Greeter) GreeterService(org.apache.camel.hello_world_soap_http.GreeterService) URL(java.net.URL) Test(org.junit.Test)

Example 10 with Bus

use of org.apache.cxf.Bus in project camel by apache.

the class Server method prepare.

public void prepare() throws Exception {
    // Set a system property used to configure the server.  The examples all run on port 9091; 
    // however, the unit tests must run on a dynamic port.  As such, we make the port configurable
    // in the Spring context.
    System.setProperty("port", "9001");
    // setup the Camel context for the Camel transport
    // START SNIPPET: e1
    SpringBusFactory bf = new SpringBusFactory();
    BusFactory.setDefaultBus(null);
    Bus bus = bf.createBus("/org/apache/camel/example/camel/transport/CamelDestination.xml");
    BusFactory.setDefaultBus(bus);
// END SNIPPET: e1
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory)

Aggregations

Bus (org.apache.cxf.Bus)57 Test (org.junit.Test)31 URL (java.net.URL)19 QName (javax.xml.namespace.QName)15 Service (javax.xml.ws.Service)12 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)11 Exchange (org.apache.cxf.message.Exchange)9 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)9 Message (org.apache.cxf.message.Message)9 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 ServiceIface (org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface)7 IOException (java.io.IOException)6 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 CamelContext (org.apache.camel.CamelContext)4 Message (org.apache.camel.Message)4 Greeter (org.apache.camel.hello_world_soap_http.Greeter)4 GreeterService (org.apache.camel.hello_world_soap_http.GreeterService)4