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.ws.MockWebServiceMessage;
21 import org.springframework.ws.MockWebServiceMessageFactory;
22 import org.springframework.ws.context.DefaultMessageContext;
23 import org.springframework.ws.context.MessageContext;
24
25 public class XPathPayloadEndpointMappingTest extends TestCase {
26
27 private XPathPayloadEndpointMapping mapping;
28
29 protected void setUp() throws Exception {
30 mapping = new XPathPayloadEndpointMapping();
31 }
32
33 public void testGetLookupKeyForMessage() throws Exception {
34 mapping.setExpression("/root/text()");
35 mapping.afterPropertiesSet();
36
37 MockWebServiceMessage request = new MockWebServiceMessage("<root>value</root>");
38 MessageContext context = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
39
40 String result = mapping.getLookupKeyForMessage(context);
41 assertNotNull("mapping returns null", result);
42 assertEquals("mapping returns invalid result", "value", result);
43 }
44 }