1
2
3
4
5
6
7
8
9
10
11
12
13
14
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", new Class[]{String.class});
34 endpoint = new MethodEndpoint(this, method);
35 }
36
37 public void testGetters() throws Exception {
38 assertEquals("Invalid bean", this, endpoint.getBean());
39 assertEquals("Invalid bean", method, endpoint.getMethod());
40 }
41
42 public void testInvoke() throws Exception {
43 assertFalse("Method invoked before invocation", myMethodInvoked);
44 endpoint.invoke(new Object[]{"arg"});
45 assertTrue("Method invoked before invocation", myMethodInvoked);
46 }
47
48 public void testEquals() throws Exception {
49 assertEquals("Not equal", endpoint, endpoint);
50 assertEquals("Not equal", new MethodEndpoint(this, method), endpoint);
51 Method otherMethod = getClass().getMethod("testEquals", new Class[0]);
52 assertFalse("Equal", new MethodEndpoint(this, otherMethod).equals(endpoint));
53 }
54
55 public void testHashCode() throws Exception {
56 assertEquals("Not equal", new MethodEndpoint(this, method).hashCode(), endpoint.hashCode());
57 Method otherMethod = getClass().getMethod("testEquals", new Class[0]);
58 assertFalse("Equal", new MethodEndpoint(this, otherMethod).hashCode() == endpoint.hashCode());
59 }
60
61 public void myMethod(String arg) {
62 assertEquals("Invalid argument", "arg", arg);
63 myMethodInvoked = true;
64 }
65
66 public void testToString() throws Exception {
67 assertNotNull("Na valid toString", endpoint.toString());
68 }
69 }