Skip to content

Commit 78d4117

Browse files
committed
SWS-544 - Add test framework for Spring WS client
1 parent 61af77d commit 78d4117

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
* @author Lukas Krecan
3636
* @since 2.0
3737
*/
38-
class PayloadMatcher extends DiffMatcher {
38+
class PayloadDiffMatcher extends DiffMatcher {
3939

4040
private final Source expected;
4141

42-
PayloadMatcher(Source expected) {
42+
PayloadDiffMatcher(Source expected) {
4343
Assert.notNull(expected, "'expected' must not be null");
4444
this.expected = expected;
4545
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static ResponseActions expect(RequestMatcher requestMatcher) {
7171
*/
7272
public static RequestMatcher payload(String payload) {
7373
Assert.notNull(payload, "'payload' must not be null");
74-
return new PayloadMatcher(new StringSource(payload));
74+
return new PayloadDiffMatcher(new StringSource(payload));
7575
}
7676

7777
/**
@@ -82,7 +82,7 @@ public static RequestMatcher payload(String payload) {
8282
*/
8383
public static RequestMatcher payload(Source payload) {
8484
Assert.notNull(payload, "'payload' must not be null");
85-
return new PayloadMatcher(payload);
85+
return new PayloadDiffMatcher(payload);
8686
}
8787

8888
/**
@@ -93,7 +93,7 @@ public static RequestMatcher payload(Source payload) {
9393
*/
9494
public static RequestMatcher payload(Resource payload) {
9595
Assert.notNull(payload, "'payload' must not be null");
96-
return new PayloadMatcher(createResourceSource(payload));
96+
return new PayloadDiffMatcher(createResourceSource(payload));
9797
}
9898

9999
/**

test/src/test/java/org/springframework/ws/mock/client/PayloadMatcherTest.java renamed to test/src/test/java/org/springframework/ws/mock/client/PayloadDiffMatcherTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import static org.easymock.EasyMock.*;
2525

26-
public class PayloadMatcherTest {
26+
public class PayloadDiffMatcherTest {
2727

2828
@Test
2929
public void match() throws Exception {
@@ -32,7 +32,7 @@ public void match() throws Exception {
3232
expect(message.getPayloadSource()).andReturn(new StringSource(xml));
3333
replay(message);
3434

35-
PayloadMatcher matcher = new PayloadMatcher(new StringSource(xml));
35+
PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(xml));
3636
matcher.match(null, message);
3737

3838
verify(message);
@@ -46,7 +46,7 @@ public void nonMatch() throws Exception {
4646
replay(message);
4747

4848
String expected = "<element2 xmlns='http://example.com'/>";
49-
PayloadMatcher matcher = new PayloadMatcher(new StringSource(expected));
49+
PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(expected));
5050
matcher.match(null, message);
5151
}
5252

xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactory.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,11 @@ public abstract class XPathExpressionFactory {
4141

4242
private static final Log logger = LogFactory.getLog(XPathExpressionFactory.class);
4343

44-
private static final String JAXEN_CLASS_NAME = "org.jaxen.XPath";
44+
private static boolean jaxp13Available = JaxpVersion.isAtLeastJaxp13();
4545

46-
private static boolean jaxp13Available;
46+
private static boolean jaxenAvailable =
47+
ClassUtils.isPresent("org.jaxen.XPath", XPathExpressionFactory.class.getClassLoader());
4748

48-
private static boolean jaxenAvailable;
49-
50-
static {
51-
// Check whether JAXP 1.3 is available
52-
jaxp13Available = JaxpVersion.isAtLeastJaxp13();
53-
54-
// Check whether Jaxen is available
55-
try {
56-
ClassUtils.forName(JAXEN_CLASS_NAME);
57-
jaxenAvailable = true;
58-
}
59-
catch (ClassNotFoundException ex) {
60-
jaxenAvailable = false;
61-
}
62-
}
6349

6450
/**
6551
* Create a compiled XPath expression using the given string.
@@ -87,6 +73,9 @@ public static XPathExpression createXPathExpression(String expression)
8773
public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces)
8874
throws IllegalStateException, XPathParseException {
8975
Assert.hasLength(expression, "expression is empty");
76+
if (namespaces == null) {
77+
namespaces = Collections.emptyMap();
78+
}
9079
if (jaxp13Available) {
9180
try {
9281
logger.trace("Creating [javax.xml.xpath.XPathExpression]");

0 commit comments

Comments
 (0)