Search in sources :

Example 21 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class JettyHTTPDestinationTest method testRandomPortAllocation.

@Test
public void testRandomPortAllocation() throws Exception {
    bus = BusFactory.getDefaultBus(true);
    transportFactory = new HTTPTransportFactory();
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));
    Destination d1 = transportFactory.getDestination(ei, bus);
    URL url = new URL(d1.getAddress().getAddress().getValue());
    assertTrue("No random port has been allocated", url.getPort() > 0);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(org.apache.cxf.transport.Destination) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) URL(java.net.URL) Test(org.junit.Test)

Example 22 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class JettyHTTPDestinationTest method testContinuationsIgnored.

@Test
public void testContinuationsIgnored() throws Exception {
    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));
    final JettyHTTPServerEngine httpEngine = new JettyHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    JettyHTTPServerEngineFactory factory = new JettyHTTPServerEngineFactory() {

        @Override
        public JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, JettyHTTPServerEngineFactory.class);
    TestJettyDestination testDestination = new TestJettyDestination(b2, transportFactory.getRegistry(), ei, factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 23 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class NettyHttpDestinationTest method testRandomPortAllocation.

@Test
public void testRandomPortAllocation() throws Exception {
    bus = BusFactory.getDefaultBus();
    transportFactory = new HTTPTransportFactory();
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));
    Destination d1 = transportFactory.getDestination(ei, bus);
    URL url = new URL(d1.getAddress().getAddress().getValue());
    assertTrue("No random port has been allocated", url.getPort() > 0);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(org.apache.cxf.transport.Destination) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) URL(java.net.URL) Test(org.junit.Test)

Example 24 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class NettyHttpDestinationTest method testGetMultiple.

@Test
public void testGetMultiple() throws Exception {
    transportFactory = new HTTPTransportFactory();
    bus = BusFactory.getDefaultBus();
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));
    ei.setAddress("http://foo");
    Destination d1 = transportFactory.getDestination(ei, bus);
    Destination d2 = transportFactory.getDestination(ei, bus);
    // Second get should not generate a new destination. It should just retrieve the existing one
    assertEquals(d1, d2);
    d2.shutdown();
    Destination d3 = transportFactory.getDestination(ei, bus);
    // Now a new destination should have been created
    assertNotSame(d1, d3);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(org.apache.cxf.transport.Destination) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Example 25 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class NettyHttpDestinationTest method testContinuationsIgnored.

@Test
public void testContinuationsIgnored() throws Exception {
    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));
    // Just create a fake engine
    final NettyHttpServerEngine httpEngine = new NettyHttpServerEngine("localhost", 8080);
    // httpEngine.setContinuationsEnabled(false);
    NettyHttpServerEngineFactory factory = new NettyHttpServerEngineFactory() {

        @Override
        public NettyHttpServerEngine retrieveNettyHttpServerEngine(int port) {
            return httpEngine;
        }
    };
    transportFactory = new HTTPTransportFactory();
    bus = BusFactory.getDefaultBus();
    bus.setExtension(factory, NettyHttpServerEngineFactory.class);
    TestJettyDestination testDestination = new TestJettyDestination(bus, transportFactory.getRegistry(), ei, factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Aggregations

HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)28 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)23 Test (org.junit.Test)22 QName (javax.xml.namespace.QName)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)15 Bus (org.apache.cxf.Bus)14 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)14 DestinationRegistry (org.apache.cxf.transport.http.DestinationRegistry)10 AbstractHTTPDestination (org.apache.cxf.transport.http.AbstractHTTPDestination)7 URL (java.net.URL)6 Message (org.apache.cxf.message.Message)6 Destination (org.apache.cxf.transport.Destination)6 AtmosphereInterceptor (org.atmosphere.cpr.AtmosphereInterceptor)6 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HashSet (java.util.HashSet)3 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)3 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)3 MessageObserver (org.apache.cxf.transport.MessageObserver)3 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)3