1   /*
2    * Copyright 2005-2010 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.soap.server.endpoint.mapping;
18  
19  import javax.xml.soap.MessageFactory;
20  
21  import org.springframework.ws.context.DefaultMessageContext;
22  import org.springframework.ws.context.MessageContext;
23  import org.springframework.ws.soap.SoapMessage;
24  import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
25  
26  import org.junit.Assert;
27  import org.junit.Before;
28  import org.junit.Test;
29  
30  public class SoapActionEndpointMappingTest {
31  
32      private SoapActionEndpointMapping mapping;
33  
34      private MessageContext context;
35  
36      @Before
37      public void setUp() throws Exception {
38          mapping = new SoapActionEndpointMapping();
39          context = new DefaultMessageContext(new SaajSoapMessageFactory(MessageFactory.newInstance()));
40      }
41  
42      @Test
43      public void testGetLookupKeyForMessage() throws Exception {
44          String soapAction = "http://springframework.org/spring-ws/SoapAction";
45          ((SoapMessage) context.getRequest()).setSoapAction(soapAction);
46          Assert.assertEquals("Invalid lookup key", soapAction, mapping.getLookupKeyForMessage(context));
47      }
48  
49      @Test
50      public void testGetLookupKeyForMessageQuoted() throws Exception {
51          String soapAction = "http://springframework.org/spring-ws/SoapAction";
52          ((SoapMessage) context.getRequest()).setSoapAction(soapAction);
53          Assert.assertEquals("Invalid lookup key", soapAction, mapping.getLookupKeyForMessage(context));
54      }
55  
56      @Test
57      public void testValidateLookupKey() throws Exception {
58          Assert.assertTrue("Soapaction not valid", mapping.validateLookupKey("SoapAction"));
59      }
60  }