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.server.endpoint.mapping;
18:
19: import junit.framework.TestCase;
20: import org.springframework.context.support.StaticApplicationContext;
21: import org.springframework.ws.server.endpoint.MethodEndpoint;
22: import org.springframework.ws.server.endpoint.annotation.Endpoint;
23: import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
24:
25: public class PayloadRootAnnotationMethodEndpointMappingTest extends
26: TestCase {
27:
28: private PayloadRootAnnotationMethodEndpointMapping mapping;
29:
30: private StaticApplicationContext applicationContext;
31:
32: protected void setUp() throws Exception {
33: applicationContext = new StaticApplicationContext();
34: applicationContext.registerSingleton("mapping",
35: PayloadRootAnnotationMethodEndpointMapping.class);
36: applicationContext.registerSingleton("endpoint",
37: MyEndpoint.class);
38: applicationContext.registerSingleton("other", OtherBean.class);
39: applicationContext.refresh();
40: mapping = (PayloadRootAnnotationMethodEndpointMapping) applicationContext
41: .getBean("mapping");
42: }
43:
44: public void testRegistration() throws NoSuchMethodException {
45: MethodEndpoint endpoint = mapping
46: .lookupEndpoint("{http://springframework.org/spring-ws}Request");
47: assertNotNull("MethodEndpoint not registered", endpoint);
48: MethodEndpoint expected = new MethodEndpoint(applicationContext
49: .getBean("endpoint"), "doIt", new Class[0]);
50: assertEquals("Invalid endpoint registered", expected, endpoint);
51:
52: assertNull(
53: "Invalid endpoint registered",
54: mapping
55: .lookupEndpoint("{http://springframework.org/spring-ws}Request2"));
56: }
57:
58: @Endpoint
59: private static class MyEndpoint {
60:
61: @PayloadRoot(localPart="Request",namespace="http://springframework.org/spring-ws")
62: public void doIt() {
63:
64: }
65:
66: }
67:
68: private static class OtherBean {
69:
70: @PayloadRoot(localPart="Request2",namespace="http://springframework.org/spring-ws")
71: public void doIt() {
72:
73: }
74:
75: }
76:
77: }
|