use of jakarta.xml.ws.BindingProvider 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.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTest method testResponseProperty.
/*
* Sets a property on the (client side) response handler context
* and verifies that the client sees it in the response context.
*/
public void testResponseProperty() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
TestService stub = getTestStub(getService());
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_USER_PROPERTY_INBOUND);
stub.testInt(1);
Map context = ((BindingProvider) stub).getResponseContext();
Object testValue = context.get(USER_HANDLER_PROPERTY_NAME);
assertNotNull("did not receive property in response context", testValue);
String testValueString = (String) testValue;
assertTrue("property value incorrect. expected ", testValueString.equals(USER_PROPERTY_HANDLER_SET));
}
use of jakarta.xml.ws.BindingProvider 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.BindingProvider 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.BindingProvider 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