use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class HTTPConduitTestCase method testWrapperWithMap.
@Test
@RunAsClient
public void testWrapperWithMap() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.CXF_CLIENT_ALLOW_CHUNKING, true);
map.put(Constants.CXF_CLIENT_CHUNKING_THRESHOLD, 8192);
map.put(Constants.CXF_CLIENT_CONNECTION_TIMEOUT, 16384L);
map.put(Constants.CXF_CLIENT_RECEIVE_TIMEOUT, 163840L);
map.put(Constants.CXF_TLS_CLIENT_DISABLE_CN_CHECK, true);
replaceWrapper(map, bus);
URL wsdlURL = new URL(baseURL + "/ServiceOne" + "?wsdl");
Service service = Service.create(wsdlURL, new QName("http://org.jboss.ws.jaxws.cxf/httpConduit", "ServiceOne"));
EndpointOne port = service.getPort(new QName("http://org.jboss.ws.jaxws.cxf/httpConduit", "EndpointOnePort"), EndpointOne.class);
HTTPConduit conduit = (HTTPConduit) ClientProxy.getClient(port).getConduit();
HTTPClientPolicy client = conduit.getClient();
assertNotNull(client);
assertEquals(true, client.isAllowChunking());
assertEquals(8192, client.getChunkingThreshold());
assertEquals(16384, client.getConnectionTimeout());
assertEquals(163840, client.getReceiveTimeout());
assertEquals(true, conduit.getTlsClientParameters().isDisableCNCheck());
assertEquals("Foo", port.echo("Foo"));
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class HelloDigestTestCase method testDigestAuthFail.
@Test
@RunAsClient
public void testDigestAuthFail() throws Exception {
final Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
QName serviceName = new QName("http://jboss.org/http/security", "HelloService");
URL wsdlURL = getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
Hello proxy = (Hello) service.getPort(Hello.class);
((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toString());
((BindingProvider) proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jbossws");
((BindingProvider) proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "wrongPwd");
HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(proxy).getConduit();
cond.setAuthSupplier(new DigestAuthSupplier());
try {
proxy.helloRequest("number");
fail("Authorization exception expected!");
} catch (Exception e) {
assertTrue(e.getCause().getMessage().contains("Authorization"));
}
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class HTTPProxyTestCaseForked method testHttpProxy.
@Test
@RunAsClient
public void testHttpProxy() throws Exception {
if (checkNativeLibraries()) {
initProxyServer();
} else {
return;
}
final String testHost = "unreachable-testHttpProxy";
HelloWorld port = getPort(getResourceURL("jaxws/cxf/httpproxy/HelloWorldService.wsdl"), testHost);
final String hi = "Hi!";
// first try without setting up the proxy -> request fails because the host is not known/reachable
try {
port.echo(hi);
fail("Exception expected");
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains(testHost));
}
// then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
setProxySystemProperties();
port = getPort(getResourceURL("jaxws/cxf/httpproxy/HelloWorldService.wsdl"), testHost);
try {
port.echo(hi);
fail("Exception expected");
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
}
// finally setup everything
port = getPort(getResourceURL("jaxws/cxf/httpproxy/HelloWorldService.wsdl"), testHost);
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
ProxyAuthorizationPolicy policy = new ProxyAuthorizationPolicy();
policy.setAuthorizationType("Basic");
policy.setUserName(PROXY_USER);
policy.setPassword(PROXY_PWD);
conduit.setProxyAuthorization(policy);
assertEquals(hi, port.echo(hi));
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class HTTPProxyTestCaseForked method testHttpProxyUsingHTTPClientPolicy.
@Test
@RunAsClient
public void testHttpProxyUsingHTTPClientPolicy() throws Exception {
if (checkNativeLibraries()) {
initProxyServer();
} else {
return;
}
final String testHost = "unreachable-testHttpProxyUsingHTTPClientPolicy";
HelloWorld port = getPort(getResourceURL("jaxws/cxf/httpproxy/HelloWorldService.wsdl"), testHost);
final String hi = "Hi!";
// first try without setting up the proxy -> request fails because the host is not known/reachable
try {
port.echo(hi);
fail("Exception expected");
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains(testHost));
}
// then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy clientPolicy = conduit.getClient();
clientPolicy.setProxyServerType(ProxyServerType.HTTP);
clientPolicy.setProxyServer(getServerHost());
clientPolicy.setProxyServerPort(proxyPort);
try {
port.echo(hi);
fail("Exception expected");
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
}
// finally setup authorization info too
ProxyAuthorizationPolicy authPolicy = new ProxyAuthorizationPolicy();
authPolicy.setAuthorizationType("Basic");
authPolicy.setUserName(PROXY_USER);
authPolicy.setPassword(PROXY_PWD);
conduit.setProxyAuthorization(authPolicy);
assertEquals(hi, port.echo(hi));
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class Helper method testGZIPServerSideOnlyInterceptorOnClient.
public boolean testGZIPServerSideOnlyInterceptorOnClient() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
HelloWorld port = getPort();
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = conduit.getClient();
// enable Accept gzip, otherwise the server will not try to reply using gzip
policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
// add interceptor for decoding gzip message
ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
configurer.setConfigProperties(port, "jaxws-client-config.xml", "Interceptor Client Config");
return ("foo".equals(port.echo("foo")));
} finally {
bus.shutdown(true);
}
}
Aggregations