diff --git a/core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java b/core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java
index f9ebd5b4..67843b33 100644
--- a/core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java
+++ b/core/src/test/java/org/springframework/ws/AbstractWebServiceMessageFactoryTestCase.java
@@ -16,20 +16,23 @@
package org.springframework.ws;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public abstract class AbstractWebServiceMessageFactoryTestCase extends TestCase {
+public abstract class AbstractWebServiceMessageFactoryTestCase {
protected WebServiceMessageFactory messageFactory;
- @Override
- protected final void setUp() throws Exception {
+ @Before
+ public final void setUp() throws Exception {
messageFactory = createMessageFactory();
}
+ @Test
public void testCreateEmptyMessage() throws Exception {
WebServiceMessage message = messageFactory.createWebServiceMessage();
- assertNotNull("WebServiceMessage is null", message);
+ Assert.assertNotNull("WebServiceMessage is null", message);
}
protected abstract WebServiceMessageFactory createMessageFactory() throws Exception;
diff --git a/core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java b/core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java
index 01c77846..b5eea395 100644
--- a/core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java
+++ b/core/src/test/java/org/springframework/ws/server/endpoint/mapping/SimpleMethodEndpointMappingTest.java
@@ -16,18 +16,21 @@
package org.springframework.ws.server.endpoint.mapping;
-import junit.framework.TestCase;
import org.springframework.ws.MockWebServiceMessage;
import org.springframework.ws.MockWebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
-public class SimpleMethodEndpointMappingTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleMethodEndpointMappingTest {
private SimpleMethodEndpointMapping mapping;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
mapping = new SimpleMethodEndpointMapping();
mapping.setMethodPrefix("prefix");
mapping.setMethodSuffix("Suffix");
@@ -36,24 +39,27 @@ public class SimpleMethodEndpointMappingTest extends TestCase {
mapping.afterPropertiesSet();
}
+ @Test
public void testRegistration() throws Exception {
- assertNotNull("Endpoint not registered", mapping.lookupEndpoint("MyRequest"));
- assertNull("Endpoint registered", mapping.lookupEndpoint("request"));
+ Assert.assertNotNull("Endpoint not registered", mapping.lookupEndpoint("MyRequest"));
+ Assert.assertNull("Endpoint registered", mapping.lookupEndpoint("request"));
}
+ @Test
public void testGetLookupKeyForMessageNoNamespace() throws Exception {
MockWebServiceMessage request = new MockWebServiceMessage("");
MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
String result = mapping.getLookupKeyForMessage(messageContext);
- assertEquals("Invalid lookup key", "MyRequest", result);
+ Assert.assertEquals("Invalid lookup key", "MyRequest", result);
}
+ @Test
public void testGetLookupKeyForMessageNamespace() throws Exception {
MockWebServiceMessage request =
new MockWebServiceMessage("");
MessageContext messageContext = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
String result = mapping.getLookupKeyForMessage(messageContext);
- assertEquals("Invalid lookup key", "MyRequest", result);
+ Assert.assertEquals("Invalid lookup key", "MyRequest", result);
}
private static class MyBean {
diff --git a/core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java b/core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java
index 2684059a..4ad54c27 100644
--- a/core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java
+++ b/core/src/test/java/org/springframework/ws/server/endpoint/mapping/UriEndpointMappingTest.java
@@ -18,9 +18,6 @@ package org.springframework.ws.server.endpoint.mapping;
import java.net.URI;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
-
import org.springframework.ws.MockWebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
@@ -28,35 +25,48 @@ import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.ws.transport.context.DefaultTransportContext;
import org.springframework.ws.transport.context.TransportContextHolder;
-public class UriEndpointMappingTest extends TestCase {
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class UriEndpointMappingTest {
private UriEndpointMapping mapping;
private MessageContext context;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
mapping = new UriEndpointMapping();
context = new DefaultMessageContext(new MockWebServiceMessageFactory());
}
- public void testGetLookupKeyForMessage() throws Exception {
- MockControl control = MockControl.createControl(WebServiceConnection.class);
- WebServiceConnection connectionMock = (WebServiceConnection) control.getMock();
- TransportContextHolder.setTransportContext(new DefaultTransportContext(connectionMock));
-
- URI uri = new URI("jms://exampleQueue");
- control.expectAndReturn(connectionMock.getUri(), uri);
- control.replay();
-
- assertEquals("Invalid lookup key", uri.toString(), mapping.getLookupKeyForMessage(context));
-
- control.verify();
+ @After
+ public void clearContext() {
TransportContextHolder.setTransportContext(null);
}
+ @Test
+ public void testGetLookupKeyForMessage() throws Exception {
+ WebServiceConnection connectionMock = createMock(WebServiceConnection.class);
+ TransportContextHolder.setTransportContext(new DefaultTransportContext(connectionMock));
+
+ URI uri = new URI("jms://exampleQueue");
+ expect(connectionMock.getUri()).andReturn(uri);
+
+ replay(connectionMock);
+
+ Assert.assertEquals("Invalid lookup key", uri.toString(), mapping.getLookupKeyForMessage(context));
+
+ verify(connectionMock);
+ }
+
+ @Test
public void testValidateLookupKey() throws Exception {
- assertTrue("URI not valid", mapping.validateLookupKey("http://example.com/services"));
- assertFalse("URI not valid", mapping.validateLookupKey("some string"));
+ Assert.assertTrue("URI not valid", mapping.validateLookupKey("http://example.com/services"));
+ Assert.assertFalse("URI not valid", mapping.validateLookupKey("some string"));
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java b/core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java
index 8441e85a..326695c0 100644
--- a/core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java
+++ b/core/src/test/java/org/springframework/ws/server/endpoint/mapping/XPathPayloadEndpointMappingTest.java
@@ -16,21 +16,25 @@
package org.springframework.ws.server.endpoint.mapping;
-import junit.framework.TestCase;
import org.springframework.ws.MockWebServiceMessage;
import org.springframework.ws.MockWebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
-public class XPathPayloadEndpointMappingTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class XPathPayloadEndpointMappingTest {
private XPathPayloadEndpointMapping mapping;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
mapping = new XPathPayloadEndpointMapping();
}
+ @Test
public void testGetLookupKeyForMessage() throws Exception {
mapping.setExpression("/root/text()");
mapping.afterPropertiesSet();
@@ -39,7 +43,7 @@ public class XPathPayloadEndpointMappingTest extends TestCase {
MessageContext context = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
String result = mapping.getLookupKeyForMessage(context);
- assertNotNull("mapping returns null", result);
- assertEquals("mapping returns invalid result", "value", result);
+ Assert.assertNotNull("mapping returns null", result);
+ Assert.assertEquals("mapping returns invalid result", "value", result);
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java b/core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java
index 83d7f31f..f3babeba 100644
--- a/core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java
+++ b/core/src/test/java/org/springframework/ws/server/endpoint/support/PayloadRootUtilsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * 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.
@@ -28,15 +28,18 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
-import junit.framework.TestCase;
+import org.springframework.xml.transform.StaxSource;
+
+import org.junit.Assert;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
-import org.springframework.xml.transform.StaxSource;
-
-public class PayloadRootUtilsTest extends TestCase {
+@SuppressWarnings("Since15")
+public class PayloadRootUtilsTest {
+ @Test
public void testGetQNameForDomSource() throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
@@ -45,46 +48,50 @@ public class PayloadRootUtilsTest extends TestCase {
document.appendChild(element);
Source source = new DOMSource(document);
QName qName = PayloadRootUtils.getPayloadRootQName(source, TransformerFactory.newInstance());
- assertNotNull("getQNameForNode returns null", qName);
- assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
- assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
- assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
+ Assert.assertNotNull("getQNameForNode returns null", qName);
+ Assert.assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
+ Assert.assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
+ Assert.assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
}
+ @Test
public void testGetQNameForStaxSource() throws Exception {
String contents = "";
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(contents));
Source source = new StaxSource(streamReader);
QName qName = PayloadRootUtils.getPayloadRootQName(source, TransformerFactory.newInstance());
- assertNotNull("getQNameForNode returns null", qName);
- assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
- assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
- assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
+ Assert.assertNotNull("getQNameForNode returns null", qName);
+ Assert.assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
+ Assert.assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
+ Assert.assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
}
+ @Test
public void testGetQNameForStreamSource() throws Exception {
String contents = "";
Source source = new StreamSource(new StringReader(contents));
QName qName = PayloadRootUtils.getPayloadRootQName(source, TransformerFactory.newInstance());
- assertNotNull("getQNameForNode returns null", qName);
- assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
- assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
- assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
+ Assert.assertNotNull("getQNameForNode returns null", qName);
+ Assert.assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
+ Assert.assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
+ Assert.assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
}
+ @Test
public void testGetQNameForSaxSource() throws Exception {
String contents = "";
Source source = new SAXSource(new InputSource(new StringReader(contents)));
QName qName = PayloadRootUtils.getPayloadRootQName(source, TransformerFactory.newInstance());
- assertNotNull("getQNameForNode returns null", qName);
- assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
- assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
- assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
+ Assert.assertNotNull("getQNameForNode returns null", qName);
+ Assert.assertEquals("QName has invalid localname", "localname", qName.getLocalPart());
+ Assert.assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI());
+ Assert.assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix());
}
+ @Test
public void testGetQNameForNullSource() throws Exception {
QName qName = PayloadRootUtils.getPayloadRootQName(null, TransformerFactory.newInstance());
- assertNull("Qname returned", qName);
+ Assert.assertNull("Qname returned", qName);
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java
index 7063c9a3..e175d09d 100644
--- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapBodyTestCase.java
@@ -19,12 +19,16 @@ package org.springframework.ws.soap;
import java.util.Locale;
import javax.xml.transform.dom.DOMResult;
+import org.springframework.xml.transform.StringResult;
+import org.springframework.xml.transform.StringSource;
+
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import org.springframework.xml.transform.StringResult;
-import org.springframework.xml.transform.StringSource;
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.*;
public abstract class AbstractSoapBodyTestCase extends AbstractSoapElementTestCase {
@@ -38,12 +42,14 @@ public abstract class AbstractSoapBodyTestCase extends AbstractSoapElementTestCa
protected abstract SoapBody createSoapBody() throws Exception;
+ @Test
public void testPayload() throws Exception {
String payload = "";
transformer.transform(new StringSource(payload), soapBody.getPayloadResult());
assertPayloadEqual(payload);
}
+ @Test
public void testGetPayloadResultTwice() throws Exception {
String payload = "";
transformer.transform(new StringSource(payload), soapBody.getPayloadResult());
@@ -55,10 +61,12 @@ public abstract class AbstractSoapBodyTestCase extends AbstractSoapElementTestCa
assertEquals("Invalid amount of child nodes", 1, children.getLength());
}
+ @Test
public void testNoFault() throws Exception {
assertFalse("body has fault", soapBody.hasFault());
}
+ @Test
public void testAddFaultWithExistingPayload() throws Exception {
StringSource contents = new StringSource("");
transformer.transform(contents, soapBody.getPayloadResult());
diff --git a/core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java
index 12337f9b..f3bd6e85 100644
--- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapElementTestCase.java
@@ -21,16 +21,18 @@ import javax.xml.namespace.QName;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
-import org.custommonkey.xmlunit.XMLTestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public abstract class AbstractSoapElementTestCase extends XMLTestCase {
+public abstract class AbstractSoapElementTestCase {
private SoapElement soapElement;
protected Transformer transformer;
- @Override
- protected final void setUp() throws Exception {
+ @Before
+ public final void setUp() throws Exception {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer = transformerFactory.newTransformer();
soapElement = createSoapElement();
@@ -38,21 +40,24 @@ public abstract class AbstractSoapElementTestCase extends XMLTestCase {
protected abstract SoapElement createSoapElement() throws Exception;
+ @Test
public void testAttributes() throws Exception {
QName name = new QName("http://springframework.org/spring-ws", "attribute");
String value = "value";
soapElement.addAttribute(name, value);
- assertEquals("Invalid attribute value", value, soapElement.getAttributeValue(name));
- Iterator allAttributes = soapElement.getAllAttributes();
- assertTrue("Iterator is empty", allAttributes.hasNext());
+ Assert.assertEquals("Invalid attribute value", value, soapElement.getAttributeValue(name));
+ Iterator allAttributes = soapElement.getAllAttributes();
+ Assert.assertTrue("Iterator is empty", allAttributes.hasNext());
}
+ @Test
public void testAddNamespaceDeclaration() throws Exception {
String prefix = "p";
String namespace = "http://springframework.org/spring-ws";
soapElement.addNamespaceDeclaration(prefix, namespace);
}
+ @Test
public void testAddDefaultNamespaceDeclaration() throws Exception {
String prefix = "";
String namespace = "http://springframework.org/spring-ws";
diff --git a/core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java
index 08dfa2ec..9d7c02ac 100644
--- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapEnvelopeTestCase.java
@@ -16,6 +16,10 @@
package org.springframework.ws.soap;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
public abstract class AbstractSoapEnvelopeTestCase extends AbstractSoapElementTestCase {
protected SoapEnvelope soapEnvelope;
@@ -28,11 +32,13 @@ public abstract class AbstractSoapEnvelopeTestCase extends AbstractSoapElementTe
protected abstract SoapEnvelope createSoapEnvelope() throws Exception;
+ @Test
public void testGetHeader() throws Exception {
SoapHeader header = soapEnvelope.getHeader();
assertNotNull("No header returned", header);
}
+ @Test
public void testGetBody() throws Exception {
SoapBody body = soapEnvelope.getBody();
assertNotNull("No body returned", body);
diff --git a/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java
index 3a7ddd78..4b62ae57 100644
--- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapHeaderTestCase.java
@@ -22,6 +22,11 @@ import javax.xml.namespace.QName;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.*;
+
public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTestCase {
protected SoapHeader soapHeader;
@@ -38,12 +43,13 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest
protected abstract SoapHeader createSoapHeader() throws Exception;
+ @Test
public void testAddHeaderElement() throws Exception {
QName qName = new QName(NAMESPACE, "localName", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
assertNotNull("No SoapHeaderElement returned", headerElement);
assertEquals("Invalid qName for element", qName, headerElement.getName());
- Iterator iterator = soapHeader.examineAllHeaderElements();
+ Iterator iterator = soapHeader.examineAllHeaderElements();
assertTrue("SoapHeader has no elements", iterator.hasNext());
String payload = "";
transformer.transform(new StringSource(payload), headerElement.getResult());
@@ -51,15 +57,17 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest
"");
}
+ @Test
public void testRemoveHeaderElement() throws Exception {
QName qName = new QName(NAMESPACE, "localName", PREFIX);
soapHeader.removeHeaderElement(qName);
soapHeader.addHeaderElement(qName);
soapHeader.removeHeaderElement(qName);
- Iterator iterator = soapHeader.examineAllHeaderElements();
+ Iterator iterator = soapHeader.examineAllHeaderElements();
assertFalse("SoapHeader has elements", iterator.hasNext());
}
+ @Test
public void testExamineAllHeaderElement() throws Exception {
QName qName = new QName(NAMESPACE, "localName", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
@@ -67,10 +75,10 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest
assertNotNull("No SoapHeaderElement returned", headerElement);
String payload = "";
transformer.transform(new StringSource(payload), headerElement.getResult());
- Iterator iterator = soapHeader.examineAllHeaderElements();
+ Iterator iterator = soapHeader.examineAllHeaderElements();
assertNotNull("header element iterator is null", iterator);
assertTrue("header element iterator has no elements", iterator.hasNext());
- headerElement = (SoapHeaderElement) iterator.next();
+ headerElement = iterator.next();
assertEquals("Invalid qName for element", qName, headerElement.getName());
StringResult result = new StringResult();
transformer.transform(headerElement.getSource(), result);
@@ -80,6 +88,7 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest
assertFalse("header element iterator has too many elements", iterator.hasNext());
}
+ @Test
public void testExamineMustUnderstandHeaderElements() throws Exception {
QName qName1 = new QName(NAMESPACE, "localName1", PREFIX);
SoapHeaderElement headerElement1 = soapHeader.addHeaderElement(qName1);
@@ -89,23 +98,24 @@ public abstract class AbstractSoapHeaderTestCase extends AbstractSoapElementTest
SoapHeaderElement headerElement2 = soapHeader.addHeaderElement(qName2);
headerElement2.setMustUnderstand(true);
headerElement2.setActorOrRole("role2");
- Iterator iterator = soapHeader.examineMustUnderstandHeaderElements("role1");
+ Iterator iterator = soapHeader.examineMustUnderstandHeaderElements("role1");
assertNotNull("header element iterator is null", iterator);
assertTrue("header element iterator has no elements", iterator.hasNext());
- SoapHeaderElement headerElement = (SoapHeaderElement) iterator.next();
+ SoapHeaderElement headerElement = iterator.next();
assertEquals("Invalid name on header element", qName1, headerElement.getName());
assertTrue("MustUnderstand not set on header element", headerElement.getMustUnderstand());
assertEquals("Invalid role on header element", "role1", headerElement.getActorOrRole());
assertFalse("header element iterator has too many elements", iterator.hasNext());
}
+ @Test
public void testGetResult() throws Exception {
String content =
"";
transformer.transform(new StringSource(content), soapHeader.getResult());
- Iterator iterator = soapHeader.examineAllHeaderElements();
+ Iterator iterator = soapHeader.examineAllHeaderElements();
assertTrue("Header has no children", iterator.hasNext());
- SoapHeaderElement headerElement = (SoapHeaderElement) iterator.next();
+ SoapHeaderElement headerElement = iterator.next();
assertFalse("Header has too many children", iterator.hasNext());
assertHeaderElementEqual(headerElement, content);
}
diff --git a/core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java b/core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java
index 57aa5af6..44764ed0 100644
--- a/core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/AbstractSoapMessageFactoryTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -19,16 +19,24 @@ package org.springframework.ws.soap;
import org.springframework.ws.AbstractWebServiceMessageFactoryTestCase;
import org.springframework.ws.WebServiceMessage;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
public abstract class AbstractSoapMessageFactoryTestCase extends AbstractWebServiceMessageFactoryTestCase {
+ @Test
public void testCreateEmptySoapMessage() throws Exception {
WebServiceMessage message = messageFactory.createWebServiceMessage();
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
}
+ @Test
public abstract void testCreateSoapMessageNoAttachment() throws Exception;
+ @Test
public abstract void testCreateSoapMessageSwA() throws Exception;
+ @Test
public abstract void testCreateSoapMessageMtom() throws Exception;
}
diff --git a/core/src/test/java/org/springframework/ws/soap/addressing/messageid/RandomGuidMessageIdStrategyTest.java b/core/src/test/java/org/springframework/ws/soap/addressing/messageid/RandomGuidMessageIdStrategyTest.java
index 69533022..09e0f04e 100644
--- a/core/src/test/java/org/springframework/ws/soap/addressing/messageid/RandomGuidMessageIdStrategyTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/addressing/messageid/RandomGuidMessageIdStrategyTest.java
@@ -18,22 +18,25 @@ package org.springframework.ws.soap.addressing.messageid;
import java.net.URI;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class RandomGuidMessageIdStrategyTest extends TestCase {
+public class RandomGuidMessageIdStrategyTest {
private MessageIdStrategy strategy;
- @Override
- protected final void setUp() throws Exception {
+ @Before
+ public final void setUp() throws Exception {
strategy = new RandomGuidMessageIdStrategy();
}
+ @Test
public void testStrategy() {
URI messageId1 = strategy.newMessageId(null);
- assertNotNull("Empty messageId", messageId1);
+ Assert.assertNotNull("Empty messageId", messageId1);
URI messageId2 = strategy.newMessageId(null);
- assertNotNull("Empty messageId", messageId2);
- assertFalse("Equal messageIds", messageId1.equals(messageId2));
+ Assert.assertNotNull("Empty messageId", messageId2);
+ Assert.assertFalse("Equal messageIds", messageId1.equals(messageId2));
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java b/core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java
index d15632cf..7b3db612 100644
--- a/core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/addressing/messageid/UuidMessageIdStrategyTest.java
@@ -18,22 +18,25 @@ package org.springframework.ws.soap.addressing.messageid;
import java.net.URI;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class UuidMessageIdStrategyTest extends TestCase {
+public class UuidMessageIdStrategyTest {
private MessageIdStrategy strategy;
- @Override
- protected final void setUp() throws Exception {
+ @Before
+ public final void setUp() throws Exception {
strategy = new UuidMessageIdStrategy();
}
+ @Test
public void testStrategy() {
URI messageId1 = strategy.newMessageId(null);
- assertNotNull("Empty messageId", messageId1);
+ Assert.assertNotNull("Empty messageId", messageId1);
URI messageId2 = strategy.newMessageId(null);
- assertNotNull("Empty messageId", messageId2);
- assertFalse("Equal messageIds", messageId1.equals(messageId2));
+ Assert.assertNotNull("Empty messageId", messageId2);
+ Assert.assertFalse("Equal messageIds", messageId1.equals(messageId2));
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java
index cfdff58e..b4290837 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11BodyTest.java
@@ -16,14 +16,15 @@
package org.springframework.ws.soap.axiom;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.soap.SOAPFactory;
-
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase;
import org.springframework.xml.transform.StringSource;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.junit.Test;
+
public class AxiomSoap11BodyTest extends AbstractSoap11BodyTestCase {
@Override
@@ -33,6 +34,7 @@ public class AxiomSoap11BodyTest extends AbstractSoap11BodyTestCase {
return axiomSoapMessage.getSoapBody();
}
+ @Test
public void testPayloadNoCaching() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setPayloadCaching(false);
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java
index 3810f374..864222d8 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap11MessageFactoryTest.java
@@ -22,9 +22,6 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.custommonkey.xmlunit.XMLUnit;
-
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.soap.soap11.AbstractSoap11MessageFactoryTestCase;
@@ -32,6 +29,13 @@ import org.springframework.ws.transport.MockTransportInputStream;
import org.springframework.ws.transport.TransportInputStream;
import org.springframework.xml.transform.StringResult;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryTestCase {
private Transformer transformer;
@@ -45,6 +49,7 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT
return factory;
}
+ @Test
public void testGetCharsetEncoding() {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
@@ -53,6 +58,7 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT
assertEquals("Invalid charset", "utf-8", messageFactory.getCharSetEncoding("application/xop+xml;type=\"text/xml; charset=utf-8\""));
}
+ @Test
public void testRepetitiveReadCaching() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setPayloadCaching(true);
@@ -69,6 +75,7 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT
transformer.transform(message.getPayloadSource(), result);
}
+ @Test
public void testRepetitiveReadNoCaching() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setPayloadCaching(false);
@@ -94,6 +101,7 @@ public class AxiomSoap11MessageFactoryTest extends AbstractSoap11MessageFactoryT
/**
* See http://jira.springframework.org/browse/SWS-502
*/
+ @Test
public void testSWS502() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setPayloadCaching(false);
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java
index b13810b5..1e2bbf66 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoap12BodyTest.java
@@ -16,14 +16,15 @@
package org.springframework.ws.soap.axiom;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.soap.SOAPFactory;
-
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.soap12.AbstractSoap12BodyTestCase;
import org.springframework.xml.transform.StringSource;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.junit.Test;
+
public class AxiomSoap12BodyTest extends AbstractSoap12BodyTestCase {
@Override
@@ -33,6 +34,7 @@ public class AxiomSoap12BodyTest extends AbstractSoap12BodyTestCase {
return axiomSoapMessage.getSoapBody();
}
+ @Test
public void testPayloadNoCaching() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setPayloadCaching(false);
diff --git a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java
index e49601a3..07051a07 100644
--- a/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/axiom/AxiomSoapFaultDetailTest.java
@@ -20,14 +20,17 @@ import java.io.StringReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
-import org.apache.axiom.soap.SOAPMessage;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapFaultDetail;
-public class AxiomSoapFaultDetailTest extends TestCase {
+import org.apache.axiom.soap.SOAPMessage;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+@SuppressWarnings("Since15")
+public class AxiomSoapFaultDetailTest {
private static final String FAILING_FAULT =
"" +
@@ -57,15 +61,15 @@ public class SaajContentHandlerTest extends TestCase {
Result result = new SAXResult(handler);
transformer.transform(source, result);
Name rootName = envelope.createName("Root", "", "http://springframework.org/spring-ws/1");
- Iterator iterator = envelope.getBody().getChildElements(rootName);
- assertTrue("No child found", iterator.hasNext());
+ Iterator> iterator = envelope.getBody().getChildElements(rootName);
+ Assert.assertTrue("No child found", iterator.hasNext());
SOAPBodyElement rootElement = (SOAPBodyElement) iterator.next();
Name childName = envelope.createName("Child", "child", "http://springframework.org/spring-ws/2");
iterator = rootElement.getChildElements(childName);
- assertTrue("No child found", iterator.hasNext());
+ Assert.assertTrue("No child found", iterator.hasNext());
SOAPElement childElement = (SOAPElement) iterator.next();
- assertEquals("Invalid contents", "Content", childElement.getValue());
+ Assert.assertEquals("Invalid contents", "Content", childElement.getValue());
Name attributeName = envelope.createName("attribute");
- assertEquals("Invalid attribute value", "value", childElement.getAttributeValue(attributeName));
+ Assert.assertEquals("Invalid attribute value", "value", childElement.getAttributeValue(attributeName));
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java b/core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java
index 3c64bbca..7f971abf 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/SoapMessageDispatcherTest.java
@@ -36,24 +36,25 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.ws.soap.soap12.Soap12Fault;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class SoapMessageDispatcherTest extends TestCase {
+import static org.easymock.EasyMock.*;
+
+public class SoapMessageDispatcherTest {
private SoapMessageDispatcher dispatcher;
- private MockControl interceptorControl;
-
private SoapEndpointInterceptor interceptorMock;
- @Override
- protected void setUp() throws Exception {
- interceptorControl = MockControl.createControl(SoapEndpointInterceptor.class);
- interceptorMock = (SoapEndpointInterceptor) interceptorControl.getMock();
+ @Before
+ public void setUp() throws Exception {
+ interceptorMock = createMock(SoapEndpointInterceptor.class);
dispatcher = new SoapMessageDispatcher();
}
+ @Test
public void testProcessMustUnderstandHeadersUnderstoodSoap11() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -63,19 +64,20 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorMock.understands(null);
- interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
- interceptorControl.setReturnValue(true);
- interceptorControl.replay();
+ expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);
+
+ replay(interceptorMock);
SoapEndpointInvocationChain chain =
new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock});
boolean result = dispatcher.handleRequest(chain, context);
- assertTrue("Header not understood", result);
- interceptorControl.verify();
+ Assert.assertTrue("Header not understood", result);
+
+ verify(interceptorMock);
}
+ @Test
public void testProcessMustUnderstandHeadersUnderstoodSoap12() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -85,19 +87,20 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorMock.understands(null);
- interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
- interceptorControl.setReturnValue(true);
- interceptorControl.replay();
+ expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);
+
+ replay(interceptorMock);
SoapEndpointInvocationChain chain =
new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock});
boolean result = dispatcher.handleRequest(chain, context);
- assertTrue("Header not understood", result);
- interceptorControl.verify();
+ Assert.assertTrue("Header not understood", result);
+
+ verify(interceptorMock);
}
+ @Test
public void testProcessMustUnderstandHeadersNotUnderstoodSoap11() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -107,28 +110,29 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorMock.understands(null);
- interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
- interceptorControl.setReturnValue(false);
- interceptorControl.replay();
+ expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(false);
+
+ replay(interceptorMock);
SoapEndpointInvocationChain chain =
new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock});
boolean result = dispatcher.handleRequest(chain, context);
- assertFalse("Header understood", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertFalse("Header understood", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapBody responseBody = ((SoapMessage) context.getResponse()).getSoapBody();
- assertTrue("Response body has no fault", responseBody.hasFault());
+ Assert.assertTrue("Response body has no fault", responseBody.hasFault());
Soap11Fault fault = (Soap11Fault) responseBody.getFault();
- assertEquals("Invalid fault code", new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "MustUnderstand"),
+ Assert.assertEquals("Invalid fault code", new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "MustUnderstand"),
fault.getFaultCode());
- assertEquals("Invalid fault string", SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT_STRING,
+ Assert.assertEquals("Invalid fault string", SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT_STRING,
fault.getFaultStringOrReason());
- assertEquals("Invalid fault string locale", Locale.ENGLISH, fault.getFaultStringLocale());
- interceptorControl.verify();
+ Assert.assertEquals("Invalid fault string locale", Locale.ENGLISH, fault.getFaultStringLocale());
+
+ verify(interceptorMock);
}
+ @Test
public void testProcessMustUnderstandHeadersNotUnderstoodSoap12() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -138,34 +142,35 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorMock.understands(null);
- interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
- interceptorControl.setReturnValue(false);
- interceptorControl.replay();
+ expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(false);
+
+ replay(interceptorMock);
SoapEndpointInvocationChain chain =
new SoapEndpointInvocationChain(new Object(), new SoapEndpointInterceptor[]{interceptorMock});
boolean result = dispatcher.handleRequest(chain, context);
- assertFalse("Header understood", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertFalse("Header understood", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
SoapBody responseBody = response.getSoapBody();
- assertTrue("Response body has no fault", responseBody.hasFault());
+ Assert.assertTrue("Response body has no fault", responseBody.hasFault());
Soap12Fault fault = (Soap12Fault) responseBody.getFault();
- assertEquals("Invalid fault code", new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "MustUnderstand"),
+ Assert.assertEquals("Invalid fault code", new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "MustUnderstand"),
fault.getFaultCode());
- assertEquals("Invalid fault string", SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT_STRING,
+ Assert.assertEquals("Invalid fault string", SoapMessageDispatcher.DEFAULT_MUST_UNDERSTAND_FAULT_STRING,
fault.getFaultReasonText(Locale.ENGLISH));
SoapHeader responseHeader = response.getSoapHeader();
- Iterator iterator = responseHeader.examineAllHeaderElements();
- assertTrue("Response header has no elements", iterator.hasNext());
- SoapHeaderElement headerElement = (SoapHeaderElement) iterator.next();
- assertEquals("No NotUnderstood header", new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood"),
- headerElement.getName());
- interceptorControl.verify();
+ Iterator iterator = responseHeader.examineAllHeaderElements();
+ Assert.assertTrue("Response header has no elements", iterator.hasNext());
+ SoapHeaderElement headerElement = iterator.next();
+ Assert.assertEquals("No NotUnderstood header",
+ new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "NotUnderstood"), headerElement.getName());
+
+ verify(interceptorMock);
}
+ @Test
public void testProcessMustUnderstandHeadersForActorSoap11() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -176,19 +181,20 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorMock.understands(null);
- interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
- interceptorControl.setReturnValue(true);
- interceptorControl.replay();
+ expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);
+
+ replay(interceptorMock);
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(),
new SoapEndpointInterceptor[]{interceptorMock}, new String[]{headerActor}, true);
boolean result = dispatcher.handleRequest(chain, context);
- assertTrue("actor-specific header not understood", result);
- interceptorControl.verify();
+ Assert.assertTrue("actor-specific header not understood", result);
+
+ verify(interceptorMock);
}
+ @Test
public void testProcessMustUnderstandHeadersForRoleSoap12() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -199,35 +205,37 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorMock.understands(null);
- interceptorControl.setMatcher(MockControl.ALWAYS_MATCHER);
- interceptorControl.setReturnValue(true);
- interceptorControl.replay();
+ expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);
+
+ replay(interceptorMock);
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(),
new SoapEndpointInterceptor[]{interceptorMock}, new String[]{headerRole}, true);
boolean result = dispatcher.handleRequest(chain, context);
- assertTrue("role-specific header not understood", result);
- interceptorControl.verify();
+ Assert.assertTrue("role-specific header not understood", result);
+
+ verify(interceptorMock);
}
+ @Test
public void testProcessNoHeader() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
request.getSOAPHeader().detachNode();
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorControl.replay();
+ replay(interceptorMock);
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(),
new SoapEndpointInterceptor[]{interceptorMock}, new String[]{"role"}, true);
boolean result = dispatcher.handleRequest(chain, context);
- assertTrue("Invalid result", result);
- interceptorControl.verify();
+ Assert.assertTrue("Invalid result", result);
+ verify(interceptorMock);
}
+ @Test
public void testProcessMustUnderstandHeadersNoInterceptors() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
@@ -237,13 +245,13 @@ public class SoapMessageDispatcherTest extends TestCase {
header.setMustUnderstand(true);
SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
- interceptorControl.replay();
+ replay(interceptorMock);
SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), null);
boolean result = dispatcher.handleRequest(chain, context);
- assertFalse("Header understood", result);
- interceptorControl.verify();
+ Assert.assertFalse("Header understood", result);
+ verify(interceptorMock);
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java
index a131d652..8109a221 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/FaultCreatingValidatingMarshallingPayloadEndpointTest.java
@@ -27,7 +27,6 @@ import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
-import junit.framework.TestCase;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
@@ -40,14 +39,18 @@ import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
-public class FaultCreatingValidatingMarshallingPayloadEndpointTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FaultCreatingValidatingMarshallingPayloadEndpointTest {
private MessageContext messageContext;
private ResourceBundleMessageSource messageSource;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
this.messageSource = new ResourceBundleMessageSource();
this.messageSource.setBasename("org.springframework.ws.soap.server.endpoint.messages");
MessageFactory messageFactory = MessageFactory.newInstance();
@@ -57,6 +60,7 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest extends TestC
new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory));
}
+ @Test
public void testValidationIncorrect() throws Exception {
Person p = new Person("", -1);
PersonMarshaller marshaller = new PersonMarshaller(p);
@@ -66,7 +70,7 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest extends TestC
@Override
protected Object invokeInternal(Object requestObject) throws Exception {
- fail("No expected");
+ Assert.fail("No expected");
return null;
}
};
@@ -78,27 +82,28 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest extends TestC
endpoint.invoke(messageContext);
SOAPMessage response = ((SaajSoapMessage) messageContext.getResponse()).getSaajMessage();
- assertTrue("Response has no fault", response.getSOAPBody().hasFault());
+ Assert.assertTrue("Response has no fault", response.getSOAPBody().hasFault());
SOAPFault fault = response.getSOAPBody().getFault();
- assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client"),
+ Assert.assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client"),
fault.getFaultCodeAsQName());
- assertEquals("Invalid fault string", endpoint.getFaultStringOrReason(), fault.getFaultString());
+ Assert.assertEquals("Invalid fault string", endpoint.getFaultStringOrReason(), fault.getFaultString());
Detail detail = fault.getDetail();
- assertNotNull("No detail", detail);
- Iterator iterator = detail.getDetailEntries();
- assertTrue("No detail entry", iterator.hasNext());
+ Assert.assertNotNull("No detail", detail);
+ Iterator> iterator = detail.getDetailEntries();
+ Assert.assertTrue("No detail entry", iterator.hasNext());
DetailEntry detailEntry = (DetailEntry) iterator.next();
- assertEquals("Invalid detail entry name", new QName("http://springframework.org/spring-ws", "ValidationError"),
- detailEntry.getElementQName());
- assertEquals("Invalid detail entry text", "Name is required", detailEntry.getTextContent());
- assertTrue("No detail entry", iterator.hasNext());
+ Assert.assertEquals("Invalid detail entry name",
+ new QName("http://springframework.org/spring-ws", "ValidationError"), detailEntry.getElementQName());
+ Assert.assertEquals("Invalid detail entry text", "Name is required", detailEntry.getTextContent());
+ Assert.assertTrue("No detail entry", iterator.hasNext());
detailEntry = (DetailEntry) iterator.next();
- assertEquals("Invalid detail entry name", new QName("http://springframework.org/spring-ws", "ValidationError"),
- detailEntry.getElementQName());
- assertEquals("Invalid detail entry text", "Age Cannot be negative", detailEntry.getTextContent());
- assertFalse("Too many detail entries", iterator.hasNext());
+ Assert.assertEquals("Invalid detail entry name",
+ new QName("http://springframework.org/spring-ws", "ValidationError"), detailEntry.getElementQName());
+ Assert.assertEquals("Invalid detail entry text", "Age Cannot be negative", detailEntry.getTextContent());
+ Assert.assertFalse("Too many detail entries", iterator.hasNext());
}
+ @Test
public void testValidationCorrect() throws Exception {
Person p = new Person("John", 42);
PersonMarshaller marshaller = new PersonMarshaller(p);
@@ -118,12 +123,12 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest extends TestC
endpoint.invoke(messageContext);
SOAPMessage response = ((SaajSoapMessage) messageContext.getResponse()).getSaajMessage();
- assertFalse("Response has fault", response.getSOAPBody().hasFault());
+ Assert.assertFalse("Response has fault", response.getSOAPBody().hasFault());
}
private static class PersonValidator implements Validator {
- public boolean supports(Class clazz) {
+ public boolean supports(Class> clazz) {
return Person.class.equals(clazz);
}
@@ -183,7 +188,7 @@ public class FaultCreatingValidatingMarshallingPayloadEndpointTest extends TestC
return person;
}
- public boolean supports(Class clazz) {
+ public boolean supports(Class> clazz) {
return Person.class.equals(clazz);
}
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java
index b6c139f7..566280c0 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/SimpleSoapExceptionResolverTest.java
@@ -18,8 +18,6 @@ package org.springframework.ws.soap.server.endpoint;
import java.util.Locale;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
import org.springframework.ws.MockWebServiceMessage;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
@@ -27,49 +25,45 @@ import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.soap11.Soap11Body;
-public class SimpleSoapExceptionResolverTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class SimpleSoapExceptionResolverTest {
private SimpleSoapExceptionResolver exceptionResolver;
private MessageContext messageContext;
- private MockControl messageControl;
-
private SoapMessage messageMock;
- private MockControl bodyControl;
-
private Soap11Body bodyMock;
- private MockControl factoryControl;
-
private WebServiceMessageFactory factoryMock;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
exceptionResolver = new SimpleSoapExceptionResolver();
- factoryControl = MockControl.createControl(WebServiceMessageFactory.class);
- factoryMock = (WebServiceMessageFactory) factoryControl.getMock();
+ factoryMock = createMock(WebServiceMessageFactory.class);
messageContext = new DefaultMessageContext(new MockWebServiceMessage(), factoryMock);
- messageControl = MockControl.createControl(SoapMessage.class);
- messageMock = (SoapMessage) messageControl.getMock();
- bodyControl = MockControl.createControl(Soap11Body.class);
- bodyControl.setDefaultMatcher(MockControl.ARRAY_MATCHER);
- bodyMock = (Soap11Body) bodyControl.getMock();
+ messageMock = createMock(SoapMessage.class);
+ bodyMock = createMock(Soap11Body.class);
}
+ @Test
public void testResolveExceptionInternal() throws Exception {
Exception exception = new Exception("message");
- factoryControl.expectAndReturn(factoryMock.createWebServiceMessage(), messageMock);
- messageControl.expectAndReturn(messageMock.getSoapBody(), bodyMock);
- bodyControl.expectAndReturn(bodyMock.addServerOrReceiverFault(exception.getMessage(), Locale.ENGLISH), null);
- factoryControl.replay();
- messageControl.replay();
- bodyControl.replay();
+ expect(factoryMock.createWebServiceMessage()).andReturn(messageMock);
+ expect(messageMock.getSoapBody()).andReturn(bodyMock);
+ expect(bodyMock.addServerOrReceiverFault(exception.getMessage(), Locale.ENGLISH)).andReturn(null);
+
+ replay(factoryMock, messageMock, bodyMock);
+
boolean result = exceptionResolver.resolveExceptionInternal(messageContext, null, exception);
- assertTrue("Invalid result", result);
- factoryControl.verify();
- messageControl.verify();
- bodyControl.verify();
+ Assert.assertTrue("Invalid result", result);
+
+ verify(factoryMock, messageMock, bodyMock);
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java
index 796b42e7..afe6a619 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultAnnotationExceptionResolverTest.java
@@ -22,7 +22,6 @@ import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
-import junit.framework.TestCase;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
@@ -35,66 +34,74 @@ import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.ws.soap.soap12.Soap12Fault;
-public class SoapFaultAnnotationExceptionResolverTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SoapFaultAnnotationExceptionResolverTest {
private SoapFaultAnnotationExceptionResolver resolver;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
resolver = new SoapFaultAnnotationExceptionResolver();
}
+ @Test
public void testResolveExceptionClientSoap11() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SoapMessageFactory factory = new SaajSoapMessageFactory(saajFactory);
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new MyClientException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "Client error", fault.getFaultStringOrReason());
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "Client error", fault.getFaultStringOrReason());
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
+ @Test
public void testResolveExceptionSenderSoap12() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SoapMessageFactory factory = new SaajSoapMessageFactory(saajFactory);
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new MySenderException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap12Fault fault = (Soap12Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getClientOrSenderFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getClientOrSenderFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "Sender error", fault.getFaultReasonText(Locale.ENGLISH));
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "Sender error", fault.getFaultReasonText(Locale.ENGLISH));
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
+ @Test
public void testResolveExceptionServerSoap11() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SoapMessageFactory factory = new SaajSoapMessageFactory(saajFactory);
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new MyServerException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getServerOrReceiverFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getServerOrReceiverFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "Server error", fault.getFaultStringOrReason());
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "Server error", fault.getFaultStringOrReason());
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
+ @Test
public void testResolveExceptionReceiverSoap12() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage message = saajFactory.createMessage();
@@ -102,17 +109,18 @@ public class SoapFaultAnnotationExceptionResolverTest extends TestCase {
MessageContext context = new DefaultMessageContext(new SaajSoapMessage(message), factory);
boolean result = resolver.resolveException(context, null, new MyReceiverException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap12Fault fault = (Soap12Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getServerOrReceiverFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getServerOrReceiverFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "Receiver error", fault.getFaultReasonText(Locale.ENGLISH));
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "Receiver error", fault.getFaultReasonText(Locale.ENGLISH));
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
+ @Test
public void testResolveExceptionDefault() throws Exception {
SoapFaultDefinition defaultFault = new SoapFaultDefinition();
defaultFault.setFaultCode(SoapFaultDefinition.CLIENT);
@@ -123,66 +131,69 @@ public class SoapFaultAnnotationExceptionResolverTest extends TestCase {
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new NonAnnotatedException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "faultstring", fault.getFaultStringOrReason());
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "faultstring", fault.getFaultStringOrReason());
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
+ @Test
public void testResolveExceptionCustom() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SoapMessageFactory factory = new SaajSoapMessageFactory(saajFactory);
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new MyCustomException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", new QName("http://springframework.org/spring-ws", "Fault"),
+ Assert.assertEquals("Invalid fault code on fault", new QName("http://springframework.org/spring-ws", "Fault"),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "MyCustomException thrown", fault.getFaultStringOrReason());
- assertEquals("Invalid fault locale on fault", new Locale("nl"), fault.getFaultStringLocale());
+ Assert.assertEquals("Invalid fault string on fault", "MyCustomException thrown", fault.getFaultStringOrReason());
+ Assert.assertEquals("Invalid fault locale on fault", new Locale("nl"), fault.getFaultStringLocale());
}
+ @Test
public void testResolveExceptionInheritance() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SoapMessageFactory factory = new SaajSoapMessageFactory(saajFactory);
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new MySubClientException());
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "Client error", fault.getFaultStringOrReason());
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "Client error", fault.getFaultStringOrReason());
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
+ @Test
public void testResolveExceptionExceptionMessage() throws Exception {
MessageFactory saajFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SoapMessageFactory factory = new SaajSoapMessageFactory(saajFactory);
MessageContext context = new DefaultMessageContext(factory);
boolean result = resolver.resolveException(context, null, new NoStringOrReasonException("Exception message"));
- assertTrue("resolveException returns false", result);
- assertTrue("Context has no response", context.hasResponse());
+ Assert.assertTrue("resolveException returns false", result);
+ Assert.assertTrue("Context has no response", context.hasResponse());
SoapMessage response = (SoapMessage) context.getResponse();
- assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
+ Assert.assertTrue("Resonse has no fault", response.getSoapBody().hasFault());
Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
- assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
+ Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
fault.getFaultCode());
- assertEquals("Invalid fault string on fault", "Exception message", fault.getFaultStringOrReason());
- assertNull("Detail on fault", fault.getFaultDetail());
+ Assert.assertEquals("Invalid fault string on fault", "Exception message", fault.getFaultStringOrReason());
+ Assert.assertNull("Detail on fault", fault.getFaultDetail());
}
@SoapFault(faultCode = FaultCode.CLIENT, faultStringOrReason = "Client error")
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java
index d6ce2bb9..8b62c942 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/SoapFaultDefinitionEditorTest.java
@@ -19,51 +19,58 @@ package org.springframework.ws.soap.server.endpoint;
import java.util.Locale;
import javax.xml.namespace.QName;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class SoapFaultDefinitionEditorTest extends TestCase {
+public class SoapFaultDefinitionEditorTest {
private SoapFaultDefinitionEditor editor;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
editor = new SoapFaultDefinitionEditor();
}
+ @Test
public void testSetAsTextNoLocale() throws Exception {
editor.setAsText("Server, Server error");
SoapFaultDefinition definition = (SoapFaultDefinition) editor.getValue();
- assertNotNull("fault not set", definition);
- assertEquals("Invalid fault code", new QName("Server"), definition.getFaultCode());
- assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
- assertEquals("Invalid fault string locale", Locale.ENGLISH, definition.getLocale());
+ Assert.assertNotNull("fault not set", definition);
+ Assert.assertEquals("Invalid fault code", new QName("Server"), definition.getFaultCode());
+ Assert.assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
+ Assert.assertEquals("Invalid fault string locale", Locale.ENGLISH, definition.getLocale());
}
+ @Test
public void testSetAsTextLocale() throws Exception {
editor.setAsText("Server, Server error, nl");
SoapFaultDefinition definition = (SoapFaultDefinition) editor.getValue();
- assertNotNull("fault not set", definition);
- assertEquals("Invalid fault code", new QName("Server"), definition.getFaultCode());
- assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
- assertEquals("Invalid fault string locale", new Locale("nl"), definition.getLocale());
+ Assert.assertNotNull("fault not set", definition);
+ Assert.assertEquals("Invalid fault code", new QName("Server"), definition.getFaultCode());
+ Assert.assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
+ Assert.assertEquals("Invalid fault string locale", new Locale("nl"), definition.getLocale());
}
+ @Test
public void testSetAsTextSender() throws Exception {
editor.setAsText("SENDER, Server error");
SoapFaultDefinition definition = (SoapFaultDefinition) editor.getValue();
- assertNotNull("fault not set", definition);
- assertEquals("Invalid fault code", SoapFaultDefinition.SENDER, definition.getFaultCode());
- assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
+ Assert.assertNotNull("fault not set", definition);
+ Assert.assertEquals("Invalid fault code", SoapFaultDefinition.SENDER, definition.getFaultCode());
+ Assert.assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
}
+ @Test
public void testSetAsTextReceiver() throws Exception {
editor.setAsText("RECEIVER, Server error");
SoapFaultDefinition definition = (SoapFaultDefinition) editor.getValue();
- assertNotNull("fault not set", definition);
- assertEquals("Invalid fault code", SoapFaultDefinition.RECEIVER, definition.getFaultCode());
- assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
+ Assert.assertNotNull("fault not set", definition);
+ Assert.assertEquals("Invalid fault code", SoapFaultDefinition.RECEIVER, definition.getFaultCode());
+ Assert.assertEquals("Invalid fault string", "Server error", definition.getFaultStringOrReason());
}
+ @Test
public void testSetAsTextIllegalArgument() throws Exception {
try {
editor.setAsText("SOAP-ENV:Server");
@@ -72,8 +79,9 @@ public class SoapFaultDefinitionEditorTest extends TestCase {
}
}
+ @Test
public void testSetAsTextEmpty() throws Exception {
editor.setAsText("");
- assertNull("definition not set to null", editor.getValue());
+ Assert.assertNull("definition not set to null", editor.getValue());
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptorTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptorTest.java
index c16f1a65..de6d69ea 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptorTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/interceptor/SoapEnvelopeLoggingInterceptorTest.java
@@ -16,20 +16,23 @@
package org.springframework.ws.soap.server.endpoint.interceptor;
-import junit.framework.TestCase;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.ws.context.DefaultMessageContext;
+import org.springframework.ws.context.MessageContext;
+import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
+
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.spi.LoggingEvent;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.ws.context.DefaultMessageContext;
-import org.springframework.ws.context.MessageContext;
-import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
-
-public class SoapEnvelopeLoggingInterceptorTest extends TestCase {
+public class SoapEnvelopeLoggingInterceptorTest {
private SoapEnvelopeLoggingInterceptor interceptor;
@@ -37,8 +40,8 @@ public class SoapEnvelopeLoggingInterceptorTest extends TestCase {
private MessageContext messageContext;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
interceptor = new SoapEnvelopeLoggingInterceptor();
appender = new SoapEnvelopeLoggingInterceptorTest.CountingAppender();
BasicConfigurator.configure(appender);
@@ -49,54 +52,60 @@ public class SoapEnvelopeLoggingInterceptorTest extends TestCase {
appender.reset();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
BasicConfigurator.resetConfiguration();
ClassPathResource resource = new ClassPathResource("log4j.properties");
PropertyConfigurator.configure(resource.getURL());
}
+ @Test
public void testHandleRequestDisabled() throws Exception {
interceptor.setLogRequest(false);
int eventCount = appender.getCount();
interceptor.handleRequest(messageContext, null);
- assertEquals("interceptor logged when disabled", appender.getCount(), eventCount);
+ Assert.assertEquals("interceptor logged when disabled", appender.getCount(), eventCount);
}
+ @Test
public void testHandleRequestEnabled() throws Exception {
int eventCount = appender.getCount();
interceptor.handleRequest(messageContext, null);
- assertTrue("interceptor did not log", appender.getCount() > eventCount);
+ Assert.assertTrue("interceptor did not log", appender.getCount() > eventCount);
}
+ @Test
public void testHandleResponseDisabled() throws Exception {
messageContext.getResponse();
interceptor.setLogResponse(false);
int eventCount = appender.getCount();
interceptor.handleResponse(messageContext, null);
- assertEquals("interceptor logged when disabled", appender.getCount(), eventCount);
+ Assert.assertEquals("interceptor logged when disabled", appender.getCount(), eventCount);
}
+ @Test
public void testHandleResponseEnabled() throws Exception {
messageContext.getResponse();
int eventCount = appender.getCount();
interceptor.handleResponse(messageContext, null);
- assertTrue("interceptor did not log", appender.getCount() > eventCount);
+ Assert.assertTrue("interceptor did not log", appender.getCount() > eventCount);
}
+ @Test
public void testHandleFaultDisabled() throws Exception {
messageContext.getResponse();
interceptor.setLogFault(false);
int eventCount = appender.getCount();
interceptor.handleFault(messageContext, null);
- assertEquals("interceptor logged when disabled", appender.getCount(), eventCount);
+ Assert.assertEquals("interceptor logged when disabled", appender.getCount(), eventCount);
}
+ @Test
public void testHandleFaultEnabled() throws Exception {
messageContext.getResponse();
int eventCount = appender.getCount();
interceptor.handleResponse(messageContext, null);
- assertTrue("interceptor did not log", appender.getCount() > eventCount);
+ Assert.assertTrue("interceptor did not log", appender.getCount() > eventCount);
}
private static class CountingAppender extends AppenderSkeleton {
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java
index 66a3cb81..af2ccb88 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/DelegatingSoapEndpointMappingTest.java
@@ -16,8 +16,6 @@
package org.springframework.ws.soap.server.endpoint.mapping;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
import org.springframework.ws.MockWebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
@@ -25,33 +23,40 @@ import org.springframework.ws.server.EndpointInvocationChain;
import org.springframework.ws.server.EndpointMapping;
import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
-public class DelegatingSoapEndpointMappingTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class DelegatingSoapEndpointMappingTest {
private DelegatingSoapEndpointMapping endpointMapping;
- private MockControl control;
-
private EndpointMapping mock;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
endpointMapping = new DelegatingSoapEndpointMapping();
- control = MockControl.createControl(EndpointMapping.class);
- mock = (EndpointMapping) control.getMock();
+ mock = createMock(EndpointMapping.class);
endpointMapping.setDelegate(mock);
}
+ @Test
public void testGetEndpointMapping() throws Exception {
String role = "http://www.springframework.org/spring-ws/role";
endpointMapping.setActorOrRole(role);
MessageContext context = new DefaultMessageContext(new MockWebServiceMessageFactory());
EndpointInvocationChain delegateChain = new EndpointInvocationChain(new Object());
- control.expectAndReturn(mock.getEndpoint(context), delegateChain);
- control.replay();
+ expect(mock.getEndpoint(context)).andReturn(delegateChain);
+
+ replay(mock);
+
SoapEndpointInvocationChain resultChain = (SoapEndpointInvocationChain) endpointMapping.getEndpoint(context);
- assertNotNull("No chain returned", resultChain);
- assertEquals("Invalid ampount of roles returned", 1, resultChain.getActorsOrRoles().length);
- assertEquals("Invalid role returned", role, resultChain.getActorsOrRoles()[0]);
- control.verify();
+ Assert.assertNotNull("No chain returned", resultChain);
+ Assert.assertEquals("Invalid ampount of roles returned", 1, resultChain.getActorsOrRoles().length);
+ Assert.assertEquals("Invalid role returned", role, resultChain.getActorsOrRoles()[0]);
+
+ verify(mock);
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java
index 650f74f8..4897da2c 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionAnnotationMethodEndpointMappingTest.java
@@ -18,9 +18,6 @@ package org.springframework.ws.soap.server.endpoint.mapping;
import java.lang.reflect.Method;
-import junit.framework.TestCase;
-import static org.easymock.EasyMock.*;
-
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
@@ -31,14 +28,20 @@ import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.server.endpoint.annotation.SoapAction;
-public class SoapActionAnnotationMethodEndpointMappingTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class SoapActionAnnotationMethodEndpointMappingTest {
private SoapActionAnnotationMethodEndpointMapping mapping;
private StaticApplicationContext applicationContext;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
applicationContext = new StaticApplicationContext();
applicationContext.registerSingleton("mapping", SoapActionAnnotationMethodEndpointMapping.class);
applicationContext.registerSingleton("endpoint", MyEndpoint.class);
@@ -46,6 +49,7 @@ public class SoapActionAnnotationMethodEndpointMappingTest extends TestCase {
mapping = (SoapActionAnnotationMethodEndpointMapping) applicationContext.getBean("mapping");
}
+ @Test
public void testRegistration() throws Exception {
SoapMessage requestMock = createMock(SoapMessage.class);
expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction");
@@ -54,10 +58,10 @@ public class SoapActionAnnotationMethodEndpointMappingTest extends TestCase {
MessageContext context = new DefaultMessageContext(requestMock, factoryMock);
EndpointInvocationChain chain = mapping.getEndpoint(context);
- assertNotNull("MethodEndpoint not registered", chain);
+ Assert.assertNotNull("MethodEndpoint not registered", chain);
Method doIt = MyEndpoint.class.getMethod("doIt", new Class[0]);
MethodEndpoint expected = new MethodEndpoint("endpoint", applicationContext, doIt);
- assertEquals("Invalid endpoint registered", expected, chain.getEndpoint());
+ Assert.assertEquals("Invalid endpoint registered", expected, chain.getEndpoint());
verify(requestMock, factoryMock);
}
diff --git a/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java b/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java
index 0e34a2b0..9c8a3e3e 100644
--- a/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/server/endpoint/mapping/SoapActionEndpointMappingTest.java
@@ -18,38 +18,43 @@ package org.springframework.ws.soap.server.endpoint.mapping;
import javax.xml.soap.MessageFactory;
-import junit.framework.TestCase;
-
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
-public class SoapActionEndpointMappingTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SoapActionEndpointMappingTest {
private SoapActionEndpointMapping mapping;
private MessageContext context;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
mapping = new SoapActionEndpointMapping();
context = new DefaultMessageContext(new SaajSoapMessageFactory(MessageFactory.newInstance()));
}
+ @Test
public void testGetLookupKeyForMessage() throws Exception {
String soapAction = "http://springframework.org/spring-ws/SoapAction";
((SoapMessage) context.getRequest()).setSoapAction(soapAction);
- assertEquals("Invalid lookup key", soapAction, mapping.getLookupKeyForMessage(context));
+ Assert.assertEquals("Invalid lookup key", soapAction, mapping.getLookupKeyForMessage(context));
}
+ @Test
public void testGetLookupKeyForMessageQuoted() throws Exception {
String soapAction = "http://springframework.org/spring-ws/SoapAction";
((SoapMessage) context.getRequest()).setSoapAction(soapAction);
- assertEquals("Invalid lookup key", soapAction, mapping.getLookupKeyForMessage(context));
+ Assert.assertEquals("Invalid lookup key", soapAction, mapping.getLookupKeyForMessage(context));
}
+ @Test
public void testValidateLookupKey() throws Exception {
- assertTrue("Soapaction not valid", mapping.validateLookupKey("SoapAction"));
+ Assert.assertTrue("Soapaction not valid", mapping.validateLookupKey("SoapAction"));
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java
index fa510687..e4f85a7a 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11BodyTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -27,16 +27,24 @@ import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.*;
+
public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCase {
+ @Test
public void testGetType() {
assertTrue("Invalid type returned", soapBody instanceof Soap11Body);
}
+ @Test
public void testGetName() throws Exception {
assertEquals("Invalid qualified name", SoapVersion.SOAP_11.getBodyName(), soapBody.getName());
}
+ @Test
public void testGetSource() throws Exception {
StringResult result = new StringResult();
transformer.transform(soapBody.getSource(), result);
@@ -44,6 +52,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
result.toString());
}
+ @Test
public void testAddMustUnderstandFault() throws Exception {
SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", null);
assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "MustUnderstand"),
@@ -53,6 +62,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
"SOAP Must Understand Error");
}
+ @Test
public void testAddClientFault() throws Exception {
SoapFault fault = soapBody.addClientOrSenderFault("faultString", null);
assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client"),
@@ -62,6 +72,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
"faultString" + "");
}
+ @Test
public void testAddServerFault() throws Exception {
SoapFault fault = soapBody.addServerOrReceiverFault("faultString", null);
assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"),
@@ -71,6 +82,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
"faultString" + "");
}
+ @Test
public void testAddFault() throws Exception {
QName faultCode = new QName("http://www.springframework.org", "fault", "spring");
String faultString = "faultString";
@@ -90,6 +102,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
"" + "");
}
+ @Test
public void testAddFaultNoPrefix() throws Exception {
QName faultCode = new QName("http://www.springframework.org", "fault");
String faultString = "faultString";
@@ -105,6 +118,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
assertEquals("Invalid fault actor", actor, fault.getFaultActorOrRole());
}
+ @Test
public void testAddFaultWithDetail() throws Exception {
QName faultCode = new QName("http://www.springframework.org", "fault", "spring");
String faultString = "faultString";
@@ -127,6 +141,7 @@ public abstract class AbstractSoap11BodyTestCase extends AbstractSoapBodyTestCas
}
+ @Test
public void testAddFaultWithDetailResult() throws Exception {
SoapFault fault = ((Soap11Body) soapBody)
.addFault(new QName("namespace", "localPart", "prefix"), "Fault", null);
diff --git a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java
index 1b3e5564..f7d99ad5 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11EnvelopeTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -22,14 +22,21 @@ import org.springframework.ws.soap.AbstractSoapEnvelopeTestCase;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.transform.StringResult;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+
public abstract class AbstractSoap11EnvelopeTestCase extends AbstractSoapEnvelopeTestCase {
+ @Test
public void testGetName() throws Exception {
assertEquals("Invalid qualified name",
new QName(SoapVersion.SOAP_11.getEnvelopeNamespaceUri(), "Envelope"),
soapEnvelope.getName());
}
+ @Test
public void testGetContent() throws Exception {
StringResult result = new StringResult();
transformer.transform(soapEnvelope.getSource(), result);
diff --git a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java
index 85e4251c..0f7487b4 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11HeaderTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -24,19 +24,27 @@ import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.transform.StringResult;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.*;
+
public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTestCase {
private static final String PREFIX = "spring";
+ @Test
public void testGetType() {
assertTrue("Invalid type returned", soapHeader instanceof Soap11Header);
}
+ @Test
public void testGetName() throws Exception {
assertEquals("Invalid qualified name", new QName(SoapVersion.SOAP_11.getEnvelopeNamespaceUri(), "Header"),
soapHeader.getName());
}
+ @Test
public void testGetSource() throws Exception {
StringResult result = new StringResult();
transformer.transform(soapHeader.getSource(), result);
@@ -44,6 +52,7 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes
"", result.toString());
}
+ @Test
public void testExamineHeaderElementsToProcessActors() throws Exception {
QName qName = new QName(NAMESPACE, "localName1", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
@@ -54,7 +63,7 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes
qName = new QName(NAMESPACE, "localName3", PREFIX);
headerElement = soapHeader.addHeaderElement(qName);
headerElement.setActorOrRole(SoapVersion.SOAP_11.getNextActorOrRoleUri());
- Iterator iterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role1"});
+ Iterator iterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role1"});
assertNotNull("header element iterator is null", iterator);
assertTrue("header element iterator has no elements", iterator.hasNext());
checkHeaderElement((SoapHeaderElement) iterator.next());
@@ -63,6 +72,7 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes
assertFalse("header element iterator has too many elements", iterator.hasNext());
}
+ @Test
public void testExamineHeaderElementsToProcessNoActors() throws Exception {
QName qName = new QName(NAMESPACE, "localName1", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
@@ -73,7 +83,7 @@ public abstract class AbstractSoap11HeaderTestCase extends AbstractSoapHeaderTes
qName = new QName(NAMESPACE, "localName3", PREFIX);
headerElement = soapHeader.addHeaderElement(qName);
headerElement.setActorOrRole(SoapVersion.SOAP_11.getNextActorOrRoleUri());
- Iterator iterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(new String[0]);
+ Iterator iterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(new String[0]);
assertNotNull("header element iterator is null", iterator);
assertTrue("header element iterator has no elements", iterator.hasNext());
checkHeaderElement((SoapHeaderElement) iterator.next());
diff --git a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java
index 704f4c58..87196c4e 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap11/AbstractSoap11MessageFactoryTestCase.java
@@ -29,8 +29,13 @@ import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.transport.MockTransportInputStream;
import org.springframework.ws.transport.TransportInputStream;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase {
+ @Test
public void testCreateEmptySoap11Message() throws Exception {
WebServiceMessage message = messageFactory.createWebServiceMessage();
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
@@ -67,8 +72,8 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals("Invalid soap version", SoapVersion.SOAP_11, soapMessage.getVersion());
- assertFalse("Message a XOP pacakge", soapMessage.isXopPackage());
- Iterator iter = soapMessage.getAttachments();
+ assertFalse("Message a XOP package", soapMessage.isXopPackage());
+ Iterator iter = soapMessage.getAttachments();
assertTrue("No attachments read", iter.hasNext());
Attachment attachment = soapMessage.getAttachment("interface21");
assertNotNull("No attachment read", attachment);
@@ -88,14 +93,15 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals("Invalid soap version", SoapVersion.SOAP_11, soapMessage.getVersion());
- assertTrue("Message not a XOP pacakge", soapMessage.isXopPackage());
- Iterator iter = soapMessage.getAttachments();
+ assertTrue("Message not a XOP package", soapMessage.isXopPackage());
+ Iterator iter = soapMessage.getAttachments();
assertTrue("No attachments read", iter.hasNext());
Attachment attachment = soapMessage.getAttachment("<1.urn:uuid:492264AB42E57108E01176731445504@apache.org>");
assertNotNull("No attachment read", attachment);
}
+ @Test
public void testCreateSoapMessageMtomWeirdStartInfo() throws Exception {
InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-mtom.bin");
Map headers = new HashMap();
@@ -108,14 +114,15 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals("Invalid soap version", SoapVersion.SOAP_11, soapMessage.getVersion());
- assertTrue("Message not a XOP pacakge", soapMessage.isXopPackage());
- Iterator iter = soapMessage.getAttachments();
+ assertTrue("Message not a XOP package", soapMessage.isXopPackage());
+ Iterator iter = soapMessage.getAttachments();
assertTrue("No attachments read", iter.hasNext());
Attachment attachment = soapMessage.getAttachment("<1.urn:uuid:492264AB42E57108E01176731445504@apache.org>");
assertNotNull("No attachment read", attachment);
}
+ @Test
public void testCreateSoapMessageUtf8ByteOrderMark() throws Exception {
InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-utf8-bom.xml");
Map headers = new HashMap();
@@ -126,6 +133,7 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertEquals("Invalid soap version", SoapVersion.SOAP_11, message.getVersion());
}
+ @Test
public void testCreateSoapMessageUtf16BigEndianByteOrderMark() throws Exception {
InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-utf16-be-bom.xml");
Map headers = new HashMap();
@@ -136,6 +144,7 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
assertEquals("Invalid soap version", SoapVersion.SOAP_11, message.getVersion());
}
+ @Test
public void testCreateSoapMessageUtf16LittleEndianByteOrderMark() throws Exception {
InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11-utf16-le-bom.xml");
Map headers = new HashMap();
diff --git a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java
index 851a7c9e..0383a715 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12BodyTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -28,17 +28,25 @@ import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.*;
+
public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCase {
+ @Test
public void testGetType() {
assertTrue("Invalid type returned", soapBody instanceof Soap12Body);
}
+ @Test
public void testGetName() throws Exception {
assertEquals("Invalid qualified name", new QName(SoapVersion.SOAP_12.getEnvelopeNamespaceUri(), "Body"),
soapBody.getName());
}
+ @Test
public void testGetSource() throws Exception {
StringResult result = new StringResult();
transformer.transform(soapBody.getSource(), result);
@@ -46,6 +54,7 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas
result.toString());
}
+ @Test
public void testAddMustUnderstandFault() throws Exception {
SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", Locale.ENGLISH);
assertEquals("Invalid fault code", new QName("http://www.w3.org/2003/05/soap-envelope", "MustUnderstand"),
@@ -60,6 +69,7 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas
"", result.toString());
}
+ @Test
public void testAddSenderFault() throws Exception {
SoapFault fault = soapBody.addClientOrSenderFault("faultString", Locale.ENGLISH);
assertEquals("Invalid fault code", new QName("http://www.w3.org/2003/05/soap-envelope", "Sender"),
@@ -74,6 +84,7 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas
"", result.toString());
}
+ @Test
public void testAddReceiverFault() throws Exception {
SoapFault fault = soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH);
assertEquals("Invalid fault code", new QName("http://www.w3.org/2003/05/soap-envelope", "Receiver"),
@@ -88,6 +99,7 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas
"", result.toString());
}
+ @Test
public void testAddFaultWithDetail() throws Exception {
SoapFault fault = soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH);
SoapFaultDetail detail = fault.addFaultDetail();
@@ -106,6 +118,7 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas
"", result.toString());
}
+ @Test
public void testAddFaultWithDetailResult() throws Exception {
SoapFault fault = soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH);
SoapFaultDetail detail = fault.addFaultDetail();
@@ -122,13 +135,14 @@ public abstract class AbstractSoap12BodyTestCase extends AbstractSoapBodyTestCas
"" + "", result.toString());
}
+ @Test
public void testAddFaultWithSubcode() throws Exception {
Soap12Fault fault = (Soap12Fault) soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH);
QName subcode1 = new QName("http://www.springframework.org", "Subcode1", "spring-ws");
fault.addFaultSubcode(subcode1);
QName subcode2 = new QName("http://www.springframework.org", "Subcode2", "spring-ws");
fault.addFaultSubcode(subcode2);
- Iterator iterator = fault.getFaultSubcodes();
+ Iterator iterator = fault.getFaultSubcodes();
assertTrue("No subcode found", iterator.hasNext());
assertEquals("Invalid subcode", subcode1, iterator.next());
assertTrue("No subcode found", iterator.hasNext());
diff --git a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java
index 97430457..a97656ea 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12EnvelopeTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -22,13 +22,20 @@ import org.springframework.ws.soap.AbstractSoapEnvelopeTestCase;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.transform.StringResult;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+
public abstract class AbstractSoap12EnvelopeTestCase extends AbstractSoapEnvelopeTestCase {
+ @Test
public void testGetName() throws Exception {
assertEquals("Invalid qualified name", new QName(SoapVersion.SOAP_12.getEnvelopeNamespaceUri(), "Envelope"),
soapEnvelope.getName());
}
+ @Test
public void testGetSource() throws Exception {
StringResult result = new StringResult();
transformer.transform(soapEnvelope.getSource(), result);
diff --git a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java
index 2ff52bbe..d1486ebb 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12HeaderTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 the original author or authors.
+ * 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.
@@ -24,17 +24,25 @@ import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.xml.transform.StringResult;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.*;
+
public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTestCase {
+ @Test
public void testGetType() {
assertTrue("Invalid type returned", soapHeader instanceof Soap12Header);
}
+ @Test
public void testGetName() throws Exception {
assertEquals("Invalid qualified name", new QName(SoapVersion.SOAP_12.getEnvelopeNamespaceUri(), "Header"),
soapHeader.getName());
}
+ @Test
public void testGetSource() throws Exception {
StringResult result = new StringResult();
transformer.transform(soapHeader.getSource(), result);
@@ -42,6 +50,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
result.toString());
}
+ @Test
public void testAddNotUnderstood() throws Exception {
Soap12Header soap12Header = (Soap12Header) soapHeader;
QName headerName = new QName("http://www.springframework.org", "NotUnderstood", "spring-ws");
@@ -53,6 +62,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
"", result.toString());
}
+ @Test
public void testAddUpgrade() throws Exception {
String[] supportedUris =
new String[]{"http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/2003/05/soap-envelope"};
@@ -72,6 +82,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
*/
}
+ @Test
public void testExamineHeaderElementsToProcessActors() throws Exception {
QName qName = new QName(NAMESPACE, "localName1", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
@@ -82,7 +93,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
qName = new QName(NAMESPACE, "localName3", PREFIX);
headerElement = soapHeader.addHeaderElement(qName);
headerElement.setActorOrRole(SoapVersion.SOAP_12.getNextActorOrRoleUri());
- Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role1"}, false);
+ Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role1"}, false);
assertNotNull("header element iterator is null", iterator);
assertTrue("header element iterator has no elements", iterator.hasNext());
checkHeaderElement((SoapHeaderElement) iterator.next());
@@ -91,6 +102,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
assertFalse("header element iterator has too many elements", iterator.hasNext());
}
+ @Test
public void testExamineHeaderElementsToProcessNoActors() throws Exception {
QName qName = new QName(NAMESPACE, "localName1", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
@@ -101,7 +113,7 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
qName = new QName(NAMESPACE, "localName3", PREFIX);
headerElement = soapHeader.addHeaderElement(qName);
headerElement.setActorOrRole(SoapVersion.SOAP_12.getNextActorOrRoleUri());
- Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[0], false);
+ Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[0], false);
assertNotNull("header element iterator is null", iterator);
assertTrue("header element iterator has no elements", iterator.hasNext());
checkHeaderElement((SoapHeaderElement) iterator.next());
@@ -110,11 +122,12 @@ public abstract class AbstractSoap12HeaderTestCase extends AbstractSoapHeaderTes
assertFalse("header element iterator has too many elements", iterator.hasNext());
}
+ @Test
public void testExamineHeaderElementsToProcessUltimateDestination() throws Exception {
QName qName = new QName(NAMESPACE, "localName", PREFIX);
SoapHeaderElement headerElement = soapHeader.addHeaderElement(qName);
headerElement.setActorOrRole(SoapVersion.SOAP_12.getUltimateReceiverRoleUri());
- Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role"}, true);
+ Iterator iterator = ((Soap12Header) soapHeader).examineHeaderElementsToProcess(new String[]{"role"}, true);
assertNotNull("header element iterator is null", iterator);
headerElement = (SoapHeaderElement) iterator.next();
assertEquals("Invalid name on header element", new QName(NAMESPACE, "localName", PREFIX),
diff --git a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java
index 9e89df36..891990d9 100644
--- a/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java
+++ b/core/src/test/java/org/springframework/ws/soap/soap12/AbstractSoap12MessageFactoryTestCase.java
@@ -30,6 +30,8 @@ import org.springframework.ws.transport.MockTransportInputStream;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportInputStream;
+import static org.junit.Assert.*;
+
public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase {
@Override
@@ -86,8 +88,8 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals("Invalid soap version", SoapVersion.SOAP_12, soapMessage.getVersion());
- assertTrue("Message is not a XOP pacakge", soapMessage.isXopPackage());
- Iterator iter = soapMessage.getAttachments();
+ assertTrue("Message is not a XOP package", soapMessage.isXopPackage());
+ Iterator iter = soapMessage.getAttachments();
assertTrue("No attachments read", iter.hasNext());
Attachment attachment = soapMessage.getAttachment("<1.urn:uuid:40864869929B855F971176851454452@apache.org>");
diff --git a/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java b/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java
index 87a1bbcf..5e88cc35 100644
--- a/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java
+++ b/core/src/test/java/org/springframework/ws/soap/support/SoapUtilsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 the original author or authors.
+ * 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.
@@ -16,56 +16,60 @@
package org.springframework.ws.soap.support;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
-public class SoapUtilsTest extends TestCase {
+public class SoapUtilsTest {
+ @Test
public void testExtractActionFromContentType() throws Exception {
String soapAction = "http://springframework.org/spring-ws/Action";
String contentType = "application/soap+xml; action=" + soapAction;
String result = SoapUtils.extractActionFromContentType(contentType);
- assertEquals("Invalid SOAP action", soapAction, result);
+ Assert.assertEquals("Invalid SOAP action", soapAction, result);
contentType = "application/soap+xml; action = " + soapAction;
result = SoapUtils.extractActionFromContentType(contentType);
- assertEquals("Invalid SOAP action", soapAction, result);
+ Assert.assertEquals("Invalid SOAP action", soapAction, result);
contentType = "application/soap+xml; action=" + soapAction + " ; charset=UTF-8";
result = SoapUtils.extractActionFromContentType(contentType);
- assertEquals("Invalid SOAP action", soapAction, result);
+ Assert.assertEquals("Invalid SOAP action", soapAction, result);
contentType = "application/soap+xml; charset=UTF-8; action=" + soapAction;
result = SoapUtils.extractActionFromContentType(contentType);
- assertEquals("Invalid SOAP action", soapAction, result);
+ Assert.assertEquals("Invalid SOAP action", soapAction, result);
}
+ @Test
public void testEscapeAction() throws Exception {
String result = SoapUtils.escapeAction("action");
- assertEquals("Invalid SOAP action", "\"action\"", result);
+ Assert.assertEquals("Invalid SOAP action", "\"action\"", result);
result = SoapUtils.escapeAction("\"action\"");
- assertEquals("Invalid SOAP action", "\"action\"", result);
+ Assert.assertEquals("Invalid SOAP action", "\"action\"", result);
result = SoapUtils.escapeAction("");
- assertEquals("Invalid SOAP action", "\"\"", result);
+ Assert.assertEquals("Invalid SOAP action", "\"\"", result);
result = SoapUtils.escapeAction(null);
- assertEquals("Invalid SOAP action", "\"\"", result);
+ Assert.assertEquals("Invalid SOAP action", "\"\"", result);
}
+ @Test
public void testSetActionInContentType() throws Exception {
String soapAction = "http://springframework.org/spring-ws/Action";
String contentType = "application/soap+xml";
String result = SoapUtils.setActionInContentType(contentType, soapAction);
- assertEquals("Invalid SOAP action", soapAction, SoapUtils.extractActionFromContentType(result));
+ Assert.assertEquals("Invalid SOAP action", soapAction, SoapUtils.extractActionFromContentType(result));
String anotherSoapAction = "http://springframework.org/spring-ws/AnotherAction";
String contentTypeWithAction = "application/soap+xml; action=http://springframework.org/spring-ws/Action";
result = SoapUtils.setActionInContentType(contentTypeWithAction, anotherSoapAction);
- assertEquals("Invalid SOAP action", anotherSoapAction, SoapUtils.extractActionFromContentType(result));
+ Assert.assertEquals("Invalid SOAP action", anotherSoapAction, SoapUtils.extractActionFromContentType(result));
}
diff --git a/core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java b/core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java
index d216e724..b0c3c967 100644
--- a/core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java
+++ b/core/src/test/java/org/springframework/ws/support/DefaultStrategiesHelperTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * 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.
@@ -27,10 +27,12 @@ import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
-public class DefaultStrategiesHelperTest extends TestCase {
+public class DefaultStrategiesHelperTest {
+ @Test
public void testGetDefaultStrategies() throws Exception {
Properties strategies = new Properties();
@@ -42,17 +44,18 @@ public class DefaultStrategiesHelperTest extends TestCase {
applicationContext.registerSingleton("strategy1", StrategyImpl.class);
applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);
- List result = helper.getDefaultStrategies(Strategy.class, applicationContext);
- assertNotNull("No result", result);
- assertEquals("Invalid amount of strategies", 2, result.size());
- assertTrue("Result not a Strategy implementation", result.get(0) instanceof Strategy);
- assertTrue("Result not a Strategy implementation", result.get(1) instanceof Strategy);
- assertTrue("Result not a StrategyImpl implementation", result.get(0) instanceof StrategyImpl);
- assertTrue("Result not a StrategyImpl implementation", result.get(1) instanceof ContextAwareStrategyImpl);
+ List result = helper.getDefaultStrategies(Strategy.class, applicationContext);
+ Assert.assertNotNull("No result", result);
+ Assert.assertEquals("Invalid amount of strategies", 2, result.size());
+ Assert.assertTrue("Result not a Strategy implementation", result.get(0) != null);
+ Assert.assertTrue("Result not a Strategy implementation", result.get(1) != null);
+ Assert.assertTrue("Result not a StrategyImpl implementation", result.get(0) instanceof StrategyImpl);
+ Assert.assertTrue("Result not a StrategyImpl implementation", result.get(1) instanceof ContextAwareStrategyImpl);
ContextAwareStrategyImpl impl = (ContextAwareStrategyImpl) result.get(1);
- assertNotNull("No application context injected", impl.getApplicationContext());
+ Assert.assertNotNull("No application context injected", impl.getApplicationContext());
}
+ @Test
public void testGetDefaultStrategy() throws Exception {
Properties strategies = new Properties();
strategies.put(Strategy.class.getName(), StrategyImpl.class.getName());
@@ -63,11 +66,12 @@ public class DefaultStrategiesHelperTest extends TestCase {
applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);
Object result = helper.getDefaultStrategy(Strategy.class, applicationContext);
- assertNotNull("No result", result);
- assertTrue("Result not a Strategy implementation", result instanceof Strategy);
- assertTrue("Result not a StrategyImpl implementation", result instanceof StrategyImpl);
+ Assert.assertNotNull("No result", result);
+ Assert.assertTrue("Result not a Strategy implementation", result instanceof Strategy);
+ Assert.assertTrue("Result not a StrategyImpl implementation", result instanceof StrategyImpl);
}
+ @Test
public void testGetDefaultStrategyMoreThanOne() throws Exception {
Properties strategies = new Properties();
strategies.put(Strategy.class.getName(),
@@ -80,13 +84,14 @@ public class DefaultStrategiesHelperTest extends TestCase {
try {
helper.getDefaultStrategy(Strategy.class, applicationContext);
- fail("Expected BeanInitializationException");
+ Assert.fail("Expected BeanInitializationException");
}
catch (BeanInitializationException ex) {
// expected
}
}
+ @Test
public void testResourceConstructor() throws Exception {
Resource resource = new ClassPathResource("strategies.properties", getClass());
new DefaultStrategiesHelper(resource);
diff --git a/core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java b/core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java
index ddb93183..8ee65394 100644
--- a/core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java
+++ b/core/src/test/java/org/springframework/ws/support/MarshallingUtilsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * 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.
@@ -19,10 +19,9 @@ package org.springframework.ws.support;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
+import org.springframework.oxm.mime.MimeContainer;
import org.springframework.oxm.mime.MimeMarshaller;
import org.springframework.oxm.mime.MimeUnmarshaller;
import org.springframework.ws.WebServiceMessage;
@@ -30,109 +29,96 @@ import org.springframework.ws.mime.MimeMessage;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
-public class MarshallingUtilsTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Test;
+import static org.easymock.EasyMock.*;
+
+public class MarshallingUtilsTest {
+
+ @Test
public void testUnmarshal() throws Exception {
- MockControl unmarshallerControl = MockControl.createControl(Unmarshaller.class);
- Unmarshaller unmarshallerMock = (Unmarshaller) unmarshallerControl.getMock();
- MockControl messageControl = MockControl.createControl(WebServiceMessage.class);
- WebServiceMessage messageMock = (WebServiceMessage) messageControl.getMock();
+ Unmarshaller unmarshallerMock = createMock(Unmarshaller.class);
+ WebServiceMessage messageMock = createMock(WebServiceMessage.class);
Source source = new StringSource("");
Object unmarshalled = new Object();
- messageControl.expectAndReturn(messageMock.getPayloadSource(), source);
- unmarshallerControl.expectAndReturn(unmarshallerMock.unmarshal(source), unmarshalled);
+ expect(messageMock.getPayloadSource()).andReturn(source);
+ expect(unmarshallerMock.unmarshal(source)).andReturn(unmarshalled);
- unmarshallerControl.replay();
- messageControl.replay();
+ replay(unmarshallerMock, messageMock);
Object result = MarshallingUtils.unmarshal(unmarshallerMock, messageMock);
- assertEquals("Invalid unmarshalled object", unmarshalled, result);
+ Assert.assertEquals("Invalid unmarshalled object", unmarshalled, result);
- unmarshallerControl.verify();
- messageControl.verify();
+ verify(unmarshallerMock, messageMock);
}
+ @Test
public void testUnmarshalMime() throws Exception {
- MockControl unmarshallerControl = MockControl.createControl(MimeUnmarshaller.class);
- MimeUnmarshaller unmarshallerMock = (MimeUnmarshaller) unmarshallerControl.getMock();
- MockControl messageControl = MockControl.createControl(MimeMessage.class);
- MimeMessage messageMock = (MimeMessage) messageControl.getMock();
+ MimeUnmarshaller unmarshallerMock = createMock(MimeUnmarshaller.class);
+ MimeMessage messageMock = createMock(MimeMessage.class);
Source source = new StringSource("");
Object unmarshalled = new Object();
- messageControl.expectAndReturn(messageMock.getPayloadSource(), source);
- unmarshallerMock.unmarshal(source, null);
- unmarshallerControl.setMatcher(MockControl.ALWAYS_MATCHER);
- unmarshallerControl.setReturnValue(unmarshalled);
+ expect(messageMock.getPayloadSource()).andReturn(source);
+ expect(unmarshallerMock.unmarshal(eq(source), isA(MimeContainer.class))).andReturn(unmarshalled);
- unmarshallerControl.replay();
- messageControl.replay();
+ replay(unmarshallerMock, messageMock);
Object result = MarshallingUtils.unmarshal(unmarshallerMock, messageMock);
- assertEquals("Invalid unmarshalled object", unmarshalled, result);
+ Assert.assertEquals("Invalid unmarshalled object", unmarshalled, result);
- unmarshallerControl.verify();
- messageControl.verify();
+ verify(unmarshallerMock, messageMock);
}
+ @Test
public void testUnmarshalNoPayload() throws Exception {
- MockControl unmarshallerControl = MockControl.createControl(MimeUnmarshaller.class);
- MimeUnmarshaller unmarshallerMock = (MimeUnmarshaller) unmarshallerControl.getMock();
- MockControl messageControl = MockControl.createControl(MimeMessage.class);
- MimeMessage messageMock = (MimeMessage) messageControl.getMock();
+ Unmarshaller unmarshallerMock = createMock(Unmarshaller.class);
+ MimeMessage messageMock = createMock(MimeMessage.class);
- messageControl.expectAndReturn(messageMock.getPayloadSource(), null);
+ expect(messageMock.getPayloadSource()).andReturn(null);
- unmarshallerControl.replay();
- messageControl.replay();
+ replay(unmarshallerMock, messageMock);
Object result = MarshallingUtils.unmarshal(unmarshallerMock, messageMock);
- assertNull("Invalid unmarshalled object", result);
+ Assert.assertNull("Invalid unmarshalled object", result);
- unmarshallerControl.verify();
- messageControl.verify();
+ verify(unmarshallerMock, messageMock);
}
+ @Test
public void testMarshal() throws Exception {
- MockControl marshallerControl = MockControl.createControl(Marshaller.class);
- Marshaller marshallerMock = (Marshaller) marshallerControl.getMock();
- MockControl messageControl = MockControl.createControl(WebServiceMessage.class);
- WebServiceMessage messageMock = (WebServiceMessage) messageControl.getMock();
+ Marshaller marshallerMock = createMock(Marshaller.class);
+ WebServiceMessage messageMock = createMock(WebServiceMessage.class);
Result result = new StringResult();
Object marshalled = new Object();
- messageControl.expectAndReturn(messageMock.getPayloadResult(), result);
+ expect(messageMock.getPayloadResult()).andReturn(result);
marshallerMock.marshal(marshalled, result);
- marshallerControl.replay();
- messageControl.replay();
+ replay(marshallerMock, messageMock);
MarshallingUtils.marshal(marshallerMock, marshalled, messageMock);
- marshallerControl.verify();
- messageControl.verify();
+ verify(marshallerMock, messageMock);
}
+ @Test
public void testMarshalMime() throws Exception {
- MockControl marshallerControl = MockControl.createControl(MimeMarshaller.class);
- MimeMarshaller marshallerMock = (MimeMarshaller) marshallerControl.getMock();
- MockControl messageControl = MockControl.createControl(MimeMessage.class);
- MimeMessage messageMock = (MimeMessage) messageControl.getMock();
+ MimeMarshaller marshallerMock = createMock(MimeMarshaller.class);
+ MimeMessage messageMock = createMock(MimeMessage.class);
Result result = new StringResult();
Object marshalled = new Object();
- messageControl.expectAndReturn(messageMock.getPayloadResult(), result);
- marshallerMock.marshal(marshalled, result, null);
- marshallerControl.setMatcher(MockControl.ALWAYS_MATCHER);
+ expect(messageMock.getPayloadResult()).andReturn(result);
+ marshallerMock.marshal(eq(marshalled), eq(result), isA(MimeContainer.class));
- marshallerControl.replay();
- messageControl.replay();
+ replay(marshallerMock, messageMock);
MarshallingUtils.marshal(marshallerMock, marshalled, messageMock);
- marshallerControl.verify();
- messageControl.verify();
+ verify(marshallerMock, messageMock);
}
diff --git a/core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java b/core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java
index 47c2ccdd..f5c1b7be 100644
--- a/core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java
+++ b/core/src/test/java/org/springframework/ws/transport/http/LastModifiedHelperTest.java
@@ -16,49 +16,51 @@
package org.springframework.ws.transport.http;
-import java.util.Date;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
-import junit.framework.*;
-
-import org.springframework.ws.transport.http.LastModifiedHelper;
-import org.springframework.core.io.Resource;
import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
import org.springframework.xml.transform.ResourceSource;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.Document;
-public class LastModifiedHelperTest extends TestCase {
+public class LastModifiedHelperTest {
private Resource resource;
private long expected;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
resource = new ClassPathResource("single.xsd", getClass());
expected = resource.lastModified();
}
+ @Test
public void testSaxSource() throws Exception {
long result = LastModifiedHelper.getLastModified(new ResourceSource(resource));
- assertEquals("Invalid last modified", expected, result);
+ Assert.assertEquals("Invalid last modified", expected, result);
}
+ @Test
public void testDomSource() throws Exception {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(resource.getFile());
long result = LastModifiedHelper.getLastModified(new DOMSource(document));
- assertEquals("Invalid last modified", expected, result);
+ Assert.assertEquals("Invalid last modified", expected, result);
}
+ @Test
public void testStreamSource() throws Exception {
long result = LastModifiedHelper.getLastModified(new StreamSource(resource.getFile()));
- assertEquals("Invalid last modified", expected, result);
+ Assert.assertEquals("Invalid last modified", expected, result);
}
}
\ No newline at end of file
diff --git a/core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java b/core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java
index f385ef4b..a9ba6fe5 100644
--- a/core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java
+++ b/core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java
@@ -16,11 +16,10 @@
package org.springframework.ws.transport.http;
+import java.io.InputStream;
+import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
-
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.ws.FaultAwareWebServiceMessage;
@@ -29,7 +28,13 @@ import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.transport.WebServiceMessageReceiver;
-public class WebServiceMessageReceiverHandlerAdapterTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class WebServiceMessageReceiverHandlerAdapterTest {
private static final String REQUEST = " QQQ";
+ @Test
public void testSignAndValidate() throws Exception {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
interceptor.setSecurementActions("Signature");
@@ -54,7 +59,7 @@ public class SaajWss4jMessageInterceptorSignTest extends Wss4jMessageInterceptor
interceptor.secureMessage(message, messageContext);
SOAPHeader header = ((SaajSoapMessage) message).getSaajMessage().getSOAPHeader();
- Iterator iterator = header.getChildElements(new QName(
+ Iterator> iterator = header.getChildElements(new QName(
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security"));
assertTrue("No security header", iterator.hasNext());
SOAPHeaderElement securityHeader = (SOAPHeaderElement) iterator.next();
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jInterceptorTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jInterceptorTestCase.java
index ca48588c..3a5a2e41 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jInterceptorTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jInterceptorTestCase.java
@@ -22,9 +22,15 @@ import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.WsSecuritySecurementException;
import org.springframework.ws.soap.security.WsSecurityValidationException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
public abstract class Wss4jInterceptorTestCase extends Wss4jTestCase {
- public void testhandleRequest() throws Exception {
+ @Test
+ public void testHandleRequest() throws Exception {
SoapMessage request = loadSoap11Message("empty-soap.xml");
final Object requestMessage = getMessage(request);
SoapMessage validatedRequest = loadSoap11Message("empty-soap.xml");
@@ -48,7 +54,8 @@ public abstract class Wss4jInterceptorTestCase extends Wss4jTestCase {
assertEquals("Invalid request", validatedRequestMessage, getMessage((SoapMessage) context.getRequest()));
}
- public void testhandleResponse() throws Exception {
+ @Test
+ public void testHandleResponse() throws Exception {
SoapMessage securedResponse = loadSoap11Message("empty-soap.xml");
final Object securedResponseMessage = getMessage(securedResponse);
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorEncryptionTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorEncryptionTestCase.java
index 156afa70..c360c84c 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorEncryptionTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorEncryptionTestCase.java
@@ -18,15 +18,16 @@ package org.springframework.ws.soap.security.wss4j;
import java.util.Properties;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.w3c.dom.Document;
-
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.wss4j.callback.KeyStoreCallbackHandler;
import org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean;
+import org.apache.ws.security.components.crypto.Crypto;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
public abstract class Wss4jMessageInterceptorEncryptionTestCase extends Wss4jTestCase {
protected Wss4jSecurityInterceptor interceptor;
@@ -61,6 +62,7 @@ public abstract class Wss4jMessageInterceptorEncryptionTestCase extends Wss4jTes
interceptor.afterPropertiesSet();
}
+ @Test
public void testDecryptRequest() throws Exception {
SoapMessage message = loadSoap11Message("encrypted-soap.xml");
MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory());
@@ -72,6 +74,7 @@ public abstract class Wss4jMessageInterceptorEncryptionTestCase extends Wss4jTes
getDocument(message));
}
+ @Test
public void testEncryptResponse() throws Exception {
SoapMessage message = loadSoap11Message("empty-soap.xml");
MessageContext messageContext = getSoap11MessageContext(message);
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorHeaderTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorHeaderTestCase.java
index 7b1038a0..202d6e8f 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorHeaderTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorHeaderTestCase.java
@@ -28,6 +28,11 @@ import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.WsSecurityValidationException;
import org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCase {
private Wss4jSecurityInterceptor interceptor;
@@ -46,6 +51,7 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas
interceptor.afterPropertiesSet();
}
+ @Test
public void testValidateUsernameTokenPlainText() throws Exception {
SoapMessage message = loadSoap11Message("usernameTokenPlainTextWithHeaders-soap.xml");
MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory());
@@ -53,8 +59,8 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas
Object result = getMessage(message);
assertNotNull("No result returned", result);
- for (Iterator i = message.getEnvelope().getHeader().examineAllHeaderElements(); i.hasNext();) {
- SoapHeaderElement element = (SoapHeaderElement) i.next();
+ for (Iterator i = message.getEnvelope().getHeader().examineAllHeaderElements(); i.hasNext();) {
+ SoapHeaderElement element = i.next();
QName name = element.getName();
if (name.getNamespaceURI()
.equals("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")) {
@@ -70,6 +76,7 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas
}
+ @Test
public void testEmptySecurityHeader() throws Exception {
SoapMessage message = loadSoap11Message("emptySecurityHeader-soap.xml");
MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory());
@@ -82,6 +89,7 @@ public abstract class Wss4jMessageInterceptorHeaderTestCase extends Wss4jTestCas
}
}
+ @Test
public void testPreserveCustomHeaders() throws Exception {
interceptor.setSecurementActions("UsernameToken");
interceptor.setSecurementUsername("Bert");
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java
index 83834832..adb9192c 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSignTestCase.java
@@ -18,15 +18,17 @@ package org.springframework.ws.soap.security.wss4j;
import java.util.Properties;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.w3c.dom.Document;
-
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+import static org.junit.Assert.assertNotNull;
+
public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase {
protected Wss4jSecurityInterceptor interceptor;
@@ -47,14 +49,15 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase
cryptoFactoryBeanConfig.setProperty("org.apache.ws.security.crypto.merlin.file", "private.jks");
cryptoFactoryBean.setConfiguration(cryptoFactoryBeanConfig);
cryptoFactoryBean.afterPropertiesSet();
- interceptor.setValidationSignatureCrypto((Crypto) cryptoFactoryBean
+ interceptor.setValidationSignatureCrypto(cryptoFactoryBean
.getObject());
- interceptor.setSecurementSignatureCrypto((Crypto) cryptoFactoryBean
+ interceptor.setSecurementSignatureCrypto(cryptoFactoryBean
.getObject());
interceptor.afterPropertiesSet();
}
+ @Test
public void testValidateCertificate() throws Exception {
SoapMessage message = loadSoap11Message("signed-soap.xml");
@@ -66,6 +69,7 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase
getDocument(message));
}
+ @Test
public void testValidateCertificateWithSignatureConfirmation() throws Exception {
SoapMessage message = loadSoap11Message("signed-soap.xml");
MessageContext messageContext = getSoap11MessageContext(message);
@@ -79,6 +83,7 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase
"/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse11:SignatureConfirmation", document);
}
+ @Test
public void testSignResponse() throws Exception {
interceptor.setSecurementActions("Signature");
interceptor.setEnableSignatureConfirmation(false);
@@ -98,6 +103,7 @@ public abstract class Wss4jMessageInterceptorSignTestCase extends Wss4jTestCase
}
+ @Test
public void testSignResponseWithSignatureUser() throws Exception {
interceptor.setSecurementActions("Signature");
interceptor.setEnableSignatureConfirmation(false);
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java
index 01747c5e..6ce9200b 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java
@@ -18,13 +18,17 @@ package org.springframework.ws.soap.security.wss4j;
import java.util.Properties;
-import org.apache.ws.security.WSConstants;
-
+import org.springframework.ws.WebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler;
-import org.springframework.ws.WebServiceMessageFactory;
+
+import org.apache.ws.security.WSConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTestCase {
@@ -49,6 +53,7 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes
interceptor.afterPropertiesSet();
}
+ @Test
public void testPreserveSoapActionOnValidation() throws Exception {
SoapMessage message = loadSoap11Message("usernameTokenPlainText-soap.xml");
message.setSoapAction(SOAP_ACTION);
@@ -59,6 +64,7 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes
assertEquals("Soap Action is different from expected", SOAP_ACTION, message.getSoapAction());
}
+ @Test
public void testPreserveSoap12ActionOnValidation() throws Exception {
SoapMessage message = loadSoap12Message("usernameTokenPlainText-soap12.xml");
message.setSoapAction(SOAP_ACTION);
@@ -70,6 +76,7 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes
assertEquals("Soap Action is different from expected", SOAP_ACTION, message.getSoapAction());
}
+ @Test
public void testPreserveSoapActionOnSecurement() throws Exception {
SoapMessage message = loadSoap11Message("empty-soap.xml");
message.setSoapAction(SOAP_ACTION);
@@ -83,6 +90,7 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes
}
+ @Test
public void testPreserveSoap12ActionOnSecurement() throws Exception {
SoapMessage message = loadSoap12Message("empty-soap12.xml");
message.setSoapAction(SOAP_ACTION);
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java
index ddc5ab7d..21d4c677 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java
@@ -18,9 +18,6 @@ package org.springframework.ws.soap.security.wss4j;
import java.util.Properties;
-import org.apache.ws.security.WSConstants;
-import org.easymock.MockControl;
-
import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationManager;
import org.springframework.security.GrantedAuthority;
@@ -35,27 +32,33 @@ import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.wss4j.callback.SpringDigestPasswordValidationCallbackHandler;
import org.springframework.ws.soap.security.wss4j.callback.SpringPlainTextPasswordValidationCallbackHandler;
+import org.apache.ws.security.WSConstants;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase extends Wss4jTestCase {
private Properties users = new Properties();
- private MockControl control;
-
- private AuthenticationManager mock;
+ private AuthenticationManager authenticationManager;
@Override
protected void onSetup() throws Exception {
- control = MockControl.createControl(AuthenticationManager.class);
- mock = (AuthenticationManager) control.getMock();
+ authenticationManager = createMock(AuthenticationManager.class);
users.setProperty("Bert", "Ernie,ROLE_TEST");
}
- @Override
- protected void tearDown() throws Exception {
- control.verify();
+ @After
+ public void tearDown() throws Exception {
+ verify(authenticationManager);
SecurityContextHolder.clearContext();
}
+ @Test
public void testValidateUsernameTokenPlainText() throws Exception {
EndpointInterceptor interceptor = prepareInterceptor("UsernameToken", true, false);
SoapMessage message = loadSoap11Message("usernameTokenPlainText-soap.xml");
@@ -69,6 +72,7 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa
assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
}
+ @Test
public void testValidateUsernameTokenDigest() throws Exception {
EndpointInterceptor interceptor = prepareInterceptor("UsernameToken", true, true);
SoapMessage message = loadSoap11Message("usernameTokenDigest-soap.xml");
@@ -114,15 +118,14 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa
SpringPlainTextPasswordValidationCallbackHandler callbackHandler =
new SpringPlainTextPasswordValidationCallbackHandler();
Authentication authResult = new TestingAuthenticationToken("Bert", "Ernie", new GrantedAuthority[0]);
- control.expectAndReturn(mock.authenticate(new UsernamePasswordAuthenticationToken("Bert", "Ernie")),
- authResult);
- callbackHandler.setAuthenticationManager(mock);
+ expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("Bert", "Ernie"))).andReturn(authResult);
+ callbackHandler.setAuthenticationManager(authenticationManager);
callbackHandler.afterPropertiesSet();
interceptor.setSecurementPasswordType(WSConstants.PW_TEXT);
interceptor.setValidationCallbackHandler(callbackHandler);
interceptor.afterPropertiesSet();
}
- control.replay();
+ replay(authenticationManager);
return interceptor;
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorTimestampTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorTimestampTestCase.java
index 6ce9ae6d..04ac9d92 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorTimestampTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorTimestampTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 the original author or authors.
+ * 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.
@@ -19,15 +19,19 @@ package org.springframework.ws.soap.security.wss4j;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import org.w3c.dom.Document;
-
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.WsSecurityValidationException;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+import static org.junit.Assert.assertEquals;
+
public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTestCase {
+ @Test
public void testAddTimestamp() throws Exception {
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
interceptor.setSecurementActions("Timestamp");
@@ -40,6 +44,7 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest
"/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsu:Timestamp", document);
}
+ @Test
public void testValidateTimestamp() throws Exception {
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
interceptor.setValidationActions("Timestamp");
@@ -52,26 +57,23 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest
getDocument(message));
}
+ @Test(expected = WsSecurityValidationException.class)
public void testValidateTimestampWithExpiredTtl() throws Exception {
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
interceptor.setValidationActions("Timestamp");
interceptor.afterPropertiesSet();
SoapMessage message = loadSoap11Message("expiredTimestamp-soap.xml");
MessageContext context = new DefaultMessageContext(message, getSoap11MessageFactory());
- try {
- interceptor.validateMessage(message, context);
- fail();
- }
- catch (WsSecurityValidationException e) {
- // expected
- }
+ interceptor.validateMessage(message, context);
}
+
+ @Test
public void testSecureTimestampWithCustomTtl() throws Exception {
- int ttlInSeconds = 1;
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
interceptor.setSecurementActions("Timestamp");
interceptor.setTimestampStrict(true);
+ int ttlInSeconds = 1;
interceptor.setSecurementTimeToLive(ttlInSeconds);
interceptor.afterPropertiesSet();
SoapMessage message = loadSoap11Message("empty-soap.xml");
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java
index 669317b5..a34b0d9a 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenSignatureTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 the original author or authors.
+ * 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.
@@ -16,13 +16,15 @@
package org.springframework.ws.soap.security.wss4j;
-import org.w3c.dom.Document;
-
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
public abstract class Wss4jMessageInterceptorUsernameTokenSignatureTestCase extends Wss4jTestCase {
+ @Test
public void testAddUsernameTokenSignature() throws Exception {
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
interceptor.setSecurementActions("UsernameTokenSignature");
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java
index 2df50008..ba9f0eec 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java
@@ -18,14 +18,17 @@ package org.springframework.ws.soap.security.wss4j;
import java.util.Properties;
-import org.apache.ws.security.WSConstants;
-import org.w3c.dom.Document;
-
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler;
+import org.apache.ws.security.WSConstants;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+import static org.junit.Assert.assertNotNull;
+
public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4jTestCase {
private Properties users = new Properties();
@@ -35,6 +38,7 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j
users.setProperty("Bert", "Ernie");
}
+ @Test
public void testValidateUsernameTokenPlainText() throws Exception {
Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, false);
SoapMessage message = loadSoap11Message("usernameTokenPlainText-soap.xml");
@@ -43,6 +47,7 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j
assertValidateUsernameToken(message);
}
+ @Test
public void testValidateUsernameTokenDigest() throws Exception {
Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, true);
SoapMessage message = loadSoap11Message("usernameTokenDigest-soap.xml");
@@ -51,6 +56,7 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j
assertValidateUsernameToken(message);
}
+ @Test
public void testValidateUsernameTokenWithQualifiedType() throws Exception {
Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, false);
SoapMessage message = loadSoap11Message("usernameTokenPlainTextQualifiedType-soap.xml");
@@ -59,6 +65,7 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j
assertValidateUsernameToken(message);
}
+ @Test
public void testAddUsernameTokenPlainText() throws Exception {
Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", false, false);
interceptor.setSecurementUsername("Bert");
@@ -71,6 +78,7 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j
assertAddUsernameTokenPlainText(message);
}
+ @Test
public void testAddUsernameTokenDigest() throws Exception {
Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", false, true);
interceptor.setSecurementUsername("Bert");
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorX509TestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorX509TestCase.java
index 7f31d022..4bc555d1 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorX509TestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorX509TestCase.java
@@ -16,15 +16,16 @@
package org.springframework.ws.soap.security.wss4j;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.apache.ws.security.components.crypto.Merlin;
-import org.w3c.dom.Document;
-
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean;
+import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.components.crypto.Merlin;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
public abstract class Wss4jMessageInterceptorX509TestCase extends Wss4jTestCase {
protected Wss4jSecurityInterceptor interceptor;
@@ -49,6 +50,7 @@ public abstract class Wss4jMessageInterceptorX509TestCase extends Wss4jTestCase
}
+ @Test
public void testAddCertificate() throws Exception {
interceptor.setSecurementPassword("123456");
@@ -64,7 +66,7 @@ public abstract class Wss4jMessageInterceptorX509TestCase extends Wss4jTestCase
assertXpathExists("Absent BinarySecurityToken element",
"/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/wsse:BinarySecurityToken", document);
- // lets verfiy the signature that we've just generated
+ // lets verify the signature that we've just generated
interceptor.validateMessage(message, messageContext);
}
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java
index 96f29e5b..70dc10ea 100755
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jTestCase.java
@@ -43,15 +43,19 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.xml.transform.StringSource;
import org.springframework.xml.xpath.Jaxp13XPathTemplate;
-import junit.framework.TestCase;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.junit.Assert;
+import org.junit.Before;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-public abstract class Wss4jTestCase extends TestCase {
+import static org.junit.Assert.assertTrue;
+
+public abstract class Wss4jTestCase {
protected MessageFactory saajSoap11MessageFactory;
+
protected MessageFactory saajSoap12MessageFactory;
protected final boolean axiomTest = this.getClass().getSimpleName().startsWith("Axiom");
@@ -60,10 +64,10 @@ public abstract class Wss4jTestCase extends TestCase {
protected Jaxp13XPathTemplate xpathTemplate = new Jaxp13XPathTemplate();
- @Override
- protected final void setUp() throws Exception {
+ @Before
+ public final void setUp() throws Exception {
if (!axiomTest && !saajTest) {
- throw new IllegalArgumentException("test class name must statrt with either Axiom or Saaj");
+ throw new IllegalArgumentException("test class name must start with either Axiom or Saaj");
}
saajSoap11MessageFactory = MessageFactory.newInstance();
saajSoap12MessageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
@@ -87,7 +91,7 @@ public abstract class Wss4jTestCase extends TestCase {
String xpathExpression,
Document document) {
String actualValue = xpathTemplate.evaluateAsString(xpathExpression, new DOMSource(document));
- assertEquals(message, expectedValue, actualValue);
+ Assert.assertEquals(message, expectedValue, actualValue);
}
protected void assertXpathEvaluatesTo(String message,
@@ -95,22 +99,22 @@ public abstract class Wss4jTestCase extends TestCase {
String xpathExpression,
String document) {
String actualValue = xpathTemplate.evaluateAsString(xpathExpression, new StringSource(document));
- assertEquals(message, expectedValue, actualValue);
+ Assert.assertEquals(message, expectedValue, actualValue);
}
protected void assertXpathExists(String message, String xpathExpression, Document document) {
Node node = xpathTemplate.evaluateAsNode(xpathExpression, new DOMSource(document));
- assertNotNull(message, node);
+ Assert.assertNotNull(message, node);
}
protected void assertXpathNotExists(String message, String xpathExpression, Document document) {
Node node = xpathTemplate.evaluateAsNode(xpathExpression, new DOMSource(document));
- assertNull(message, node);
+ Assert.assertNull(message, node);
}
protected void assertXpathNotExists(String message, String xpathExpression, String document) {
Node node = xpathTemplate.evaluateAsNode(xpathExpression, new StringSource(document));
- assertNull(message, node);
+ Assert.assertNull(message, node);
}
protected SaajSoapMessage loadSaaj11Message(String fileName) throws Exception {
@@ -160,6 +164,7 @@ public abstract class Wss4jTestCase extends TestCase {
}
}
+ @SuppressWarnings("Since15")
protected AxiomSoapMessage loadAxiom12Message(String fileName) throws Exception {
Resource resource = new ClassPathResource(fileName, getClass());
InputStream is = resource.getInputStream();
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/KeyStoreCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/KeyStoreCallbackHandlerTest.java
index b052f9c0..624de4d5 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/KeyStoreCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/KeyStoreCallbackHandlerTest.java
@@ -18,20 +18,22 @@ package org.springframework.ws.soap.security.wss4j.callback;
import java.security.KeyStore;
-import junit.framework.TestCase;
-import org.apache.ws.security.WSPasswordCallback;
-
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.soap.security.support.KeyStoreFactoryBean;
-public class KeyStoreCallbackHandlerTest extends TestCase {
+import org.apache.ws.security.WSPasswordCallback;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class KeyStoreCallbackHandlerTest {
private KeyStoreCallbackHandler callbackHandler;
private WSPasswordCallback callback;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
callbackHandler = new KeyStoreCallbackHandler();
callback = new WSPasswordCallback("secretkey", WSPasswordCallback.KEY_NAME);
@@ -45,9 +47,10 @@ public class KeyStoreCallbackHandlerTest extends TestCase {
callbackHandler.setSymmetricKeyPassword("123456");
}
+ @Test
public void testHandleKeyName() throws Exception {
callbackHandler.handleInternal(callback);
- assertNotNull("symmetric key must not be null", callback.getKey());
+ Assert.assertNotNull("symmetric key must not be null", callback.getKey());
}
}
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java
index 24191bb4..cb718a7a 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java
@@ -16,10 +16,6 @@
package org.springframework.ws.soap.security.wss4j.callback;
-import junit.framework.TestCase;
-import org.apache.ws.security.WSUsernameTokenPrincipal;
-import org.easymock.MockControl;
-
import org.springframework.security.Authentication;
import org.springframework.security.GrantedAuthority;
import org.springframework.security.GrantedAuthorityImpl;
@@ -29,50 +25,54 @@ import org.springframework.security.userdetails.User;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService;
+import org.apache.ws.security.WSUsernameTokenPrincipal;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
/** @author tareq */
-public class SpringDigestPasswordValidationCallbackHandlerTest extends TestCase {
+public class SpringDigestPasswordValidationCallbackHandlerTest {
private SpringDigestPasswordValidationCallbackHandler callbackHandler;
private GrantedAuthorityImpl grantedAuthority;
- private UserDetailsService userDetailsService;
-
- private MockControl control;
-
- private WSUsernameTokenPrincipal principal;
-
private UsernameTokenPrincipalCallback callback;
private UserDetails user;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
callbackHandler = new SpringDigestPasswordValidationCallbackHandler();
grantedAuthority = new GrantedAuthorityImpl("ROLE_1");
user = new User("Ernie", "Bert", true, true, true, true, new GrantedAuthority[]{grantedAuthority});
- control = MockControl.createControl(UserDetailsService.class);
- userDetailsService = (UserDetailsService) control.getMock();
- userDetailsService.loadUserByUsername("Ernie");
- control.setDefaultReturnValue(user);
- control.replay();
+ WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal("Ernie", true);
+ callback = new UsernameTokenPrincipalCallback(principal);
+ }
+
+ @Test
+ public void testHandleUsernameTokenPrincipal() throws Exception {
+ UserDetailsService userDetailsService = createMock(UserDetailsService.class);
callbackHandler.setUserDetailsService(userDetailsService);
- principal = new WSUsernameTokenPrincipal("Ernie", true);
- callback = new UsernameTokenPrincipalCallback(principal);
+ expect(userDetailsService.loadUserByUsername("Ernie")).andReturn(user).anyTimes();
- }
+ replay(userDetailsService);
- public void testHandleUsernameTokenPrincipal() throws Exception {
callbackHandler.handleUsernameTokenPrincipal(callback);
SecurityContext context = SecurityContextHolder.getContext();
- assertNotNull("SecurityContext must not be null", context);
+ Assert.assertNotNull("SecurityContext must not be null", context);
Authentication authentication = context.getAuthentication();
- assertNotNull("Authentication must not be null", authentication);
+ Assert.assertNotNull("Authentication must not be null", authentication);
GrantedAuthority[] authorities = authentication.getAuthorities();
- assertTrue("GrantedAuthority[] must not be null or empty", (authorities != null && authorities.length > 0));
- assertEquals("Unexpected authority", grantedAuthority, authorities[0]);
+ Assert.assertTrue("GrantedAuthority[] must not be null or empty",
+ (authorities != null && authorities.length > 0));
+ Assert.assertEquals("Unexpected authority", grantedAuthority, authorities[0]);
+
+ verify(userDetailsService);
}
}
diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/support/CryptoFactoryBeanTest.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/support/CryptoFactoryBeanTest.java
index c5a66598..38e23a95 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/support/CryptoFactoryBeanTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/support/CryptoFactoryBeanTest.java
@@ -18,21 +18,24 @@ package org.springframework.ws.soap.security.wss4j.support;
import java.util.Properties;
-import junit.framework.TestCase;
-import org.apache.ws.security.components.crypto.Merlin;
-
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ClassUtils;
-public class CryptoFactoryBeanTest extends TestCase {
+import org.apache.ws.security.components.crypto.Merlin;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CryptoFactoryBeanTest {
private CryptoFactoryBean factoryBean;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
factoryBean = new CryptoFactoryBean();
}
+ @Test
public void testSetConfiguration() throws Exception {
Properties configuration = new Properties();
configuration.setProperty("org.apache.ws.security.crypto.provider",
@@ -46,10 +49,11 @@ public class CryptoFactoryBeanTest extends TestCase {
factoryBean.afterPropertiesSet();
Object result = factoryBean.getObject();
- assertNotNull("No result", result);
- assertTrue("Not a Merlin instance", result instanceof Merlin);
+ Assert.assertNotNull("No result", result);
+ Assert.assertTrue("Not a Merlin instance", result instanceof Merlin);
}
+ @Test
public void testProperties() throws Exception {
factoryBean.setKeyStoreType("jceks");
factoryBean.setKeyStorePassword("123456");
@@ -57,7 +61,7 @@ public class CryptoFactoryBeanTest extends TestCase {
factoryBean.setBeanClassLoader(ClassUtils.getDefaultClassLoader());
factoryBean.afterPropertiesSet();
Object result = factoryBean.getObject();
- assertNotNull("No result", result);
- assertTrue("Not a Merlin instance", result instanceof Merlin);
+ Assert.assertNotNull("No result", result);
+ Assert.assertTrue("Not a Merlin instance", result instanceof Merlin);
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java
index 143d3fbc..121ea22b 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/XwsSecurityInterceptorTest.java
@@ -19,8 +19,6 @@ package org.springframework.ws.soap.security.xwss;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
-import junit.framework.TestCase;
-
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapMessage;
@@ -28,16 +26,21 @@ import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.ws.soap.security.WsSecurityValidationException;
-public class XwsSecurityInterceptorTest extends TestCase {
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class XwsSecurityInterceptorTest {
private MessageFactory messageFactory;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
messageFactory = MessageFactory.newInstance();
}
- public void testhandleServerRequest() throws Exception {
+ @Test
+ public void testHandleServerRequest() throws Exception {
final SOAPMessage request = messageFactory.createMessage();
final SOAPMessage validatedRequest = messageFactory.createMessage();
XwsSecurityInterceptor interceptor = new XwsSecurityInterceptor() {
@@ -45,14 +48,14 @@ public class XwsSecurityInterceptorTest extends TestCase {
@Override
protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext)
throws XwsSecuritySecurementException {
- fail("secure not expected");
+ Assert.fail("secure not expected");
}
@Override
protected void validateMessage(SoapMessage message, MessageContext messageContext)
throws WsSecurityValidationException {
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
- assertEquals("Invalid message", request, saajSoapMessage.getSaajMessage());
+ Assert.assertEquals("Invalid message", request, saajSoapMessage.getSaajMessage());
saajSoapMessage.setSaajMessage(validatedRequest);
}
@@ -60,10 +63,12 @@ public class XwsSecurityInterceptorTest extends TestCase {
MessageContext context =
new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory));
interceptor.handleRequest(context, null);
- assertEquals("Invalid request", validatedRequest, ((SaajSoapMessage) context.getRequest()).getSaajMessage());
+ Assert.assertEquals("Invalid request", validatedRequest,
+ ((SaajSoapMessage) context.getRequest()).getSaajMessage());
}
- public void testhandleServerResponse() throws Exception {
+ @Test
+ public void testHandleServerResponse() throws Exception {
final SOAPMessage securedResponse = messageFactory.createMessage();
XwsSecurityInterceptor interceptor = new XwsSecurityInterceptor() {
@@ -77,7 +82,7 @@ public class XwsSecurityInterceptorTest extends TestCase {
@Override
protected void validateMessage(SoapMessage soapMessage, MessageContext messageContext)
throws WsSecurityValidationException {
- fail("validate not expected");
+ Assert.fail("validate not expected");
}
};
@@ -86,9 +91,11 @@ public class XwsSecurityInterceptorTest extends TestCase {
new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory));
context.getResponse();
interceptor.handleResponse(context, null);
- assertEquals("Invalid response", securedResponse, ((SaajSoapMessage) context.getResponse()).getSaajMessage());
+ Assert.assertEquals("Invalid response", securedResponse,
+ ((SaajSoapMessage) context.getResponse()).getSaajMessage());
}
+ @Test
public void testhandleClientRequest() throws Exception {
final SOAPMessage request = messageFactory.createMessage();
final SOAPMessage securedRequest = messageFactory.createMessage();
@@ -98,31 +105,33 @@ public class XwsSecurityInterceptorTest extends TestCase {
protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext)
throws XwsSecuritySecurementException {
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) soapMessage;
- assertEquals("Invalid message", request, saajSoapMessage.getSaajMessage());
+ Assert.assertEquals("Invalid message", request, saajSoapMessage.getSaajMessage());
saajSoapMessage.setSaajMessage(securedRequest);
}
@Override
protected void validateMessage(SoapMessage message, MessageContext messageContext)
throws WsSecurityValidationException {
- fail("validate not expected");
+ Assert.fail("validate not expected");
}
};
MessageContext context =
new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory));
interceptor.handleRequest(context);
- assertEquals("Invalid request", securedRequest, ((SaajSoapMessage) context.getRequest()).getSaajMessage());
+ Assert.assertEquals("Invalid request", securedRequest,
+ ((SaajSoapMessage) context.getRequest()).getSaajMessage());
}
- public void testhandleClientResponse() throws Exception {
+ @Test
+ public void testHandleClientResponse() throws Exception {
final SOAPMessage validatedResponse = messageFactory.createMessage();
XwsSecurityInterceptor interceptor = new XwsSecurityInterceptor() {
@Override
protected void secureMessage(SoapMessage message, MessageContext messageContext)
throws XwsSecuritySecurementException {
- fail("secure not expected");
+ Assert.fail("secure not expected");
}
@Override
@@ -138,7 +147,8 @@ public class XwsSecurityInterceptorTest extends TestCase {
new DefaultMessageContext(new SaajSoapMessage(request), new SaajSoapMessageFactory(messageFactory));
context.getResponse();
interceptor.handleResponse(context);
- assertEquals("Invalid response", validatedResponse, ((SaajSoapMessage) context.getResponse()).getSaajMessage());
+ Assert.assertEquals("Invalid response", validatedResponse,
+ ((SaajSoapMessage) context.getResponse()).getSaajMessage());
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java
index 3b21ddf2..25c875af 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/DefaultTimestampValidatorTest.java
@@ -17,23 +17,26 @@
package org.springframework.ws.soap.security.xwss.callback;
import com.sun.xml.wss.impl.callback.TimestampValidationCallback;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
-public class DefaultTimestampValidatorTest extends TestCase {
+public class DefaultTimestampValidatorTest {
private DefaultTimestampValidator validator;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
validator = new DefaultTimestampValidator();
}
+ @Test
public void testValidate() throws Exception {
TimestampValidationCallback.Request request = new TimestampValidationCallback.UTCTimestampRequest(
"2006-09-25T20:42:50Z", "2107-09-25T20:42:50Z", 100, Long.MAX_VALUE);
validator.validate(request);
}
+ @Test
public void testValidateNoExpired() throws Exception {
TimestampValidationCallback.Request request =
new TimestampValidationCallback.UTCTimestampRequest("2006-09-25T20:42:50Z", null, 100, Long.MAX_VALUE);
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java
index 68448c3f..6310eb6f 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/KeyStoreCallbackHandlerTest.java
@@ -16,17 +16,19 @@
package org.springframework.ws.soap.security.xwss.callback;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
-public class KeyStoreCallbackHandlerTest extends TestCase {
+public class KeyStoreCallbackHandlerTest {
private KeyStoreCallbackHandler handler;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
handler = new KeyStoreCallbackHandler();
}
+ @Test
public void testLoadDefaultTrustStore() throws Exception {
System.setProperty("javax.net.ssl.trustStore",
"/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/");
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java
index 2c8ab067..3a85192d 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimplePasswordValidationCallbackHandlerTest.java
@@ -16,50 +16,56 @@
package org.springframework.ws.soap.security.xwss.callback;
-import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
-import junit.framework.TestCase;
-
import java.util.Properties;
-public class SimplePasswordValidationCallbackHandlerTest extends TestCase {
+import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimplePasswordValidationCallbackHandlerTest {
private SimplePasswordValidationCallbackHandler handler;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
handler = new SimplePasswordValidationCallbackHandler();
Properties users = new Properties();
users.setProperty("Bert", "Ernie");
handler.setUsers(users);
}
+ @Test
public void testPlainTextPasswordValid() throws Exception {
PasswordValidationCallback.PlainTextPasswordRequest request =
new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Ernie");
PasswordValidationCallback callback = new PasswordValidationCallback(request);
handler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Not authenticated", authenticated);
+ Assert.assertTrue("Not authenticated", authenticated);
}
+ @Test
public void testPlainTextPasswordInvalid() throws Exception {
PasswordValidationCallback.PlainTextPasswordRequest request =
new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Big bird");
PasswordValidationCallback callback = new PasswordValidationCallback(request);
handler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
+ Assert.assertFalse("Authenticated", authenticated);
}
+ @Test
public void testPlainTextPasswordNoSuchUser() throws Exception {
PasswordValidationCallback.PlainTextPasswordRequest request =
new PasswordValidationCallback.PlainTextPasswordRequest("Big bird", "Bert");
PasswordValidationCallback callback = new PasswordValidationCallback(request);
handler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
+ Assert.assertFalse("Authenticated", authenticated);
}
+ @Test
public void testDigestPasswordValid() throws Exception {
String username = "Bert";
String nonce = "9mdsYDCrjjYRur0rxzYt2oD7";
@@ -70,10 +76,11 @@ public class SimplePasswordValidationCallbackHandlerTest extends TestCase {
PasswordValidationCallback callback = new PasswordValidationCallback(request);
handler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Authenticated", authenticated);
+ Assert.assertTrue("Authenticated", authenticated);
}
+ @Test
public void testDigestPasswordInvalid() throws Exception {
String username = "Bert";
String nonce = "9mdsYDCrjjYRur0rxzYt2oD7";
@@ -84,7 +91,7 @@ public class SimplePasswordValidationCallbackHandlerTest extends TestCase {
PasswordValidationCallback callback = new PasswordValidationCallback(request);
handler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
+ Assert.assertFalse("Authenticated", authenticated);
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java
index bce61dc2..b0494e3f 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SimpleUsernamePasswordCallbackHandlerTest.java
@@ -18,28 +18,32 @@ package org.springframework.ws.soap.security.xwss.callback;
import com.sun.xml.wss.impl.callback.PasswordCallback;
import com.sun.xml.wss.impl.callback.UsernameCallback;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class SimpleUsernamePasswordCallbackHandlerTest extends TestCase {
+public class SimpleUsernamePasswordCallbackHandlerTest {
private SimpleUsernamePasswordCallbackHandler handler;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
handler = new SimpleUsernamePasswordCallbackHandler();
handler.setUsername("Bert");
handler.setPassword("Ernie");
}
+ @Test
public void testUsernameCallback() throws Exception {
UsernameCallback usernameCallback = new UsernameCallback();
handler.handleInternal(usernameCallback);
- assertEquals("Invalid username", "Bert", usernameCallback.getUsername());
+ Assert.assertEquals("Invalid username", "Bert", usernameCallback.getUsername());
}
+ @Test
public void testPasswordCallback() throws Exception {
PasswordCallback passwordCallback = new PasswordCallback();
handler.handleInternal(passwordCallback);
- assertEquals("Invalid username", "Ernie", passwordCallback.getPassword());
+ Assert.assertEquals("Invalid username", "Ernie", passwordCallback.getPassword());
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java
index 2de86308..b281e16d 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java
@@ -20,10 +20,6 @@ import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
-import com.sun.xml.wss.impl.callback.CertificateValidationCallback;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
-
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.AuthenticationManager;
import org.springframework.security.BadCredentialsException;
@@ -33,24 +29,29 @@ import org.springframework.security.providers.TestingAuthenticationToken;
import org.springframework.security.providers.x509.X509AuthenticationToken;
import org.springframework.ws.soap.security.callback.CleanupCallback;
-public class SpringCertificateValidationCallbackHandlerTest extends TestCase {
+import com.sun.xml.wss.impl.callback.CertificateValidationCallback;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class SpringCertificateValidationCallbackHandlerTest {
private SpringCertificateValidationCallbackHandler callbackHandler;
- private MockControl control;
-
- private AuthenticationManager mock;
+ private AuthenticationManager authenticationManager;
private X509Certificate certificate;
private CertificateValidationCallback callback;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
callbackHandler = new SpringCertificateValidationCallbackHandler();
- control = MockControl.createControl(AuthenticationManager.class);
- mock = (AuthenticationManager) control.getMock();
- callbackHandler.setAuthenticationManager(mock);
+ authenticationManager = createMock(AuthenticationManager.class);
+ callbackHandler.setAuthenticationManager(authenticationManager);
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream is = null;
try {
@@ -66,35 +67,42 @@ public class SpringCertificateValidationCallbackHandlerTest extends TestCase {
callback = new CertificateValidationCallback(certificate);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
SecurityContextHolder.clearContext();
}
+ @Test
public void testValidateCertificateValid() throws Exception {
- mock.authenticate(new X509AuthenticationToken(certificate));
- control.setMatcher(MockControl.ALWAYS_MATCHER);
- control.setReturnValue(new TestingAuthenticationToken(certificate, null, new GrantedAuthority[0]));
- control.replay();
+ expect(authenticationManager.authenticate(isA(X509AuthenticationToken.class)))
+ .andReturn(new TestingAuthenticationToken(certificate, null, new GrantedAuthority[0]));
+
+ replay(authenticationManager);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Not authenticated", authenticated);
- assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertTrue("Not authenticated", authenticated);
+ Assert.assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(authenticationManager);
}
+ @Test
public void testValidateCertificateInvalid() throws Exception {
- mock.authenticate(new X509AuthenticationToken(certificate));
- control.setMatcher(MockControl.ALWAYS_MATCHER);
- control.setThrowable(new BadCredentialsException(""));
- control.replay();
+ expect(authenticationManager.authenticate(isA(X509AuthenticationToken.class)))
+ .andThrow(new BadCredentialsException(""));
+
+ replay(authenticationManager);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertFalse("Authenticated", authenticated);
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(authenticationManager);
}
+ @Test
public void testCleanUp() throws Exception {
TestingAuthenticationToken authentication =
new TestingAuthenticationToken(new Object(), new Object(), new GrantedAuthority[0]);
@@ -102,7 +110,7 @@ public class SpringCertificateValidationCallbackHandlerTest extends TestCase {
CleanupCallback cleanupCallback = new CleanupCallback();
callbackHandler.handleInternal(cleanupCallback);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java
index c21f4fda..15b9a060 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java
@@ -16,12 +16,8 @@
package org.springframework.ws.soap.security.xwss.callback;
-import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
-
-import org.springframework.security.GrantedAuthority;
import org.springframework.security.DisabledException;
+import org.springframework.security.GrantedAuthority;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.providers.TestingAuthenticationToken;
import org.springframework.security.userdetails.User;
@@ -29,13 +25,19 @@ import org.springframework.security.userdetails.UserDetailsService;
import org.springframework.security.userdetails.UsernameNotFoundException;
import org.springframework.ws.soap.security.callback.CleanupCallback;
-public class SpringDigestPasswordValidationCallbackHandlerTest extends TestCase {
+import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class SpringDigestPasswordValidationCallbackHandlerTest {
private SpringDigestPasswordValidationCallbackHandler callbackHandler;
- private MockControl control;
-
- private UserDetailsService mock;
+ private UserDetailsService userDetailsService;
private String username;
@@ -43,12 +45,11 @@ public class SpringDigestPasswordValidationCallbackHandlerTest extends TestCase
private PasswordValidationCallback callback;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
callbackHandler = new SpringDigestPasswordValidationCallbackHandler();
- control = MockControl.createControl(UserDetailsService.class);
- mock = (UserDetailsService) control.getMock();
- callbackHandler.setUserDetailsService(mock);
+ userDetailsService = createMock(UserDetailsService.class);
+ callbackHandler.setUserDetailsService(userDetailsService);
username = "Bert";
password = "Ernie";
String nonce = "9mdsYDCrjjYRur0rxzYt2oD7";
@@ -59,55 +60,72 @@ public class SpringDigestPasswordValidationCallbackHandlerTest extends TestCase
callback = new PasswordValidationCallback(request);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
SecurityContextHolder.clearContext();
}
+ @Test
public void testAuthenticateUserDigestUserNotFound() throws Exception {
- control.expectAndThrow(mock.loadUserByUsername(username), new UsernameNotFoundException(username));
- control.replay();
+ expect(userDetailsService.loadUserByUsername(username)).andThrow(new UsernameNotFoundException(username));
+
+ replay(userDetailsService);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertFalse("Authenticated", authenticated);
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(userDetailsService);
}
+ @Test
public void testAuthenticateUserDigestValid() throws Exception {
User user = new User(username, password, true, true, true, true, new GrantedAuthority[0]);
- control.expectAndReturn(mock.loadUserByUsername(username), user);
- control.replay();
+ expect(userDetailsService.loadUserByUsername(username)).andReturn(user);
+
+ replay(userDetailsService);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Not authenticated", authenticated);
- assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertTrue("Not authenticated", authenticated);
+ Assert.assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(userDetailsService);
}
+ @Test
public void testAuthenticateUserDigestValidInvalid() throws Exception {
User user = new User(username, "Big bird", true, true, true, true, new GrantedAuthority[0]);
- control.expectAndReturn(mock.loadUserByUsername(username), user);
- control.replay();
+ expect(userDetailsService.loadUserByUsername(username)).andReturn(user);
+
+ replay(userDetailsService);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertFalse("Authenticated", authenticated);
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(userDetailsService);
}
+ @Test
public void testAuthenticateUserDigestDisbaled() throws Exception {
User user = new User(username, "Ernie", false, true, true, true, new GrantedAuthority[0]);
- control.expectAndReturn(mock.loadUserByUsername(username), user);
- control.replay();
+ expect(userDetailsService.loadUserByUsername(username)).andReturn(user);
+
+ replay(userDetailsService);
+
try {
callbackHandler.handleInternal(callback);
- fail("disabled user authenticated");
- } catch (
- DisabledException expected) {
+ Assert.fail("disabled user authenticated");
+ } catch (DisabledException expected) {
+ // expected
}
+ verify(userDetailsService);
}
+ @Test
public void testCleanUp() throws Exception {
TestingAuthenticationToken authentication =
new TestingAuthenticationToken(new Object(), new Object(), new GrantedAuthority[0]);
@@ -115,7 +133,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest extends TestCase
CleanupCallback cleanupCallback = new CleanupCallback();
callbackHandler.handleInternal(cleanupCallback);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java
index 4f8a183e..000d8969 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java
@@ -16,10 +16,6 @@
package org.springframework.ws.soap.security.xwss.callback;
-import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
-import junit.framework.TestCase;
-import org.easymock.MockControl;
-
import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationManager;
import org.springframework.security.BadCredentialsException;
@@ -29,13 +25,19 @@ import org.springframework.security.providers.TestingAuthenticationToken;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
import org.springframework.ws.soap.security.callback.CleanupCallback;
-public class SpringPlainTextPasswordValidationCallbackHandlerTest extends TestCase {
+import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.EasyMock.*;
+
+public class SpringPlainTextPasswordValidationCallbackHandlerTest {
private SpringPlainTextPasswordValidationCallbackHandler callbackHandler;
- private MockControl control;
-
- private AuthenticationManager mock;
+ private AuthenticationManager authenticationManager;
private PasswordValidationCallback callback;
@@ -43,12 +45,11 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest extends TestCa
private String password;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
callbackHandler = new SpringPlainTextPasswordValidationCallbackHandler();
- control = MockControl.createControl(AuthenticationManager.class);
- mock = (AuthenticationManager) control.getMock();
- callbackHandler.setAuthenticationManager(mock);
+ authenticationManager = createMock(AuthenticationManager.class);
+ callbackHandler.setAuthenticationManager(authenticationManager);
username = "Bert";
password = "Ernie";
PasswordValidationCallback.PlainTextPasswordRequest request =
@@ -56,34 +57,41 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest extends TestCa
callback = new PasswordValidationCallback(request);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
SecurityContextHolder.clearContext();
}
+ @Test
public void testAuthenticateUserPlainTextValid() throws Exception {
Authentication authResult = new TestingAuthenticationToken(username, password, new GrantedAuthority[0]);
- control.expectAndReturn(mock.authenticate(new UsernamePasswordAuthenticationToken(username, password)),
- authResult);
- control.replay();
+ expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))).andReturn(authResult);
+
+ replay(authenticationManager);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Not authenticated", authenticated);
- assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertTrue("Not authenticated", authenticated);
+ Assert.assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(authenticationManager);
}
+ @Test
public void testAuthenticateUserPlainTextInvalid() throws Exception {
- control.expectAndThrow(mock.authenticate(new UsernamePasswordAuthenticationToken(username, password)),
- new BadCredentialsException(""));
- control.replay();
+ expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))).andThrow(new BadCredentialsException(""));
+
+ replay(authenticationManager);
+
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
- control.verify();
+ Assert.assertFalse("Authenticated", authenticated);
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+
+ verify(authenticationManager);
}
+ @Test
public void testCleanUp() throws Exception {
TestingAuthenticationToken authentication =
new TestingAuthenticationToken(new Object(), new Object(), new GrantedAuthority[0]);
@@ -91,7 +99,7 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest extends TestCa
CleanupCallback cleanupCallback = new CleanupCallback();
callbackHandler.handleInternal(cleanupCallback);
- assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
+ Assert.assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java
index c669ac92..4b2cbcaf 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringUsernamePasswordCallbackHandlerTest.java
@@ -16,39 +16,44 @@
package org.springframework.ws.soap.security.xwss.callback;
-import com.sun.xml.wss.impl.callback.PasswordCallback;
-import com.sun.xml.wss.impl.callback.UsernameCallback;
-import junit.framework.TestCase;
-
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
-public class SpringUsernamePasswordCallbackHandlerTest extends TestCase {
+import com.sun.xml.wss.impl.callback.PasswordCallback;
+import com.sun.xml.wss.impl.callback.UsernameCallback;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SpringUsernamePasswordCallbackHandlerTest {
private SpringUsernamePasswordCallbackHandler handler;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
handler = new SpringUsernamePasswordCallbackHandler();
Authentication authentication = new UsernamePasswordAuthenticationToken("Bert", "Ernie");
SecurityContextHolder.getContext().setAuthentication(authentication);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
SecurityContextHolder.clearContext();
}
+ @Test
public void testUsernameCallback() throws Exception {
UsernameCallback usernameCallback = new UsernameCallback();
handler.handleInternal(usernameCallback);
- assertEquals("Invalid username", "Bert", usernameCallback.getUsername());
+ Assert.assertEquals("Invalid username", "Bert", usernameCallback.getUsername());
}
+ @Test
public void testPasswordCallback() throws Exception {
PasswordCallback passwordCallback = new PasswordCallback();
handler.handleInternal(passwordCallback);
- assertEquals("Invalid username", "Ernie", passwordCallback.getPassword());
+ Assert.assertEquals("Invalid username", "Ernie", passwordCallback.getPassword());
}
}
\ No newline at end of file
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java
index e7e7d8e9..8f60b478 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasCertificateValidationCallbackHandlerTest.java
@@ -20,19 +20,21 @@ import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
-import com.sun.xml.wss.impl.callback.CertificateValidationCallback;
-import junit.framework.TestCase;
-
import org.springframework.core.io.ClassPathResource;
-public class JaasCertificateValidationCallbackHandlerTest extends TestCase {
+import com.sun.xml.wss.impl.callback.CertificateValidationCallback;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JaasCertificateValidationCallbackHandlerTest {
private JaasCertificateValidationCallbackHandler callbackHandler;
private CertificateValidationCallback callback;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
System.setProperty("java.security.auth.login.config", getClass().getResource("jaas.config").toString());
callbackHandler = new JaasCertificateValidationCallbackHandler();
callbackHandler.setLoginContextName("Certificate");
@@ -51,10 +53,11 @@ public class JaasCertificateValidationCallbackHandlerTest extends TestCase {
callback = new CertificateValidationCallback(certificate);
}
+ @Test
public void testValidateCertificateValid() throws Exception {
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Not authenticated", authenticated);
+ Assert.assertTrue("Not authenticated", authenticated);
}
}
diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java
index e2b5282a..8a967452 100644
--- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java
+++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/jaas/JaasPlainTextPasswordValidationCallbackHandlerTest.java
@@ -17,35 +17,39 @@
package org.springframework.ws.soap.security.xwss.callback.jaas;
import com.sun.xml.wss.impl.callback.PasswordValidationCallback;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class JaasPlainTextPasswordValidationCallbackHandlerTest extends TestCase {
+public class JaasPlainTextPasswordValidationCallbackHandlerTest {
private JaasPlainTextPasswordValidationCallbackHandler callbackHandler;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
System.setProperty("java.security.auth.login.config", getClass().getResource("jaas.config").toString());
callbackHandler = new JaasPlainTextPasswordValidationCallbackHandler();
callbackHandler.setLoginContextName("PlainText");
}
+ @Test
public void testAuthenticateUserPlainTextValid() throws Exception {
PasswordValidationCallback.PlainTextPasswordRequest request =
new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Ernie");
PasswordValidationCallback callback = new PasswordValidationCallback(request);
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertTrue("Not authenticated", authenticated);
+ Assert.assertTrue("Not authenticated", authenticated);
}
+ @Test
public void testAuthenticateUserPlainTextInvalid() throws Exception {
PasswordValidationCallback.PlainTextPasswordRequest request =
new PasswordValidationCallback.PlainTextPasswordRequest("Bert", "Big bird");
PasswordValidationCallback callback = new PasswordValidationCallback(request);
callbackHandler.handleInternal(callback);
boolean authenticated = callback.getResult();
- assertFalse("Authenticated", authenticated);
+ Assert.assertFalse("Authenticated", authenticated);
}
}
\ No newline at end of file
diff --git a/xml/src/test/java/org/springframework/xml/stream/XmlEventStreamReaderTest.java b/xml/src/test/java/org/springframework/xml/stream/XmlEventStreamReaderTest.java
index 18d4d737..ac740d4f 100644
--- a/xml/src/test/java/org/springframework/xml/stream/XmlEventStreamReaderTest.java
+++ b/xml/src/test/java/org/springframework/xml/stream/XmlEventStreamReaderTest.java
@@ -25,31 +25,34 @@ import javax.xml.transform.TransformerFactory;
import org.springframework.xml.transform.StaxSource;
import org.springframework.xml.transform.StringResult;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
@SuppressWarnings("Since15")
-public class XmlEventStreamReaderTest extends TestCase {
+public class XmlEventStreamReaderTest {
private static final String XML =
"content";
private XmlEventStreamReader streamReader;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML));
streamReader = new XmlEventStreamReader(eventReader);
}
+ @Test
public void testReadAll() throws Exception {
while (streamReader.hasNext()) {
streamReader.next();
}
}
+ @Test
public void testReadCorrect() throws Exception {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
StaxSource source = new StaxSource(streamReader);