SWS-651 - Fishined client-side docs

This commit is contained in:
Arjen Poutsma
2010-11-09 12:09:59 +00:00
parent a066e9a360
commit 01bcd2661a
4 changed files with 208 additions and 12 deletions

View File

@@ -21,10 +21,7 @@ import javax.xml.transform.Source;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.test.client.MockWebServiceServer;
import org.springframework.ws.test.integration.CustomerCountRequest;
import org.springframework.ws.test.integration.CustomerCountResponse;
import org.springframework.xml.transform.StringSource;
import org.junit.Before;
@@ -46,13 +43,13 @@ import static org.springframework.ws.test.client.ResponseCreators.withPayload;
public class ClientIntegrationTest {
@Autowired
private WebServiceTemplate webServiceTemplate;
private CustomerClient client;
private MockWebServiceServer mockServer;
@Before
public void createServer() throws Exception {
mockServer = MockWebServiceServer.createServer(webServiceTemplate);
mockServer = MockWebServiceServer.createServer(client);
}
@Test
@@ -66,11 +63,8 @@ public class ClientIntegrationTest {
mockServer.expect(payload(expectedRequestPayload)).andRespond(withPayload(responsePayload));
CustomerCountRequest request = new CustomerCountRequest();
request.setCustomerName("John Doe");
CustomerCountResponse response = (CustomerCountResponse) webServiceTemplate.marshalSendAndReceive(request);
assertEquals(10, response.getCustomerCount());
int result = client.getCustomerCount();
assertEquals(10, result);
mockServer.verify();
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ws.test.client.integration;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.ws.test.integration.CustomerCountRequest;
import org.springframework.ws.test.integration.CustomerCountResponse;
public class CustomerClient extends WebServiceGatewaySupport {
public int getCustomerCount() {
CustomerCountRequest request = new CustomerCountRequest();
request.setCustomerName("John Doe");
CustomerCountResponse response = (CustomerCountResponse) getWebServiceTemplate().marshalSendAndReceive(request);
return response.getCustomerCount();
}
}

View File

@@ -3,6 +3,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="client" class="org.springframework.ws.test.client.integration.CustomerClient">
<property name="webServiceTemplate" ref="webServiceTemplate"/>
</bean>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="marshaller" ref="marshaller"/>
<property name="unmarshaller" ref="marshaller"/>