Author: coheigea
Date: Mon Dec 6 14:45:44 2010
New Revision: 1042661
URL: http://svn.apache.org/viewvc?rev=1042661&view=rev
Log:
[WSS-250] - More test reshuffling.
Added:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomAction.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/MyAction.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/CustomCrypto.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomHandler.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/MyHandler.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/MyProcessor.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SOAPUtil.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/SOAPUtil.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/SignatureConfirmationTest.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityCertError.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/TestModifiedRequest.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/PasswordTypeTest.java
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java
- copied, changed from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/SignatureKeyValueTest.java
Removed:
webservices/wss4j/trunk/src/test/java/wssec/CustomCrypto.java
webservices/wss4j/trunk/src/test/java/wssec/MyAction.java
webservices/wss4j/trunk/src/test/java/wssec/MyHandler.java
webservices/wss4j/trunk/src/test/java/wssec/MyProcessor.java
webservices/wss4j/trunk/src/test/java/wssec/PackageTests.java
webservices/wss4j/trunk/src/test/java/wssec/PasswordTypeTest.java
webservices/wss4j/trunk/src/test/java/wssec/PrivilegedAccessor.java
webservices/wss4j/trunk/src/test/java/wssec/SOAPUtil.java
webservices/wss4j/trunk/src/test/java/wssec/SignatureConfirmationTest.java
webservices/wss4j/trunk/src/test/java/wssec/SignatureKeyValueTest.java
webservices/wss4j/trunk/src/test/java/wssec/TestModifiedRequest.java
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityCertError.java
webservices/wss4j/trunk/test/
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomAction.java
(from r1042632, webservices/wss4j/trunk/src/test/java/wssec/MyAction.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomAction.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomAction.java&p1=webservices/wss4j/trunk/src/test/java/wssec/MyAction.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/MyAction.java (original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomAction.java
Mon Dec 6 14:45:44 2010
@@ -17,7 +17,7 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.common;
import org.apache.ws.security.action.Action;
import org.apache.ws.security.handler.WSHandler;
@@ -27,7 +27,7 @@ import org.apache.ws.security.WSSecurity
/**
* a custom action that leaves a breadcumb
*/
-public class MyAction implements Action {
+public class CustomAction implements Action {
public void
execute(
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java
(from r1042632, webservices/wss4j/trunk/src/test/java/wssec/CustomCrypto.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java&p1=webservices/wss4j/trunk/src/test/java/wssec/CustomCrypto.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/CustomCrypto.java (original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java
Mon Dec 6 14:45:44 2010
@@ -17,7 +17,7 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.common;
import org.apache.ws.security.components.crypto.CryptoBase;
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomHandler.java
(from r1042632, webservices/wss4j/trunk/src/test/java/wssec/MyHandler.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomHandler.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomHandler.java&p1=webservices/wss4j/trunk/src/test/java/wssec/MyHandler.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/MyHandler.java (original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomHandler.java
Mon Dec 6 14:45:44 2010
@@ -17,7 +17,7 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.common;
import org.apache.ws.security.WSSecurityEngineResult;
import org.apache.ws.security.handler.WSHandler;
@@ -25,13 +25,14 @@ import org.apache.ws.security.handler.Re
import org.w3c.dom.Document;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
* A trivial extension of the WSHandler type for use in unit-testing.
*/
-public class MyHandler extends WSHandler {
+public class CustomHandler extends WSHandler {
private Map<String, Object> optionsMap = new HashMap<String, Object>();
@@ -52,13 +53,13 @@ public class MyHandler extends WSHandler
String key,
Object value
) {
- ((java.util.Map<String, Object>)ctx).put(key, value);
+ ((Map<String, Object>)ctx).put(key, value);
}
public Object
getProperty(Object ctx, String key) {
- if (ctx instanceof java.util.Map<?,?>) {
- return ((java.util.Map<?,?>)ctx).get(key);
+ if (ctx instanceof Map<?,?>) {
+ return ((Map<?,?>)ctx).get(key);
}
return null;
}
@@ -69,8 +70,8 @@ public class MyHandler extends WSHandler
public String
getPassword(Object msgContext) {
- if (msgContext instanceof java.util.Map<?,?>) {
- return (String)((java.util.Map<?,?>)msgContext).get("password");
+ if (msgContext instanceof Map<?,?>) {
+ return (String)((Map<?,?>)msgContext).get("password");
}
return null;
}
@@ -79,7 +80,7 @@ public class MyHandler extends WSHandler
int action,
Document doc,
RequestData reqData,
- java.util.List<Integer> actions,
+ List<Integer> actions,
boolean request
) throws org.apache.ws.security.WSSecurityException {
doSenderAction(
@@ -103,21 +104,21 @@ public class MyHandler extends WSHandler
public void signatureConfirmation(
RequestData requestData,
- java.util.List<WSSecurityEngineResult> results
+ List<WSSecurityEngineResult> results
) throws org.apache.ws.security.WSSecurityException {
checkSignatureConfirmation(requestData, results);
}
public boolean checkResults(
- java.util.List<WSSecurityEngineResult> results,
- java.util.List<Integer> actions
+ List<WSSecurityEngineResult> results,
+ List<Integer> actions
) throws org.apache.ws.security.WSSecurityException {
return checkReceiverResults(results, actions);
}
public boolean checkResultsAnyOrder(
- java.util.List<WSSecurityEngineResult> results,
- java.util.List<Integer> actions
+ List<WSSecurityEngineResult> results,
+ List<Integer> actions
) throws org.apache.ws.security.WSSecurityException {
return checkReceiverResultsAnyOrder(results, actions);
}
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java
(from r1042632, webservices/wss4j/trunk/src/test/java/wssec/MyProcessor.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java&p1=webservices/wss4j/trunk/src/test/java/wssec/MyProcessor.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/MyProcessor.java (original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java
Mon Dec 6 14:45:44 2010
@@ -17,7 +17,7 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.common;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.message.token.SecurityContextToken;
@@ -29,9 +29,9 @@ import org.apache.ws.security.WSSecurity
import org.apache.ws.security.WSSecurityException;
/**
- * a custom processor that inserts itself into the results vector
+ * a custom processor that inserts itself into the results list
*/
-public class MyProcessor implements Processor {
+public class CustomProcessor implements Processor {
public final void
handleToken(
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SOAPUtil.java
(from r1042632, webservices/wss4j/trunk/src/test/java/wssec/SOAPUtil.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SOAPUtil.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SOAPUtil.java&p1=webservices/wss4j/trunk/src/test/java/wssec/SOAPUtil.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/SOAPUtil.java (original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/SOAPUtil.java
Mon Dec 6 14:45:44 2010
@@ -17,7 +17,7 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.common;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java
(from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/SignatureConfirmationTest.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/SignatureConfirmationTest.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/SignatureConfirmationTest.java
(original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java
Mon Dec 6 14:45:44 2010
@@ -17,17 +17,16 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.handler;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSPasswordCallback;
import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.SOAPUtil;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.handler.RequestData;
@@ -49,7 +48,7 @@ import javax.security.auth.callback.Unsu
/**
* A set of test-cases for SignatureConfirmation.
*/
-public class SignatureConfirmationTest extends TestCase implements
CallbackHandler {
+public class SignatureConfirmationTest extends org.junit.Assert implements
CallbackHandler {
private static final Log LOG =
LogFactory.getLog(SignatureConfirmationTest.class);
private static final String SOAPMSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -68,28 +67,10 @@ public class SignatureConfirmationTest e
private Crypto crypto = CryptoFactory.getInstance();
/**
- * TestWSSecurity constructor
- *
- * @param name name of the test
- */
- public SignatureConfirmationTest(String name) {
- super(name);
- }
-
- /**
- * JUnit suite
- *
- * @return a junit test suite
- */
- public static Test suite() {
- return new TestSuite(SignatureConfirmationTest.class);
- }
-
-
- /**
* Test to see that a signature is saved correctly on the outbound request.
*/
@SuppressWarnings("unchecked")
+ @org.junit.Test
public void
testRequestSavedSignature() throws Exception {
final RequestData reqData = new RequestData();
@@ -103,7 +84,7 @@ public class SignatureConfirmationTest e
final java.util.List<Integer> actions = new
java.util.ArrayList<Integer>();
actions.add(new Integer(WSConstants.SIGN));
final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
- MyHandler handler = new MyHandler();
+ CustomHandler handler = new CustomHandler();
handler.send(
WSConstants.SIGN, doc, reqData, actions, true
);
@@ -128,6 +109,7 @@ public class SignatureConfirmationTest e
* enable signature confirmation is false.
*/
@SuppressWarnings("unchecked")
+ @org.junit.Test
public void
testRequestNotSavedSignature() throws Exception {
final RequestData reqData = new RequestData();
@@ -141,7 +123,7 @@ public class SignatureConfirmationTest e
final java.util.List<Integer> actions = new
java.util.ArrayList<Integer>();
actions.add(new Integer(WSConstants.SIGN));
final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
- MyHandler handler = new MyHandler();
+ CustomHandler handler = new CustomHandler();
handler.send(
WSConstants.SIGN, doc, reqData, actions, true
);
@@ -164,6 +146,7 @@ public class SignatureConfirmationTest e
* a signed message.
*/
@SuppressWarnings("unchecked")
+ @org.junit.Test
public void
testSignatureConfirmationResponse() throws Exception {
final RequestData reqData = new RequestData();
@@ -177,7 +160,7 @@ public class SignatureConfirmationTest e
final java.util.List<Integer> actions = new
java.util.ArrayList<Integer>();
actions.add(new Integer(WSConstants.SIGN));
Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
- MyHandler handler = new MyHandler();
+ CustomHandler handler = new CustomHandler();
handler.send(
WSConstants.SIGN, doc, reqData, actions, true
);
@@ -224,6 +207,7 @@ public class SignatureConfirmationTest e
* Test to see that a signature confirmation response is correctly
processed.
*/
@SuppressWarnings("unchecked")
+ @org.junit.Test
public void
testSignatureConfirmationProcessing() throws Exception {
final RequestData reqData = new RequestData();
@@ -237,7 +221,7 @@ public class SignatureConfirmationTest e
final java.util.List<Integer> actions = new
java.util.ArrayList<Integer>();
actions.add(new Integer(WSConstants.SIGN));
Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
- MyHandler handler = new MyHandler();
+ CustomHandler handler = new CustomHandler();
handler.send(
WSConstants.SIGN, doc, reqData, actions, true
);
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java
(from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityCertError.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityCertError.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityCertError.java
(original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java
Mon Dec 6 14:45:44 2010
@@ -17,12 +17,10 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.message;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.common.SOAPUtil;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecEncrypt;
import org.apache.ws.security.message.WSSecSignature;
@@ -34,7 +32,7 @@ import org.w3c.dom.Document;
* This class tests for error messages that apply to certificates, e.g. when a
bad
* "username" is used for encryption or signature. See WSS-137.
*/
-public class TestWSSecurityCertError extends TestCase {
+public class CertErrorTest extends org.junit.Assert {
private static final String SOAPMSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SOAP-ENV:Envelope "
@@ -50,29 +48,9 @@ public class TestWSSecurityCertError ext
/**
- * TestWSSecurity constructor
- * <p/>
- *
- * @param name name of the test
- */
- public TestWSSecurityCertError(String name) {
- super(name);
- }
-
- /**
- * JUnit suite
- * <p/>
- *
- * @return a junit test suite
- */
- public static Test suite() {
- return new TestSuite(TestWSSecurityNew3.class);
- }
-
-
- /**
* Test for when a bad certificate is used for Signature
*/
+ @org.junit.Test
public void testX509Signature() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("bob", "security");
@@ -91,6 +69,7 @@ public class TestWSSecurityCertError ext
/**
* Test for when a bad certificate is used for Encryption
*/
+ @org.junit.Test
public void testEncryption() throws Exception {
WSSecEncrypt builder = new WSSecEncrypt();
builder.setUserInfo("alice");
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java
(from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/TestModifiedRequest.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestModifiedRequest.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestModifiedRequest.java
(original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java
Mon Dec 6 14:45:44 2010
@@ -17,11 +17,8 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.message;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSConstants;
@@ -29,6 +26,7 @@ import org.apache.ws.security.WSEncrypti
import org.apache.ws.security.WSPasswordCallback;
import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.common.SOAPUtil;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecSignature;
@@ -46,8 +44,8 @@ import java.util.ArrayList;
/**
* This class tests the modification of requests to see if signature
verification fails.
*/
-public class TestModifiedRequest extends TestCase implements CallbackHandler {
- private static final Log LOG =
LogFactory.getLog(TestModifiedRequest.class);
+public class ModifiedRequestTest extends org.junit.Assert implements
CallbackHandler {
+ private static final Log LOG =
LogFactory.getLog(ModifiedRequestTest.class);
private static final String SOAPMSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SOAP-ENV:Envelope "
@@ -65,31 +63,12 @@ public class TestModifiedRequest extends
private Crypto crypto = CryptoFactory.getInstance();
/**
- * TestWSSecurity constructor
- * <p/>
- *
- * @param name name of the test
- */
- public TestModifiedRequest(String name) {
- super(name);
- }
-
- /**
- * JUnit suite
- * <p/>
- *
- * @return a junit test suite
- */
- public static Test suite() {
- return new TestSuite(TestModifiedRequest.class);
- }
-
- /**
* Test that signs a SOAP body element "value". The SOAP request is then
modified
* so that the signed "value" element is put in the header, and the value
of the
* original element is changed. This test will fail as the request will
contain
* multiple elements with the same wsu:Id.
*/
+ @org.junit.Test
public void testMovedElement() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e",
"security");
@@ -143,6 +122,7 @@ public class TestModifiedRequest extends
* original element is changed. The wsu:Id value of the original element
is also
* changed. Signature verification will pass, so we need to check that
wsu:Id's.
*/
+ @org.junit.Test
public void testMovedElementChangedId() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e",
"security");
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java
(from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/PasswordTypeTest.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/PasswordTypeTest.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/PasswordTypeTest.java (original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java
Mon Dec 6 14:45:44 2010
@@ -17,11 +17,8 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.message;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSSecurityException;
@@ -29,6 +26,8 @@ import org.apache.ws.security.WSPassword
import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSSConfig;
+import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.SOAPUtil;
import org.apache.ws.security.handler.RequestData;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.ws.security.message.WSSecUsernameToken;
@@ -44,7 +43,7 @@ import java.io.IOException;
* This is a test for processing a Username Token to enforce either a
plaintext or digest
* password type. See WSS-255.
*/
-public class PasswordTypeTest extends TestCase implements CallbackHandler {
+public class PasswordTypeTest extends org.junit.Assert implements
CallbackHandler {
private static final Log LOG = LogFactory.getLog(PasswordTypeTest.class);
private static final String SOAPMSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -60,27 +59,9 @@ public class PasswordTypeTest extends Te
+ "</SOAP-ENV:Envelope>";
/**
- * TestWSSecurity constructor
- *
- * @param name name of the test
- */
- public PasswordTypeTest(String name) {
- super(name);
- }
-
- /**
- * JUnit suite
- *
- * @return a junit test suite
- */
- public static Test suite() {
- return new TestSuite(PasswordTypeTest.class);
- }
-
-
- /**
* Test that adds a UserNameToken with password Digest to a WS-Security
envelope
*/
+ @org.junit.Test
public void testPasswordDigest() throws Exception {
WSSecUsernameToken builder = new WSSecUsernameToken();
builder.setUserInfo("wernerd", "verySecret");
@@ -129,6 +110,7 @@ public class PasswordTypeTest extends Te
/**
* Test that adds a UserNameToken with password text to a WS-Security
envelope
*/
+ @org.junit.Test
public void testUsernameTokenText() throws Exception {
WSSecUsernameToken builder = new WSSecUsernameToken();
builder.setPasswordType(WSConstants.PASSWORD_TEXT);
@@ -179,8 +161,9 @@ public class PasswordTypeTest extends Te
/**
* Test that adds a UserNameToken via WSHandler
*/
+ @org.junit.Test
public void testUsernameTokenWSHandler() throws Exception {
- MyHandler handler = new MyHandler();
+ CustomHandler handler = new CustomHandler();
Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
RequestData reqData = new RequestData();
Copied:
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java
(from r1042632,
webservices/wss4j/trunk/src/test/java/wssec/SignatureKeyValueTest.java)
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/SignatureKeyValueTest.java&r1=1042632&r2=1042661&rev=1042661&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/SignatureKeyValueTest.java
(original)
+++
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java
Mon Dec 6 14:45:44 2010
@@ -17,11 +17,8 @@
* under the License.
*/
-package wssec;
+package org.apache.ws.security.message;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.PublicKeyCallback;
@@ -29,6 +26,7 @@ import org.apache.ws.security.PublicKeyP
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.common.SOAPUtil;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecSignature;
@@ -48,7 +46,7 @@ import javax.security.auth.callback.Unsu
* a ds:KeyInfo/ds:KeyValue element. Although this isn't strictly recommended
for use in
* WS-Security, it's necessary to support it for WCF interop.
*/
-public class SignatureKeyValueTest extends TestCase implements CallbackHandler
{
+public class SignatureKeyValueTest extends org.junit.Assert implements
CallbackHandler {
private static final Log LOG =
LogFactory.getLog(SignatureKeyValueTest.class);
private static final String SOAPMSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -67,30 +65,14 @@ public class SignatureKeyValueTest exten
private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
private java.security.KeyStore keyStore = null;
- /**
- * TestWSSecurity constructor
- * <p/>
- *
- * @param name name of the test
- */
- public SignatureKeyValueTest(String name) {
- super(name);
+ public SignatureKeyValueTest() {
keyStore = crypto.getKeyStore();
}
/**
- * JUnit suite
- * <p/>
- *
- * @return a junit test suite
- */
- public static Test suite() {
- return new TestSuite(SignatureKeyValueTest.class);
- }
-
- /**
* Successful RSAKeyValue test.
*/
+ @org.junit.Test
public void testRSAKeyValue() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("wss40", "security");
@@ -126,6 +108,7 @@ public class SignatureKeyValueTest exten
* Failed RSAKeyValue test, where a message is signed using a key-pair
which doesn't
* correspond to the public key in the "trust"-store.
*/
+ @org.junit.Test
public void testBadRSAKeyValue() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("wss86", "security");
@@ -156,6 +139,7 @@ public class SignatureKeyValueTest exten
/**
* Successful DSAKeyValue test.
*/
+ @org.junit.Test
public void testDSAKeyValue() throws Exception {
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("wss40DSA", "security");