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 java.net.URI;
20
21 import junit.framework.TestCase;
22 import org.easymock.MockControl;
23
24 import org.springframework.ws.MockWebServiceMessageFactory;
25 import org.springframework.ws.context.DefaultMessageContext;
26 import org.springframework.ws.context.MessageContext;
27 import org.springframework.ws.transport.WebServiceConnection;
28 import org.springframework.ws.transport.context.DefaultTransportContext;
29 import org.springframework.ws.transport.context.TransportContextHolder;
30
31 public class UriEndpointMappingTest extends TestCase {
32
33 private UriEndpointMapping mapping;
34
35 private MessageContext context;
36
37 protected void setUp() throws Exception {
38 mapping = new UriEndpointMapping();
39 context = new DefaultMessageContext(new MockWebServiceMessageFactory());
40 }
41
42 public void testGetLookupKeyForMessage() throws Exception {
43 MockControl control = MockControl.createControl(WebServiceConnection.class);
44 WebServiceConnection connectionMock = (WebServiceConnection) control.getMock();
45 TransportContextHolder.setTransportContext(new DefaultTransportContext(connectionMock));
46
47 URI uri = new URI("jms://exampleQueue");
48 control.expectAndReturn(connectionMock.getUri(), uri);
49 control.replay();
50
51 assertEquals("Invalid lookup key", uri.toString(), mapping.getLookupKeyForMessage(context));
52
53 control.verify();
54 TransportContextHolder.setTransportContext(null);
55 }
56
57 public void testValidateLookupKey() throws Exception {
58 assertTrue("URI not valid", mapping.validateLookupKey("http://example.com/services"));
59 assertFalse("URI not valid", mapping.validateLookupKey("some string"));
60 }
61 }