1   /*
2    * Copyright 2008 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  public class AddressingInterceptor10Test extends AbstractAddressingInterceptorTestCase {
30  
31      protected AddressingVersion getVersion() {
32          return new Addressing10();
33      }
34  
35      protected String getTestPath() {
36          return "10";
37      }
38  
39      public void testNoTo() throws Exception {
40          SaajSoapMessage valid = loadSaajMessage(getTestPath() + "/request-no-to.xml");
41          MessageContext context = new DefaultMessageContext(valid, new SaajSoapMessageFactory(messageFactory));
42          URI messageId = new URI("uid:1234");
43          strategyControl.expectAndReturn(strategyMock.newMessageId((SoapMessage) context.getResponse()), messageId);
44          strategyControl.replay();
45          boolean result = interceptor.handleResponse(context, null);
46          assertTrue("Request with no To not handled", result);
47          assertTrue("Message Context has no response", context.hasResponse());
48          SaajSoapMessage expectedResponse = loadSaajMessage(getTestPath() + "/response-anonymous.xml");
49          assertXMLEqual("Invalid response for message with invalid MAP", expectedResponse,
50                  (SaajSoapMessage) context.getResponse());
51          strategyControl.verify();
52      }
53  
54  }