use of jakarta.xml.ws.handler.Handler 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);
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class BindingTester method testBindingInstances.
/*
* get the binding object on dispatch object
*/
// public void testDispatch1() throws Exception {
// Dispatch dispatch = createDispatchForSource(
// new QName("urn:test", "TestServicePort"));
// assertNotNull("dispatch object is null", dispatch);
// Binding binding = dispatch.getBinding();
// assertNotNull("binding object should not be null", binding);
// List handlers = binding.getHandlerChain();
// assertNotNull("handler list should not be null", handlers);
// assertTrue("There should be no handlers in list", handlers.size() == 0);
// }
/*
* 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.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class EndToEndTester method testResponsePropertyDispatch.
/*
* Sets a property on the (client side) response handler context
* and verifies that the client sees it in the response context.
* This version uses a dispatch client rather than proxy.
*/
public void testResponsePropertyDispatch() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
Dispatch<Object> dispatch = getDispatchJAXB(testPortQName);
// tell the server handlers not to do anything
ReportService reportStub = getReportStub(getService());
reportStub.clearHandlerTracker();
// add handler
String myHandlerName = "MyDispatchHandler";
BaseSOAPHandler propAddingHandler = new BaseSOAPHandler();
propAddingHandler.setName(CLIENT_PREFIX + myHandlerName);
propAddingHandler.initTheHandler();
List<Handler> newHandlers = new ArrayList<Handler>();
newHandlers.add(propAddingHandler);
dispatch.getBinding().setHandlerChain(newHandlers);
// tell the client handlers what to do
tracker.clearAll();
tracker.setHandlerAction(CLIENT_PREFIX + myHandlerName, HA_ADD_USER_PROPERTY_INBOUND);
int x = 1;
TestInt request = new TestInt();
request.setIntin(x);
TestIntResponse response = (TestIntResponse) dispatch.invoke(request);
assertEquals("did not get proper response", x, response.getIntout());
Map context = dispatch.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.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerChainTester method testHandlersOnTestPort2.
public void testHandlersOnTestPort2() {
TestService_Service service = getService();
TestService testStub = service.getPort(TestService.class);
Binding testBinding = ((BindingProvider) testStub).getBinding();
List<Handler> chain = testBinding.getHandlerChain();
// System.out.println(chain.size());
assertEquals(3, chain.size());
}
use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.
the class HandlerChainTester method testHandlersOnTestPort3.
public void testHandlersOnTestPort3() {
Service service = Service.create(WSDL_LOCATION, TESTSERVICE);
TestService testStub = service.getPort(TESTSERVICEPORT, TestService.class);
Binding testBinding = ((BindingProvider) testStub).getBinding();
List<Handler> chain = testBinding.getHandlerChain();
// System.out.println(chain.size());
assertEquals(0, chain.size());
}
Aggregations