Search in sources :

Example 26 with HTTPTransportFactory

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

the class UndertowHTTPDestinationTest 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 27 with HTTPTransportFactory

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

the class UndertowHTTPDestinationTest 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 UndertowHTTPServerEngine httpEngine = new UndertowHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    UndertowHTTPServerEngineFactory factory = new UndertowHTTPServerEngineFactory() {

        @Override
        public UndertowHTTPServerEngine retrieveUndertowHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, UndertowHTTPServerEngineFactory.class);
    TestUndertowDestination testDestination = new TestUndertowDestination(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 28 with HTTPTransportFactory

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

the class UndertowHTTPDestinationTest method testServerPolicyInServiceModel.

@Test
public void testServerPolicyInServiceModel() throws Exception {
    policy = new HTTPServerPolicy();
    address = getEPR("bar/foo");
    bus = BusFactory.getDefaultBus(true);
    transportFactory = new HTTPTransportFactory();
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    endpointInfo = new EndpointInfo(serviceInfo, "");
    endpointInfo.setName(new QName("bla", "Port"));
    endpointInfo.addExtensor(policy);
    engine = EasyMock.createMock(UndertowHTTPServerEngine.class);
    EasyMock.replay();
    endpointInfo.setAddress(NOWHERE + "bar/foo");
    UndertowHTTPDestination dest = new EasyMockUndertowHTTPDestination(bus, transportFactory.getRegistry(), endpointInfo, null, engine);
    assertEquals(policy, dest.getServer());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) HTTPServerPolicy(org.apache.cxf.transports.http.configuration.HTTPServerPolicy) 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