Migrating away from WebServiceMock

This commit is contained in:
Arjen Poutsma
2010-11-03 13:48:46 +00:00
parent 6156682f42
commit c1489eabff
8 changed files with 49 additions and 26 deletions

View File

@@ -29,7 +29,8 @@ import org.springframework.ws.test.support.MockStrategiesHelper;
* <p/>
* The typical usage of this class is:
* <ol>
* <li>Create a {@code MockWebServiceServer} instance by calling {@link #createServer(WebServiceTemplate)}.
* <li>Create a {@code MockWebServiceServer} instance by calling {@link #createServer(WebServiceTemplate)},
* or any other the other {@code createServer()} methods.
* Typically, the template is configured as a Spring bean, either explicitly or as a property of a class that extends
* {@link WebServiceGatewaySupport WebServiceGatewaySupport}.</li>
* <li>Set up request expectations by calling {@link #expect(RequestMatcher)}, possibly by using the default
@@ -66,7 +67,7 @@ import org.springframework.ws.test.support.MockStrategiesHelper;
*
* &#064;Before
* public void createServer() throws Exception {
* <strong>mockServer = MockWebServiceServer.createServer(client.getWebServiceTemplate())</strong>;
* <strong>mockServer = MockWebServiceServer.createServer(client)</strong>;
* }
*
* &#064;Test

View File

@@ -17,7 +17,8 @@
package org.springframework.ws.test.client;
/**
* Allows for setting up responses. Implementations of this interface are returned by {@link WebServiceMock}.
* Allows for setting up responses and additional expectations. Implementations of this interface are returned by
* {@link MockWebServiceServer#expect(RequestMatcher)}.
*
* @author Arjen Poutsma
* @author Lukas Krecan

View File

@@ -23,7 +23,7 @@ import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.WebServiceMessageFactory;
/**
* Allows for creating up responses. Implementations of this interface are returned by {@link WebServiceMock}.
* Allows for creating up responses. Implementations of this interface are returned by {@link ResponseCreators}.
*
* @author Arjen Poutsma
* @author Lukas Krecan

View File

@@ -19,14 +19,14 @@ package org.springframework.ws.test.client;
/**
* Allows for setting up expectations on XPath expressions.
* <p/>
* Implementations of this interface are returned by {@link WebServiceMock#xpath(String)} and {@link
* WebServiceMock#xpath(String, java.util.Map)}, as part of the fluent API. As such, it is not typical to implement this
* Implementations of this interface are returned by {@link RequestMatchers#xpath(String)} and {@link
* RequestMatchers#xpath(String, java.util.Map)}, as part of the fluent API. As such, it is not typical to implement this
* interface yourself.
*
* @author Lukas Krecan
* @author Arjen Poutsma
* @see WebServiceMock#xpath(String)
* @see WebServiceMock#xpath(String, java.util.Map)
* @see RequestMatchers#xpath(String)
* @see RequestMatchers#xpath(String, java.util.Map)
* @since 2.0
*/
public interface XPathExpectations {

View File

@@ -16,6 +16,6 @@
/**
* Provides a testing framework for client-side Web service testing. This package contains the
* {@link org.springframework.ws.test.client.WebServiceMock}, and various related test interfaces.
* {@link org.springframework.ws.test.client.MockWebServiceServer}, and various related test interfaces.
*/
package org.springframework.ws.test.client;

View File

@@ -0,0 +1,21 @@
/*
* 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.
*/
/**
* Provides a testing framework for server-side Web service testing. This package contains the
* {@link org.springframework.ws.test.client.MockWebServiceClient}, and various related test interfaces.
*/
package org.springframework.ws.test.server;

View File

@@ -32,7 +32,7 @@ public class DefaultXPathExpectationsTest {
@Test
public void existsMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b").exists();
RequestMatcher requestMatcher = RequestMatchers.xpath("//b").exists();
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -47,7 +47,7 @@ public class DefaultXPathExpectationsTest {
@Test(expected = AssertionError.class)
public void existsNonMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//c").exists();
RequestMatcher requestMatcher = RequestMatchers.xpath("//c").exists();
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -60,7 +60,7 @@ public class DefaultXPathExpectationsTest {
@Test
public void notExistsMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//c").doesNotExist();
RequestMatcher requestMatcher = RequestMatchers.xpath("//c").doesNotExist();
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -75,7 +75,7 @@ public class DefaultXPathExpectationsTest {
@Test(expected = AssertionError.class)
public void notExistsNonMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//a").doesNotExist();
RequestMatcher requestMatcher = RequestMatchers.xpath("//a").doesNotExist();
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -88,7 +88,7 @@ public class DefaultXPathExpectationsTest {
@Test
public void evaluatesToTrueMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b=1").evaluatesTo(true);
RequestMatcher requestMatcher = RequestMatchers.xpath("//b=1").evaluatesTo(true);
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -103,7 +103,7 @@ public class DefaultXPathExpectationsTest {
@Test(expected = AssertionError.class)
public void evaluatesToTrueNonMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b=2").evaluatesTo(true);
RequestMatcher requestMatcher = RequestMatchers.xpath("//b=2").evaluatesTo(true);
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -116,7 +116,7 @@ public class DefaultXPathExpectationsTest {
@Test
public void evaluatesToFalseMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b!=1").evaluatesTo(false);
RequestMatcher requestMatcher = RequestMatchers.xpath("//b!=1").evaluatesTo(false);
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -131,7 +131,7 @@ public class DefaultXPathExpectationsTest {
@Test(expected = AssertionError.class)
public void evaluatesToFalseNonMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b!=2").evaluatesTo(false);
RequestMatcher requestMatcher = RequestMatchers.xpath("//b!=2").evaluatesTo(false);
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -145,7 +145,7 @@ public class DefaultXPathExpectationsTest {
@Test
public void existsWithNamespacesMatch() throws IOException, AssertionError {
Map<String, String> ns = Collections.singletonMap("x", "http://example.org");
RequestMatcher requestMatcher = WebServiceMock.xpath("//x:b", ns).exists();
RequestMatcher requestMatcher = RequestMatchers.xpath("//x:b", ns).exists();
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -162,7 +162,7 @@ public class DefaultXPathExpectationsTest {
@Test(expected = AssertionError.class)
public void existsWithNamespacesNonMatch() throws IOException, AssertionError {
Map<String, String> ns = Collections.singletonMap("x", "http://example.org");
RequestMatcher requestMatcher = WebServiceMock.xpath("//b", ns).exists();
RequestMatcher requestMatcher = RequestMatchers.xpath("//b", ns).exists();
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -176,7 +176,7 @@ public class DefaultXPathExpectationsTest {
@Test
public void evaluatesToIntegerMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b").evaluatesTo(1);
RequestMatcher requestMatcher = RequestMatchers.xpath("//b").evaluatesTo(1);
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);
@@ -191,7 +191,7 @@ public class DefaultXPathExpectationsTest {
@Test(expected = AssertionError.class)
public void evaluatesToIntegerNonMatch() throws IOException, AssertionError {
RequestMatcher requestMatcher = WebServiceMock.xpath("//b").evaluatesTo(2);
RequestMatcher requestMatcher = RequestMatchers.xpath("//b").evaluatesTo(2);
assertNotNull(requestMatcher);
WebServiceMessage message = createMock(WebServiceMessage.class);

View File

@@ -51,7 +51,7 @@ public class SchemaValidatingRequestMatcherTest {
expect(message.getPayloadSource()).andReturn(new StringSource(
"<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));
RequestMatcher requestMatcher = WebServiceMock.validPayload(schema1);
RequestMatcher requestMatcher = RequestMatchers.validPayload(schema1);
replay(message);
@@ -65,7 +65,7 @@ public class SchemaValidatingRequestMatcherTest {
expect(message.getPayloadSource()).andReturn(new StringSource(
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"));
RequestMatcher requestMatcher = WebServiceMock.validPayload(schema1);
RequestMatcher requestMatcher = RequestMatchers.validPayload(schema1);
replay(message);
@@ -79,7 +79,7 @@ public class SchemaValidatingRequestMatcherTest {
expect(message.getPayloadSource()).andReturn(new StringSource(
"<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));
RequestMatcher requestMatcher = WebServiceMock.validPayload(schema1, schema2);
RequestMatcher requestMatcher = RequestMatchers.validPayload(schema1, schema2);
replay(message);
@@ -93,7 +93,7 @@ public class SchemaValidatingRequestMatcherTest {
expect(message.getPayloadSource()).andReturn(new StringSource(
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"));
RequestMatcher requestMatcher = WebServiceMock.validPayload(schema1, schema2);
RequestMatcher requestMatcher = RequestMatchers.validPayload(schema1, schema2);
replay(message);
@@ -107,7 +107,7 @@ public class SchemaValidatingRequestMatcherTest {
expect(message.getPayloadSource()).andReturn(new StringSource(
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"));
RequestMatcher requestMatcher = WebServiceMock.validPayload(schema2, schema1);
RequestMatcher requestMatcher = RequestMatchers.validPayload(schema2, schema1);
replay(message);