Review checkstyle rules of spring-ws-test
See gh-1479
This commit is contained in:
@@ -48,7 +48,7 @@ public interface RequestXPathExpectations {
|
||||
* @param expectedValue the expected value
|
||||
* @return the request matcher
|
||||
*/
|
||||
RequestMatcher evaluatesTo(final boolean expectedValue);
|
||||
RequestMatcher evaluatesTo(boolean expectedValue);
|
||||
|
||||
/**
|
||||
* Expects the XPath expression to evaluate to the given integer.
|
||||
|
||||
@@ -22,8 +22,7 @@ import java.net.URI;
|
||||
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;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ResponseCreator} that responds with a SOAP fault.
|
||||
@@ -36,12 +35,12 @@ abstract class SoapFaultResponseCreator extends AbstractResponseCreator {
|
||||
@Override
|
||||
protected void doWithResponse(URI uri, WebServiceMessage request, WebServiceMessage response) throws IOException {
|
||||
if (!(response instanceof SoapMessage soapResponse)) {
|
||||
fail("Response is not a SOAP message");
|
||||
AssertionErrors.fail("Response is not a SOAP message");
|
||||
return;
|
||||
}
|
||||
SoapBody responseBody = soapResponse.getSoapBody();
|
||||
if (responseBody == null) {
|
||||
fail("SOAP message [" + response + "] does not contain SOAP body");
|
||||
AssertionErrors.fail("SOAP message [" + response + "] does not contain SOAP body");
|
||||
}
|
||||
addSoapFault(responseBody);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.ws.test.client;
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertEquals;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
|
||||
/**
|
||||
* Matches {@link URI}s.
|
||||
@@ -38,7 +37,8 @@ class UriMatcher implements RequestMatcher {
|
||||
|
||||
@Override
|
||||
public void match(URI actual, WebServiceMessage request) {
|
||||
assertEquals("Unexpected connection", this.expected, actual, "Payload", request.getPayloadSource());
|
||||
AssertionErrors.assertEquals("Unexpected connection", this.expected, actual, "Payload",
|
||||
request.getPayloadSource());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
* Copyright 2005-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -29,11 +29,10 @@ import org.springframework.ws.context.DefaultMessageContext;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.soap.server.SoapMessageDispatcher;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.ws.test.support.MockStrategiesHelper;
|
||||
import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* <strong>Main entry point for server-side Web service testing</strong>. Typically used
|
||||
* to test a {@link org.springframework.ws.server.MessageDispatcher MessageDispatcher}
|
||||
@@ -105,7 +104,7 @@ import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
* @author Lukas Krecan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MockWebServiceClient {
|
||||
public final class MockWebServiceClient {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(MockWebServiceClient.class);
|
||||
|
||||
@@ -186,7 +185,7 @@ public class MockWebServiceClient {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.error("Could not send request", ex);
|
||||
fail(ex.getMessage());
|
||||
AssertionErrors.fail(ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -207,7 +206,7 @@ public class MockWebServiceClient {
|
||||
WebServiceMessage request = this.messageContext.getRequest();
|
||||
WebServiceMessage response = this.messageContext.getResponse();
|
||||
if (response == null) {
|
||||
fail("No response received");
|
||||
AssertionErrors.fail("No response received");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
@@ -216,7 +215,7 @@ public class MockWebServiceClient {
|
||||
}
|
||||
catch (IOException ex) {
|
||||
logger.error("Could not match request", ex);
|
||||
fail(ex.getMessage());
|
||||
AssertionErrors.fail(ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,14 +28,13 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.ws.FaultAwareWebServiceMessage;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapVersion;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.ws.test.support.matcher.SchemaValidatingMatcher;
|
||||
import org.springframework.ws.test.support.matcher.SoapHeaderMatcher;
|
||||
import org.springframework.ws.test.support.matcher.xmlunit2.PayloadDiffMatcher;
|
||||
import org.springframework.ws.test.support.matcher.xmlunit2.SoapEnvelopeDiffMatcher;
|
||||
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)}.
|
||||
@@ -139,7 +138,7 @@ public abstract class ResponseMatchers {
|
||||
throws IOException, AssertionError {
|
||||
if (response instanceof FaultAwareWebServiceMessage faultMessage) {
|
||||
if (faultMessage.hasFault()) {
|
||||
fail("Response has a SOAP Fault: \"" + faultMessage.getFaultReason() + "\"");
|
||||
AssertionErrors.fail("Response has a SOAP Fault: \"" + faultMessage.getFaultReason() + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface ResponseXPathExpectations {
|
||||
* @param expectedValue the expected value
|
||||
* @return the request matcher
|
||||
*/
|
||||
ResponseMatcher evaluatesTo(final boolean expectedValue);
|
||||
ResponseMatcher evaluatesTo(boolean expectedValue);
|
||||
|
||||
/**
|
||||
* Expects the XPath expression to evaluate to the given integer.
|
||||
|
||||
@@ -25,9 +25,7 @@ import org.springframework.ws.soap.SoapBody;
|
||||
import org.springframework.ws.soap.SoapFault;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.SoapVersion;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertEquals;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
|
||||
/**
|
||||
* Abstract Implementation of {@link ResponseMatcher} that checks for a SOAP fault.
|
||||
@@ -45,16 +43,16 @@ abstract class SoapFaultResponseMatcher implements ResponseMatcher {
|
||||
|
||||
@Override
|
||||
public void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError {
|
||||
assertTrue("Response is not a SOAP message", response instanceof SoapMessage);
|
||||
AssertionErrors.assertTrue("Response is not a SOAP message", response instanceof SoapMessage);
|
||||
SoapMessage soapResponse = (SoapMessage) response;
|
||||
SoapBody responseBody = soapResponse.getSoapBody();
|
||||
assertTrue("Response has no SOAP Body", responseBody != null);
|
||||
assertTrue("Response has no SOAP Fault", responseBody.hasFault());
|
||||
AssertionErrors.assertTrue("Response has no SOAP Body", responseBody != null);
|
||||
AssertionErrors.assertTrue("Response has no SOAP Fault", responseBody.hasFault());
|
||||
SoapFault soapFault = responseBody.getFault();
|
||||
QName expectedFaultCode = getExpectedFaultCode(soapResponse.getVersion());
|
||||
assertEquals("Invalid SOAP Fault code", expectedFaultCode, soapFault.getFaultCode());
|
||||
AssertionErrors.assertEquals("Invalid SOAP Fault code", expectedFaultCode, soapFault.getFaultCode());
|
||||
if (this.expectedFaultStringOrReason != null) {
|
||||
assertEquals("Invalid SOAP Fault string/reason", this.expectedFaultStringOrReason,
|
||||
AssertionErrors.assertEquals("Invalid SOAP Fault string/reason", this.expectedFaultStringOrReason,
|
||||
soapFault.getFaultStringOrReason());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
* Copyright 2005-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SourceAssertionError extends AssertionError {
|
||||
if (sourceString != null) {
|
||||
String newLine = System.lineSeparator();
|
||||
builder.append(newLine);
|
||||
String label = this.sourceLabel != null ? this.sourceLabel : "Source";
|
||||
String label = (this.sourceLabel != null) ? this.sourceLabel : "Source";
|
||||
builder.append(label);
|
||||
builder.append(": ");
|
||||
builder.append(sourceString);
|
||||
|
||||
@@ -23,10 +23,9 @@ import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
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}.
|
||||
@@ -56,7 +55,7 @@ public class PayloadMessageCreator extends AbstractMessageCreator {
|
||||
this.transformerHelper.transform(this.payload, message.getPayloadResult());
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
fail("Could not transform request payload to message: " + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform request payload to message: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,9 @@ import org.w3c.dom.Document;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
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}.
|
||||
@@ -57,7 +55,8 @@ public class SoapEnvelopeMessageCreator extends AbstractMessageCreator {
|
||||
|
||||
@Override
|
||||
protected void doWithMessage(WebServiceMessage message) throws IOException {
|
||||
assertTrue("Message created with factory is not a SOAP message", message instanceof SoapMessage);
|
||||
AssertionErrors.assertTrue("Message created with factory is not a SOAP message",
|
||||
message instanceof SoapMessage);
|
||||
SoapMessage soapMessage = (SoapMessage) message;
|
||||
try {
|
||||
DOMResult result = new DOMResult();
|
||||
@@ -65,7 +64,7 @@ public class SoapEnvelopeMessageCreator extends AbstractMessageCreator {
|
||||
soapMessage.setDocument((Document) result.getNode());
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
fail("Could not transform request SOAP envelope to message: " + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform request SOAP envelope to message: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
* Copyright 2005-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.io.IOException;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
|
||||
/**
|
||||
* Abstract base class for SOAP-specific {@link WebServiceMessageMatcher} implementations.
|
||||
@@ -36,7 +35,7 @@ public abstract class AbstractSoapMessageMatcher implements WebServiceMessageMat
|
||||
|
||||
@Override
|
||||
public final void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
assertTrue("Message is not a SOAP message", message instanceof SoapMessage);
|
||||
AssertionErrors.assertTrue("Message is not a SOAP message", message instanceof SoapMessage);
|
||||
match((SoapMessage) message);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.ws.test.support.matcher;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
|
||||
/**
|
||||
* Implementation of {@link WebServiceMessageMatcher} based on XMLUnit's {@link Diff}.
|
||||
@@ -37,7 +36,8 @@ public abstract class DiffMatcher implements WebServiceMessageMatcher {
|
||||
public final void match(WebServiceMessage message) throws AssertionError {
|
||||
|
||||
Diff diff = createDiff(message);
|
||||
assertTrue("Messages are different, " + diff.toString(), diff.similar(), "Payload", message.getPayloadSource());
|
||||
AssertionErrors.assertTrue("Messages are different, " + diff.toString(), diff.similar(), "Payload",
|
||||
message.getPayloadSource());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,10 +25,9 @@ import org.w3c.dom.Document;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} payloads.
|
||||
*
|
||||
@@ -54,7 +53,7 @@ public class PayloadDiffMatcher extends DiffMatcher {
|
||||
protected final Diff createDiff(WebServiceMessage message) {
|
||||
Source payload = message.getPayloadSource();
|
||||
if (payload == null) {
|
||||
fail("Request message does not contain payload");
|
||||
AssertionErrors.fail("Request message does not contain payload");
|
||||
}
|
||||
return createDiff(payload);
|
||||
}
|
||||
@@ -72,7 +71,7 @@ public class PayloadDiffMatcher extends DiffMatcher {
|
||||
return (Document) result.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,10 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.xml.validation.XmlValidator;
|
||||
import org.springframework.xml.validation.XmlValidatorFactory;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Uses the {@link XmlValidator} to validate request payload.
|
||||
*
|
||||
@@ -60,7 +59,8 @@ public class SchemaValidatingMatcher implements WebServiceMessageMatcher {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
SAXParseException[] exceptions = this.xmlValidator.validate(message.getPayloadSource());
|
||||
if (!ObjectUtils.isEmpty(exceptions)) {
|
||||
fail("XML is not valid: " + Arrays.toString(exceptions), "Payload", message.getPayloadSource());
|
||||
AssertionErrors.fail("XML is not valid: " + Arrays.toString(exceptions), "Payload",
|
||||
message.getPayloadSource());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,9 @@ import org.w3c.dom.Document;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} SOAP envelopes.
|
||||
*
|
||||
@@ -64,7 +62,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
Document actualDocument = soapMessage.getDocument();
|
||||
Document expectedDocument = createDocumentFromSource(this.expected);
|
||||
Diff diff = new Diff(expectedDocument, actualDocument);
|
||||
assertTrue("Envelopes are different, " + diff, diff.similar());
|
||||
AssertionErrors.assertTrue("Envelopes are different, " + diff, diff.similar());
|
||||
}
|
||||
|
||||
private Document createDocumentFromSource(Source source) {
|
||||
@@ -75,7 +73,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
return (Document) result.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ import org.springframework.util.Assert;
|
||||
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;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
|
||||
/**
|
||||
* Matches SOAP headers.
|
||||
@@ -51,8 +50,8 @@ public class SoapHeaderMatcher extends AbstractSoapMessageMatcher {
|
||||
@Override
|
||||
protected void match(SoapMessage soapMessage) throws IOException, AssertionError {
|
||||
SoapHeader soapHeader = soapMessage.getSoapHeader();
|
||||
assertTrue("SOAP message [" + soapMessage + "] does not contain SOAP header", soapHeader != null, "Envelope",
|
||||
soapMessage.getEnvelope().getSource());
|
||||
AssertionErrors.assertTrue("SOAP message [" + soapMessage + "] does not contain SOAP header",
|
||||
soapHeader != null, "Envelope", soapMessage.getEnvelope().getSource());
|
||||
|
||||
Iterator<SoapHeaderElement> soapHeaderElementIterator = soapHeader.examineAllHeaderElements();
|
||||
boolean found = false;
|
||||
@@ -63,7 +62,7 @@ public class SoapHeaderMatcher extends AbstractSoapMessageMatcher {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue("SOAP header [" + this.soapHeaderName + "] not found", found, "Envelope",
|
||||
AssertionErrors.assertTrue("SOAP header [" + this.soapHeaderName + "] not found", found, "Envelope",
|
||||
soapMessage.getEnvelope().getSource());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,11 @@ import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
|
||||
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.
|
||||
*
|
||||
@@ -75,8 +73,8 @@ public class XPathExpectationsHelper {
|
||||
Node payload = transformToNode(message);
|
||||
Node result = XPathExpectationsHelper.this.expression.evaluateAsNode(payload);
|
||||
if (result == null) {
|
||||
fail("No match for \"" + XPathExpectationsHelper.this.expressionString + "\" found", "Payload",
|
||||
message.getPayloadSource());
|
||||
AssertionErrors.fail("No match for \"" + XPathExpectationsHelper.this.expressionString + "\" found",
|
||||
"Payload", message.getPayloadSource());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -88,8 +86,8 @@ public class XPathExpectationsHelper {
|
||||
Node payload = transformToNode(message);
|
||||
Node result = XPathExpectationsHelper.this.expression.evaluateAsNode(payload);
|
||||
if (result != null) {
|
||||
fail("Match for \"" + XPathExpectationsHelper.this.expressionString + "\" found", "Payload",
|
||||
message.getPayloadSource());
|
||||
AssertionErrors.fail("Match for \"" + XPathExpectationsHelper.this.expressionString + "\" found",
|
||||
"Payload", message.getPayloadSource());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -100,8 +98,9 @@ public class XPathExpectationsHelper {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
Node payload = transformToNode(message);
|
||||
boolean result = XPathExpectationsHelper.this.expression.evaluateAsBoolean(payload);
|
||||
assertEquals("Evaluation of XPath expression \"" + XPathExpectationsHelper.this.expressionString
|
||||
+ "\" failed.", expectedValue, result, "Payload", message.getPayloadSource());
|
||||
AssertionErrors.assertEquals("Evaluation of XPath expression \""
|
||||
+ XPathExpectationsHelper.this.expressionString + "\" failed.", expectedValue, result,
|
||||
"Payload", message.getPayloadSource());
|
||||
|
||||
}
|
||||
};
|
||||
@@ -116,8 +115,9 @@ public class XPathExpectationsHelper {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
Node payload = transformToNode(message);
|
||||
double result = XPathExpectationsHelper.this.expression.evaluateAsNumber(payload);
|
||||
assertEquals("Evaluation of XPath expression \"" + XPathExpectationsHelper.this.expressionString
|
||||
+ "\" failed.", expectedValue, result, "Payload", message.getPayloadSource());
|
||||
AssertionErrors.assertEquals("Evaluation of XPath expression \""
|
||||
+ XPathExpectationsHelper.this.expressionString + "\" failed.", expectedValue, result,
|
||||
"Payload", message.getPayloadSource());
|
||||
|
||||
}
|
||||
};
|
||||
@@ -129,8 +129,9 @@ public class XPathExpectationsHelper {
|
||||
public void match(WebServiceMessage message) throws IOException, AssertionError {
|
||||
Node payload = transformToNode(message);
|
||||
String result = XPathExpectationsHelper.this.expression.evaluateAsString(payload);
|
||||
assertEquals("Evaluation of XPath expression \"" + XPathExpectationsHelper.this.expressionString
|
||||
+ "\" failed.", expectedValue, result, "Payload", message.getPayloadSource());
|
||||
AssertionErrors.assertEquals("Evaluation of XPath expression \""
|
||||
+ XPathExpectationsHelper.this.expressionString + "\" failed.", expectedValue, result,
|
||||
"Payload", message.getPayloadSource());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -142,7 +143,7 @@ public class XPathExpectationsHelper {
|
||||
return domResult.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
fail("Could not transform request payload: " + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform request payload: " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
* Copyright 2005-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -19,10 +19,9 @@ package org.springframework.ws.test.support.matcher.xmlunit2;
|
||||
import org.xmlunit.diff.Diff;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
|
||||
/**
|
||||
* Implementation of {@link WebServiceMessageMatcher} based on XMLUnit's {@link Diff}.
|
||||
*
|
||||
@@ -33,9 +32,8 @@ public abstract class DiffMatcher implements WebServiceMessageMatcher {
|
||||
|
||||
@Override
|
||||
public final void match(WebServiceMessage message) throws AssertionError {
|
||||
|
||||
Diff diff = createDiff(message);
|
||||
assertTrue("Messages are different, " + diff.toString(), !diff.hasDifferences(), "Payload",
|
||||
AssertionErrors.assertTrue("Messages are different, " + diff.toString(), !diff.hasDifferences(), "Payload",
|
||||
message.getPayloadSource());
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,9 @@ import org.xmlunit.placeholder.PlaceholderDifferenceEvaluator;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} payloads.
|
||||
*
|
||||
@@ -57,7 +56,7 @@ public class PayloadDiffMatcher extends DiffMatcher {
|
||||
Source payload = message.getPayloadSource();
|
||||
|
||||
if (payload == null) {
|
||||
fail("Request message does not contain payload");
|
||||
AssertionErrors.fail("Request message does not contain payload");
|
||||
}
|
||||
|
||||
return createDiff(payload);
|
||||
@@ -86,8 +85,7 @@ public class PayloadDiffMatcher extends DiffMatcher {
|
||||
return (Document) result.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
|
||||
fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,10 @@ import org.xmlunit.placeholder.PlaceholderDifferenceEvaluator;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.test.support.AssertionErrors;
|
||||
import org.springframework.ws.test.support.matcher.AbstractSoapMessageMatcher;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
|
||||
import static org.springframework.ws.test.support.AssertionErrors.assertTrue;
|
||||
import static org.springframework.ws.test.support.AssertionErrors.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} SOAP envelopes.
|
||||
*
|
||||
@@ -66,7 +64,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
DifferenceEvaluators.chain(new PlaceholderDifferenceEvaluator(), DifferenceEvaluators.Default))
|
||||
.checkForSimilar()
|
||||
.build();
|
||||
assertTrue("Envelopes are different, " + diff.toString(), !diff.hasDifferences());
|
||||
AssertionErrors.assertTrue("Envelopes are different, " + diff.toString(), !diff.hasDifferences());
|
||||
}
|
||||
|
||||
private Document createDocumentFromSource(Source source) {
|
||||
@@ -77,7 +75,7 @@ public class SoapEnvelopeDiffMatcher extends AbstractSoapMessageMatcher {
|
||||
return (Document) result.getNode();
|
||||
}
|
||||
catch (TransformerException ex) {
|
||||
fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
AssertionErrors.fail("Could not transform source to DOMResult" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Matcher support for XMLUnit.
|
||||
*/
|
||||
package org.springframework.ws.test.support.matcher.xmlunit2;
|
||||
package org.springframework.ws.test.support.matcher.xmlunit2;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
* Copyright 2005-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
Reference in New Issue
Block a user