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 org.springframework.ws.MockWebServiceMessageFactory;
20 import org.springframework.ws.context.DefaultMessageContext;
21 import org.springframework.ws.context.MessageContext;
22 import org.springframework.ws.server.EndpointInvocationChain;
23 import org.springframework.ws.server.EndpointMapping;
24 import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
25
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29
30 import static org.easymock.EasyMock.*;
31
32 public class DelegatingSoapEndpointMappingTest {
33
34 private DelegatingSoapEndpointMapping endpointMapping;
35
36 private EndpointMapping mock;
37
38 @Before
39 public void setUp() throws Exception {
40 endpointMapping = new DelegatingSoapEndpointMapping();
41 mock = createMock(EndpointMapping.class);
42 endpointMapping.setDelegate(mock);
43 }
44
45 @Test
46 public void testGetEndpointMapping() throws Exception {
47 String role = "http://www.springframework.org/spring-ws/role";
48 endpointMapping.setActorOrRole(role);
49 MessageContext context = new DefaultMessageContext(new MockWebServiceMessageFactory());
50 EndpointInvocationChain delegateChain = new EndpointInvocationChain(new Object());
51 expect(mock.getEndpoint(context)).andReturn(delegateChain);
52
53 replay(mock);
54
55 SoapEndpointInvocationChain resultChain = (SoapEndpointInvocationChain) endpointMapping.getEndpoint(context);
56 Assert.assertNotNull("No chain returned", resultChain);
57 Assert.assertEquals("Invalid ampount of roles returned", 1, resultChain.getActorsOrRoles().length);
58 Assert.assertEquals("Invalid role returned", role, resultChain.getActorsOrRoles()[0]);
59
60 verify(mock);
61 }
62 }