1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.server.endpoint.mapping;
18
19 import java.lang.reflect.Method;
20
21 import org.springframework.context.support.StaticApplicationContext;
22 import org.springframework.ws.WebServiceMessageFactory;
23 import org.springframework.ws.context.DefaultMessageContext;
24 import org.springframework.ws.context.MessageContext;
25 import org.springframework.ws.server.EndpointInvocationChain;
26 import org.springframework.ws.server.endpoint.MethodEndpoint;
27 import org.springframework.ws.server.endpoint.annotation.Endpoint;
28 import org.springframework.ws.soap.SoapMessage;
29 import org.springframework.ws.soap.server.endpoint.annotation.SoapAction;
30
31 import org.junit.Assert;
32 import org.junit.Before;
33 import org.junit.Test;
34
35 import static org.easymock.EasyMock.*;
36
37 public class SoapActionAnnotationMethodEndpointMappingTest {
38
39 private SoapActionAnnotationMethodEndpointMapping mapping;
40
41 private StaticApplicationContext applicationContext;
42
43 @Before
44 public void setUp() throws Exception {
45 applicationContext = new StaticApplicationContext();
46 applicationContext.registerSingleton("mapping", SoapActionAnnotationMethodEndpointMapping.class);
47 applicationContext.registerSingleton("endpoint", MyEndpoint.class);
48 applicationContext.refresh();
49 mapping = (SoapActionAnnotationMethodEndpointMapping) applicationContext.getBean("mapping");
50 }
51
52 @Test
53 public void testRegistration() throws Exception {
54 SoapMessage requestMock = createMock(SoapMessage.class);
55 expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction");
56 WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
57 replay(requestMock, factoryMock);
58
59 MessageContext context = new DefaultMessageContext(requestMock, factoryMock);
60 EndpointInvocationChain chain = mapping.getEndpoint(context);
61 Assert.assertNotNull("MethodEndpoint not registered", chain);
62 Method doIt = MyEndpoint.class.getMethod("doIt", new Class[0]);
63 MethodEndpoint expected = new MethodEndpoint("endpoint", applicationContext, doIt);
64 Assert.assertEquals("Invalid endpoint registered", expected, chain.getEndpoint());
65
66 verify(requestMock, factoryMock);
67 }
68
69 @Endpoint
70 private static class MyEndpoint {
71
72 @SoapAction("http://springframework.org/spring-ws/SoapAction")
73 public void doIt() {
74
75 }
76
77 }
78 }