Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,30 +17,40 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
 
-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.WSEncryptionPart;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSConstants;
+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.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
+import org.apache.ws.security.handler.RequestData;
+import org.apache.ws.security.handler.WSHandlerConstants;
 import org.w3c.dom.Document;
 
 
 /**
- * WS-Security Test Case
- * <p/>
+ * A set of test-cases for signing and verifying SOAP requests.
  * 
  * @author Davanum Srinivas ([email protected])
+ * @author Werner Dittmann ([email protected])
  */
-public class TestWSSecurityNew extends TestCase {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew.class);
+public class SignatureTest extends org.junit.Assert implements CallbackHandler 
{
+    private static final Log LOG = LogFactory.getLog(SignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -58,104 +68,458 @@ public class TestWSSecurityNew extends T
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
+     * The test uses the Issuer Serial key identifier type.
      * <p/>
      * 
-     * @param name name of the test
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
      */
-    public TestWSSecurityNew(String name) {
-        super(name);
+    @org.junit.Test
+    public void testX509SignatureIS() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+        LOG.info("Before Signing IS....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signed message with IssuerSerial key identifier:");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        LOG.info("After Signing IS....");
+        verify(signedDoc);
     }
+    
 
     /**
-     * JUnit suite
+     * Test that signs (twice) and verifies a WS-Security envelope.
      * <p/>
      * 
-     * @return a junit test suite
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
      */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew.class);
+    @org.junit.Test
+    public void testDoubleX509SignatureIS() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc1 = builder.build(signedDoc, crypto, secHeader);
+        verify(signedDoc1);
     }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
+     */
+    @org.junit.Test
+    public void testIssuerSerialSignature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
 
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
+     */
+    @org.junit.Test
+    public void testSignatureInclusiveC14N() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setSigCanonicalization(WSConstants.C14N_OMIT_COMMENTS);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
 
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
     /**
-     * The test uses the ThumbprintSHA1 key identifier type.
+     * Test that signs and verifies a WS-Security envelope
      * <p/>
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
      */
-    public void testX509SignatureIS() throws Exception {
+    @org.junit.Test
+    public void testSignatureInclusivePrefixes() throws Exception {
+        WSSConfig wssConfig = WSSConfig.getNewInstance();
+        wssConfig.setWsiBSPCompliant(true);
         WSSecSignature builder = new WSSecSignature();
+        builder.setWsConfig(wssConfig);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
-        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-        LOG.info("Before Signing IS....");
+        LOG.info("Before Signing....");
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Signed message with IssuerSerial key identifier:");
+            LOG.debug("After Signing....");
             String outputString = 
                 
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        LOG.info("After Signing IS....");
+        
         verify(signedDoc);
     }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
+     */
+    @org.junit.Test
+    public void testBSTSignature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
 
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
+     */
+    @org.junit.Test
+    public void testBSTPKIPathSignature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("wss40", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setUseSingleCertificate(false);
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        
+        Crypto pkiCrypto = CryptoFactory.getInstance("wss40.properties");
+        Document signedDoc = builder.build(doc, pkiCrypto, secHeader);
 
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After PKI Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        secEngine.processSecurityHeader(doc, null, this, pkiCrypto, null);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
+     */
+    @org.junit.Test
+    public void testX509Signature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope.
+     * The test uses the ThumbprintSHA1 key identifier type. 
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
+     */
+    @org.junit.Test
+    public void testX509SignatureThumb() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+        LOG.info("Before Signing ThumbprintSHA1....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signed message with ThumbprintSHA1 key identifier:");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        LOG.info("After Signing ThumbprintSHA1....");
+        verify(signedDoc);
+    }
+
+    
     /**
      * Test that signs (twice) and verifies a WS-Security envelope.
+     * The test uses the ThumbprintSHA1 key identifier type.
      * <p/>
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
      */
-    public void testDoubleX509SignatureIS() throws Exception {
+    @org.junit.Test
+    public void testDoubleX509SignatureThumb() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
+
         Document signedDoc = builder.build(doc, crypto, secHeader);
         Document signedDoc1 = builder.build(signedDoc, crypto, secHeader);
         verify(signedDoc1);
     }
-
+    
+    
     /**
-     * Verifies the soap envelope.
-     * This method verfies all the signature generated. 
+     * Test that signs and verifies a Timestamp. The request is then modified 
so that the
+     * Timestamp has a default (WSU) namespace inserted. The signature 
validation should still
+     * pass due to c14n (see WSS-181).
      * 
-     * @param env soap envelope
-     * @throws java.lang.Exception Thrown when there is a problem in 
verification
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
      */
-    private void verify(Document doc) throws Exception {
-        secEngine.processSecurityHeader(doc, null, null, crypto);
+    @org.junit.Test
+    public void testValidModifiedSignature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        
+        WSSecTimestamp timestamp = new WSSecTimestamp();
+        timestamp.setTimeToLive(300);
+        Document createdDoc = timestamp.build(doc, secHeader);
+        
+        List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
+        WSEncryptionPart encP =
+            new WSEncryptionPart(
+                "Timestamp",
+                WSConstants.WSU_NS,
+                "");
+        parts.add(encP);
+        builder.setParts(parts);
+        
+        Document signedDoc = builder.build(createdDoc, crypto, secHeader);
+        org.w3c.dom.Element secHeaderElement = secHeader.getSecurityHeader();
+        org.w3c.dom.Node timestampNode = 
+            secHeaderElement.getElementsByTagNameNS(WSConstants.WSU_NS, 
"Timestamp").item(0);
+        ((org.w3c.dom.Element)timestampNode).setAttributeNS(
+            WSConstants.XMLNS_NS, "xmlns", WSConstants.WSU_NS
+        );
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
     }
     
     /**
-     * Ensure that we can load a custom crypto implementation using a Map
+     * Sign using a different digest algorithm (SHA-256).
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing 
or verification
      */
-    public void testCustomCrypto() {
-        java.util.Map<String, Object> tmp = new java.util.TreeMap<String, 
Object>();
-        Crypto crypto = CryptoFactory.getInstance(
-            "wssec.CustomCrypto",
-            tmp
-        );
-        assertNotNull(crypto);
-        assertTrue(crypto instanceof CustomCrypto);
-        CustomCrypto custom = (CustomCrypto)crypto;
-        assertSame(tmp, custom.config);
+    @org.junit.Test
+    public void testX509SignatureSha256() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+        
builder.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";);
+        builder.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256";);
+        LOG.info("Before Signing IS....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signed message with IssuerSerial key identifier:");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        LOG.info("After Signing IS....");
+        verify(signedDoc);
     }
     
     /**
-     * Test for WSS-149 - "AbstractCrypto requires 
org.apache.ws.security.crypto.merlin.file
-     * to be set and point to an existing file"
+     * A test for "SignatureAction does not set DigestAlgorithm on 
WSSecSignature instance"
      */
-    public void testNoKeyStoreFile() {
-        Crypto crypto = CryptoFactory.getInstance(
-            "nofile.properties"
+    @org.junit.Test
+    public void
+    testWSS170() throws Exception {
+        final WSSConfig cfg = WSSConfig.getNewInstance();
+        final int action = WSConstants.SIGN;
+        final RequestData reqData = new RequestData();
+        reqData.setWssConfig(cfg);
+        reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
+        java.util.Map<String, Object> config = new java.util.TreeMap<String, 
Object>();
+        config.put(WSHandlerConstants.SIG_PROP_FILE, "crypto.properties");
+        config.put("password", "security");
+        config.put(
+            WSHandlerConstants.SIG_ALGO, 
+            "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
+        );
+        config.put(
+            WSHandlerConstants.SIG_DIGEST_ALGO, 
+            "http://www.w3.org/2001/04/xmlenc#sha256";
         );
-        assertNotNull(crypto);
+        reqData.setMsgContext(config);
+        
+        final java.util.List<Integer> actions = new 
java.util.ArrayList<Integer>();
+        actions.add(new Integer(action));
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        CustomHandler handler = new CustomHandler();
+        handler.send(
+            action, 
+            doc, 
+            reqData, 
+            actions,
+            true
+        );
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signed message:");
+            LOG.debug(outputString);
+        }
+        assertTrue(
+            
outputString.indexOf("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";) != -1
+        );
+        assertTrue(
+            outputString.indexOf("http://www.w3.org/2001/04/xmlenc#sha256";) != 
-1
+        );
+        
+        verify(doc);
     }
+    
+    /**
+     * This is a test for WSS-234 - 
+     * "When a document contains a comment as its first child element, 
+     * wss4j will not find the SOAP body." 
+     */
+    @org.junit.Test
+    public void testWSS234() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+        
+        // Add a comment node as the first node element
+        org.w3c.dom.Node firstChild = signedDoc.getFirstChild();
+        org.w3c.dom.Node newNode = signedDoc.removeChild(firstChild);
+        org.w3c.dom.Node commentNode = signedDoc.createComment("This is a 
comment");
+        signedDoc.appendChild(commentNode);
+        signedDoc.appendChild(newNode);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+
+    /**
+     * Verifies the soap envelope.
+     * This method verifies all the signature generated. 
+     * 
+     * @param env soap envelope
+     * @throws java.lang.Exception Thrown when there is a problem in 
verification
+     */
+    private void verify(Document doc) throws Exception {
+        secEngine.processSecurityHeader(doc, null, null, crypto);
+    }
+    
+
+    public void handle(Callback[] callbacks)
+        throws IOException, UnsupportedCallbackException {
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof WSPasswordCallback) {
+                WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
+                /*
+                 * here call a function/method to lookup the password for
+                 * the given identifier (e.g. a user name or keystore alias)
+                 * e.g.: 
pc.setPassword(passStore.getPassword(pc.getIdentfifier))
+                 * for Testing we supply a fixed name here.
+                 */
+                pc.setPassword("security");
+            } else {
+                throw new UnsupportedCallbackException(callbacks[i], 
"Unrecognized Callback");
+            }
+        }
+    }
+    
 }

Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew17.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew17.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew17.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
 import java.io.IOException;
 
@@ -28,10 +28,6 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.xml.crypto.dsig.SignatureMethod;
 
-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;
@@ -40,6 +36,8 @@ import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
+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.WSSecEncrypt;
@@ -54,8 +52,8 @@ import org.w3c.dom.Document;
  * Demonstrates that Signature Crypto object can have null values when 
  * calling processSecurityHeader method of WSSecurityEngine.
  */
-public class TestWSSecurityNew17 extends TestCase implements CallbackHandler {
-    private static final Log LOG = 
LogFactory.getLog(TestWSSecurityNew17.class);
+public class SymmetricSignatureTest extends org.junit.Assert implements 
CallbackHandler {
+    private static final Log LOG = 
LogFactory.getLog(SymmetricSignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -74,32 +72,13 @@ public class TestWSSecurityNew17 extends
     private byte[] keyData;
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNew17(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew17.class);
-    }
-
-    /**
      * Setup method
      * <p/>
      * 
      * @throws Exception Thrown when there is a problem in setup
      */
-    protected void setUp() throws Exception {
+    @org.junit.Before
+    public void setUp() throws Exception {
         KeyGenerator keyGen = KeyGenerator.getInstance("AES");
         keyGen.init(128);
         SecretKey key = keyGen.generateKey();
@@ -109,6 +88,7 @@ public class TestWSSecurityNew17 extends
     /**
      * Test signing a message body using a symmetric key with EncryptedKeySHA1
      */
+    @org.junit.Test
     public void testSymmetricSignatureSHA1() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
@@ -137,6 +117,7 @@ public class TestWSSecurityNew17 extends
      * Test signing a message body using a symmetric key with Direct Reference 
to an
      * EncryptedKey
      */
+    @org.junit.Test
     public void testSymmetricSignatureDR() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
@@ -175,6 +156,7 @@ public class TestWSSecurityNew17 extends
      * @throws Exception Thrown when there is any problem in signing, 
encryption,
      *                   decryption, or verification
      */
+    @org.junit.Test
     public void testEncryptedKeySignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         LOG.info("Before Sign/Encryption....");
@@ -219,6 +201,7 @@ public class TestWSSecurityNew17 extends
      * Test signing a message body using a symmetric key with 
EncryptedKeySHA1. 
      * The request is generated using WSHandler, instead of coding it.
      */
+    @org.junit.Test
     public void testSymmetricSignatureSHA1Handler() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
         RequestData reqData = new RequestData();
@@ -233,7 +216,7 @@ public class TestWSSecurityNew17 extends
         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, 

Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/TimestampTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityTimestamp.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/TimestampTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/TimestampTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityTimestamp.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityTimestamp.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/TimestampTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,22 +17,18 @@
  * 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;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
-import org.apache.ws.security.util.WSSecurityUtil;
 import org.apache.ws.security.WSSecurityEngine;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecTimestamp;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.message.token.Timestamp;
+import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
 import java.util.List;
@@ -40,8 +36,8 @@ import java.util.List;
 /**
  * WS-Security Test Case for Timestamps.
  */
-public class TestWSSecurityTimestamp extends TestCase {
-    private static final Log LOG = 
LogFactory.getLog(TestWSSecurityTimestamp.class);
+public class TimestampTest extends org.junit.Assert {
+    private static final Log LOG = LogFactory.getLog(TimestampTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -58,29 +54,9 @@ public class TestWSSecurityTimestamp ext
     private WSSecurityEngine secEngine = new WSSecurityEngine();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityTimestamp(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityTimestamp.class);
-    }
-
-    
-    /**
      * This is a test for processing a valid Timestamp.
      */
+    @org.junit.Test
     public void testValidTimestamp() throws Exception {
 
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -114,6 +90,7 @@ public class TestWSSecurityTimestamp ext
     /**
      * This is a test for processing a valid Timestamp with no expires element
      */
+    @org.junit.Test
     public void testValidTimestampNoExpires() throws Exception {
 
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -147,6 +124,7 @@ public class TestWSSecurityTimestamp ext
     /**
      * This is a test for processing an expired Timestamp.
      */
+    @org.junit.Test
     public void testExpiredTimestamp() throws Exception {
 
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -176,6 +154,7 @@ public class TestWSSecurityTimestamp ext
      * This is a test for processing an "old" Timestamp, i.e. one with a 
"Created" element that is
      * out of date
      */
+    @org.junit.Test
     public void testOldTimestamp() throws Exception {
         
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);

Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew5.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew5.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew5.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java
 Mon Dec  6 17:22:39 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,10 +26,10 @@ 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;
-import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.message.token.UsernameToken;
 import org.apache.ws.security.util.Base64;
 import org.w3c.dom.Document;
@@ -48,8 +45,8 @@ import java.security.MessageDigest;
  * 
  * @author Davanum Srinivas ([email protected])
  */
-public class TestWSSecurityNew5 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew5.class);
+public class UsernameTokenTest extends org.junit.Assert implements 
CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(UsernameTokenTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -117,27 +114,9 @@ public class TestWSSecurityNew5 extends 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
 
     /**
-     * TestWSSecurity constructor
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNew5(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew5.class);
-    }
-
-
-    /**
      * Test that adds a UserNameToken with password Digest to a WS-Security 
envelope
      */
+    @org.junit.Test
     public void testUsernameTokenDigest() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setUserInfo("wernerd", "verySecret");
@@ -160,6 +139,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test for encoded passwords.
      */
+    @org.junit.Test
     public void testUsernameTokenWithEncodedPasswordBaseline() throws 
Exception {
         String password = "password";
         // The SHA-1 of the password is known as a password equivalent in the 
UsernameToken specification.
@@ -175,6 +155,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that adds a UserNameToken with password Digest to a WS-Security 
envelope
      */
+    @org.junit.Test
     public void testUsernameTokenWithEncodedPassword() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordsAreEncoded(true);
@@ -206,6 +187,7 @@ public class TestWSSecurityNew5 extends 
      * Test that a bad username with password digest does not leak whether the 
username
      * is valid or not - see WSS-141.
      */
+    @org.junit.Test
     public void testUsernameTokenBadUsername() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setUserInfo("badusername", "verySecret");
@@ -236,6 +218,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that adds a UserNameToken with a bad password Digest to a 
WS-Security envelope
      */
+    @org.junit.Test
     public void testUsernameTokenBadDigest() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setUserInfo("wernerd", "verySecre");
@@ -264,6 +247,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * 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);
@@ -287,6 +271,7 @@ public class TestWSSecurityNew5 extends 
      * Test that adds a UserNameToken with a digested password but with type of
      * password test.
      */
+    @org.junit.Test
     public void testUsernameTokenDigestText() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(WSConstants.PASSWORD_TEXT);
@@ -313,6 +298,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that adds a UserNameToken with (bad) password text to a 
WS-Security envelope
      */
+    @org.junit.Test
     public void testUsernameTokenBadText() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(WSConstants.PASSWORD_TEXT);
@@ -346,6 +332,7 @@ public class TestWSSecurityNew5 extends 
      * The 1.1 spec states that the password type is optional and defaults to 
password text, 
      * and so we should handle an incoming Username Token accordingly.
      */
+    @org.junit.Test
     public void testUsernameTokenNoPasswordType() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUTMSG);
         if (LOG.isDebugEnabled()) {
@@ -361,6 +348,7 @@ public class TestWSSecurityNew5 extends 
      * See WSS-185 - https://issues.apache.org/jira/browse/WSS-185
      * "NullPointerException on empty UsernameToken"
      */
+    @org.junit.Test
     public void testUsernameTokenNoUser() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUTNOUSERMSG);
         if (LOG.isDebugEnabled()) {
@@ -380,6 +368,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that adds a UserNameToken with no password
      */
+    @org.junit.Test
     public void testUsernameTokenNoPassword() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(null);
@@ -406,6 +395,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that adds a UserNameToken with an empty password
      */
+    @org.junit.Test
     public void testUsernameTokenEmptyPassword() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(WSConstants.PASSWORD_TEXT);
@@ -426,6 +416,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that processes a UserNameToken with an empty password
      */
+    @org.junit.Test
     public void testEmptyPasswordProcessing() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(EMPTY_PASSWORD_MSG);
         if (LOG.isDebugEnabled()) {
@@ -442,6 +433,7 @@ public class TestWSSecurityNew5 extends 
      * Test with a null token type. This will fail as the default is to reject 
custom
      * token types.
      */
+    @org.junit.Test
     public void testUsernameTokenCustomFail() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(null);
@@ -471,6 +463,7 @@ public class TestWSSecurityNew5 extends 
      * Test with a non-standard token type. This will fail as the default is 
to reject custom
      * token types.
      */
+    @org.junit.Test
     public void testUsernameTokenCustomFail2() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType("RandomType");
@@ -500,6 +493,7 @@ public class TestWSSecurityNew5 extends 
      * Test with a non-standard password type. This will pass as the WSSConfig 
is configured to 
      * handle custom token types.
      */
+    @org.junit.Test
     public void testUsernameTokenCustomPass() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType("RandomType");
@@ -538,6 +532,7 @@ public class TestWSSecurityNew5 extends 
      * http://issues.apache.org/jira/browse/WSS-66
      * "Possible security hole when PasswordDigest is used by client."
      */
+    @org.junit.Test
     public void testNullNonce() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
@@ -580,6 +575,7 @@ public class TestWSSecurityNew5 extends 
      * http://issues.apache.org/jira/browse/WSS-66
      * "Possible security hole when PasswordDigest is used by client."
      */
+    @org.junit.Test
     public void testNullCreated() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
@@ -620,6 +616,7 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that verifies an EncodingType is set for the nonce. See WSS-169.
      */
+    @org.junit.Test
     public void testUsernameTokenNonceEncodingType() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.setUserInfo("wernerd", "verySecret");
@@ -637,7 +634,7 @@ public class TestWSSecurityNew5 extends 
      * Test that adds a UserNameToken via WSHandler
      */
     public void testUsernameTokenWSHandler() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         RequestData reqData = new RequestData();
@@ -663,8 +660,9 @@ public class TestWSSecurityNew5 extends 
     /**
      * Test that adds a UserNameToken with an empty password via WSHandler
      */
+    @org.junit.Test
     public void testUsernameTokenWSHandlerEmptyPassword() 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/token/BSTKerberosTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityKerberosTokenProfile.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityKerberosTokenProfile.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityKerberosTokenProfile.java
 (original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message.token;
 
-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.WSEncryptionPart;
@@ -29,6 +26,7 @@ import org.apache.ws.security.WSPassword
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSConstants;
+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;
@@ -47,8 +45,8 @@ import java.util.ArrayList;
 /**
  * This is a test for the Kerberos Token Profile 1.1
  */
-public class TestWSSecurityKerberosTokenProfile extends TestCase implements 
CallbackHandler {
-    private static final Log LOG = 
LogFactory.getLog(TestWSSecurityKerberosTokenProfile.class);
+public class BSTKerberosTest extends org.junit.Assert implements 
CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(BSTKerberosTest.class);
     private static final String AP_REQ = 
         
"http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#Kerberosv5_AP_REQ";;
     private static final String BASE64_NS = 
@@ -70,29 +68,9 @@ public class TestWSSecurityKerberosToken
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityKerberosTokenProfile(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityKerberosTokenProfile.class);
-    }
-
-
-    /**
      * A unit test for creating BinarySecurityTokens
      */
+    @org.junit.Test
     public void testCreateBinarySecurityToken() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSConfig.getNewInstance();
@@ -121,6 +99,7 @@ public class TestWSSecurityKerberosToken
     /**
      * A test for signing a Kerberos BST
      */
+    @org.junit.Test
     public void testSignBST() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSConfig.getNewInstance();
@@ -159,6 +138,7 @@ public class TestWSSecurityKerberosToken
     /**
      * A test for signing a Kerberos BST as well as a Timestamp
      */
+    @org.junit.Test
     public void testSignBSTTimestamp() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSConfig.getNewInstance();

Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/misc/FaultCodeTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityFaultCodes.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/misc/FaultCodeTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/misc/FaultCodeTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityFaultCodes.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityFaultCodes.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/misc/FaultCodeTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,15 +17,13 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.misc;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
+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.WSSecEncrypt;
@@ -48,7 +46,7 @@ import java.io.IOException;
  * WS-Security Test Case for fault codes. The SOAP Message Security 
specification 1.1 defines
  * standard fault codes and fault strings for error propagation.
  */
-public class TestWSSecurityFaultCodes extends TestCase implements 
CallbackHandler {
+public class FaultCodeTest extends org.junit.Assert implements CallbackHandler 
{
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -66,30 +64,10 @@ public class TestWSSecurityFaultCodes ex
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityFaultCodes(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityFaultCodes.class);
-    }
-
-    
-    /**
      * Test for the wsse:FailedCheck faultcode. This will fail due to a bad 
password in
      * the callback handler.
      */
+    @org.junit.Test
     public void testFailedCheck() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", 
"security");
@@ -113,6 +91,7 @@ public class TestWSSecurityFaultCodes ex
      * Test for the wsse:UnsupportedAlgorithm faultcode. This will fail due to 
the argument
      * passed to getCipherInstance.
      */
+    @org.junit.Test
     public void testUnsupportedAlgorithm() throws Exception {
         try {
             WSSecurityUtil.getCipherInstance("Bad Algorithm");
@@ -130,6 +109,7 @@ public class TestWSSecurityFaultCodes ex
      * Test for the wsse:SecurityTokenUnavailable faultcode. This will fail 
due to the 
      * argument to loadCertificate.
      */
+    @org.junit.Test
     public void testSecurityTokenUnavailable() throws Exception {
         try {
             crypto.loadCertificate(new java.io.ByteArrayInputStream(new 
byte[]{}));
@@ -146,6 +126,7 @@ public class TestWSSecurityFaultCodes ex
      * Test for the wsse:MessageExpired faultcode. This will fail due to the 
argument
      * passed to setTimeToLive.
      */
+    @org.junit.Test
     public void testMessageExpired() throws Exception {
         WSSecTimestamp builder = new WSSecTimestamp();
         builder.setTimeToLive(-1);
@@ -170,6 +151,7 @@ public class TestWSSecurityFaultCodes ex
      * Test for the wsse:FailedAuthentication faultcode. This will fail due to 
a bad password in
      * the callback handler.
      */
+    @org.junit.Test
     public void testFailedAuthentication() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.addCreated();
@@ -196,6 +178,7 @@ public class TestWSSecurityFaultCodes ex
      * Test for the wsse:InvalidSecurityToken faultcode. This will fail due to 
the fact
      * that a null username is used.
      */
+    @org.junit.Test
     public void testInvalidSecurityToken() throws Exception {
         WSSecUsernameToken builder = new WSSecUsernameToken();
         builder.addCreated();
@@ -221,6 +204,7 @@ public class TestWSSecurityFaultCodes ex
     /**
      * Test for the wsse:InvalidSecurity faultcode. 
      */
+    @org.junit.Test
     public void testInvalidSecurity() throws Exception {
         try {
             new Reference((org.w3c.dom.Element)null);

Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/EncryptedKeyDataRefTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef1.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/EncryptedKeyDataRefTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/EncryptedKeyDataRefTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef1.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef1.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/EncryptedKeyDataRefTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.processor;
 
 import java.io.IOException;
 import java.util.List;
@@ -27,10 +27,6 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
 
-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;
@@ -39,6 +35,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.WSSecEncrypt;
@@ -58,10 +55,9 @@ import org.w3c.dom.Element;
  * 
  * WSDataRef object must contain the correct QName of the decrypted element. 
  * 
- * 
  */
-public class TestWSSecurityDataRef1 extends TestCase implements 
CallbackHandler {
-    private static final Log LOG = 
LogFactory.getLog(TestWSSecurityDataRef1.class);
+public class EncryptedKeyDataRefTest extends org.junit.Assert implements 
CallbackHandler {
+    private static final Log LOG = 
LogFactory.getLog(EncryptedKeyDataRefTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -77,32 +73,13 @@ public class TestWSSecurityDataRef1 exte
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
 
     /**
-     * TestWSSecurityDataRef constructor <p/>
-     * 
-     * @param name
-     *            name of the test
-     */
-    public TestWSSecurityDataRef1(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite( TestWSSecurityDataRef1.class);
-    }
-
-
-    /**
      * Test that check for correct WSDataRef object from EncryptedKey 
Processor 
      * 
      * 
      * @throws Exception
      *             Thrown when there is an error in encryption or decryption
      */
+    @org.junit.Test
     public void testDataRefEncryptedKeyProcessor() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecEncrypt builder = new WSSecEncrypt();

Copied: 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/ReferenceListDataRefTest.java
 (from r1042661, 
webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef.java)
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/ReferenceListDataRefTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/ReferenceListDataRefTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef.java 
(original)
+++ 
webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/ReferenceListDataRefTest.java
 Mon Dec  6 17:22:39 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.processor;
 
 import java.io.IOException;
 import java.util.List;
@@ -27,10 +27,6 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
 
-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;
@@ -39,6 +35,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.WSSecEncrypt;
@@ -58,10 +55,9 @@ import org.w3c.dom.Element;
  * 
  * WSDataRef object must contain the correct QName of the decrypted element. 
  * 
- * 
  */
-public class TestWSSecurityDataRef extends TestCase implements CallbackHandler 
{
-    private static final Log LOG = 
LogFactory.getLog(TestWSSecurityDataRef.class);
+public class ReferenceListDataRefTest extends org.junit.Assert implements 
CallbackHandler {
+    private static final Log LOG = 
LogFactory.getLog(ReferenceListDataRefTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -77,31 +73,13 @@ public class TestWSSecurityDataRef exten
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
 
     /**
-     * TestWSSecurityDataRef constructor <p/>
-     * 
-     * @param name
-     *            name of the test
-     */
-    public TestWSSecurityDataRef(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite( TestWSSecurityDataRef.class);
-    }
-
-    /**
      * Test that check for correct WSDataRef object from ReferenceList 
Processor 
      * 
      * 
      * @throws Exception
      *             Thrown when there is an error in encryption or decryption
      */
+    @org.junit.Test
     public void testDataRefReferenceListProcessor() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecEncrypt builder = new WSSecEncrypt();


Reply via email to