#1160 - Update code style.
This commit is contained in:
@@ -24,9 +24,9 @@ import org.springframework.ws.WebServiceMessageFactory;
|
||||
|
||||
/**
|
||||
* Abstract base class for the {@link ResponseCreator} interface.
|
||||
*
|
||||
* <p>Creates a response using the given {@link WebServiceMessageFactory}, and passes it on to {@link #doWithResponse(URI,
|
||||
* WebServiceMessage, WebServiceMessage)}.
|
||||
* <p>
|
||||
* Creates a response using the given {@link WebServiceMessageFactory}, and passes it on to
|
||||
* {@link #doWithResponse(URI, WebServiceMessage, WebServiceMessage)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
@@ -34,9 +34,8 @@ import org.springframework.ws.WebServiceMessageFactory;
|
||||
abstract class AbstractResponseCreator implements ResponseCreator {
|
||||
|
||||
@Override
|
||||
public final WebServiceMessage createResponse(URI uri,
|
||||
WebServiceMessage request,
|
||||
WebServiceMessageFactory messageFactory) throws IOException {
|
||||
public final WebServiceMessage createResponse(URI uri, WebServiceMessage request,
|
||||
WebServiceMessageFactory messageFactory) throws IOException {
|
||||
WebServiceMessage response = messageFactory.createWebServiceMessage();
|
||||
doWithResponse(uri, request, response);
|
||||
return response;
|
||||
@@ -45,8 +44,8 @@ abstract class AbstractResponseCreator implements ResponseCreator {
|
||||
/**
|
||||
* Execute any number of operations on the supplied response, given the request and URI.
|
||||
*
|
||||
* @param uri the URI
|
||||
* @param request the request message
|
||||
* @param uri the URI
|
||||
* @param request the request message
|
||||
* @param response the response message
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
|
||||
@@ -38,9 +38,8 @@ class ErrorResponseCreator implements ResponseCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceMessage createResponse(URI uri,
|
||||
WebServiceMessage request,
|
||||
WebServiceMessageFactory factory) throws IOException {
|
||||
public WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory factory)
|
||||
throws IOException {
|
||||
// Do nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ResponseCreator} that responds by throwing either an {@link IOException} or a {@link
|
||||
* RuntimeException}.
|
||||
* Implementation of {@link ResponseCreator} that responds by throwing either an {@link IOException} or a
|
||||
* {@link RuntimeException}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
@@ -42,13 +42,11 @@ class ExceptionResponseCreator implements ResponseCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceMessage createResponse(URI uri,
|
||||
WebServiceMessage request,
|
||||
WebServiceMessageFactory factory) throws IOException {
|
||||
public WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory factory)
|
||||
throws IOException {
|
||||
if (exception instanceof IOException) {
|
||||
throw (IOException) exception;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@ class MockSenderConnection implements WebServiceConnection, ResponseActions {
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
requestMatcher.match(uri, message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new AssertionError("Unexpected send() for [" + message + "]");
|
||||
}
|
||||
this.request = message;
|
||||
@@ -86,8 +85,7 @@ class MockSenderConnection implements WebServiceConnection, ResponseActions {
|
||||
public WebServiceMessage receive(WebServiceMessageFactory messageFactory) throws IOException {
|
||||
if (responseCreator != null) {
|
||||
return responseCreator.createResponse(uri, request, messageFactory);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -106,8 +104,7 @@ class MockSenderConnection implements WebServiceConnection, ResponseActions {
|
||||
public String getErrorMessage() throws IOException {
|
||||
if (responseCreator instanceof ErrorResponseCreator) {
|
||||
return ((ErrorResponseCreator) responseCreator).getErrorMessage();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ public class MockWebServiceMessageSender implements WebServiceMessageSender {
|
||||
}
|
||||
|
||||
void reset() {
|
||||
expectedConnections.clear();
|
||||
connectionIterator = null;
|
||||
}
|
||||
expectedConnections.clear();
|
||||
connectionIterator = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,26 +23,28 @@ import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
|
||||
import org.springframework.ws.test.support.MockStrategiesHelper;
|
||||
|
||||
/**
|
||||
* <strong>Main entry point for client-side Web service testing</strong>. Typically used to test a {@link
|
||||
* WebServiceTemplate}, set up expectations on request messages, and create response messages.
|
||||
*
|
||||
* <p>The typical usage of this class is:
|
||||
* <strong>Main entry point for client-side Web service testing</strong>. Typically used to test a
|
||||
* {@link WebServiceTemplate}, set up expectations on request messages, and create response messages.
|
||||
* <p>
|
||||
* The typical usage of this class is:
|
||||
* <ol>
|
||||
* <li>Create a {@code MockWebServiceServer} instance by calling {@link #createServer(WebServiceTemplate)},
|
||||
* {@link #createServer(WebServiceGatewaySupport)}, or {@link #createServer(ApplicationContext)}.
|
||||
* <li>Set up request expectations by calling {@link #expect(RequestMatcher)}, possibly by using the default
|
||||
* {@link RequestMatcher} implementations provided in {@link RequestMatchers} (which can be statically imported).
|
||||
* Multiple expectations can be set up by chaining {@link ResponseActions#andExpect(RequestMatcher)} calls.</li>
|
||||
* <li>Create an appropriate response message by calling
|
||||
* {@link ResponseActions#andRespond(ResponseCreator) andRespond(ResponseCreator)}, possibly by using the default
|
||||
* {@link ResponseCreator} implementations provided in {@link ResponseCreators} (which can be statically imported).</li>
|
||||
* <li>Create an appropriate response message by calling {@link ResponseActions#andRespond(ResponseCreator)
|
||||
* andRespond(ResponseCreator)}, possibly by using the default {@link ResponseCreator} implementations provided in
|
||||
* {@link ResponseCreators} (which can be statically imported).</li>
|
||||
* <li>Use the {@code WebServiceTemplate} as normal, either directly of through client code.</li>
|
||||
* <li>Call {@link #verify()}.</ol>
|
||||
* <li>Call {@link #verify()}.
|
||||
* </ol>
|
||||
* Note that because of the 'fluent' API offered by this class (and related classes), you can typically use the Code
|
||||
* Completion features (i.e. ctrl-space) in your IDE to set up the mocks.
|
||||
*
|
||||
* <p>For example:
|
||||
* <blockquote><pre>
|
||||
* <p>
|
||||
* For example: <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* import org.junit.*;
|
||||
* import org.springframework.beans.factory.annotation.Autowired;
|
||||
* import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -84,7 +86,9 @@ import org.springframework.ws.test.support.MockStrategiesHelper;
|
||||
* <strong>mockServer.verify();</strong>
|
||||
* }
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Lukas Krecan
|
||||
@@ -128,15 +132,15 @@ public class MockWebServiceServer {
|
||||
|
||||
/**
|
||||
* Creates a {@code MockWebServiceServer} instance based on the given {@link ApplicationContext}.
|
||||
*
|
||||
* <p>This factory method will try and find a configured {@link WebServiceTemplate} in the given application context.
|
||||
* If no template can be found, it will try and find a {@link WebServiceGatewaySupport}, and use its configured
|
||||
* template. If neither can be found, an exception is thrown.
|
||||
* <p>
|
||||
* This factory method will try and find a configured {@link WebServiceTemplate} in the given application context. If
|
||||
* no template can be found, it will try and find a {@link WebServiceGatewaySupport}, and use its configured template.
|
||||
* If neither can be found, an exception is thrown.
|
||||
*
|
||||
* @param applicationContext the application context to base the client on
|
||||
* @return the created server
|
||||
* @throws IllegalArgumentException if the given application context contains neither a {@link WebServiceTemplate}
|
||||
* nor a {@link WebServiceGatewaySupport}.
|
||||
* @throws IllegalArgumentException if the given application context contains neither a {@link WebServiceTemplate} nor
|
||||
* a {@link WebServiceGatewaySupport}.
|
||||
*/
|
||||
public static MockWebServiceServer createServer(ApplicationContext applicationContext) {
|
||||
MockStrategiesHelper strategiesHelper = new MockStrategiesHelper(applicationContext);
|
||||
@@ -153,8 +157,8 @@ public class MockWebServiceServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Records an expectation specified by the given {@link RequestMatcher}. Returns a {@link ResponseActions} object
|
||||
* that allows for creating the response, or to set up more expectations.
|
||||
* Records an expectation specified by the given {@link RequestMatcher}. Returns a {@link ResponseActions} object that
|
||||
* allows for creating the response, or to set up more expectations.
|
||||
*
|
||||
* @param requestMatcher the request matcher expected
|
||||
* @return the response actions
|
||||
@@ -174,12 +178,11 @@ public class MockWebServiceServer {
|
||||
mockMessageSender.verifyConnections();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the {@link MockWebServiceMessageSender}'s expectations.
|
||||
*/
|
||||
public void reset() {
|
||||
mockMessageSender.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the {@link MockWebServiceMessageSender}'s expectations.
|
||||
*/
|
||||
public void reset() {
|
||||
mockMessageSender.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ public interface RequestMatcher {
|
||||
* Matches the given request message against the expectations. Implementations typically make use of JUnit-based
|
||||
* assertions.
|
||||
*
|
||||
* @param uri the uri connected to
|
||||
* @param uri the uri connected to
|
||||
* @param request the request message to make assertions on
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws AssertionError if expectations are not met
|
||||
*/
|
||||
void match(URI uri, WebServiceMessage request) throws IOException, AssertionError;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.ws.test.client;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
@@ -32,26 +33,24 @@ import org.springframework.ws.test.support.matcher.SoapHeaderMatcher;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
|
||||
/**
|
||||
* Factory methods for {@link RequestMatcher} classes. Typically used to provide input for {@link
|
||||
* MockWebServiceServer#expect(RequestMatcher)}.
|
||||
* Factory methods for {@link RequestMatcher} classes. Typically used to provide input for
|
||||
* {@link MockWebServiceServer#expect(RequestMatcher)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class RequestMatchers {
|
||||
|
||||
private RequestMatchers() {
|
||||
}
|
||||
private RequestMatchers() {}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Expects any request.
|
||||
*
|
||||
* @return the request matcher
|
||||
*/
|
||||
public static RequestMatcher anything() {
|
||||
return new RequestMatcher() {
|
||||
public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
|
||||
}
|
||||
public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ public abstract class RequestMatchers {
|
||||
/**
|
||||
* Expects the payload to validate against the given XSD schema(s).
|
||||
*
|
||||
* @param schema the schema
|
||||
* @param schema the schema
|
||||
* @param furtherSchemas further schemas, if necessary
|
||||
* @return the request matcher
|
||||
*/
|
||||
@@ -103,7 +102,7 @@ public abstract class RequestMatchers {
|
||||
/**
|
||||
* Expects the given XPath expression to (not) exist or be evaluated to a value.
|
||||
*
|
||||
* @param xpathExpression the XPath expression
|
||||
* @param xpathExpression the XPath expression
|
||||
* @param namespaceMapping the namespaces
|
||||
* @return the XPath expectations, to be further configured
|
||||
*/
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.ws.test.client;
|
||||
|
||||
/**
|
||||
* Allows for setting up expectations on XPath expressions.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>
|
||||
* 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
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
/**
|
||||
* Allows for setting up responses and additional expectations. Implementations of this interface are returned by
|
||||
* Allows for setting up responses and additional expectations. Implementations of this interface are returned by
|
||||
* {@link MockWebServiceServer#expect(RequestMatcher)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
@@ -39,4 +39,4 @@ public interface ResponseActions {
|
||||
*/
|
||||
void andRespond(ResponseCreator responseCreator);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,12 @@ public interface ResponseCreator {
|
||||
/**
|
||||
* Create a response for the given the request and URI.
|
||||
*
|
||||
* @param uri the URI
|
||||
* @param request the request message
|
||||
* @param uri the URI
|
||||
* @param request the request message
|
||||
* @param messageFactory the message that can be used to create responses
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory messageFactory) throws IOException;
|
||||
WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory messageFactory)
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.ws.test.client;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -32,16 +33,15 @@ import org.springframework.ws.test.support.creator.WebServiceMessageCreator;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
|
||||
/**
|
||||
* Factory methods for {@link ResponseCreator} classes. Typically used to provide input for {@link
|
||||
* ResponseActions#andRespond(ResponseCreator)}.
|
||||
* Factory methods for {@link ResponseCreator} classes. Typically used to provide input for
|
||||
* {@link ResponseActions#andRespond(ResponseCreator)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class ResponseCreators {
|
||||
|
||||
private ResponseCreators() {
|
||||
}
|
||||
private ResponseCreators() {}
|
||||
|
||||
// Payload
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class ResponseCreators {
|
||||
}
|
||||
|
||||
// Error/Exception
|
||||
|
||||
|
||||
/**
|
||||
* Respond with an error.
|
||||
*
|
||||
@@ -130,12 +130,11 @@ public abstract class ResponseCreators {
|
||||
return withSoapEnvelope(new ResourceSource(soapEnvelope));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Respond with a {@code MustUnderstand} fault.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @see SoapBody#addMustUnderstandFault(String, java.util.Locale)
|
||||
*/
|
||||
public static ResponseCreator withMustUnderstandFault(final String faultStringOrReason, final Locale locale) {
|
||||
@@ -152,7 +151,7 @@ public abstract class ResponseCreators {
|
||||
* Respond with a {@code Client} (SOAP 1.1) or {@code Sender} (SOAP 1.2) fault.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale)
|
||||
*/
|
||||
public static ResponseCreator withClientOrSenderFault(final String faultStringOrReason, final Locale locale) {
|
||||
@@ -169,7 +168,7 @@ public abstract class ResponseCreators {
|
||||
* Respond with a {@code Server} (SOAP 1.1) or {@code Receiver} (SOAP 1.2) fault.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @see org.springframework.ws.soap.SoapBody#addServerOrReceiverFault(String, Locale)
|
||||
*/
|
||||
public static ResponseCreator withServerOrReceiverFault(final String faultStringOrReason, final Locale locale) {
|
||||
@@ -186,7 +185,7 @@ public abstract class ResponseCreators {
|
||||
* Respond with a {@code VersionMismatch} fault.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @param locale the language of faultStringOrReason. Optional for SOAP 1.1
|
||||
* @see org.springframework.ws.soap.SoapBody#addVersionMismatchFault(String, Locale)
|
||||
*/
|
||||
public static ResponseCreator withVersionMismatchFault(final String faultStringOrReason, final Locale locale) {
|
||||
@@ -211,12 +210,10 @@ public abstract class ResponseCreators {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceMessage createResponse(URI uri,
|
||||
WebServiceMessage request,
|
||||
WebServiceMessageFactory messageFactory) throws IOException {
|
||||
public WebServiceMessage createResponse(URI uri, WebServiceMessage request, WebServiceMessageFactory messageFactory)
|
||||
throws IOException {
|
||||
return adaptee.createMessage(messageFactory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
@@ -23,8 +25,6 @@ import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapBody;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ResponseCreator} that responds with a SOAP fault.
|
||||
*
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import java.net.URI;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertEquals;
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.ws.test.server;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
@@ -34,25 +34,27 @@ import org.springframework.ws.test.support.MockStrategiesHelper;
|
||||
import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
|
||||
/**
|
||||
* <strong>Main entry point for server-side Web service testing</strong>. Typically used to test a {@link
|
||||
* org.springframework.ws.server.MessageDispatcher MessageDispatcher} (including its endpoints, mappings, etc) by
|
||||
* <strong>Main entry point for server-side Web service testing</strong>. Typically used to test a
|
||||
* {@link org.springframework.ws.server.MessageDispatcher MessageDispatcher} (including its endpoints, mappings, etc) by
|
||||
* creating request messages, and setting up expectations about response messages.
|
||||
*
|
||||
* <p>The typical usage of this class is:
|
||||
* <p>
|
||||
* The typical usage of this class is:
|
||||
* <ol>
|
||||
* <li>Create a {@code MockWebServiceClient} instance by using {@link #createClient(ApplicationContext)} or
|
||||
* {@link #createClient(WebServiceMessageReceiver, WebServiceMessageFactory)}</li>
|
||||
* <li>Send request messages by calling {@link #sendRequest(RequestCreator)}, possibly by using the default
|
||||
* {@link RequestCreator} implementations provided in {@link RequestCreators} (which can be statically imported).</li>
|
||||
* <li>Set up response expectations by calling {@link ResponseActions#andExpect(ResponseMatcher) andExpect(ResponseMatcher)},
|
||||
* possibly by using the default {@link ResponseMatcher} implementations provided in {@link ResponseMatchers}
|
||||
* (which can be statically imported). Multiple expectations can be set up by chaining {@code andExpect()} calls.</li>
|
||||
* <li>Set up response expectations by calling {@link ResponseActions#andExpect(ResponseMatcher)
|
||||
* andExpect(ResponseMatcher)}, possibly by using the default {@link ResponseMatcher} implementations provided in
|
||||
* {@link ResponseMatchers} (which can be statically imported). Multiple expectations can be set up by chaining
|
||||
* {@code andExpect()} calls.</li>
|
||||
* </ol>
|
||||
* Note that because of the 'fluent' API offered by this class (and related classes), you can typically use the Code
|
||||
* Completion features (i.e. ctrl-space) in your IDE to set up the mocks.
|
||||
*
|
||||
* <p>For example:
|
||||
* <blockquote><pre>
|
||||
* <p>
|
||||
* For example: <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* import org.junit.*;
|
||||
* import org.springframework.beans.factory.annotation.Autowired;
|
||||
* import org.springframework.context.ApplicationContext;
|
||||
@@ -94,7 +96,9 @@ import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
* <strong>mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload))</strong>;
|
||||
* }
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Lukas Krecan
|
||||
@@ -120,28 +124,27 @@ public class MockWebServiceClient {
|
||||
// Factory methods
|
||||
|
||||
/**
|
||||
* Creates a {@code MockWebServiceClient} instance based on the given {@link WebServiceMessageReceiver} and {@link
|
||||
* WebServiceMessageFactory}.
|
||||
* Creates a {@code MockWebServiceClient} instance based on the given {@link WebServiceMessageReceiver} and
|
||||
* {@link WebServiceMessageFactory}.
|
||||
*
|
||||
* @param messageReceiver the message receiver, typically a {@link SoapMessageDispatcher}
|
||||
* @param messageFactory the message factory
|
||||
* @param messageFactory the message factory
|
||||
* @return the created client
|
||||
*/
|
||||
public static MockWebServiceClient createClient(WebServiceMessageReceiver messageReceiver,
|
||||
WebServiceMessageFactory messageFactory) {
|
||||
WebServiceMessageFactory messageFactory) {
|
||||
return new MockWebServiceClient(messageReceiver, messageFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code MockWebServiceClient} instance based on the given {@link ApplicationContext}.
|
||||
*
|
||||
* This factory method works in a similar fashion as the standard
|
||||
* {@link org.springframework.ws.transport.http.MessageDispatcherServlet MessageDispatcherServlet}. That is:
|
||||
* Creates a {@code MockWebServiceClient} instance based on the given {@link ApplicationContext}. This factory method
|
||||
* works in a similar fashion as the standard {@link org.springframework.ws.transport.http.MessageDispatcherServlet
|
||||
* MessageDispatcherServlet}. That is:
|
||||
* <ul>
|
||||
* <li>If a {@link WebServiceMessageReceiver} is configured in the given application context, it will use that.
|
||||
* If no message receiver is configured, it will create a default {@link SoapMessageDispatcher}.</li>
|
||||
* <li>If a {@link WebServiceMessageFactory} is configured in the given application context, it will use that.
|
||||
* If no message factory is configured, it will create a default {@link SaajSoapMessageFactory}.</li>
|
||||
* <li>If a {@link WebServiceMessageReceiver} is configured in the given application context, it will use that. If no
|
||||
* message receiver is configured, it will create a default {@link SoapMessageDispatcher}.</li>
|
||||
* <li>If a {@link WebServiceMessageFactory} is configured in the given application context, it will use that. If no
|
||||
* message factory is configured, it will create a default {@link SaajSoapMessageFactory}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param applicationContext the application context to base the client on
|
||||
@@ -152,10 +155,10 @@ public class MockWebServiceClient {
|
||||
|
||||
MockStrategiesHelper strategiesHelper = new MockStrategiesHelper(applicationContext);
|
||||
|
||||
WebServiceMessageReceiver messageReceiver =
|
||||
strategiesHelper.getStrategy(WebServiceMessageReceiver.class, SoapMessageDispatcher.class);
|
||||
WebServiceMessageFactory messageFactory =
|
||||
strategiesHelper.getStrategy(WebServiceMessageFactory.class, SaajSoapMessageFactory.class);
|
||||
WebServiceMessageReceiver messageReceiver = strategiesHelper.getStrategy(WebServiceMessageReceiver.class,
|
||||
SoapMessageDispatcher.class);
|
||||
WebServiceMessageFactory messageFactory = strategiesHelper.getStrategy(WebServiceMessageFactory.class,
|
||||
SaajSoapMessageFactory.class);
|
||||
return new MockWebServiceClient(messageReceiver, messageFactory);
|
||||
}
|
||||
|
||||
@@ -178,8 +181,7 @@ public class MockWebServiceClient {
|
||||
messageReceiver.receive(messageContext);
|
||||
|
||||
return new MockWebServiceClientResponseActions(messageContext);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
logger.error("Could not send request", ex);
|
||||
fail(ex.getMessage());
|
||||
return null;
|
||||
@@ -208,8 +210,7 @@ public class MockWebServiceClient {
|
||||
try {
|
||||
responseMatcher.match(request, response);
|
||||
return this;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
logger.error("Could not match request", ex);
|
||||
fail(ex.getMessage());
|
||||
return null;
|
||||
@@ -217,5 +218,4 @@ public class MockWebServiceClient {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,5 +38,4 @@ public interface RequestCreator {
|
||||
*/
|
||||
WebServiceMessage createRequest(WebServiceMessageFactory messageFactory) throws IOException;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.ws.test.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -29,16 +30,15 @@ import org.springframework.ws.test.support.creator.WebServiceMessageCreator;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
|
||||
/**
|
||||
* Factory methods for {@link RequestCreator} classes. Typically used to provide input for {@link
|
||||
* MockWebServiceClient#sendRequest(RequestCreator)}.
|
||||
* Factory methods for {@link RequestCreator} classes. Typically used to provide input for
|
||||
* {@link MockWebServiceClient#sendRequest(RequestCreator)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class RequestCreators {
|
||||
|
||||
private RequestCreators() {
|
||||
}
|
||||
private RequestCreators() {}
|
||||
|
||||
// Payload
|
||||
|
||||
@@ -65,7 +65,7 @@ public abstract class RequestCreators {
|
||||
}
|
||||
|
||||
// SOAP
|
||||
|
||||
|
||||
/**
|
||||
* Create a request with the given {@link Source} XML as SOAP envelope.
|
||||
*
|
||||
@@ -107,5 +107,4 @@ public abstract class RequestCreators {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public interface ResponseMatcher {
|
||||
*
|
||||
* @param request the request message
|
||||
* @param response the response message to make assertions on
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws AssertionError if expectations are not met
|
||||
*/
|
||||
void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError;
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.springframework.ws.test.server;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
@@ -33,20 +36,17 @@ import org.springframework.ws.test.support.matcher.SoapEnvelopeDiffMatcher;
|
||||
import org.springframework.ws.test.support.matcher.SoapHeaderMatcher;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Factory methods for {@link ResponseMatcher} classes. Typically used to provide input for {@link
|
||||
* ResponseActions#andExpect(ResponseMatcher)}.
|
||||
* Factory methods for {@link ResponseMatcher} classes. Typically used to provide input for
|
||||
* {@link ResponseActions#andExpect(ResponseMatcher)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class ResponseMatchers {
|
||||
|
||||
private ResponseMatchers() {
|
||||
}
|
||||
|
||||
private ResponseMatchers() {}
|
||||
|
||||
// Payload
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public abstract class ResponseMatchers {
|
||||
/**
|
||||
* Expects the payload to validate against the given XSD schema(s).
|
||||
*
|
||||
* @param schema the schema
|
||||
* @param schema the schema
|
||||
* @param furtherSchemas further schemas, if necessary
|
||||
* @return the response matcher
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ public abstract class ResponseMatchers {
|
||||
/**
|
||||
* Expects the given XPath expression to (not) exist or be evaluated to a value.
|
||||
*
|
||||
* @param xpathExpression the XPath expression
|
||||
* @param xpathExpression the XPath expression
|
||||
* @param namespaceMapping the namespaces
|
||||
* @return the XPath expectations, to be further configured
|
||||
*/
|
||||
@@ -143,8 +143,7 @@ public abstract class ResponseMatchers {
|
||||
*/
|
||||
public static ResponseMatcher noFault() {
|
||||
return new ResponseMatcher() {
|
||||
public void match(WebServiceMessage request, WebServiceMessage response)
|
||||
throws IOException, AssertionError {
|
||||
public void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError {
|
||||
if (response instanceof FaultAwareWebServiceMessage) {
|
||||
FaultAwareWebServiceMessage faultMessage = (FaultAwareWebServiceMessage) response;
|
||||
if (faultMessage.hasFault()) {
|
||||
@@ -169,7 +168,7 @@ public abstract class ResponseMatchers {
|
||||
* Expects a {@code MustUnderstand} fault with a particular fault string or reason.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or
|
||||
* reason text will not be verified
|
||||
* reason text will not be verified
|
||||
* @see org.springframework.ws.soap.SoapBody#addMustUnderstandFault(String, Locale)
|
||||
*/
|
||||
public static ResponseMatcher mustUnderstandFault(String faultStringOrReason) {
|
||||
@@ -194,7 +193,7 @@ public abstract class ResponseMatchers {
|
||||
* Expects a {@code Client} (SOAP 1.1) or {@code Sender} (SOAP 1.2) fault with a particular fault string or reason.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or
|
||||
* reason text will not be verified
|
||||
* reason text will not be verified
|
||||
* @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale)
|
||||
*/
|
||||
public static ResponseMatcher clientOrSenderFault(String faultStringOrReason) {
|
||||
@@ -219,7 +218,7 @@ public abstract class ResponseMatchers {
|
||||
* Expects a {@code Server} (SOAP 1.1) or {@code Receiver} (SOAP 1.2) fault with a particular fault string or reason.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or
|
||||
* reason text will not be verified
|
||||
* reason text will not be verified
|
||||
* @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale)
|
||||
*/
|
||||
public static ResponseMatcher serverOrReceiverFault(String faultStringOrReason) {
|
||||
@@ -244,7 +243,7 @@ public abstract class ResponseMatchers {
|
||||
* Expects a {@code VersionMismatch} fault with a particular fault string or reason.
|
||||
*
|
||||
* @param faultStringOrReason the SOAP 1.1 fault string or SOAP 1.2 reason text. If {@code null} the fault string or
|
||||
* reason text will not be verified
|
||||
* reason text will not be verified
|
||||
* @see org.springframework.ws.soap.SoapBody#addClientOrSenderFault(String, Locale)
|
||||
*/
|
||||
public static ResponseMatcher versionMismatchFault(String faultStringOrReason) {
|
||||
|
||||
@@ -18,10 +18,11 @@ package org.springframework.ws.test.server;
|
||||
|
||||
/**
|
||||
* Allows for setting up expectations on XPath expressions.
|
||||
*
|
||||
* <p>Implementations of this interface are returned by {@link org.springframework.ws.test.client.RequestMatchers#xpath(String)} and {@link
|
||||
* org.springframework.ws.test.client.RequestMatchers#xpath(String, java.util.Map)}, as part of the fluent API. As such, it is not typical to implement this
|
||||
* interface yourself.
|
||||
* <p>
|
||||
* Implementations of this interface are returned by
|
||||
* {@link org.springframework.ws.test.client.RequestMatchers#xpath(String)} and
|
||||
* {@link org.springframework.ws.test.client.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
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package org.springframework.ws.test.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.namespace.QName;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertEquals;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapBody;
|
||||
@@ -53,8 +53,7 @@ abstract class SoapFaultResponseMatcher implements ResponseMatcher {
|
||||
QName expectedFaultCode = getExpectedFaultCode(soapResponse.getVersion());
|
||||
assertEquals("Invalid SOAP Fault code", expectedFaultCode, soapFault.getFaultCode());
|
||||
if (expectedFaultStringOrReason != null) {
|
||||
assertEquals("Invalid SOAP Fault string/reason", expectedFaultStringOrReason,
|
||||
soapFault.getFaultStringOrReason());
|
||||
assertEquals("Invalid SOAP Fault string/reason", expectedFaultStringOrReason, soapFault.getFaultStringOrReason());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ import javax.xml.transform.Source;
|
||||
*/
|
||||
public abstract class AssertionErrors {
|
||||
|
||||
private AssertionErrors() {
|
||||
}
|
||||
private AssertionErrors() {}
|
||||
|
||||
/**
|
||||
* Fails a test with the given message.
|
||||
@@ -43,13 +42,12 @@ public abstract class AssertionErrors {
|
||||
* Fails a test with the given message and source.
|
||||
*
|
||||
* @param message the message
|
||||
* @param source the source
|
||||
* @param source the source
|
||||
*/
|
||||
public static void fail(String message, String sourceLabel, Source source) {
|
||||
if (source != null) {
|
||||
throw new SourceAssertionError(message, sourceLabel, source);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fail(message);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +55,7 @@ public abstract class AssertionErrors {
|
||||
/**
|
||||
* Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message.
|
||||
*
|
||||
* @param message the message
|
||||
* @param message the message
|
||||
* @param condition the condition to test for
|
||||
*/
|
||||
public static void assertTrue(String message, boolean condition) {
|
||||
@@ -68,7 +66,7 @@ public abstract class AssertionErrors {
|
||||
* Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message and
|
||||
* source.
|
||||
*
|
||||
* @param message the message
|
||||
* @param message the message
|
||||
* @param condition the condition to test for
|
||||
*/
|
||||
public static void assertTrue(String message, boolean condition, String sourceLabel, Source source) {
|
||||
@@ -80,9 +78,9 @@ public abstract class AssertionErrors {
|
||||
/**
|
||||
* Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message.
|
||||
*
|
||||
* @param message the message
|
||||
* @param message the message
|
||||
* @param expected the expected value
|
||||
* @param actual the actual value
|
||||
* @param actual the actual value
|
||||
*/
|
||||
public static void assertEquals(String message, Object expected, Object actual) {
|
||||
assertEquals(message, expected, actual, null, null);
|
||||
@@ -91,10 +89,10 @@ public abstract class AssertionErrors {
|
||||
/**
|
||||
* Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message.
|
||||
*
|
||||
* @param message the message
|
||||
* @param message the message
|
||||
* @param expected the expected value
|
||||
* @param actual the actual value
|
||||
* @param source the source
|
||||
* @param actual the actual value
|
||||
* @param source the source
|
||||
*/
|
||||
public static void assertEquals(String message, Object expected, Object actual, String sourceLabel, Source source) {
|
||||
if (expected == null && actual == null) {
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.ws.test.support;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
@@ -27,9 +29,6 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Helper class for for loading default implementations of an interface.
|
||||
*
|
||||
@@ -71,15 +70,13 @@ public class MockStrategiesHelper {
|
||||
Map<String, T> map = applicationContext.getBeansOfType(type);
|
||||
if (map.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
else if (map.size() == 1) {
|
||||
} else if (map.size() == 1) {
|
||||
Map.Entry<String, T> entry = map.entrySet().iterator().next();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Using " + ClassUtils.getShortName(type) + " [" + entry.getKey() + "]");
|
||||
}
|
||||
return entry.getValue();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new BeanInitializationException(
|
||||
"Could not find exactly 1 " + ClassUtils.getShortName(type) + " in application context");
|
||||
}
|
||||
@@ -99,11 +96,10 @@ public class MockStrategiesHelper {
|
||||
T t = getStrategy(type);
|
||||
if (t != null) {
|
||||
return t;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No " + ClassUtils.getShortName(type) + " found, using default " +
|
||||
ClassUtils.getShortName(defaultType));
|
||||
logger.debug(
|
||||
"No " + ClassUtils.getShortName(type) + " found, using default " + ClassUtils.getShortName(defaultType));
|
||||
}
|
||||
T defaultStrategy = BeanUtils.instantiateClass(defaultType);
|
||||
if (defaultStrategy instanceof ApplicationContextAware) {
|
||||
@@ -114,8 +110,7 @@ public class MockStrategiesHelper {
|
||||
InitializingBean initializingBean = (InitializingBean) defaultStrategy;
|
||||
try {
|
||||
initializingBean.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
throw new BeanCreationException("Invocation of init method failed", ex);
|
||||
}
|
||||
}
|
||||
@@ -123,5 +118,4 @@ public class MockStrategiesHelper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.xml.transform.TransformerHelper;
|
||||
*
|
||||
* @author Lukas Krecan
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0.1
|
||||
* @since 2.0.1
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SourceAssertionError extends AssertionError {
|
||||
@@ -52,6 +52,7 @@ public class SourceAssertionError extends AssertionError {
|
||||
|
||||
/**
|
||||
* Returns the source context of this error.
|
||||
*
|
||||
* @return the source
|
||||
*/
|
||||
public Source getSource() {
|
||||
@@ -81,8 +82,7 @@ public class SourceAssertionError extends AssertionError {
|
||||
Transformer transformer = createNonIndentingTransformer();
|
||||
transformer.transform(source, result);
|
||||
return result.toString();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
} catch (TransformerException ex) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
@@ -96,5 +96,4 @@ public class SourceAssertionError extends AssertionError {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import org.springframework.ws.WebServiceMessageFactory;
|
||||
|
||||
/**
|
||||
* Abstract base class for the {@link WebServiceMessageCreator} interface.
|
||||
*
|
||||
* <p>Creates a message using the given {@link WebServiceMessageFactory}, and passes it on to {@link
|
||||
* #doWithMessage(WebServiceMessage)}.
|
||||
* <p>
|
||||
* Creates a message using the given {@link WebServiceMessageFactory}, and passes it on to
|
||||
* {@link #doWithMessage(WebServiceMessage)}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.springframework.ws.test.support.creator;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
@@ -24,8 +27,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Implementation of {@link WebServiceMessageCreator} that creates a request based on a {@link Source}.
|
||||
*
|
||||
@@ -52,8 +53,7 @@ public class PayloadMessageCreator extends AbstractMessageCreator {
|
||||
protected void doWithMessage(WebServiceMessage message) throws IOException {
|
||||
try {
|
||||
transformerHelper.transform(payload, message.getPayloadResult());
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
} catch (TransformerException ex) {
|
||||
fail("Could not transform request payload to message: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.springframework.ws.test.support.creator;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
@@ -25,12 +28,8 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Implementation of {@link WebServiceMessageCreator} that creates a request based on a SOAP envelope {@link Source}.
|
||||
*
|
||||
@@ -38,11 +37,11 @@ import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
* @since 2.1.1
|
||||
*/
|
||||
public class SoapEnvelopeMessageCreator extends AbstractMessageCreator {
|
||||
|
||||
|
||||
private final Source soapEnvelope;
|
||||
|
||||
private final TransformerHelper transformerHelper = new TransformerHelper();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of the {@code SoapEnvelopeMessageCreator} with the given SOAP envelope source.
|
||||
*
|
||||
@@ -61,10 +60,9 @@ public class SoapEnvelopeMessageCreator extends AbstractMessageCreator {
|
||||
DOMResult result = new DOMResult();
|
||||
transformerHelper.transform(soapEnvelope, result);
|
||||
soapMessage.setDocument((Document) result.getNode());
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
} catch (TransformerException ex) {
|
||||
fail("Could not transform request SOAP envelope to message: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,5 +37,4 @@ public interface WebServiceMessageCreator {
|
||||
*/
|
||||
WebServiceMessage createMessage(WebServiceMessageFactory messageFactory) throws IOException;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the generic {@link org.springframework.ws.test.support.creator.WebServiceMessageCreator WebServiceMessageCreator}
|
||||
* interface, and implementations.
|
||||
* Provides the generic {@link org.springframework.ws.test.support.creator.WebServiceMessageCreator
|
||||
* WebServiceMessageCreator} interface, and implementations.
|
||||
*/
|
||||
package org.springframework.ws.test.support.creator;
|
||||
|
||||
@@ -16,18 +16,18 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
/**
|
||||
* Abstract base class for SOAP-specific {@link WebServiceMessageMatcher} implementations.
|
||||
*
|
||||
* <p>Asserts that the message given to {@link #match(WebServiceMessage)} is a {@link SoapMessage}, and invokes {@link
|
||||
* #match(SoapMessage)} with it if so.
|
||||
* <p>
|
||||
* Asserts that the message given to {@link #match(WebServiceMessage)} is a {@link SoapMessage}, and invokes
|
||||
* {@link #match(SoapMessage)} with it if so.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractSoapMessageMatcher implements WebServiceMessageMat
|
||||
* {@link SoapMessage}.
|
||||
*
|
||||
* @param soapMessage the soap message
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws AssertionError if expectations are not met
|
||||
*/
|
||||
protected abstract void match(SoapMessage soapMessage) throws IOException, AssertionError;
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} payloads.
|
||||
*
|
||||
@@ -67,10 +66,9 @@ public class PayloadDiffMatcher extends DiffMatcher {
|
||||
DOMResult result = new DOMResult();
|
||||
transformerHelper.transform(source, result);
|
||||
return (Document) result.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
} catch (TransformerException ex) {
|
||||
fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.xml.validation.XmlValidator;
|
||||
import org.springframework.xml.validation.XmlValidatorFactory;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
/**
|
||||
* Uses the {@link XmlValidator} to validate request payload.
|
||||
@@ -43,7 +43,7 @@ public class SchemaValidatingMatcher implements WebServiceMessageMatcher {
|
||||
/**
|
||||
* Creates a {@code SchemaValidatingMatcher} based on the given schema resource(s).
|
||||
*
|
||||
* @param schema the schema
|
||||
* @param schema the schema
|
||||
* @param furtherSchemas further schemas, if necessary
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
|
||||
@@ -16,22 +16,21 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} SOAP envelopes.
|
||||
*
|
||||
@@ -39,7 +38,7 @@ import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
* @since 2.1.1
|
||||
*/
|
||||
public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
|
||||
|
||||
private final Source expected;
|
||||
|
||||
private final TransformerHelper transformerHelper = new TransformerHelper();
|
||||
@@ -52,7 +51,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
Assert.notNull(expected, "'expected' must not be null");
|
||||
this.expected = expected;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void match(SoapMessage soapMessage) throws IOException, AssertionError {
|
||||
Document actualDocument = soapMessage.getDocument();
|
||||
@@ -66,8 +65,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
DOMResult result = new DOMResult();
|
||||
transformerHelper.transform(source, result);
|
||||
return (Document) result.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
} catch (TransformerException ex) {
|
||||
fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -25,8 +28,6 @@ import org.springframework.ws.soap.SoapHeader;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
|
||||
/**
|
||||
* Matches SOAP headers.
|
||||
*
|
||||
@@ -38,8 +39,7 @@ public class SoapHeaderMatcher extends AbstractSoapMessageMatcher {
|
||||
private final QName soapHeaderName;
|
||||
|
||||
/**
|
||||
* Creates a new instance of the {@code SoapHeaderMatcher} that checks for the presence of the given SOAP header
|
||||
* name.
|
||||
* Creates a new instance of the {@code SoapHeaderMatcher} that checks for the presence of the given SOAP header name.
|
||||
*
|
||||
* @param soapHeaderName the header name to check for
|
||||
*/
|
||||
|
||||
@@ -29,11 +29,10 @@ import org.springframework.ws.WebServiceMessage;
|
||||
public interface WebServiceMessageMatcher {
|
||||
|
||||
/**
|
||||
* Matches the given message against the expectations. Implementations typically make use of JUnit-based
|
||||
* assertions.
|
||||
* Matches the given message against the expectations. Implementations typically make use of JUnit-based assertions.
|
||||
*
|
||||
* @param message the message
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws AssertionError if expectations are not met
|
||||
*/
|
||||
void match(WebServiceMessage message) throws IOException, AssertionError;
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
@@ -26,12 +29,8 @@ import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertEquals;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Helper class for dealing with XPath expectations.
|
||||
*
|
||||
@@ -55,6 +54,7 @@ public class XPathExpectationsHelper {
|
||||
public XPathExpectationsHelper(String expression) {
|
||||
this(expression, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of the {@code XPathExpectationsSupport} with the given XPath expression and namespaces.
|
||||
*
|
||||
@@ -96,8 +96,8 @@ public class XPathExpectationsHelper {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
Node payload = transformToNode(message);
|
||||
boolean result = expression.evaluateAsBoolean(payload);
|
||||
assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue,
|
||||
result, "Payload", message.getPayloadSource());
|
||||
assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, result,
|
||||
"Payload", message.getPayloadSource());
|
||||
|
||||
}
|
||||
};
|
||||
@@ -112,8 +112,8 @@ public class XPathExpectationsHelper {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
Node payload = transformToNode(message);
|
||||
double result = expression.evaluateAsNumber(payload);
|
||||
assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue,
|
||||
result, "Payload", message.getPayloadSource());
|
||||
assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, result,
|
||||
"Payload", message.getPayloadSource());
|
||||
|
||||
}
|
||||
};
|
||||
@@ -125,8 +125,8 @@ public class XPathExpectationsHelper {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
Node payload = transformToNode(message);
|
||||
String result = expression.evaluateAsString(payload);
|
||||
assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue,
|
||||
result, "Payload", message.getPayloadSource());
|
||||
assertEquals("Evaluation of XPath expression \"" + expressionString + "\" failed.", expectedValue, result,
|
||||
"Payload", message.getPayloadSource());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -136,12 +136,10 @@ public class XPathExpectationsHelper {
|
||||
try {
|
||||
transformerHelper.transform(request.getPayloadSource(), domResult);
|
||||
return domResult.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
} catch (TransformerException ex) {
|
||||
fail("Could not transform request payload: " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the generic {@link org.springframework.ws.test.support.matcher.WebServiceMessageMatcher WebServiceMessageMatcher}
|
||||
* interface, and implementations.
|
||||
* Provides the generic {@link org.springframework.ws.test.support.matcher.WebServiceMessageMatcher
|
||||
* WebServiceMessageMatcher} interface, and implementations.
|
||||
*/
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ErrorResponseCreatorTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -35,4 +35,4 @@ public class ExceptionResponseCreatorTest {
|
||||
|
||||
callback.createResponse(null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.withError;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.withPayload;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
public class MockSenderConnectionTest {
|
||||
|
||||
|
||||
@@ -16,16 +16,25 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.ws.test.client.RequestMatchers.*;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -40,16 +49,6 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.ws.test.client.RequestMatchers.*;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.withClientOrSenderFault;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.withPayload;
|
||||
|
||||
public class MockWebServiceServerTest {
|
||||
|
||||
private WebServiceTemplate template;
|
||||
@@ -214,7 +213,8 @@ public class MockWebServiceServerTest {
|
||||
@Test
|
||||
public void xsdMatch() throws Exception {
|
||||
Resource schema = new ByteArrayResource(
|
||||
"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://example.com\" elementFormDefault=\"qualified\"><element name=\"request\"/></schema>".getBytes());
|
||||
"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://example.com\" elementFormDefault=\"qualified\"><element name=\"request\"/></schema>"
|
||||
.getBytes());
|
||||
|
||||
server.expect(validPayload(schema));
|
||||
|
||||
@@ -226,7 +226,8 @@ public class MockWebServiceServerTest {
|
||||
@Test(expected = AssertionError.class)
|
||||
public void xsdNonMatch() throws Exception {
|
||||
Resource schema = new ByteArrayResource(
|
||||
"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://example.com\" elementFormDefault=\"qualified\"><element name=\"request\"/></schema>".getBytes());
|
||||
"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://example.com\" elementFormDefault=\"qualified\"><element name=\"request\"/></schema>"
|
||||
.getBytes());
|
||||
|
||||
server.expect(validPayload(schema));
|
||||
|
||||
@@ -304,7 +305,7 @@ public class MockWebServiceServerTest {
|
||||
StringResult result = new StringResult();
|
||||
template.sendSourceAndReceiveToResult(request, result);
|
||||
}
|
||||
|
||||
|
||||
public static class MyClient extends WebServiceGatewaySupport {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,21 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
@@ -33,12 +41,6 @@ import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ResponseCreatorsTest {
|
||||
|
||||
private final TransformerHelper transformerHelper = new TransformerHelper();
|
||||
@@ -65,14 +67,13 @@ public class ResponseCreatorsTest {
|
||||
@Test
|
||||
public void withPayloadResource() throws Exception {
|
||||
String payload = "<payload xmlns='http://springframework.org'/>";
|
||||
ResponseCreator responseCreator =
|
||||
ResponseCreators.withPayload(new ByteArrayResource(payload.getBytes("UTF-8")));
|
||||
ResponseCreator responseCreator = ResponseCreators.withPayload(new ByteArrayResource(payload.getBytes("UTF-8")));
|
||||
|
||||
WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);
|
||||
|
||||
assertXMLEqual(payload, getPayloadAsString(response));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void withSoapEnvelopeSource() throws Exception {
|
||||
StringBuilder xmlBuilder = new StringBuilder();
|
||||
@@ -84,9 +85,9 @@ public class ResponseCreatorsTest {
|
||||
String envelope = xmlBuilder.toString();
|
||||
ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new StringSource(envelope));
|
||||
WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);
|
||||
assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage)response));
|
||||
assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage) response));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void withSoapEnvelopeResource() throws Exception {
|
||||
StringBuilder xmlBuilder = new StringBuilder();
|
||||
@@ -96,9 +97,10 @@ public class ResponseCreatorsTest {
|
||||
xmlBuilder.append("<soap:Body><payload xmlns='http://springframework.org'/></soap:Body>");
|
||||
xmlBuilder.append("</soap:Envelope>");
|
||||
String envelope = xmlBuilder.toString();
|
||||
ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new ByteArrayResource(envelope.getBytes("UTF-8")));
|
||||
ResponseCreator responseCreator = ResponseCreators
|
||||
.withSoapEnvelope(new ByteArrayResource(envelope.getBytes("UTF-8")));
|
||||
WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);
|
||||
assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage)response));
|
||||
assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage) response));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,12 +110,11 @@ public class ResponseCreatorsTest {
|
||||
|
||||
try {
|
||||
responseCreator.createResponse(null, null, null);
|
||||
}
|
||||
catch (IOException actual) {
|
||||
} catch (IOException actual) {
|
||||
assertSame(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void withRuntimeException() throws Exception {
|
||||
RuntimeException expected = new RuntimeException("Foo");
|
||||
@@ -121,8 +122,7 @@ public class ResponseCreatorsTest {
|
||||
|
||||
try {
|
||||
responseCreator.createResponse(null, null, null);
|
||||
}
|
||||
catch (RuntimeException actual) {
|
||||
} catch (RuntimeException actual) {
|
||||
assertSame(expected, actual);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class ResponseCreatorsTest {
|
||||
|
||||
testFault(responseCreator, faultString, SoapVersion.SOAP_11.getVersionMismatchFaultName());
|
||||
}
|
||||
|
||||
|
||||
private void testFault(ResponseCreator responseCreator, String faultString, QName faultCode) throws IOException {
|
||||
SoapMessage response = (SoapMessage) responseCreator.createResponse(null, null, messageFactory);
|
||||
|
||||
@@ -174,7 +174,7 @@ public class ResponseCreatorsTest {
|
||||
transformerHelper.transform(message.getPayloadSource(), result);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
private String getSoapEnvelopeAsString(SoapMessage message) throws TransformerException {
|
||||
DOMSource source = new DOMSource(message.getDocument());
|
||||
Result result = new StringResult();
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
public class UriMatcherTest {
|
||||
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
package org.springframework.ws.test.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -43,7 +42,7 @@ public class WebServiceMessageMatcherAdapterTest {
|
||||
adaptee = createMock(WebServiceMessageMatcher.class);
|
||||
adapter = new WebServiceMessageMatcherAdapter(adaptee);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void match() throws IOException {
|
||||
adaptee.match(message);
|
||||
|
||||
@@ -16,22 +16,21 @@
|
||||
|
||||
package org.springframework.ws.test.client.integration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.ws.test.client.RequestMatchers.*;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.*;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.ws.test.client.MockWebServiceServer;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.ws.test.client.RequestMatchers.payload;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.withPayload;
|
||||
|
||||
/**
|
||||
* Integration test for client-side WebService testing. In different package so we can't use the package-protected
|
||||
* classes.
|
||||
@@ -42,8 +41,7 @@ import static org.springframework.ws.test.client.ResponseCreators.withPayload;
|
||||
@ContextConfiguration("integration-test.xml")
|
||||
public class ClientIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private CustomerClient client;
|
||||
@Autowired private CustomerClient client;
|
||||
|
||||
private MockWebServiceServer mockServer;
|
||||
|
||||
@@ -55,11 +53,10 @@ public class ClientIntegrationTest {
|
||||
@Test
|
||||
public void basic() throws Exception {
|
||||
Source expectedRequestPayload = new StringSource(
|
||||
"<customerCountRequest xmlns='http://springframework.org/spring-ws'>" +
|
||||
"<customerName>John Doe</customerName>" + "</customerCountRequest>");
|
||||
Source responsePayload = new StringSource(
|
||||
"<customerCountResponse xmlns='http://springframework.org/spring-ws'>" +
|
||||
"<customerCount>10</customerCount>" + "</customerCountResponse>");
|
||||
"<customerCountRequest xmlns='http://springframework.org/spring-ws'>" + "<customerName>John Doe</customerName>"
|
||||
+ "</customerCountRequest>");
|
||||
Source responsePayload = new StringSource("<customerCountResponse xmlns='http://springframework.org/spring-ws'>"
|
||||
+ "<customerCount>10</customerCount>" + "</customerCountResponse>");
|
||||
|
||||
mockServer.expect(payload(expectedRequestPayload)).andRespond(withPayload(responsePayload));
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ 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() {
|
||||
|
||||
@@ -32,4 +32,4 @@ public class CustomerCountRequest {
|
||||
public void setCustomerName(String name) {
|
||||
this.customerName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@ public class CustomerCountResponse {
|
||||
public void setCustomerCount(int customerCount) {
|
||||
this.customerCount = customerCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
|
||||
package org.springframework.ws.test.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.soap.server.SoapMessageDispatcher;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class MockWebServiceClientTest {
|
||||
|
||||
@Test
|
||||
@@ -36,7 +35,7 @@ public class MockWebServiceClientTest {
|
||||
MockWebServiceClient client = MockWebServiceClient.createClient(applicationContext);
|
||||
assertNotNull(client);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createServerApplicationContextDefaults() throws Exception {
|
||||
StaticApplicationContext applicationContext = new StaticApplicationContext();
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
package org.springframework.ws.test.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -43,7 +42,7 @@ public class WebServiceMessageMatcherAdapterTest {
|
||||
adaptee = createMock(WebServiceMessageMatcher.class);
|
||||
adapter = new WebServiceMessageMatcherAdapter(adaptee);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void match() throws IOException {
|
||||
adaptee.match(message);
|
||||
|
||||
@@ -16,8 +16,14 @@
|
||||
|
||||
package org.springframework.ws.test.server.integration;
|
||||
|
||||
import static org.springframework.ws.test.server.RequestCreators.*;
|
||||
import static org.springframework.ws.test.server.ResponseMatchers.*;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -25,13 +31,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.ws.test.server.MockWebServiceClient;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.springframework.ws.test.server.RequestCreators.withPayload;
|
||||
import static org.springframework.ws.test.server.ResponseMatchers.payload;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@@ -39,8 +38,7 @@ import static org.springframework.ws.test.server.ResponseMatchers.payload;
|
||||
@ContextConfiguration("integration-test.xml")
|
||||
public class ServerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired private ApplicationContext applicationContext;
|
||||
|
||||
private MockWebServiceClient mockClient;
|
||||
|
||||
@@ -51,14 +49,13 @@ public class ServerIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void basic() throws Exception {
|
||||
Source requestPayload = new StringSource("<customerCountRequest xmlns='http://springframework.org/spring-ws'>" +
|
||||
"<customerName>John Doe</customerName>" + "</customerCountRequest>");
|
||||
Source requestPayload = new StringSource("<customerCountRequest xmlns='http://springframework.org/spring-ws'>"
|
||||
+ "<customerName>John Doe</customerName>" + "</customerCountRequest>");
|
||||
Source expectedResponsePayload = new StringSource(
|
||||
"<customerCountResponse xmlns='http://springframework.org/spring-ws'>" +
|
||||
"<customerCount>42</customerCount>" + "</customerCountResponse>");
|
||||
"<customerCountResponse xmlns='http://springframework.org/spring-ws'>" + "<customerCount>42</customerCount>"
|
||||
+ "</customerCountResponse>");
|
||||
|
||||
mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package org.springframework.ws.test.support;
|
||||
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
public class MockStrategiesHelperTest {
|
||||
|
||||
@@ -52,17 +50,15 @@ public class MockStrategiesHelperTest {
|
||||
MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
|
||||
helper.getStrategy(IMyBean.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noneWithDefault() {
|
||||
StaticApplicationContext applicationContext = new StaticApplicationContext();
|
||||
|
||||
|
||||
MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
|
||||
assertNotNull(helper.getStrategy(IMyBean.class, MyBean.class));
|
||||
}
|
||||
|
||||
|
||||
public interface IMyBean {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,17 +16,16 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import javax.xml.soap.MessageFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessage;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
public class PayloadDiffMatcherTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
public class SchemaValidatingMatcherTest {
|
||||
|
||||
private Resource schema;
|
||||
@@ -48,8 +47,8 @@ public class SchemaValidatingMatcherTest {
|
||||
|
||||
@Test
|
||||
public void singleSchemaMatch() throws IOException, AssertionError {
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource(
|
||||
"<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));
|
||||
expect(message.getPayloadSource()).andReturn(
|
||||
new StringSource("<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));
|
||||
|
||||
SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema);
|
||||
|
||||
@@ -62,8 +61,9 @@ public class SchemaValidatingMatcherTest {
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void singleSchemaNonMatch() throws IOException, AssertionError {
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource(
|
||||
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>")).times(2);
|
||||
expect(message.getPayloadSource()).andReturn(
|
||||
new StringSource("<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"))
|
||||
.times(2);
|
||||
|
||||
SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema);
|
||||
|
||||
@@ -76,8 +76,8 @@ public class SchemaValidatingMatcherTest {
|
||||
|
||||
@Test
|
||||
public void multipleSchemaMatch() throws IOException, AssertionError {
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource(
|
||||
"<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));
|
||||
expect(message.getPayloadSource()).andReturn(
|
||||
new StringSource("<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));
|
||||
|
||||
SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2);
|
||||
|
||||
@@ -90,8 +90,9 @@ public class SchemaValidatingMatcherTest {
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void multipleSchemaNotOk() throws IOException, AssertionError {
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource(
|
||||
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>")).times(2);
|
||||
expect(message.getPayloadSource()).andReturn(
|
||||
new StringSource("<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"))
|
||||
.times(2);
|
||||
|
||||
SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2);
|
||||
|
||||
@@ -104,8 +105,9 @@ public class SchemaValidatingMatcherTest {
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void multipleSchemaDifferentOrderNotOk() throws IOException, AssertionError {
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource(
|
||||
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>")).times(2);
|
||||
expect(message.getPayloadSource()).andReturn(
|
||||
new StringSource("<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"))
|
||||
.times(2);
|
||||
|
||||
SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema1, schema2);
|
||||
|
||||
@@ -118,8 +120,9 @@ public class SchemaValidatingMatcherTest {
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void xmlValidatorNotOk() throws IOException, AssertionError {
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource(
|
||||
"<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>")).times(2);
|
||||
expect(message.getPayloadSource()).andReturn(
|
||||
new StringSource("<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>"))
|
||||
.times(2);
|
||||
|
||||
SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema);
|
||||
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
public class SoapEnvelopeDiffMatcherTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void match() throws Exception {
|
||||
StringBuilder xmlBuilder = new StringBuilder();
|
||||
@@ -42,7 +41,7 @@ public class SoapEnvelopeDiffMatcherTest {
|
||||
TransformerHelper transformerHelper = new TransformerHelper();
|
||||
transformerHelper.transform(new StringSource(xml), result);
|
||||
SoapMessage message = createMock(SoapMessage.class);
|
||||
expect(message.getDocument()).andReturn((Document)result.getNode()).once();
|
||||
expect(message.getDocument()).andReturn((Document) result.getNode()).once();
|
||||
replay(message);
|
||||
|
||||
SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(xml));
|
||||
@@ -50,7 +49,7 @@ public class SoapEnvelopeDiffMatcherTest {
|
||||
|
||||
verify(message);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void nonMatch() throws Exception {
|
||||
StringBuilder xmlBuilder = new StringBuilder();
|
||||
@@ -65,12 +64,12 @@ public class SoapEnvelopeDiffMatcherTest {
|
||||
TransformerHelper transformerHelper = new TransformerHelper();
|
||||
transformerHelper.transform(new StringSource(actual), result);
|
||||
SoapMessage message = createMock(SoapMessage.class);
|
||||
expect(message.getDocument()).andReturn((Document)result.getNode()).once();
|
||||
expect(message.getDocument()).andReturn((Document) result.getNode()).once();
|
||||
replay(message);
|
||||
|
||||
String expected = String.format(xml, "2");
|
||||
SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(expected));
|
||||
matcher.match(message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessage;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
|
||||
public class SoapHeaderMatcherTest {
|
||||
|
||||
private SoapHeaderMatcher matcher;
|
||||
@@ -67,4 +66,4 @@ public class SoapHeaderMatcherTest {
|
||||
matcher.match(message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package org.springframework.ws.test.support.matcher;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class XPathExpectationsHelperTest {
|
||||
|
||||
@Test
|
||||
@@ -188,8 +187,7 @@ public class XPathExpectationsHelperTest {
|
||||
assertNotNull(matcher);
|
||||
|
||||
WebServiceMessage message = createMock(WebServiceMessage.class);
|
||||
expect(message.getPayloadSource())
|
||||
.andReturn(new StringSource("<a:a xmlns:a=\"http://example.org\"><a:b/></a:a>"));
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource("<a:a xmlns:a=\"http://example.org\"><a:b/></a:a>"));
|
||||
|
||||
replay(message);
|
||||
|
||||
@@ -206,8 +204,8 @@ public class XPathExpectationsHelperTest {
|
||||
assertNotNull(matcher);
|
||||
|
||||
WebServiceMessage message = createMock(WebServiceMessage.class);
|
||||
expect(message.getPayloadSource())
|
||||
.andReturn(new StringSource("<a:a xmlns:a=\"http://example.org\"><a:b/></a:a>")).times(2);
|
||||
expect(message.getPayloadSource()).andReturn(new StringSource("<a:a xmlns:a=\"http://example.org\"><a:b/></a:a>"))
|
||||
.times(2);
|
||||
|
||||
replay(message);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
log4j.rootCategory=INFO, stdout
|
||||
log4j.logger.org.springframework.ws=DEBUG
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
@@ -3,23 +3,23 @@
|
||||
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="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"/>
|
||||
<property name="defaultUri" value="http://example.com"/>
|
||||
</bean>
|
||||
|
||||
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||
<property name="classesToBeBound">
|
||||
<list>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountRequest</value>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountResponse</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
|
||||
<property name="marshaller" ref="marshaller"/>
|
||||
<property name="unmarshaller" ref="marshaller"/>
|
||||
<property name="defaultUri" value="http://example.com"/>
|
||||
</bean>
|
||||
|
||||
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||
<property name="classesToBeBound">
|
||||
<list>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountRequest</value>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountResponse</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema" xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema"
|
||||
xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
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 class="org.springframework.ws.server.endpoint.mapping.jaxb.XmlRootElementEndpointMapping"/>
|
||||
<bean class="org.springframework.ws.server.endpoint.mapping.jaxb.XmlRootElementEndpointMapping"/>
|
||||
|
||||
<bean class="org.springframework.ws.test.server.integration.CustomerEndpoint"/>
|
||||
<bean class="org.springframework.ws.test.server.integration.CustomerEndpoint"/>
|
||||
|
||||
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||
<property name="classesToBeBound">
|
||||
<list>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountRequest</value>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountResponse</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||
<property name="classesToBeBound">
|
||||
<list>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountRequest</value>
|
||||
<value>org.springframework.ws.test.integration.CustomerCountResponse</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema" xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema"
|
||||
xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema" xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
|
||||
</schema>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema" xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema"
|
||||
xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema" xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema"
|
||||
xmlns:tns="http://www.example.org/schema" elementFormDefault="qualified">
|
||||
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<element name="test" type="tns:testMessage"/>
|
||||
|
||||
<complexType name="testMessage">
|
||||
<sequence>
|
||||
<element name="number" type="int"/>
|
||||
<element name="text" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
|
||||
Reference in New Issue
Block a user