01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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(
36: new MockWebServiceMessageFactory());
37: }
38:
39: public void testSupported() throws NoSuchMethodException {
40: MethodEndpoint methodEndpoint = new MethodEndpoint(this ,
41: "supported", new Class[] { MessageContext.class });
42: assertTrue("Method unsupported", adapter
43: .supportsInternal(methodEndpoint));
44: }
45:
46: public void testUnsupportedMethodMultipleParams()
47: throws NoSuchMethodException {
48: assertFalse("Method supported", adapter
49: .supportsInternal(new MethodEndpoint(this ,
50: "unsupportedMultipleParams", new Class[] {
51: MessageContext.class,
52: MessageContext.class })));
53: }
54:
55: public void testUnsupportedMethodWrongParam()
56: throws NoSuchMethodException {
57: assertFalse("Method supported", adapter
58: .supportsInternal(new MethodEndpoint(this ,
59: "unsupportedWrongParam",
60: new Class[] { String.class })));
61: }
62:
63: public void testInvokeSupported() throws Exception {
64: MethodEndpoint methodEndpoint = new MethodEndpoint(this ,
65: "supported", new Class[] { MessageContext.class });
66: assertFalse("Method invoked", supportedInvoked);
67: adapter.invoke(messageContext, methodEndpoint);
68: assertTrue("Method not invoked", supportedInvoked);
69: }
70:
71: public void supported(MessageContext context) {
72: supportedInvoked = true;
73: }
74:
75: public void unsupportedMultipleParams(MessageContext s1,
76: MessageContext s2) {
77: }
78:
79: public void unsupportedWrongParam(String request) {
80: }
81: }
|