Skip to content

Commit 1859c89

Browse files
committed
SWS-544 - Removed JUnit as a compile dependency
1 parent 78d4117 commit 1859c89

File tree

8 files changed

+79
-13
lines changed

8 files changed

+79
-13
lines changed

test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>junit</groupId>
4444
<artifactId>junit</artifactId>
45-
<scope>compile</scope>
45+
<scope>test</scope>
4646
</dependency>
4747
<dependency>
4848
<groupId>xmlunit</groupId>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2005-2010 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ws.mock.client;
18+
19+
/**
20+
* JUnit independent assertion class.
21+
*
22+
* @author Lukas Krecan
23+
* @author Arjen Poutsma
24+
* @since 2.0
25+
*/
26+
class Assert {
27+
28+
/**
29+
* Fails a test with the given message.
30+
*
31+
* @param message the message
32+
*/
33+
static void fail(String message) {
34+
throw new AssertionError(message);
35+
}
36+
37+
/**
38+
* Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message.
39+
*
40+
* @param message the message
41+
* @param condition the condition to test for
42+
*/
43+
static void assertTrue(String message, boolean condition) {
44+
if (!condition) {
45+
fail(message);
46+
}
47+
}
48+
49+
/**
50+
* Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message.
51+
*
52+
* @param message the message
53+
* @param expected the expected value
54+
* @param actual the actual value
55+
*/
56+
static void assertEquals(String message, Object expected, Object actual) {
57+
if (expected == null && actual == null) {
58+
return;
59+
}
60+
if (expected != null && expected.equals(actual)) {
61+
return;
62+
}
63+
fail(message + " expected:<" + expected + "> but was:<" + actual + ">");
64+
}
65+
}

test/src/main/java/org/springframework/ws/mock/client/DiffMatcher.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
import org.custommonkey.xmlunit.Diff;
2626

27-
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
28-
import static org.custommonkey.xmlunit.XMLAssert.fail;
27+
import static org.springframework.ws.mock.client.Assert.assertTrue;
28+
import static org.springframework.ws.mock.client.Assert.fail;
2929

3030
/**
3131
* Implementation of {@link RequestMatcher} based on XMLUnit's {@link Diff}.
@@ -38,7 +38,7 @@ abstract class DiffMatcher extends TransformerObjectSupport implements RequestMa
3838
public final void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
3939
try {
4040
Diff diff = createDiff(request);
41-
assertXMLEqual(diff, true);
41+
assertTrue("Messages are different, " + diff.toString(), diff.similar());
4242
}
4343
catch (IOException ex) {
4444
throw ex;
@@ -57,4 +57,4 @@ public final void match(URI uri, WebServiceMessage request) throws IOException,
5757
*/
5858
protected abstract Diff createDiff(WebServiceMessage request) throws Exception;
5959

60-
}
60+
}

test/src/main/java/org/springframework/ws/mock/client/PayloadDiffMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.custommonkey.xmlunit.Diff;
2727
import org.w3c.dom.Document;
2828

29-
import static junit.framework.Assert.fail;
29+
import static org.springframework.ws.mock.client.Assert.fail;
3030

3131
/**
3232
* Matches {@link Source} payloads.

test/src/main/java/org/springframework/ws/mock/client/SoapFaultResponseCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.ws.soap.SoapBody;
2424
import org.springframework.ws.soap.SoapMessage;
2525

26-
import static org.junit.Assert.fail;
26+
import static org.springframework.ws.mock.client.Assert.fail;
2727

2828
/**
2929
* Implementation of {@link ResponseCallback} that responds with a SOAP fault.
@@ -92,4 +92,4 @@ public void addSoapFault(SoapBody soapBody) {
9292
}
9393

9494

95-
}
95+
}

test/src/main/java/org/springframework/ws/mock/client/SoapHeaderMatcher.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
import org.springframework.ws.soap.SoapHeaderElement;
2727
import org.springframework.ws.soap.SoapMessage;
2828

29-
import static org.junit.Assert.assertTrue;
30-
import static org.junit.Assert.fail;
29+
import static org.springframework.ws.mock.client.Assert.assertTrue;
30+
import static org.springframework.ws.mock.client.Assert.fail;
31+
3132

3233
/**
3334
* Matches SOAP headers.
@@ -52,6 +53,7 @@ public void match(URI uri, WebServiceMessage request) throws IOException, Assert
5253
SoapHeader soapHeader = soapMessage.getSoapHeader();
5354
if (soapHeader == null) {
5455
fail("SOAP message [" + soapMessage + "] does not contain SOAP header");
56+
return;
5557
}
5658
Iterator<SoapHeaderElement> soapHeaderElementIterator = soapHeader.examineAllHeaderElements();
5759
boolean found = false;
@@ -64,4 +66,4 @@ public void match(URI uri, WebServiceMessage request) throws IOException, Assert
6466
}
6567
assertTrue("SOAP header [" + soapHeaderName + "] not found", found);
6668
}
67-
}
69+
}

test/src/main/java/org/springframework/ws/mock/client/UriMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import org.springframework.ws.WebServiceMessage;
2222

23-
import static org.junit.Assert.assertEquals;
23+
import static org.springframework.ws.mock.client.Assert.assertEquals;
2424

2525
/**
2626
* Matches {@link URI}s.

test/template.mf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Import-Template:
88
javax.xml.parsers.*;version="0",
99
javax.xml.transform.*;version="0",
1010
org.custommonkey.xmlunit.*;version="[1.3.0, 2.0.0)",
11-
org.junit.*;version="[4.7.0, 5.0.0)",
1211
org.springframework.core.*;version=${spring.framework.osgi.range},
1312
org.springframework.util.*;version=${spring.framework.osgi.range},
1413
org.springframework.ws.*;version=${osgi.range},

0 commit comments

Comments
 (0)