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;
18:
19: import java.lang.reflect.Method;
20:
21: import junit.framework.TestCase;
22:
23: public class MethodEndpointTest extends TestCase {
24:
25: private MethodEndpoint endpoint;
26:
27: private boolean myMethodInvoked;
28:
29: private Method method;
30:
31: protected void setUp() throws Exception {
32: myMethodInvoked = false;
33: method = getClass().getMethod("myMethod",
34: new Class[] { String.class });
35: endpoint = new MethodEndpoint(this , method);
36: }
37:
38: public void testGetters() throws Exception {
39: assertEquals("Invalid bean", this , endpoint.getBean());
40: assertEquals("Invalid bean", method, endpoint.getMethod());
41: }
42:
43: public void testInvoke() throws Exception {
44: assertFalse("Method invoked before invocation", myMethodInvoked);
45: endpoint.invoke(new Object[] { "arg" });
46: assertTrue("Method invoked before invocation", myMethodInvoked);
47: }
48:
49: public void testEquals() throws Exception {
50: assertEquals("Not equal", endpoint, endpoint);
51: assertEquals("Not equal", new MethodEndpoint(this , method),
52: endpoint);
53: Method otherMethod = getClass().getMethod("testEquals",
54: new Class[0]);
55: assertFalse("Equal", new MethodEndpoint(this , otherMethod)
56: .equals(endpoint));
57: }
58:
59: public void testHashCode() throws Exception {
60: assertEquals("Not equal", new MethodEndpoint(this , method)
61: .hashCode(), endpoint.hashCode());
62: Method otherMethod = getClass().getMethod("testEquals",
63: new Class[0]);
64: assertFalse("Equal", new MethodEndpoint(this , otherMethod)
65: .hashCode() == endpoint.hashCode());
66: }
67:
68: public void myMethod(String arg) {
69: assertEquals("Invalid argument", "arg", arg);
70: myMethodInvoked = true;
71: }
72:
73: public void testToString() throws Exception {
74: assertNotNull("Na valid toString", endpoint.toString());
75: }
76: }
|