Search in sources :

Example 6 with JettyHTTPServerEngine

use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine in project camel by apache.

the class CxfCustomerStartStopTest method startAndStopServiceFromSpring.

@Test
public void startAndStopServiceFromSpring() throws Exception {
    System.setProperty("CamelCxfConsumerContext.port2", Integer.toString(PORT2));
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CamelCxfConsumerContext.xml");
    Bus bus = applicationContext.getBean("cxf", Bus.class);
    // Bus shutdown will be called when the application context is closed.
    String orig = System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "false");
    IOHelper.close(applicationContext);
    System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", orig == null ? "true" : "false");
    JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
    // test if the port is still used
    JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT2);
    assertNull("Jetty engine should be removed", engine);
}
Also used : Bus(org.apache.cxf.Bus) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) Test(org.junit.Test)

Example 7 with JettyHTTPServerEngine

use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine in project cxf by apache.

the class ApplicationContextTest method checkContext.

private void checkContext(TestApplicationContext ctx) throws Exception {
    ConfigurerImpl cfg = new ConfigurerImpl(ctx);
    EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
    Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
    bus.setExtension(cfg, Configurer.class);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    DestinationFactory factory = dfm.getDestinationFactory("http://cxf.apache.org/transports/http");
    Destination d = factory.getDestination(info, bus);
    assertTrue(d instanceof JettyHTTPDestination);
    JettyHTTPDestination jd = (JettyHTTPDestination) d;
    assertEquals("foobar", jd.getServer().getContentEncoding());
    JettyHTTPServerEngine engine = (JettyHTTPServerEngine) jd.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    ConduitInitiator ci = cim.getConduitInitiator("http://cxf.apache.org/transports/http");
    HTTPConduit conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(97, conduit.getClient().getConnectionTimeout());
    info.setName(new QName("urn:test:ns", "Bar"));
    conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(79, conduit.getClient().getConnectionTimeout());
    JettyHTTPDestination jd2 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
    engine = (JettyHTTPServerEngine) jd2.getEngine();
    assertEquals(40000, engine.getMaxIdleTime());
    assertFalse(engine.getSendServerVersion());
    assertEquals(99, engine.getThreadingParameters().getMinThreads());
    assertEquals(777, engine.getThreadingParameters().getMaxThreads());
    assertEquals("AnotherPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    assertEquals("session timeout should be 600 secs", 600, engine.getSessionTimeout());
    assertTrue("The engine should support session manager", engine.isSessionSupport());
    assertNotNull("The handlers should not be null", engine.getHandlers());
    assertEquals(1, engine.getHandlers().size());
    JettyHTTPDestination jd3 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
    engine = (JettyHTTPServerEngine) jd3.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    assertTrue(engine.getTlsServerParameters().getClientAuthentication().isWant());
    assertTrue(engine.getTlsServerParameters().getClientAuthentication().isRequired());
    JettyHTTPDestination jd4 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
    engine = (JettyHTTPServerEngine) jd4.getEngine();
    assertFalse(engine.getTlsServerParameters().getClientAuthentication().isWant());
    assertFalse(engine.getTlsServerParameters().getClientAuthentication().isRequired());
    JettyHTTPDestination jd5 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
    engine = (JettyHTTPServerEngine) jd5.getEngine();
    String r = "expected fallback thread parameters configured for port 0";
    assertNotNull(r, engine.getThreadingParameters());
    assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
    assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) QName(javax.xml.namespace.QName) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination)

Example 8 with JettyHTTPServerEngine

use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine in project cxf by apache.

the class JettyWebSocketDestinationTest method testRegisteration.

@Test
public void testRegisteration() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);
    JettyHTTPServerEngine engine = EasyMock.createMock(JettyHTTPServerEngine.class);
    control.replay();
    TestJettyWebSocketDestination dest = new TestJettyWebSocketDestination(bus, registry, endpoint, null, engine);
    dest.activate();
    assertNotNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
    dest.deactivate();
    assertNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationRegistry(org.apache.cxf.transport.http.DestinationRegistry) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 9 with JettyHTTPServerEngine

use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine in project cxf by apache.

the class EngineLifecycleTest method testUpDownWithServlets.

@Test
public void testUpDownWithServlets() throws Exception {
    setUpBus();
    Bus bus = (Bus) applicationContext.getBean("cxf");
    ServerRegistry sr = bus.getExtension(ServerRegistry.class);
    ServerImpl si = (ServerImpl) sr.getServers().get(0);
    JettyHTTPDestination jhd = (JettyHTTPDestination) si.getDestination();
    JettyHTTPServerEngine e = (JettyHTTPServerEngine) jhd.getEngine();
    org.eclipse.jetty.server.Server jettyServer = e.getServer();
    for (Handler h : jettyServer.getChildHandlersByClass(WebAppContext.class)) {
        WebAppContext wac = (WebAppContext) h;
        if ("/jsunit".equals(wac.getContextPath())) {
            wac.addServlet("org.eclipse.jetty.servlet.DefaultServlet", "/bloop");
            break;
        }
    }
    try {
        verifyStaticHtml();
        invokeService();
    } finally {
        shutdownService();
    }
}
Also used : Bus(org.apache.cxf.Bus) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) ServerImpl(org.apache.cxf.endpoint.ServerImpl) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) Handler(org.eclipse.jetty.server.Handler) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination) Test(org.junit.Test)

Aggregations

JettyHTTPServerEngine (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine)9 Bus (org.apache.cxf.Bus)6 JettyHTTPServerEngineFactory (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory)4 Test (org.junit.Test)4 JettyHTTPDestination (org.apache.cxf.transport.http_jetty.JettyHTTPDestination)3 ArrayList (java.util.ArrayList)2 TLSServerParameters (org.apache.cxf.configuration.jsse.TLSServerParameters)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 Handler (org.eclipse.jetty.server.Handler)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 GeneralSecurityException (java.security.GeneralSecurityException)1 TreeMap (java.util.TreeMap)1 RuntimeDelegate (javax.ws.rs.ext.RuntimeDelegate)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 QName (javax.xml.namespace.QName)1 CamelContext (org.apache.camel.CamelContext)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1