SpringBusFactory.setDefaultBus(bus);
SpringBusFactory.setThreadDefaultBus(bus);
DoubleItService service = new DoubleItService();
DoubleItPortType saml1Port = service.getDoubleItSaml1TransportPort();
updateAddressPort(saml1Port, PORT2);
try {
saml1Port.doubleIt(BigInteger.valueOf(25));
fail("Expected failure on an invocation with no SAML Assertion");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
assertTrue(ex.getMessage().contains("No SAML CallbackHandler available"));
}
((BindingProvider)saml1Port).getRequestContext().put(
"ws-security.saml-callback-handler", new SamlCallbackHandler()
);
try {
saml1Port.doubleIt(BigInteger.valueOf(25));
fail("Expected failure on an invocation with a SAML2 Assertion");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
assertTrue(ex.getMessage().contains("Wrong SAML Version"));
}
((BindingProvider)saml1Port).getRequestContext().put(
"ws-security.saml-callback-handler", new SamlCallbackHandler(false)
);
BigInteger result = saml1Port.doubleIt(BigInteger.valueOf(25));
assertTrue(result.equals(BigInteger.valueOf(50)));
}