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();
}
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();
}
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);
}
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);
}
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"));
}
Aggregations