use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class FaultTest method testSoap12.
@org.junit.Test
public void testSoap12() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = FaultTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSoap12Port");
DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(utPort, PORT);
// Make a successful invocation
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
assertEquals(50, utPort.doubleIt(25));
// Now make an invocation using another username
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob");
((BindingProvider) utPort).getRequestContext().put("security.password", "password");
try {
utPort.doubleIt(25);
fail("Expected failure on bob");
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("This is a fault"));
}
((java.io.Closeable) utPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class FaultTest method testUnsecuredSoap11ActionStAX.
@org.junit.Test
public void testUnsecuredSoap11ActionStAX() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = FaultTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSoap11UnsecuredPort2");
DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(utPort, PORT);
try {
utPort.doubleIt(25);
fail("Expected failure on bob");
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("This is a fault"));
}
((java.io.Closeable) utPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class ModifiedRequestTest method testModifiedEncryptedSOAPBody.
@org.junit.Test
public void testModifiedEncryptedSOAPBody() throws Exception {
if (!unrestrictedPoliciesInstalled) {
return;
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ModifiedRequestTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ModifiedRequestTest.class.getResource("DoubleItFault.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
Client cxfClient = ClientProxy.getClient(port);
ModifiedEncryptedSOAPBody modifyInterceptor = new ModifiedEncryptedSOAPBody();
cxfClient.getOutInterceptors().add(modifyInterceptor);
makeInvocation(port, false);
// Streaming invocation
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, STAX_PORT);
cxfClient = ClientProxy.getClient(port);
modifyInterceptor = new ModifiedEncryptedSOAPBody();
cxfClient.getOutInterceptors().add(modifyInterceptor);
makeInvocation(port, true);
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class ModifiedRequestTest method testUntrustedSignature.
@org.junit.Test
public void testUntrustedSignature() throws Exception {
if (!unrestrictedPoliciesInstalled) {
return;
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ModifiedRequestTest.class.getResource("client-untrusted.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ModifiedRequestTest.class.getResource("DoubleItFault.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
makeInvocation(port, false);
// Streaming invocation
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, STAX_PORT);
makeInvocation(port, true);
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class ModifiedRequestTest method testModifiedSignedTimestamp.
@org.junit.Test
public void testModifiedSignedTimestamp() throws Exception {
if (!unrestrictedPoliciesInstalled) {
return;
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ModifiedRequestTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ModifiedRequestTest.class.getResource("DoubleItFault.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
Client cxfClient = ClientProxy.getClient(port);
ModifiedTimestampInterceptor modifyInterceptor = new ModifiedTimestampInterceptor();
cxfClient.getOutInterceptors().add(modifyInterceptor);
makeInvocation(port, false);
// Streaming invocation
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, STAX_PORT);
cxfClient = ClientProxy.getClient(port);
modifyInterceptor = new ModifiedTimestampInterceptor();
cxfClient.getOutInterceptors().add(modifyInterceptor);
makeInvocation(port, true);
((java.io.Closeable) port).close();
bus.shutdown(true);
}
Aggregations