1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.server.endpoint.adapter;
18
19 import junit.framework.TestCase;
20 import org.springframework.ws.MockWebServiceMessageFactory;
21 import org.springframework.ws.context.DefaultMessageContext;
22 import org.springframework.ws.context.MessageContext;
23 import org.springframework.ws.server.endpoint.MethodEndpoint;
24
25 public class MessageMethodEndpointAdapterTest extends TestCase {
26
27 private MessageMethodEndpointAdapter adapter;
28
29 private boolean supportedInvoked;
30
31 private MessageContext messageContext;
32
33 protected void setUp() throws Exception {
34 adapter = new MessageMethodEndpointAdapter();
35 messageContext = new DefaultMessageContext(new MockWebServiceMessageFactory());
36 }
37
38 public void testSupported() throws NoSuchMethodException {
39 MethodEndpoint methodEndpoint = new MethodEndpoint(this, "supported", new Class[]{MessageContext.class});
40 assertTrue("Method unsupported", adapter.supportsInternal(methodEndpoint));
41 }
42
43 public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException {
44 assertFalse("Method supported", adapter.supportsInternal(new MethodEndpoint(this, "unsupportedMultipleParams",
45 new Class[]{MessageContext.class, MessageContext.class})));
46 }
47
48 public void testUnsupportedMethodWrongParam() throws NoSuchMethodException {
49 assertFalse("Method supported",
50 adapter.supportsInternal(new MethodEndpoint(this, "unsupportedWrongParam", new Class[]{String.class})));
51 }
52
53 public void testInvokeSupported() throws Exception {
54 MethodEndpoint methodEndpoint = new MethodEndpoint(this, "supported", new Class[]{MessageContext.class});
55 assertFalse("Method invoked", supportedInvoked);
56 adapter.invoke(messageContext, methodEndpoint);
57 assertTrue("Method not invoked", supportedInvoked);
58 }
59
60 public void supported(MessageContext context) {
61 supportedInvoked = true;
62 }
63
64 public void unsupportedMultipleParams(MessageContext s1, MessageContext s2) {
65 }
66
67 public void unsupportedWrongParam(String request) {
68 }
69 }