use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HTTPConduitTest method testGetTarget.
/**
* This test verfies that the "getTarget() call returns the correct
* EndpointReferenceType for the given endpoint address.
*/
@Test
public void testGetTarget() throws Exception {
Bus bus = new ExtensionManagerBus();
EndpointInfo ei = new EndpointInfo();
ei.setAddress("http://nowhere.com/bar/foo");
HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
conduit.finalizeConfig();
EndpointReferenceType target = EndpointReferenceUtils.getEndpointReference("http://nowhere.com/bar/foo");
// Test call
EndpointReferenceType ref = conduit.getTarget();
assertNotNull("unexpected null target", ref);
assertEquals("unexpected target", EndpointReferenceUtils.getAddress(ref), EndpointReferenceUtils.getAddress(target));
assertEquals("unexpected address", conduit.getAddress(), "http://nowhere.com/bar/foo");
assertEquals("unexpected on-demand URL", conduit.getURI().getPath(), "/bar/foo");
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HTTPConduitTest method testHandleResponseOnWorkqueueAllowCurrentThread.
@Test
public void testHandleResponseOnWorkqueueAllowCurrentThread() throws Exception {
Message m = getNewMessage();
Exchange exchange = new ExchangeImpl();
Bus bus = new ExtensionManagerBus();
exchange.put(Bus.class, bus);
EndpointInfo endpointInfo = new EndpointInfo();
Endpoint endpoint = new EndpointImpl(null, null, endpointInfo);
exchange.put(Endpoint.class, endpoint);
m.setExchange(exchange);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setAsyncExecuteTimeoutRejection(true);
m.put(HTTPClientPolicy.class, policy);
exchange.put(Executor.class, new Executor() {
@Override
public void execute(Runnable command) {
// forces us to use current thread
throw new RejectedExecutionException("expected");
}
});
HTTPConduit conduit = new MockHTTPConduit(bus, endpointInfo, policy);
OutputStream os = conduit.createOutputStream(m, false, false, 0);
assertTrue(os instanceof WrappedOutputStream);
WrappedOutputStream wos = (WrappedOutputStream) os;
try {
wos.handleResponseOnWorkqueue(true, false);
assertEquals(Thread.currentThread(), m.get(Thread.class));
try {
wos.handleResponseOnWorkqueue(false, false);
fail("Expected RejectedExecutionException not thrown");
} catch (RejectedExecutionException ex) {
assertEquals("expected", ex.getMessage());
}
} catch (Exception ex) {
throw ex;
}
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HttpConduitConfigApplierTest method testTrustVerificationEnabled.
@Test
public void testTrustVerificationEnabled() throws IOException {
HttpConduitConfigApplier configApplier = new HttpConduitConfigApplier();
Dictionary<String, String> configValues = new Hashtable<>();
configValues.put("tlsClientParameters.disableCNCheck", "true");
configValues.put("tlsClientParameters.trustManagers.disableTrustVerification", "false");
String address = "https://localhost:12345";
Bus bus = new ExtensionManagerBus();
EndpointInfo ei = new EndpointInfo();
ei.setAddress(address);
HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
configApplier.apply(configValues, conduit, address);
assertNotNull(conduit.getTlsClientParameters().getTrustManagers());
assertEquals(conduit.getTlsClientParameters().getTrustManagers().length, 1);
assertFalse(conduit.getTlsClientParameters().getTrustManagers()[0].getClass().getName().startsWith(InsecureTrustManager.class.getName()));
assertTrue(conduit.getTlsClientParameters().isDisableCNCheck());
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HttpConduitConfigApplierTest method testNormalTrustLoading.
@Test
public void testNormalTrustLoading() throws IOException {
HttpConduitConfigApplier configApplier = new HttpConduitConfigApplier();
Dictionary<String, String> configValues = new Hashtable<>();
configValues.put("tlsClientParameters.disableCNCheck", "false");
String address = "https://localhost:12345";
Bus bus = new ExtensionManagerBus();
EndpointInfo ei = new EndpointInfo();
ei.setAddress(address);
HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
configApplier.apply(configValues, conduit, address);
assertNull(conduit.getTlsClientParameters().getTrustManagers());
assertFalse(conduit.getTlsClientParameters().isDisableCNCheck());
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HttpConduitConfigApplierTest method testDisableTrustVerification.
@Test
public void testDisableTrustVerification() throws IOException {
HttpConduitConfigApplier configApplier = new HttpConduitConfigApplier();
Dictionary<String, String> configValues = new Hashtable<>();
configValues.put("tlsClientParameters.disableCNCheck", "true");
configValues.put("tlsClientParameters.trustManagers.disableTrustVerification", "true");
String address = "https://localhost:12345";
Bus bus = new ExtensionManagerBus();
EndpointInfo ei = new EndpointInfo();
ei.setAddress(address);
HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
configApplier.apply(configValues, conduit, address);
assertNotNull(conduit.getTlsClientParameters().getTrustManagers());
assertEquals(conduit.getTlsClientParameters().getTrustManagers().length, 1);
assertTrue(conduit.getTlsClientParameters().getTrustManagers()[0].getClass().getName().startsWith(InsecureTrustManager.class.getName()));
assertTrue(conduit.getTlsClientParameters().isDisableCNCheck());
}
Aggregations