SWS-544 - Add test framework for Spring WS client

This commit is contained in:
Arjen Poutsma
2010-07-16 14:05:32 +00:00
parent 61af77d06e
commit 78d41170f3
4 changed files with 14 additions and 25 deletions

View File

@@ -35,11 +35,11 @@ import static junit.framework.Assert.fail;
* @author Lukas Krecan
* @since 2.0
*/
class PayloadMatcher extends DiffMatcher {
class PayloadDiffMatcher extends DiffMatcher {
private final Source expected;
PayloadMatcher(Source expected) {
PayloadDiffMatcher(Source expected) {
Assert.notNull(expected, "'expected' must not be null");
this.expected = expected;
}

View File

@@ -71,7 +71,7 @@ public abstract class WebServiceMock {
*/
public static RequestMatcher payload(String payload) {
Assert.notNull(payload, "'payload' must not be null");
return new PayloadMatcher(new StringSource(payload));
return new PayloadDiffMatcher(new StringSource(payload));
}
/**
@@ -82,7 +82,7 @@ public abstract class WebServiceMock {
*/
public static RequestMatcher payload(Source payload) {
Assert.notNull(payload, "'payload' must not be null");
return new PayloadMatcher(payload);
return new PayloadDiffMatcher(payload);
}
/**
@@ -93,7 +93,7 @@ public abstract class WebServiceMock {
*/
public static RequestMatcher payload(Resource payload) {
Assert.notNull(payload, "'payload' must not be null");
return new PayloadMatcher(createResourceSource(payload));
return new PayloadDiffMatcher(createResourceSource(payload));
}
/**

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import static org.easymock.EasyMock.*;
public class PayloadMatcherTest {
public class PayloadDiffMatcherTest {
@Test
public void match() throws Exception {
@@ -32,7 +32,7 @@ public class PayloadMatcherTest {
expect(message.getPayloadSource()).andReturn(new StringSource(xml));
replay(message);
PayloadMatcher matcher = new PayloadMatcher(new StringSource(xml));
PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(xml));
matcher.match(null, message);
verify(message);
@@ -46,7 +46,7 @@ public class PayloadMatcherTest {
replay(message);
String expected = "<element2 xmlns='http://example.com'/>";
PayloadMatcher matcher = new PayloadMatcher(new StringSource(expected));
PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(expected));
matcher.match(null, message);
}

View File

@@ -41,25 +41,11 @@ public abstract class XPathExpressionFactory {
private static final Log logger = LogFactory.getLog(XPathExpressionFactory.class);
private static final String JAXEN_CLASS_NAME = "org.jaxen.XPath";
private static boolean jaxp13Available = JaxpVersion.isAtLeastJaxp13();
private static boolean jaxp13Available;
private static boolean jaxenAvailable =
ClassUtils.isPresent("org.jaxen.XPath", XPathExpressionFactory.class.getClassLoader());
private static boolean jaxenAvailable;
static {
// Check whether JAXP 1.3 is available
jaxp13Available = JaxpVersion.isAtLeastJaxp13();
// Check whether Jaxen is available
try {
ClassUtils.forName(JAXEN_CLASS_NAME);
jaxenAvailable = true;
}
catch (ClassNotFoundException ex) {
jaxenAvailable = false;
}
}
/**
* Create a compiled XPath expression using the given string.
@@ -87,6 +73,9 @@ public abstract class XPathExpressionFactory {
public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces)
throws IllegalStateException, XPathParseException {
Assert.hasLength(expression, "expression is empty");
if (namespaces == null) {
namespaces = Collections.emptyMap();
}
if (jaxp13Available) {
try {
logger.trace("Creating [javax.xml.xpath.XPathExpression]");