use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class BindingTest method testSoapBinding1.
/*
* tests for SOAPBinding.
*
*/
public void testSoapBinding1() throws Exception {
TestService_Service service = getService();
TestService stub = getTestStub(service);
Binding binding = ((BindingProvider) stub).getBinding();
if (binding instanceof SOAPBinding) {
SOAPBinding sb = (SOAPBinding) binding;
assertNotNull("did not get SOAPBinding", sb);
Set<String> roles = sb.getRoles();
assertNotNull("roles cannot be null", roles);
assertFalse("found zero roles in SOAPBinding", roles.isEmpty());
assertTrue("soap 1.1 \"next\" role is not included in roles", roles.contains(NEXT_1_1));
assertFalse("soap 1.2 \"none\" role cannot be included in roles", roles.contains(NONE));
// try setting new roles
Set<String> newSet = new HashSet<String>();
String testURI = "http://java.sun.com/justanexample";
newSet.add(testURI);
sb.setRoles(newSet);
try {
newSet.add(NONE);
sb.setRoles(newSet);
throw new RuntimeException("did not get jaxrpc exception for setting \"none\" role");
} catch (WebServiceException e) {
// pass
}
newSet.addAll(roles);
newSet.remove(NONE);
sb.setRoles(newSet);
// add empty set and check for next/ultimate
newSet = new HashSet<String>();
sb.setRoles(newSet);
Set<String> newSet2 = sb.getRoles();
assertTrue("soap 1.1 \"next\" role is not included in roles", newSet2.contains(NEXT_1_1));
assertFalse("soap 1.2 \"none\" role cannot be included in roles", newSet2.contains(NONE));
} else {
throw new Exception("binding is not a SOAPBinding");
}
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class BindingTest method testBindingInstances.
/*
* Used for testing of handlers shared between bindings.
*/
public void testBindingInstances() throws Exception {
TestService_Service service = getService();
TestService stub1 = getTestStub(service);
TestService stub2 = getTestStub(service);
// make some calls
stub1.testInt(0);
stub2.testInt(0);
Binding b1 = ((BindingProvider) stub1).getBinding();
Binding b2 = ((BindingProvider) stub2).getBinding();
List<Handler> chain = b1.getHandlerChain();
// get a soap handler from the chain. doesn't matter which one
BaseSOAPHandler handler = null;
for (Handler h : chain) {
if (h instanceof BaseSOAPHandler) {
handler = (BaseSOAPHandler) h;
break;
}
}
assertTrue("handler should be in 'ready' state", handler.isAvailable());
b2.setHandlerChain(new ArrayList<Handler>());
assertTrue("handler should be in 'ready' state", handler.isAvailable());
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testLogicalJAXB.
/*
* Test removes the static handler and adds a logical
* handler that uses JAXB to change the message.
*/
public void testLogicalJAXB() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.JAXB);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 4;
int y = stub.hello(x);
// x+4 with all handlers
assertEquals(x + diff, y);
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testLogicalGetSourceOnly.
/*
* Test removes the static handler and adds a logical
* handler that gets the source but does not change it.
*/
public void testLogicalGetSourceOnly() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE_NO_CHANGE);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertEquals(x + diff, y);
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testDynamic1.
/*
* Test tries to add a handler programmatically after clearing
* handlers out of the service. Adds handler to binding. Uses
* an empty handler resolver for clearing the service.
*/
public void testDynamic1() throws Exception {
Hello_Service service = createService();
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
return new ArrayList<Handler>();
}
});
Hello stub = createStub(service);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertTrue(y == x + diff);
// now add client handler
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new SOAPTestHandler());
Binding binding = ((BindingProvider) stub).getBinding();
binding.setHandlerChain(handlerList);
// test again
diff = 4;
y = stub.hello(x);
assertTrue(y == x + diff);
}
Aggregations