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