Search in sources :

Example 16 with Greeter

use of org.apache.hello_world.Greeter in project cxf by apache.

the class SSLv3Test method testClientSSL3Allowed.

@org.junit.Test
public void testClientSSL3Allowed() throws Exception {
    // Doesn't work with IBM JDK
    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SSLv3Test.class.getResource("sslv3-client-allow.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, PORT3);
    assertEquals(port.greetMe("Kitty"), "Hello Kitty");
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL)

Example 17 with Greeter

use of org.apache.hello_world.Greeter in project cxf by apache.

the class SSLv3Test method testAsyncClientSSL3NotAllowed.

@org.junit.Test
public void testAsyncClientSSL3NotAllowed() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SSLv3Test.class.getResource("sslv3-client.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);
    // Enable Async
    ((BindingProvider) port).getRequestContext().put("use.async.http.conduit", true);
    updateAddressPort(port, PORT3);
    try {
        port.greetMe("Kitty");
        fail("Failure expected on the client not supporting SSLv3 by default");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL) IOException(java.io.IOException)

Example 18 with Greeter

use of org.apache.hello_world.Greeter in project cxf by apache.

the class HTTPConduitTest method testLogLevelIssueCXF3466.

@Test
public void testLogLevelIssueCXF3466() throws Exception {
    startServer("Mortimer");
    Greeter mortimer = getMortimerGreeter();
    Logger rootLogger = LogManager.getLogManager().getLogger("");
    Level oldLevel = rootLogger.getLevel();
    rootLogger.setLevel(Level.FINE);
    try {
        // Will throw exception Stream is closed if bug is present
        mortimer.sayHi();
    } finally {
        rootLogger.setLevel(oldLevel);
    }
    assertProxyRequestCount(1);
}
Also used : Greeter(org.apache.hello_world.Greeter) Level(java.util.logging.Level) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 19 with Greeter

use of org.apache.hello_world.Greeter in project cxf by apache.

the class HTTPConduitTest method testHttp2HttpLoopRedirectFail.

/**
 * This methods tests that a redirection loop will fail.
 * Hurlon redirects to Abost, which redirects to Hurlon.
 *
 * Note: Unfortunately, the invocation may "fail" for any
 * number of reasons.
 */
@Test
public void testHttp2HttpLoopRedirectFail() throws Exception {
    startServer("Abost");
    startServer("Hurlon");
    URL config = getClass().getResource("Http2HttpLoopRedirectFail.cxf");
    // We go through the back door, setting the default bus.
    new DefaultBusFactory().createBus(config);
    URL wsdl = getClass().getResource("greeting.wsdl");
    assertNotNull("WSDL is null", wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull("Service is null", service);
    Greeter hurlon = service.getPort(hurlonQ, Greeter.class);
    assertNotNull("Port is null", hurlon);
    updateAddressPort(hurlon, getPort("PORT3"));
    configureProxy(ClientProxy.getClient(hurlon));
    String answer = null;
    try {
        answer = hurlon.sayHi();
        fail("Redirect didn't fail. Got answer: " + answer);
    } catch (Exception e) {
    // This exception will be one of not being able to
    // read from the StreamReader
    // e.printStackTrace();
    }
    assertProxyRequestCount(2);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) Test(org.junit.Test)

Example 20 with Greeter

use of org.apache.hello_world.Greeter in project cxf by apache.

the class DigestAuthTest method testDigestAuth.

@Test
public void testDigestAuth() throws Exception {
    URL wsdl = getClass().getResource("../greeting.wsdl");
    assertNotNull("WSDL is null", wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull("Service is null", service);
    Greeter mortimer = service.getPort(mortimerQ, Greeter.class);
    assertNotNull("Port is null", mortimer);
    TestUtil.setAddress(mortimer, "http://localhost:" + PORT + "/digestauth/greeter");
    Client client = ClientProxy.getClient(mortimer);
    HTTPConduit http = (HTTPConduit) client.getConduit();
    AuthorizationPolicy authPolicy = new AuthorizationPolicy();
    authPolicy.setAuthorizationType("Digest");
    authPolicy.setUserName("foo");
    authPolicy.setPassword("bar");
    http.setAuthorization(authPolicy);
    String answer = mortimer.sayHi();
    assertEquals("Unexpected answer: " + answer, "Hi", answer);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Greeter(org.apache.hello_world.Greeter) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Greeter (org.apache.hello_world.Greeter)63 URL (java.net.URL)57 SOAPService (org.apache.hello_world.services.SOAPService)57 Bus (org.apache.cxf.Bus)42 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)40 Test (org.junit.Test)19 Client (org.apache.cxf.endpoint.Client)14 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)14 CertificateException (java.security.cert.CertificateException)9 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)8 TrustManager (javax.net.ssl.TrustManager)7 X509TrustManager (javax.net.ssl.X509TrustManager)7 IOException (java.io.IOException)5 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)5 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)4 GeneralSecurityException (java.security.GeneralSecurityException)3 BindingProvider (javax.xml.ws.BindingProvider)3 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)3 UntrustedURLConnectionIOException (org.apache.cxf.transport.http.UntrustedURLConnectionIOException)3 MalformedURLException (java.net.MalformedURLException)2