1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.server.endpoint.mapping;
18
19 import junit.framework.TestCase;
20 import org.springframework.context.support.StaticApplicationContext;
21 import org.springframework.ws.server.endpoint.MethodEndpoint;
22 import org.springframework.ws.server.endpoint.annotation.Endpoint;
23 import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
24
25 public class PayloadRootAnnotationMethodEndpointMappingTest extends TestCase {
26
27 private PayloadRootAnnotationMethodEndpointMapping mapping;
28
29 private StaticApplicationContext applicationContext;
30
31 protected void setUp() throws Exception {
32 applicationContext = new StaticApplicationContext();
33 applicationContext.registerSingleton("mapping", PayloadRootAnnotationMethodEndpointMapping.class);
34 applicationContext.registerSingleton("endpoint", MyEndpoint.class);
35 applicationContext.registerSingleton("other", OtherBean.class);
36 applicationContext.refresh();
37 mapping = (PayloadRootAnnotationMethodEndpointMapping) applicationContext.getBean("mapping");
38 }
39
40 public void testRegistration() throws NoSuchMethodException {
41 MethodEndpoint endpoint = mapping.lookupEndpoint("{http://springframework.org/spring-ws}Request");
42 assertNotNull("MethodEndpoint not registered", endpoint);
43 MethodEndpoint expected = new MethodEndpoint(applicationContext.getBean("endpoint"), "doIt", new Class[0]);
44 assertEquals("Invalid endpoint registered", expected, endpoint);
45
46 assertNull("Invalid endpoint registered",
47 mapping.lookupEndpoint("{http://springframework.org/spring-ws}Request2"));
48 }
49
50 @Endpoint
51 private static class MyEndpoint {
52
53 @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws")
54 public void doIt() {
55
56 }
57
58 }
59
60 private static class OtherBean {
61
62 @PayloadRoot(localPart = "Request2", namespace = "http://springframework.org/spring-ws")
63 public void doIt() {
64
65 }
66
67 }
68
69 }