01: package org.objectweb.celtix.systest.handlers;
02:
03: import java.net.URL;
04: import java.util.List;
05:
06: import javax.xml.namespace.QName;
07: import javax.xml.ws.BindingProvider;
08: import javax.xml.ws.handler.Handler;
09: import javax.xml.ws.handler.HandlerResolver;
10:
11: import org.objectweb.celtix.bus.handlers.PortInfoImpl;
12: import org.objectweb.celtix.systest.common.ClientServerTestBase;
13: import org.objectweb.hello_world_soap_http.Greeter;
14: import org.objectweb.hello_world_soap_http.SOAPService;
15:
16: public class RegistrationTest extends ClientServerTestBase {
17:
18: private final QName serviceName = new QName(
19: "http://objectweb.org/hello_world_soap_http", "SOAPService");
20: private final QName portName = new QName(
21: "http://objectweb.org/hello_world_soap_http", "SoapPort");
22:
23: private URL wsdl;
24: private SOAPService service;
25: private Greeter greeter;
26:
27: public void setUp() {
28: try {
29: super .setUp();
30:
31: wsdl = RegistrationTest.class
32: .getResource("/wsdl/hello_world.wsdl");
33: service = new SOAPService(wsdl, serviceName);
34: greeter = service.getPort(portName, Greeter.class);
35: } catch (Exception ex) {
36: ex.printStackTrace();
37: fail(ex.toString());
38: }
39: }
40:
41: public void testServerHandlerRegistrationOnBinding() {
42:
43: }
44:
45: /**
46: * test that a handler registered via Service HandlerResolver ends up
47: * in the port's handler chain
48: *
49: */
50: public void testClientHandlerRegistrationOnService() {
51:
52: PortInfoImpl p1 = new PortInfoImpl(serviceName, portName, null);
53:
54: assertNotNull(service);
55: HandlerResolver resolver = service.getHandlerResolver();
56: assertNotNull(resolver);
57:
58: List<Handler> handlers = resolver.getHandlerChain(p1);
59: assertEquals(0, handlers.size());
60: final TestHandler dummyHandler = new TestHandler();
61: handlers.add(dummyHandler);
62: assertEquals(1, handlers.size());
63:
64: Greeter g = service.getPort(portName, Greeter.class);
65: assertTrue(g instanceof BindingProvider);
66:
67: List<Handler> bindingHandlers = ((BindingProvider) g)
68: .getBinding().getHandlerChain();
69: assertNotNull(bindingHandlers);
70: assertEquals(1, bindingHandlers.size());
71: assertSame(dummyHandler, bindingHandlers.get(0));
72: }
73:
74: public void testChangingServiceHandlerChainDoesNotAffectProxy() {
75:
76: List<Handler> proxyHandlers = ((BindingProvider) greeter)
77: .getBinding().getHandlerChain();
78: assertEquals(0, proxyHandlers.size());
79:
80: PortInfoImpl p1 = new PortInfoImpl(serviceName, portName, null);
81: HandlerResolver resolver = service.getHandlerResolver();
82: resolver.getHandlerChain(p1).add(new TestHandler());
83: assertEquals(0, proxyHandlers.size());
84: }
85:
86: }
|