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);
}
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();
}
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"));
}
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"));
}
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
}
Aggregations