1   /*
2    * Copyright 2005-2011 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
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 java.lang.reflect.Method;
20  import javax.xml.namespace.QName;
21  
22  import org.springframework.beans.factory.annotation.Autowired;
23  import org.springframework.context.ApplicationContext;
24  import org.springframework.test.context.ContextConfiguration;
25  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
26  import org.springframework.ws.server.endpoint.MethodEndpoint;
27  import org.springframework.ws.server.endpoint.annotation.Endpoint;
28  import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
29  
30  import org.junit.Test;
31  import org.junit.runner.RunWith;
32  
33  import static org.junit.Assert.assertEquals;
34  import static org.junit.Assert.assertNotNull;
35  
36  @RunWith(SpringJUnit4ClassRunner.class)
37  @ContextConfiguration("bridged-method-registration.xml")
38  public class BridgedMethodRegistrationTest {
39  
40      @Autowired
41      private PayloadRootAnnotationMethodEndpointMapping mapping;
42  
43      @Autowired
44      private ApplicationContext applicationContext;
45  
46      @Test
47      public void registration() throws NoSuchMethodException {
48          MethodEndpoint bridgedMethod = mapping.lookupEndpoint(new QName("http://springframework.org/spring-ws", "Request"));
49          assertNotNull("bridged method endpoint not registered", bridgedMethod);
50          Method doIt = B.class.getMethod("doIt");
51          MethodEndpoint expected = new MethodEndpoint("bridgedMethodEndpoint", applicationContext, doIt);
52          assertEquals("Invalid endpoint registered", expected, bridgedMethod);
53      }
54  
55      @Endpoint
56      public static class A {
57  
58          @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws")
59          public A doIt() {
60              return this;
61          }
62      }
63  
64      public static class B extends A {
65  
66          @Override
67          public B doIt() {
68              return this;
69          }
70      }
71  
72  }