You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2013/03/20 14:28:01 UTC

svn commit: r1458820 - in /commons/sandbox/openpgp/trunk: ./ src/test/java/org/apache/commons/openpgp/

Author: britter
Date: Wed Mar 20 13:28:01 2013
New Revision: 1458820

URL: http://svn.apache.org/r1458820
Log:
Update to JUnit 4.11

Modified:
    commons/sandbox/openpgp/trunk/pom.xml
    commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleKeyRingTest.java
    commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java
    commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignerTest.java

Modified: commons/sandbox/openpgp/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/pom.xml?rev=1458820&r1=1458819&r2=1458820&view=diff
==============================================================================
--- commons/sandbox/openpgp/trunk/pom.xml (original)
+++ commons/sandbox/openpgp/trunk/pom.xml Wed Mar 20 13:28:01 2013
@@ -21,7 +21,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.2</version>
+      <version>4.11</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -78,7 +78,7 @@
     <maven.compile.target>1.5</maven.compile.target>
     <commons.componentid>openpgp</commons.componentid>
     <commons.jira.componentid>12311187</commons.jira.componentid>
-  </properties> 
+  </properties>
 
 </project>
 

Modified: commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleKeyRingTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleKeyRingTest.java?rev=1458820&r1=1458819&r2=1458820&view=diff
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleKeyRingTest.java (original)
+++ commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleKeyRingTest.java Wed Mar 20 13:28:01 2013
@@ -17,18 +17,19 @@ package org.apache.commons.openpgp;
  * limitations under the License.
  */
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
+import org.junit.Before;
+import org.junit.Test;
+
 /**
  * Test the open pgp key ring.
- * 
+ *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
-public class BouncyCastleKeyRingTest extends TestCase
+public class BouncyCastleKeyRingTest
 {
     private String[] pubKeyId = { "A7D16BD4", "84C9113", "E6C2AB68" };
 
@@ -38,15 +39,15 @@ public class BouncyCastleKeyRingTest ext
 
     private static final String PASSWORD = "cop";
 
-    protected void setUp() throws Exception
+    @Before
+    public void setUp() throws Exception
     {
-        super.setUp();
-
         keyRing =
             new BouncyCastleKeyRing( getClass().getResourceAsStream( "/secring.gpg" ),
                                      getClass().getResourceAsStream( "/pubring.gpg" ), PASSWORD.toCharArray() );
     }
 
+    @Test
     public void testPublicKeys() throws OpenPgpException, IOException
     {
         for (String keyId : pubKeyId)
@@ -55,6 +56,7 @@ public class BouncyCastleKeyRingTest ext
         }
     }
 
+    @Test
     public void testSecretKeys() throws OpenPgpException, IOException
     {
         for (String keyId : secKeyId)

Modified: commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java?rev=1458820&r1=1458819&r2=1458820&view=diff
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java (original)
+++ commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java Wed Mar 20 13:28:01 2013
@@ -17,20 +17,24 @@ package org.apache.commons.openpgp;
  * limitations under the License.
  */
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
+import org.junit.Before;
+import org.junit.Test;
+
 /**
  * Test the open pgp signer.
- * 
+ *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @todo test text input as well as binary - apparently it fails cross platform
  */
 public class BouncyCastleOpenPgpSignerTest
-    extends TestCase
 {
     private OpenPgpSigner signer = new BouncyCastleOpenPgpSigner();
 
@@ -42,16 +46,16 @@ public class BouncyCastleOpenPgpSignerTe
 
     private static final String PASSWORD = "cop";
 
-    protected void setUp()
+    @Before
+    public void setUp()
         throws Exception
     {
-        super.setUp();
-
         keyRing =
             new BouncyCastleKeyRing( getClass().getResourceAsStream( "/secring.gpg" ),
                                      getClass().getResourceAsStream( "/pubring.gpg" ), PASSWORD.toCharArray() );
     }
 
+    @Test
     public void testSignDataDetachedBinary()
         throws OpenPgpException, IOException
     {
@@ -65,6 +69,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifySignatureDetachedBinary()
         throws IOException, OpenPgpException
     {
@@ -76,6 +81,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifySignatureDetachedBinaryGpg()
         throws IOException, OpenPgpException
     {
@@ -87,6 +93,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testSignDataDetachedAscii()
         throws OpenPgpException, IOException
     {
@@ -100,6 +107,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifySignatureDetachedAscii()
         throws IOException, OpenPgpException
     {
@@ -111,6 +119,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyMultipleSignatureDetachedAsciiBothGood()
         throws IOException, OpenPgpException
     {
@@ -122,6 +131,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyMultipleSignatureDetachedAsciiOneGoodOneBad()
         throws IOException, OpenPgpException
     {
@@ -134,6 +144,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyMultipleSignatureDetachedAsciiOneGoodOneMissing()
         throws IOException, OpenPgpException
     {
@@ -146,6 +157,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyMultipleSignatureDetachedAsciiOneBadOneGood()
         throws IOException, OpenPgpException
     {
@@ -170,21 +182,15 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }*/
 
+    @Test( expected = UnknownKeyException.class )
     public void testVerifyMultipleSignatureDetachedAsciiBothMissing()
         throws IOException, OpenPgpException
     {
-        try
-        {
-            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ),
+        verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ),
                                               getClass().getResourceAsStream( "/test-input-both-missing.asc" ), keyRing );
-            fail( "Expected failure due to missing keys" );
-        }
-        catch ( UnknownKeyException e )
-        {
-            assertTrue( true );
-        }
     }
 
+    @Test
     public void testVerifyDualSignatureDetachedAsciiBothGood()
         throws IOException, OpenPgpException
     {
@@ -196,6 +202,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyDualSignatureDetachedAsciiOneGoodOneMissing()
         throws IOException, OpenPgpException
     {
@@ -208,6 +215,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyDualSignatureDetachedAsciiBad()
         throws IOException, OpenPgpException
     {
@@ -220,6 +228,7 @@ public class BouncyCastleOpenPgpSignerTe
         assertFalse( "check it was not successful", status.isValid() );
     }
 
+    @Test
     public void testVerifyDualSignatureDetachedAsciiOneMissingOneGood()
         throws IOException, OpenPgpException
     {
@@ -232,18 +241,11 @@ public class BouncyCastleOpenPgpSignerTe
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test( expected = UnknownKeyException.class )
     public void testVerifyDualSignatureDetachedAsciiBothMissing()
         throws IOException, OpenPgpException
     {
-        try
-        {
-            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ),
-                                              getClass().getResourceAsStream( "/test-input-dual-both-missing.asc" ), keyRing );
-            fail( "Expected failure due to missing keys" );
-        }
-        catch ( UnknownKeyException e )
-        {
-            assertTrue( true );
-        }
+        verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ),
+                                          getClass().getResourceAsStream( "/test-input-dual-both-missing.asc" ), keyRing );
     }
 }

Modified: commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignerTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignerTest.java?rev=1458820&r1=1458819&r2=1458820&view=diff
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignerTest.java (original)
+++ commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignerTest.java Wed Mar 20 13:28:01 2013
@@ -17,11 +17,14 @@ package org.apache.commons.openpgp;
  * limitations under the License.
  */
 
+import static org.junit.Assert.*;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Test the open pgp signer.
@@ -30,7 +33,6 @@ import junit.framework.TestCase;
  * @todo test text input as well as binary - apparently it fails cross platform
  */
 public class BouncyCastleOpenPgpStreamingSignerTest
-    extends TestCase
 {
     private String keyId = "A7D16BD4";
 
@@ -38,15 +40,15 @@ public class BouncyCastleOpenPgpStreamin
 
     private static final String PASSWORD = "cop";
 
-    protected void setUp()
+    @Before
+    public void setUp()
         throws Exception
     {
-        super.setUp();
-
         keyRing = new BouncyCastleKeyRing( getClass().getResourceAsStream( "/secring.gpg" ),
                                            getClass().getResourceAsStream( "/pubring.gpg" ), PASSWORD.toCharArray() );
     }
 
+    @Test
     public void testSignDataDetachedBinary()
         throws OpenPgpException, IOException
     {
@@ -73,7 +75,7 @@ public class BouncyCastleOpenPgpStreamin
         }
 
         byte[] signature = signer.finish();
-        
+
         OpenPgpSignatureVerifier verifier = new BouncyCastleOpenPgpSignatureVerifier();
 
         SignatureStatus status =
@@ -83,6 +85,7 @@ public class BouncyCastleOpenPgpStreamin
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifySignatureDetachedBinary()
         throws IOException, OpenPgpException
     {
@@ -111,11 +114,12 @@ public class BouncyCastleOpenPgpStreamin
         }
 
         SignatureStatus status = verifier.finish();
-        
+
         assertNotNull( "check we got a status", status );
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifySignatureDetachedBinaryGpg()
         throws IOException, OpenPgpException
     {
@@ -149,6 +153,7 @@ public class BouncyCastleOpenPgpStreamin
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testSignDataDetachedAscii()
         throws OpenPgpException, IOException
     {
@@ -175,7 +180,7 @@ public class BouncyCastleOpenPgpStreamin
         }
 
         byte[] signature = signer.finish();
-        
+
         OpenPgpSignatureVerifier verifier = new BouncyCastleOpenPgpSignatureVerifier();
 
         SignatureStatus status =
@@ -185,6 +190,7 @@ public class BouncyCastleOpenPgpStreamin
         assertTrue( "check it was successful", status.isValid() );
     }
 
+    @Test
     public void testVerifySignatureDetachedAscii()
         throws IOException, OpenPgpException
     {
@@ -213,7 +219,7 @@ public class BouncyCastleOpenPgpStreamin
         }
 
         SignatureStatus status = verifier.finish();
-        
+
         assertNotNull( "check we got a status", status );
         assertTrue( "check it was successful", status.isValid() );
     }