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.test.server.integration;
18  
19  import javax.xml.transform.Source;
20  
21  import org.springframework.beans.factory.annotation.Autowired;
22  import org.springframework.context.ApplicationContext;
23  import org.springframework.test.context.ContextConfiguration;
24  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
25  import org.springframework.ws.test.server.MockWebServiceClient;
26  import org.springframework.xml.transform.StringSource;
27  
28  import org.junit.Before;
29  import org.junit.Test;
30  import org.junit.runner.RunWith;
31  
32  import static org.springframework.ws.test.server.RequestCreators.withPayload;
33  import static org.springframework.ws.test.server.ResponseMatchers.payload;
34  
35  /**
36   * @author Arjen Poutsma
37   */
38  @RunWith(SpringJUnit4ClassRunner.class)
39  @ContextConfiguration("integration-test.xml")
40  public class ServerIntegrationTest {
41  
42      @Autowired
43      private ApplicationContext applicationContext;
44  
45      private MockWebServiceClient mockClient;
46  
47      @Before
48      public void createClient() {
49          mockClient = MockWebServiceClient.createClient(applicationContext);
50      }
51  
52      @Test
53      public void basic() throws Exception {
54          Source requestPayload = new StringSource("<customerCountRequest xmlns='http://springframework.org/spring-ws'>" +
55                  "<customerName>John Doe</customerName>" + "</customerCountRequest>");
56          Source expectedResponsePayload = new StringSource(
57                  "<customerCountResponse xmlns='http://springframework.org/spring-ws'>" +
58                          "<customerCount>42</customerCount>" + "</customerCountResponse>");
59  
60          mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload));
61      }
62  
63  
64  }