Search in sources :

Example 36 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.

the class JavaFirstPolicyServiceTest method testOperationClientCertAlternativePolicy.

@Test
public void testOperationClientCertAlternativePolicy() {
    System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
    ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/cxf/systest/ws/policy/sslcertclient.xml" });
    OperationSimpleService simpleService = clientContext.getBean("OperationSimpleServiceClient", OperationSimpleService.class);
    // no security on ping!
    simpleService.ping();
    try {
        simpleService.doStuff();
        fail("Expected exception as no credentials");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    WSS4JOutInterceptor wssOut = addToClient(simpleService);
    wssOut.setProperties(getNoPasswordProperties("alice"));
    simpleService.doStuff();
    // this is successful because the alternative policy allows a password to be specified.
    wssOut.setProperties(getPasswordProperties("alice", "password"));
    simpleService.doStuff();
    clientContext.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) OperationSimpleService(org.apache.cxf.systest.ws.policy.javafirst.OperationSimpleService) NoAlternativesOperationSimpleService(org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleService) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Test(org.junit.Test)

Example 37 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.

the class JavaFirstPolicyServiceTest method testBindingNoClientCertAlternativePolicy.

@Test
public void testBindingNoClientCertAlternativePolicy() {
    System.setProperty("testutil.ports.JavaFirstPolicyServer", PORT);
    ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/cxf/systest/ws/policy/sslnocertclient.xml" });
    BindingSimpleService simpleService = clientContext.getBean("BindingSimpleServiceClient", BindingSimpleService.class);
    try {
        simpleService.doStuff();
        fail("Expected exception as no credentials");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    WSS4JOutInterceptor wssOut = addToClient(simpleService);
    wssOut.setProperties(getNoPasswordProperties("alice"));
    try {
        simpleService.doStuff();
        fail("Expected exception as no password and no client cert");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    wssOut.setProperties(getPasswordProperties("alice", "password"));
    simpleService.doStuff();
    clientContext.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BindingSimpleService(org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Test(org.junit.Test)

Example 38 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.

the class WSRM12ServerCycleTest method runTest.

public void runTest(String cfg, boolean faultOnRestart) throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    ControlService cs = new ControlService();
    Control control = cs.getControlPort();
    ConnectionHelper.setKeepAliveConnection(control, false, true);
    updateAddressPort(control, PORT);
    Assert.assertTrue("Failed to start greeter", control.startGreeter(cfg));
    System.setProperty("db.name", getPrefix() + "-recovery");
    Bus greeterBus = new SpringBusFactory().createBus();
    System.clearProperty("db.name");
    BusFactory.setDefaultBus(greeterBus);
    // avoid early client resends
    greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterPort(new LoggingFeature(), new AddressingFeature(), wsrm());
    updateAddressPort(greeter, PORT);
    greeter.greetMe("one");
    greeter.greetMe("two");
    greeter.greetMe("three");
    control.stopGreeter(cfg);
    // make sure greeter is down
    Thread.sleep(1000);
    control.startGreeter(cfg);
    // CXF-7392
    if (faultOnRestart) {
        try {
            greeter.greetMe("four");
        } catch (SOAPFaultException ex) {
            assertTrue(ex.getMessage().contains("wsrm:Identifier"));
        // expected, sequence identifier doesn't exist on other side
        }
    } else {
        // this should work as the sequence should be recovered on the server side
        greeter.greetMe("four");
    }
    ((Closeable) greeter).close();
    greeterBus.shutdown(true);
    control.stopGreeter(cfg);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) Control(org.apache.cxf.greeter_control.Control) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) AddressingFeature(javax.xml.ws.soap.AddressingFeature) ControlService(org.apache.cxf.greeter_control.ControlService) Greeter(org.apache.cxf.greeter_control.Greeter) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Closeable(java.io.Closeable) GreeterService(org.apache.cxf.greeter_control.GreeterService) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Example 39 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.

the class BraveTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault.

@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault() throws MalformedURLException {
    final Tracing brave = Tracing.newBuilder().localServiceName("book-store").reporter(new TestSpanReporter()).build();
    final BookStoreService service = createJaxWsService(new Configurator() {

        @Override
        public void configure(final JaxWsProxyFactoryBean factory) {
            factory.getFeatures().add(new BraveClientFeature(brave));
            factory.getOutInterceptors().add(new LoggingOutInterceptor());
            factory.getInInterceptors().add(new LoggingInInterceptor());
        }
    });
    try {
        service.removeBooks();
        fail("Expected SOAPFaultException to be raised");
    } catch (final SOAPFaultException ex) {
    /* expected exception */
    }
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans().get(0).name, equalTo("post /bookstore"));
    assertThat(TestSpanReporter.getAllSpans().get(1).name, equalTo("post http://localhost:" + PORT + "/bookstore"));
    final Map<String, List<String>> response = getResponseHeaders(service);
    assertThatTraceHeadersArePresent(response, false);
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) TestSpanReporter(org.apache.cxf.systest.brave.TestSpanReporter) BraveClientFeature(org.apache.cxf.tracing.brave.BraveClientFeature) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) List(java.util.List) Tracing(brave.Tracing) Test(org.junit.Test)

Example 40 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.

the class OpenTracingTracingTest method testThatNewSpanIsCreatedInCaseOfFault.

@Test
public void testThatNewSpanIsCreatedInCaseOfFault() throws MalformedURLException {
    final BookStoreService service = createJaxWsService();
    try {
        service.removeBooks();
        fail("Expected SOAPFaultException to be raised");
    } catch (final SOAPFaultException ex) {
    /* expected exception */
    }
    assertThat(TestSender.getAllSpans().size(), equalTo(1));
    assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("POST /BookStore"));
}
Also used : BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Aggregations

SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)97 Test (org.junit.Test)47 QName (javax.xml.namespace.QName)33 URL (java.net.URL)22 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 Test (org.testng.annotations.Test)21 Holder (javax.xml.ws.Holder)19 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)17 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)17 SOAPFault (javax.xml.soap.SOAPFault)17 SOAPException (javax.xml.soap.SOAPException)16 Service (javax.xml.ws.Service)11 WebServiceException (javax.xml.ws.WebServiceException)9 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)9 SOAPMessage (javax.xml.soap.SOAPMessage)8 SoapFault (org.apache.cxf.binding.soap.SoapFault)8 Bus (org.apache.cxf.Bus)6 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)6 Fault (org.apache.cxf.interceptor.Fault)6