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