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.addressing.server;
18  
19  import java.net.URI;
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.addressing.version.Addressing10;
25  import org.springframework.ws.soap.addressing.version.AddressingVersion;
26  import org.springframework.ws.soap.saaj.SaajSoapMessage;
27  import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
28  
29  import static org.easymock.EasyMock.*;
30  import static org.junit.Assert.assertTrue;
31  
32  public class AddressingInterceptor10Test extends AbstractAddressingInterceptorTestCase {
33  
34      @Override
35      protected AddressingVersion getVersion() {
36          return new Addressing10();
37      }
38  
39      @Override
40      protected String getTestPath() {
41          return "10";
42      }
43  
44      public void testNoTo() throws Exception {
45          SaajSoapMessage valid = loadSaajMessage(getTestPath() + "/request-no-to.xml");
46          MessageContext context = new DefaultMessageContext(valid, new SaajSoapMessageFactory(messageFactory));
47          URI messageId = new URI("uid:1234");
48          expect(strategyMock.newMessageId((SoapMessage) context.getResponse())).andReturn(messageId);
49          replay(strategyMock);
50          boolean result = interceptor.handleResponse(context, null);
51          assertTrue("Request with no To not handled", result);
52          assertTrue("Message Context has no response", context.hasResponse());
53          SaajSoapMessage expectedResponse = loadSaajMessage(getTestPath() + "/response-anonymous.xml");
54          assertXMLEqual("Invalid response for message with invalid MAP", expectedResponse,
55                  (SaajSoapMessage) context.getResponse());
56          verify(strategyMock);
57      }
58  
59  }