use of org.apache.hello_world.Greeter in project cxf by apache.
the class ClientAuthTest method testInvalidChainTrust.
// Server does not trust the issuer of the client cert
@org.junit.Test
public void testInvalidChainTrust() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ClientAuthTest.class.getResource("client-auth-invalid2.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL url = SOAPService.WSDL_LOCATION;
SOAPService service = new SOAPService(url, SOAPService.SERVICE);
assertNotNull("Service is null", service);
final Greeter port = service.getHttpsPort();
assertNotNull("Port is null", port);
updateAddressPort(port, PORT2);
try {
port.greetMe("Kitty");
fail("Failure expected on no trusted cert");
} catch (Exception ex) {
// expected
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class ClientAuthTest method testClientInvalidCertChain.
// Client does not trust the issuer of the server cert
@org.junit.Test
public void testClientInvalidCertChain() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ClientAuthTest.class.getResource("client-auth-invalid2.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL url = SOAPService.WSDL_LOCATION;
SOAPService service = new SOAPService(url, SOAPService.SERVICE);
assertNotNull("Service is null", service);
final Greeter port = service.getHttpsPort();
assertNotNull("Port is null", port);
updateAddressPort(port, PORT);
try {
port.greetMe("Kitty");
fail("Failure expected on no trusted cert");
} catch (Exception ex) {
// expected
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class HTTPSClientTest method testSuccessfulCall.
public final void testSuccessfulCall(String configuration, String address, URL url, boolean dynamicClient) throws Exception {
setTheConfiguration(configuration);
startServers();
if (url == null) {
url = SOAPService.WSDL_LOCATION;
}
// CXF-4037 - dynamic client isn't using the conduit settings to resolve schemas
if (dynamicClient) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
JaxWsDynamicClientFactory.newInstance(BusFactory.getDefaultBus()).createClient(url.toExternalForm());
Thread.currentThread().setContextClassLoader(loader);
}
SOAPService service = new SOAPService(url, SOAPService.SERVICE);
assertNotNull("Service is null", service);
final Greeter port = service.getHttpsPort();
assertNotNull("Port is null", port);
BindingProvider provider = (BindingProvider) port;
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
// for (int x = 0; x < 100000; x++) {
assertEquals(port.greetMe("Kitty"), "Hello Kitty");
// }
stopServers();
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class HTTPSConduitTest method testHttpsBasicConnection.
/**
* This methods tests a basic https connection to Bethal.
* It supplies an authorization policy with premetive user/pass
* to avoid the 401.
*/
@Test
public void testHttpsBasicConnection() throws Exception {
startServer("Bethal");
URL wsdl = getClass().getResource("greeting.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
Greeter bethal = service.getPort(bethalQ, Greeter.class);
assertNotNull("Port is null", bethal);
updateAddressPort(bethal, getPort("PORT4"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
Client client = ClientProxy.getClient(bethal);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAutoRedirect(false);
// If we set any name, but Edward, Mary, or George,
// and a password of "password" we will get through
// Bethal.
AuthorizationPolicy authPolicy = new AuthorizationPolicy();
authPolicy.setUserName("Betty");
authPolicy.setPassword("password");
http.setClient(httpClientPolicy);
http.setTlsClientParameters(tlsClientParameters);
http.setAuthorization(authPolicy);
configureProxy(client);
String answer = bethal.sayHi();
assertTrue("Unexpected answer: " + answer, "Bonjour from Bethal".equals(answer));
assertProxyRequestCount(0);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class HTTPSConduitTest method testGetClientFromSpringContext.
@Test
public void testGetClientFromSpringContext() throws Exception {
startServer("Bethal");
BusFactory.setDefaultBus(null);
// The client bean configuration file
URL beans = getClass().getResource("BethalClientBeans.xml");
// We go through the back door, setting the default bus.
Bus bus = new DefaultBusFactory().createBus(beans);
ApplicationContext context = bus.getExtension(BusApplicationContext.class);
Greeter bethal = (Greeter) context.getBean("Bethal");
updateAddressPort(bethal, getPort("PORT4"));
// verify the client side's setting
verifyBethalClient(bethal);
}
Aggregations