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  import javax.xml.transform.Source;
22  
23  import org.springframework.beans.factory.annotation.Autowired;
24  import org.springframework.context.ApplicationContext;
25  import org.springframework.test.context.ContextConfiguration;
26  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
27  import org.springframework.ws.server.endpoint.MethodEndpoint;
28  import org.springframework.ws.server.endpoint.annotation.Endpoint;
29  import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
30  import org.springframework.ws.server.endpoint.annotation.RequestPayload;
31  
32  import org.junit.Test;
33  import org.junit.runner.RunWith;
34  
35  import static org.junit.Assert.assertEquals;
36  import static org.junit.Assert.assertNotNull;
37  
38  @RunWith(SpringJUnit4ClassRunner.class)
39  @ContextConfiguration("cglib-proxy-registration.xml")
40  public class CgLibProxyRegistrationTest {
41  
42      @Autowired
43      private PayloadRootAnnotationMethodEndpointMapping mapping;
44  
45      @Autowired
46      private ApplicationContext applicationContext;
47  
48      @Test
49      public void registration() throws NoSuchMethodException {
50          MethodEndpoint cglibProxy = mapping.lookupEndpoint(new QName("http://springframework.org/spring-ws", "Request"));
51          assertNotNull("cg lib proxy endpoint not registered", cglibProxy);
52          Method doIt = MyEndpoint.class.getMethod("doIt", Source.class);
53          MethodEndpoint expected = new MethodEndpoint("cgLibProxyEndpoint", applicationContext, doIt);
54          assertEquals("Invalid endpoint registered", expected, cglibProxy);
55      }
56  
57      @Endpoint
58      public static class MyEndpoint {
59  
60          @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws")
61          @Log
62          public void doIt(@RequestPayload Source payload) {
63          }
64  
65      }
66  
67  }