You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2012/04/04 14:59:30 UTC

svn commit: r1309362 - in /santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig: XMLObjectTest.java XMLSignContextTest.java XMLSignatureFactoryTest.java XMLSignatureTest.java XMLValidateContextTest.java

Author: coheigea
Date: Wed Apr  4 12:59:30 2012
New Revision: 1309362

URL: http://svn.apache.org/viewvc?rev=1309362&view=rev
Log:
Upgrading some remaining tests to use Junit4 annotations

Modified:
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java?rev=1309362&r1=1309361&r2=1309362&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java Wed Apr  4 12:59:30 2012
@@ -24,37 +24,26 @@ package javax.xml.crypto.test.dsig;
 import java.util.*;
 import javax.xml.crypto.dsig.*;
 
-import junit.framework.*;
-
 /**
  * Unit test for javax.xml.crypto.dsig.XMLObject
  *
  * @version $Id$
  * @author Valerie Peng
  */
-public class XMLObjectTest extends TestCase {
+public class XMLObjectTest extends org.junit.Assert {
 
     private XMLSignatureFactory factory;
     private String id = "id";
     private String mimeType = "mime";
     private String encoding = "encoding";
 
-    public XMLObjectTest() {
-        super("XMLObjectTest");
-    }
-
-    public XMLObjectTest(String name) {
-        super(name);
-    }
-
-    public void setUp() throws Exception {
+    public XMLObjectTest() throws Exception {
         factory = XMLSignatureFactory.getInstance
             ("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
     }
     
-    public void tearDown() {}
-    
     @SuppressWarnings("unchecked")
+    @org.junit.Test
     public void testConstructor() {
         // test XMLSignatureFactory.newXMLObject(List, String, String, String) 
         XMLObject obj;
@@ -95,6 +84,7 @@ public class XMLObjectTest extends TestC
         assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
     }
 
+    @org.junit.Test
     public void testisFeatureSupported() {
         List<Object> list = new Vector<Object>();
         list.add(new TestUtils.MyOwnXMLStructure());

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java?rev=1309362&r1=1309361&r2=1309362&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java Wed Apr  4 12:59:30 2012
@@ -30,29 +30,19 @@ import javax.crypto.SecretKey;
 import javax.crypto.spec.SecretKeySpec;
 import org.w3c.dom.Document;
 
-import junit.framework.*;
-
 /**
  * Unit test for javax.xml.crypto.dsig.XMLSignContext
  *
  * @version $Id$
  * @author Valerie Peng
  */
-public class XMLSignContextTest extends TestCase {
+public class XMLSignContextTest extends org.junit.Assert {
 
     private XMLSignContext defContext;
     private Key[] KEYS;
     private Document doc;
 
-    public XMLSignContextTest() {
-        super("XMLSignContextTest");
-    }
-
-    public XMLSignContextTest(String name) {
-        super(name);
-    }
-
-    public void setUp() throws Exception {
+    public XMLSignContextTest() throws Exception {
         // set up the signingKeys
         KEYS = new Key[3];
         KEYS[0] = TestUtils.getPrivateKey("DSA");
@@ -64,8 +54,7 @@ public class XMLSignContextTest extends 
         defContext = new DOMSignContext(sk, doc);
     }
 
-    public void tearDown() { }
-
+    @org.junit.Test
     public void testsetngetBaseURI() throws Exception {
         assertNull(defContext.getBaseURI());
 
@@ -77,6 +66,7 @@ public class XMLSignContextTest extends 
     }
 
 
+    @org.junit.Test
     public void testsetngetProperty() throws Exception {
         String name = "key";
         assertNull(defContext.getProperty(name));
@@ -97,6 +87,7 @@ public class XMLSignContextTest extends 
         assertNull(defContext.getProperty(name));
     }
 
+    @org.junit.Test
     public void testsetngetURIDereferencer() throws Exception {
         assertNull(defContext.getURIDereferencer());
         byte[] data = "simpleDereferencer".getBytes();
@@ -108,6 +99,7 @@ public class XMLSignContextTest extends 
         assertNull(defContext.getURIDereferencer());
     }
 
+    @org.junit.Test
     public void testsetngetKeySelector() throws Exception {
         defContext.setKeySelector(null);
         assertNull(defContext.getKeySelector());

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java?rev=1309362&r1=1309361&r2=1309362&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java Wed Apr  4 12:59:30 2012
@@ -34,15 +34,13 @@ import javax.xml.parsers.DocumentBuilder
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
-import junit.framework.*;
-
 /**
  * Unit test for javax.xml.crypto.dsig.XMLSignatureFactory
  *
  * @version $Id$
  * @author Valerie Peng
  */
-public class XMLSignatureFactoryTest extends TestCase {
+public class XMLSignatureFactoryTest extends org.junit.Assert {
 
     XMLSignatureFactory factory;
 
@@ -51,17 +49,12 @@ public class XMLSignatureFactoryTest ext
             (new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
     }
 
-    public XMLSignatureFactoryTest(String name) {
-        super(name);
-    }
-
-    public void setUp() throws Exception { 
+    public XMLSignatureFactoryTest() throws Exception { 
         factory = XMLSignatureFactory.getInstance
             ("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
     }
 
-    public void tearDown() { }
-
+    @org.junit.Test
     public void testgetInstance() {
         try {
             XMLSignatureFactory.getInstance("non-existent");
@@ -94,11 +87,13 @@ public class XMLSignatureFactoryTest ext
         } catch (NullPointerException npe) {}
     }
 
+    @org.junit.Test
     public void testgetMechanismType() {
         assertNotNull(factory);
         assertEquals("DOM", factory.getMechanismType());
     }
 
+    @org.junit.Test
     public void testisFeatureSupported() {
         try {
             factory.isFeatureSupported(null); 
@@ -108,12 +103,14 @@ public class XMLSignatureFactoryTest ext
         assertTrue(!factory.isFeatureSupported("not supported"));
     }
 
+    @org.junit.Test
     public void testgetKeyInfoFactory() throws Exception {
         KeyInfoFactory kifac = factory.getKeyInfoFactory();
         assertEquals(kifac.getMechanismType(), factory.getMechanismType());
         assertEquals(kifac.getProvider(), factory.getProvider());
     }
 
+    @org.junit.Test
     public void testunmarshalXMLSignature() throws Exception {
         XMLSignature stuff;
         try {
@@ -182,11 +179,4 @@ public class XMLSignatureFactoryTest ext
         }
     }
 
-    // for debugging purposes
-    public static void main(String[] args) throws Exception {
-        XMLSignatureFactoryTest test = 
-            new XMLSignatureFactoryTest("XMLSignatureFactoryTest");
-        test.setUp();
-        test.testunmarshalXMLSignature();
-    }
 }

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java?rev=1309362&r1=1309361&r2=1309362&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java Wed Apr  4 12:59:30 2012
@@ -36,15 +36,13 @@ import javax.crypto.spec.SecretKeySpec;
 
 import org.w3c.dom.*;
 
-import junit.framework.*;
-
 /**
  * Unit test for javax.xml.crypto.dsig.XMLSignature
  *
  * @version $Id$
  * @author Valerie Peng
  */
-public class XMLSignatureTest extends TestCase {
+public class XMLSignatureTest extends org.junit.Assert {
     private XMLSignatureFactory fac;
     private KeyInfoFactory kifac;
     private SignedInfo defSi;
@@ -62,15 +60,7 @@ public class XMLSignatureTest extends Te
             (new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
     }
 
-    public XMLSignatureTest() {
-        super("XMLSignatureTest");
-    }
-
-    public XMLSignatureTest(String name) {
-        super(name);
-    }
-
-    public void setUp() throws Exception {
+    public XMLSignatureTest() throws Exception {
         fac = XMLSignatureFactory.getInstance
             ("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
         kifac = KeyInfoFactory.getInstance
@@ -99,8 +89,7 @@ public class XMLSignatureTest extends Te
         ud = new LocalHttpCacheURIDereferencer();
     }
 
-    public void tearDown() {}
-
+    @org.junit.Test
     public void testConstructor() throws Exception {
         XMLSignature sig = null;
         // test  XMLSignatureFactory.newXMLSignature(SignedInfo, KeyInfo)
@@ -150,6 +139,7 @@ public class XMLSignatureTest extends Te
         assertEquals(sig.getSignedInfo(), defSi);
     }
     
+    @org.junit.Test
     public void testisFeatureSupported() throws Exception {
 
         XMLSignature sig = fac.newXMLSignature(defSi, null);
@@ -162,6 +152,7 @@ public class XMLSignatureTest extends Te
         assertTrue(!sig.isFeatureSupported("not supported"));
     }
 
+    @org.junit.Test
     public void testsignANDvalidate() throws Exception {
         XMLSignature sig;
         SignedInfo si;
@@ -194,6 +185,7 @@ public class XMLSignatureTest extends Te
         assertTrue(status);
     }
 
+    @org.junit.Test
     public void testsignWithProvider() throws Exception {
         XMLSignature sig;
         SignedInfo si;
@@ -226,6 +218,7 @@ public class XMLSignatureTest extends Te
         }
     }
 
+    @org.junit.Test
     public void testSignWithEmptyNSPrefix() throws Exception {
         SignedInfo si = createSignedInfo(SIG_METHODS[1]);
         KeyInfo	ki = kifac.newKeyInfo(Collections.singletonList
@@ -243,6 +236,7 @@ public class XMLSignatureTest extends Te
 */
     }
 
+    @org.junit.Test
     public void testSignWithReferenceManifestDependencies() throws Exception {
         // create references
         DigestMethod dm = fac.newDigestMethod(DigestMethod.SHA1, null);
@@ -298,6 +292,7 @@ public class XMLSignatureTest extends Te
         }
     }
 
+    @org.junit.Test
     public void testSignTemplateWithObjectNSDefs() throws Exception {
         String base = System.getProperty("basedir") == null ? "./"
                       : System.getProperty("basedir");

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java?rev=1309362&r1=1309361&r2=1309362&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java Wed Apr  4 12:59:30 2012
@@ -28,30 +28,19 @@ import java.security.*;
 import javax.crypto.SecretKey;
 import javax.crypto.spec.SecretKeySpec;
 
-import junit.framework.*;
-
 /**
  * Unit test for javax.xml.crypto.dsig.XMLValidateContext
  *
  * @version $Id$
  * @author Valerie Peng
  */
-public class XMLValidateContextTest extends TestCase {
+public class XMLValidateContextTest extends org.junit.Assert {
 
     private XMLValidateContext defContext;
     private Key[] KEYS;
     private KeySelector[] KEY_SELECTORS;
 
-    public XMLValidateContextTest() {
-        super("XMLValidateContextTest");
-    }
-
-    public XMLValidateContextTest(String name) {
-        super(name);
-    }
-
-    public void setUp() throws Exception {
-
+    public XMLValidateContextTest() throws Exception {
         // set up the validatingKeys
         KEYS = new Key[3];
         KEYS[0] = TestUtils.getPublicKey("DSA");
@@ -67,8 +56,7 @@ public class XMLValidateContextTest exte
         KEY_SELECTORS[0] = KeySelector.singletonKeySelector(sk);
     }
 
-    public void tearDown() { }
-
+    @org.junit.Test
     public void testsetngetKeySelector() throws Exception {
         defContext.setKeySelector(null);
         assertNull(defContext.getKeySelector());
@@ -79,6 +67,7 @@ public class XMLValidateContextTest exte
         }
     }
 
+    @org.junit.Test
     public void testsetngetBaseURI() throws Exception {
         assertNull(defContext.getBaseURI());
 
@@ -89,6 +78,7 @@ public class XMLValidateContextTest exte
         assertNull(defContext.getBaseURI());
     }
 
+    @org.junit.Test
     public void testsetngetProperty() throws Exception {
         String name = "key";
         assertNull(defContext.getProperty(name));
@@ -109,6 +99,7 @@ public class XMLValidateContextTest exte
         assertNull(defContext.getProperty(name));
     }
 
+    @org.junit.Test
     public void testsetngetURIDereferencer() throws Exception {
         assertNull(defContext.getURIDereferencer());
         byte[] data = "simpleDereferencer".getBytes();