SWS-544 - Removed JUnit as a compile dependency
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>compile</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xmlunit</groupId>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.mock.client;
|
||||
|
||||
/**
|
||||
* JUnit independent assertion class.
|
||||
*
|
||||
* @author Lukas Krecan
|
||||
* @author Arjen Poutsma
|
||||
* @since 2.0
|
||||
*/
|
||||
class Assert {
|
||||
|
||||
/**
|
||||
* Fails a test with the given message.
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
static void fail(String message) {
|
||||
throw new AssertionError(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message.
|
||||
*
|
||||
* @param message the message
|
||||
* @param condition the condition to test for
|
||||
*/
|
||||
static void assertTrue(String message, boolean condition) {
|
||||
if (!condition) {
|
||||
fail(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message.
|
||||
*
|
||||
* @param message the message
|
||||
* @param expected the expected value
|
||||
* @param actual the actual value
|
||||
*/
|
||||
static void assertEquals(String message, Object expected, Object actual) {
|
||||
if (expected == null && actual == null) {
|
||||
return;
|
||||
}
|
||||
if (expected != null && expected.equals(actual)) {
|
||||
return;
|
||||
}
|
||||
fail(message + " expected:<" + expected + "> but was:<" + actual + ">");
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.fail;
|
||||
import static org.springframework.ws.mock.client.Assert.assertTrue;
|
||||
import static org.springframework.ws.mock.client.Assert.fail;
|
||||
|
||||
/**
|
||||
* Implementation of {@link RequestMatcher} based on XMLUnit's {@link Diff}.
|
||||
@@ -38,7 +38,7 @@ abstract class DiffMatcher extends TransformerObjectSupport implements RequestMa
|
||||
public final void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
|
||||
try {
|
||||
Diff diff = createDiff(request);
|
||||
assertXMLEqual(diff, true);
|
||||
assertTrue("Messages are different, " + diff.toString(), diff.similar());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw ex;
|
||||
@@ -57,4 +57,4 @@ abstract class DiffMatcher extends TransformerObjectSupport implements RequestMa
|
||||
*/
|
||||
protected abstract Diff createDiff(WebServiceMessage request) throws Exception;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.ws.WebServiceMessage;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.springframework.ws.mock.client.Assert.fail;
|
||||
|
||||
/**
|
||||
* Matches {@link Source} payloads.
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.soap.SoapBody;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.springframework.ws.mock.client.Assert.fail;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ResponseCallback} that responds with a SOAP fault.
|
||||
@@ -92,4 +92,4 @@ abstract class SoapFaultResponseCallback implements ResponseCallback {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ import org.springframework.ws.soap.SoapHeader;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.springframework.ws.mock.client.Assert.assertTrue;
|
||||
import static org.springframework.ws.mock.client.Assert.fail;
|
||||
|
||||
|
||||
/**
|
||||
* Matches SOAP headers.
|
||||
@@ -52,6 +53,7 @@ class SoapHeaderMatcher implements RequestMatcher {
|
||||
SoapHeader soapHeader = soapMessage.getSoapHeader();
|
||||
if (soapHeader == null) {
|
||||
fail("SOAP message [" + soapMessage + "] does not contain SOAP header");
|
||||
return;
|
||||
}
|
||||
Iterator<SoapHeaderElement> soapHeaderElementIterator = soapHeader.examineAllHeaderElements();
|
||||
boolean found = false;
|
||||
@@ -64,4 +66,4 @@ class SoapHeaderMatcher implements RequestMatcher {
|
||||
}
|
||||
assertTrue("SOAP header [" + soapHeaderName + "] not found", found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.net.URI;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.ws.mock.client.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Matches {@link URI}s.
|
||||
|
||||
@@ -8,7 +8,6 @@ Import-Template:
|
||||
javax.xml.parsers.*;version="0",
|
||||
javax.xml.transform.*;version="0",
|
||||
org.custommonkey.xmlunit.*;version="[1.3.0, 2.0.0)",
|
||||
org.junit.*;version="[4.7.0, 5.0.0)",
|
||||
org.springframework.core.*;version=${spring.framework.osgi.range},
|
||||
org.springframework.util.*;version=${spring.framework.osgi.range},
|
||||
org.springframework.ws.*;version=${osgi.range},
|
||||
|
||||
Reference in New Issue
Block a user