01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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
32: TestCase {
33:
34: private SoapActionAnnotationMethodEndpointMapping mapping;
35:
36: private StaticApplicationContext applicationContext;
37:
38: protected void setUp() throws Exception {
39: applicationContext = new StaticApplicationContext();
40: applicationContext.registerSingleton("mapping",
41: SoapActionAnnotationMethodEndpointMapping.class);
42: applicationContext.registerSingleton("endpoint",
43: MyEndpoint.class);
44: applicationContext.refresh();
45: mapping = (SoapActionAnnotationMethodEndpointMapping) applicationContext
46: .getBean("mapping");
47: }
48:
49: public void testRegistration() throws Exception {
50: SoapMessage requestMock = createMock(SoapMessage.class);
51: expect(requestMock.getSoapAction()).andReturn(
52: "http://springframework.org/spring-ws/SoapAction");
53: WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
54: replay(requestMock, factoryMock);
55:
56: MessageContext context = new DefaultMessageContext(requestMock,
57: factoryMock);
58: EndpointInvocationChain chain = mapping.getEndpoint(context);
59: assertNotNull("MethodEndpoint not registered", chain);
60: MethodEndpoint expected = new MethodEndpoint(applicationContext
61: .getBean("endpoint"), "doIt", new Class[0]);
62: assertEquals("Invalid endpoint registered", expected, chain
63: .getEndpoint());
64:
65: verify(requestMock, factoryMock);
66: }
67:
68: @Endpoint
69: private static class MyEndpoint {
70:
71: @SoapAction("http://springframework.org/spring-ws/SoapAction")
72: public void doIt() {
73:
74: }
75:
76: }
77: }
|