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 junit.framework.TestCase;
20 import static org.easymock.EasyMock.*;
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 public class SoapActionAnnotationMethodEndpointMappingTest extends TestCase {
32
33 private SoapActionAnnotationMethodEndpointMapping mapping;
34
35 private StaticApplicationContext applicationContext;
36
37 protected void setUp() throws Exception {
38 applicationContext = new StaticApplicationContext();
39 applicationContext.registerSingleton("mapping", SoapActionAnnotationMethodEndpointMapping.class);
40 applicationContext.registerSingleton("endpoint", MyEndpoint.class);
41 applicationContext.refresh();
42 mapping = (SoapActionAnnotationMethodEndpointMapping) applicationContext.getBean("mapping");
43 }
44
45 public void testRegistration() throws Exception {
46 SoapMessage requestMock = createMock(SoapMessage.class);
47 expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction");
48 WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
49 replay(requestMock, factoryMock);
50
51 MessageContext context = new DefaultMessageContext(requestMock, factoryMock);
52 EndpointInvocationChain chain = mapping.getEndpoint(context);
53 assertNotNull("MethodEndpoint not registered", chain);
54 MethodEndpoint expected = new MethodEndpoint(applicationContext.getBean("endpoint"), "doIt", new Class[0]);
55 assertEquals("Invalid endpoint registered", expected, chain.getEndpoint());
56
57 verify(requestMock,factoryMock);
58 }
59
60 @Endpoint
61 private static class MyEndpoint {
62
63 @SoapAction("http://springframework.org/spring-ws/SoapAction")
64 public void doIt() {
65
66 }
67
68 }
69 }