directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r754793 - in /directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives: BitStringTest.java OIDTest.java PrimitivesTest.java
Date Sun, 15 Mar 2009 23:50:05 GMT
Author: elecharny
Date: Sun Mar 15 23:50:04 2009
New Revision: 754793

URL: http://svn.apache.org/viewvc?rev=754793&view=rev
Log:
Switched to JUNIT 4.4

Modified:
    directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java
    directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
    directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/PrimitivesTest.java

Modified: directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java?rev=754793&r1=754792&r2=754793&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java
(original)
+++ directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java
Sun Mar 15 23:50:04 2009
@@ -20,11 +20,12 @@
 package org.apache.directory.shared.asn1.primitives;
 
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.util.Asn1StringUtils;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -32,7 +33,7 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class BitStringTest extends TestCase
+public class BitStringTest
 {
     // ~ Methods
     // ------------------------------------------------------------------------------------
@@ -40,6 +41,7 @@
     /**
      * Test a null BitString
      */
+    @Test
     public void testBitStringNull()
     {
 
@@ -50,11 +52,11 @@
         try
         {
             bitString.getBit( 0 );
-            Assert.fail( "Should not reach this point ..." );
+            fail( "Should not reach this point ..." );
         }
         catch ( IndexOutOfBoundsException ioobe )
         {
-            Assert.assertTrue( true );
+            assertTrue( true );
         }
     }
 
@@ -62,6 +64,7 @@
     /**
      * Test an empty BitString
      */
+    @Test
     public void testBitStringEmpty()
     {
 
@@ -73,11 +76,11 @@
         try
         {
             bitString.getBit( 0 );
-            Assert.fail( "Should not reach this point ..." );
+            fail( "Should not reach this point ..." );
         }
         catch ( IndexOutOfBoundsException ioobe )
         {
-            Assert.assertTrue( true );
+            assertTrue( true );
         }
     }
 
@@ -85,6 +88,7 @@
     /**
      * Test a single bit BitString
      */
+    @Test
     public void testSingleBitBitString() throws DecoderException
     {
 
@@ -93,13 +97,14 @@
         bitString.setData( new byte[]
             { 0x07, ( byte ) 0x80 } );
 
-        Assert.assertEquals( true, bitString.getBit( 0 ) );
+        assertEquals( true, bitString.getBit( 0 ) );
     }
 
 
     /**
      * Test a 32 bits BitString
      */
+    @Test
     public void test32BitsBitString() throws DecoderException
     {
 
@@ -110,7 +115,7 @@
 
         for ( int i = 0; i < 32; i++ )
         {
-            Assert.assertEquals( true, bitString.getBit( i ) );
+            assertEquals( true, bitString.getBit( i ) );
         }
     }
 
@@ -118,6 +123,7 @@
     /**
      * Test a 33 bits BitString
      */
+    @Test
     public void test33BitsBitString() throws DecoderException
     {
 
@@ -128,16 +134,17 @@
 
         for ( int i = 0; i < 33; i++ )
         {
-            Assert.assertEquals( true, bitString.getBit( i ) );
+            assertEquals( true, bitString.getBit( i ) );
         }
 
-        Assert.assertEquals( true, bitString.getBit( 32 ) );
+        assertEquals( true, bitString.getBit( 32 ) );
     }
 
 
     /**
      * Test all bits from 0 to 128 BitString
      */
+    @Test
     public void test0to128BitString() throws DecoderException
     {
 
@@ -149,7 +156,7 @@
 
         for ( int i = 0; i < 14; i++ )
         {
-            Assert.assertEquals( true, bitString14.getBit( i ) );
+            assertEquals( true, bitString14.getBit( i ) );
         }
 
         // bit number 31
@@ -160,7 +167,7 @@
 
         for ( int i = 0; i < 31; i++ )
         {
-            Assert.assertEquals( true, bitString31.getBit( i ) );
+            assertEquals( true, bitString31.getBit( i ) );
         }
 
         // bit number 128
@@ -173,10 +180,11 @@
 
         for ( int i = 0; i < 128; i++ )
         {
-            Assert.assertEquals( true, bitString128.getBit( i ) );
+            assertEquals( true, bitString128.getBit( i ) );
         }
     }
     
+    @Test
     public void testBitStringSet()
     {
         BitString bitString = new BitString( 32 );
@@ -203,6 +211,7 @@
         assertEquals( Asn1StringUtils.dumpBytes( bytes ), Asn1StringUtils.dumpBytes( bitString.getData()
) );
     }
 
+    @Test
     public void testBitStringSetBit()
     {
         BitString bitString = new BitString( 32 );
@@ -230,6 +239,7 @@
         assertEquals( Asn1StringUtils.dumpBytes( bytesModified ), Asn1StringUtils.dumpBytes(
bitString.getData() ) );
     }
 
+    @Test
     public void testBitStringClearBit()
     {
         BitString bitString = new BitString( 32 );

Modified: directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java?rev=754793&r1=754792&r2=754793&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
(original)
+++ directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
Sun Mar 15 23:50:04 2009
@@ -20,10 +20,12 @@
 package org.apache.directory.shared.asn1.primitives;
 
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
 import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 
 /**
@@ -31,7 +33,7 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class OIDTest extends TestCase
+public class OIDTest
 {
     // ~ Methods
     // ------------------------------------------------------------------------------------
@@ -39,6 +41,7 @@
     /**
      * Test a null OID
      */
+    @Test
     public void testOidNull()
     {
 
@@ -47,11 +50,11 @@
         try
         {
             oid.setOID( ( byte[] ) null );
-            Assert.fail( "Should not reach this point ..." );
+            fail( "Should not reach this point ..." );
         }
         catch ( DecoderException de )
         {
-            Assert.assertTrue( true );
+            assertTrue( true );
         }
     }
 
@@ -59,6 +62,7 @@
     /**
      * Test an empty OID
      */
+    @Test
     public void testOidEmpty()
     {
 
@@ -68,11 +72,11 @@
         {
             oid.setOID( new byte[]
                 {} );
-            Assert.fail( "Should not reach this point ..." );
+            fail( "Should not reach this point ..." );
         }
         catch ( DecoderException de )
         {
-            Assert.assertTrue( true );
+            assertTrue( true );
         }
     }
 
@@ -80,6 +84,7 @@
     /**
      * Test itu-t OID tree
      */
+    @Test
     public void testOidItuT()
     {
 
@@ -93,20 +98,20 @@
             {
                 oid.setOID( new byte[]
                     { 0x00, ( byte ) i } );
-                Assert.assertEquals( "0.0." + i, oid.toString() );
+                assertEquals( "0.0." + i, oid.toString() );
             }
 
             // itu-t(0), question(1)
             oid.setOID( new byte[]
                 { 0x01 } );
-            Assert.assertEquals( "0.1", oid.toString() );
+            assertEquals( "0.1", oid.toString() );
 
             // itu-t(0), administration(2), country(202 .. 748)
             for ( int i = 202; i < 748; i++ )
             {
                 oid.setOID( new byte[]
                     { 0x02, ( byte ) ( ( i / 128 ) | 0x0080 ), ( byte ) ( i % 128 ) } );
-                Assert.assertEquals( "0.2." + i, oid.toString() );
+                assertEquals( "0.2." + i, oid.toString() );
             }
 
             // itu-t(0), network-operator(3), operator(2023 .. 41363)
@@ -117,21 +122,21 @@
                 {
                     oid.setOID( new byte[]
                         { 0x03, ( byte ) ( ( i / 128 ) | 0x0080 ), ( byte ) ( i % 128 ) }
);
-                    Assert.assertEquals( "0.3." + i, oid.toString() );
+                    assertEquals( "0.3." + i, oid.toString() );
                 }
                 else
                 {
                     oid.setOID( new byte[]
                         { 0x03, ( byte ) ( ( i / ( 128 * 128 ) ) | 0x0080 ),
                             ( byte ) ( ( ( i / 128 ) % 128 ) | 0x0080 ), ( byte ) ( i % 128
) } );
-                    Assert.assertEquals( "0.3." + i, oid.toString() );
+                    assertEquals( "0.3." + i, oid.toString() );
 
                 }
             }
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
@@ -139,6 +144,7 @@
     /**
      * Test iso OID tree
      */
+    @Test
     public void testOidIso()
     {
 
@@ -150,26 +156,26 @@
             // iso(1), standard(0)
             oid.setOID( new byte[]
                 { 40 + 0 } );
-            Assert.assertEquals( "1.0", oid.toString() );
+            assertEquals( "1.0", oid.toString() );
 
             // iso(1), registration-authority(1)
             oid.setOID( new byte[]
                 { 40 + 1 } );
-            Assert.assertEquals( "1.1", oid.toString() );
+            assertEquals( "1.1", oid.toString() );
 
             // iso(1), member-body(2)
             oid.setOID( new byte[]
                 { 40 + 2 } );
-            Assert.assertEquals( "1.2", oid.toString() );
+            assertEquals( "1.2", oid.toString() );
 
             // iso(1), identified-organization(3) | org(3) | organization(3)
             oid.setOID( new byte[]
                 { 40 + 3 } );
-            Assert.assertEquals( "1.3", oid.toString() );
+            assertEquals( "1.3", oid.toString() );
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
@@ -177,6 +183,7 @@
     /**
      * Test joint-iso-itu-t OID tree
      */
+    @Test
     public void testOidJointIsoItuT()
     {
 
@@ -188,38 +195,38 @@
             // joint-iso-itu-t(2), presentation(0)
             oid.setOID( new byte[]
                 { 80 + 0 } );
-            Assert.assertEquals( "2.0", oid.toString() );
+            assertEquals( "2.0", oid.toString() );
 
             // joint-iso-itu-t(2), asn1(1)
             oid.setOID( new byte[]
                 { 80 + 1 } );
-            Assert.assertEquals( "2.1", oid.toString() );
+            assertEquals( "2.1", oid.toString() );
 
             // joint-iso-itu-t(2), association-control(2)
             oid.setOID( new byte[]
                 { 80 + 2 } );
-            Assert.assertEquals( "2.2", oid.toString() );
+            assertEquals( "2.2", oid.toString() );
 
             // joint-iso-itu-t(2), reliable-transfer(3)
             oid.setOID( new byte[]
                 { 80 + 3 } );
-            Assert.assertEquals( "2.3", oid.toString() );
+            assertEquals( "2.3", oid.toString() );
 
             // ...
             // joint-iso-itu-t(2), upu(40)
             oid.setOID( new byte[]
                 { 80 + 40 } );
-            Assert.assertEquals( "2.40", oid.toString() );
+            assertEquals( "2.40", oid.toString() );
 
             // ...
             // joint-iso-itu-t(2), xxx(100)
             oid.setOID( new byte[]
                 { ( byte ) ( 0x81 ), 0x34 } );
-            Assert.assertEquals( "2.100", oid.toString() );
+            assertEquals( "2.100", oid.toString() );
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
@@ -227,6 +234,7 @@
     /**
      * Test valid String OIDs
      */
+    @Test
     public void testOidStringGood()
     {
 
@@ -235,23 +243,23 @@
         try
         {
             oid.setOID( "0.0" );
-            Assert.assertEquals( "0.0", oid.toString() );
+            assertEquals( "0.0", oid.toString() );
 
             oid.setOID( "0.0.0.0.0" );
-            Assert.assertEquals( "0.0.0.0.0", oid.toString() );
+            assertEquals( "0.0.0.0.0", oid.toString() );
 
             oid.setOID( "0.1.2.3.4" );
-            Assert.assertEquals( "0.1.2.3.4", oid.toString() );
+            assertEquals( "0.1.2.3.4", oid.toString() );
 
             oid.setOID( "2.123456" );
-            Assert.assertEquals( "2.123456", oid.toString() );
+            assertEquals( "2.123456", oid.toString() );
 
             oid.setOID( "1.2.840.113554.1.2.2" );
-            Assert.assertEquals( "1.2.840.113554.1.2.2", oid.toString() );
+            assertEquals( "1.2.840.113554.1.2.2", oid.toString() );
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
@@ -259,6 +267,7 @@
     /**
      * Test invalid String OIDs
      */
+    @Test
     public void testOidStringBad()
     {
         assertFalse( OID.isOID( "0" ) );
@@ -277,6 +286,7 @@
     /**
      * Test Spnego OID
      */
+    @Test
     public void testOidSpnego()
     {
 
@@ -287,11 +297,11 @@
             oid.setOID( new byte[]
                 { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 } );
 
-            Assert.assertEquals( "1.3.6.1.5.5.2", oid.toString() );
+            assertEquals( "1.3.6.1.5.5.2", oid.toString() );
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
@@ -299,6 +309,7 @@
     /**
      * Test Kerberos V5 OID
      */
+    @Test
     public void testOidKerberosV5()
     {
 
@@ -309,11 +320,11 @@
             oid.setOID( new byte[]
                 { 0x2a, ( byte ) 0x86, 0x48, ( byte ) 0x86, ( byte ) 0xf7, 0x12, 0x01, 0x02,
0x02 } );
 
-            Assert.assertEquals( "1.2.840.113554.1.2.2", oid.toString() );
+            assertEquals( "1.2.840.113554.1.2.2", oid.toString() );
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
@@ -321,6 +332,7 @@
     /**
      * Test OIDs bytes
      */
+    @Test
     public void testOidBytes()
     {
         OID oid = new OID();
@@ -330,33 +342,34 @@
         {
             oid.setOID( "0.0" );
             oid2.setOID( oid.getOID() );
-            Assert.assertEquals( oid.toString(), oid2.toString() );
+            assertEquals( oid.toString(), oid2.toString() );
 
             oid.setOID( "0.0.0.0.0" );
             oid2.setOID( oid.getOID() );
-            Assert.assertEquals( oid.toString(), oid2.toString() );
+            assertEquals( oid.toString(), oid2.toString() );
 
             oid.setOID( "0.1.2.3.4" );
             oid2.setOID( oid.getOID() );
-            Assert.assertEquals( oid.toString(), oid2.toString() );
+            assertEquals( oid.toString(), oid2.toString() );
 
             oid.setOID( "2.123456" );
             oid2.setOID( oid.getOID() );
-            Assert.assertEquals( oid.toString(), oid2.toString() );
+            assertEquals( oid.toString(), oid2.toString() );
 
             oid.setOID( "1.2.840.113554.1.2.2" );
             oid2.setOID( oid.getOID() );
-            Assert.assertEquals( oid.toString(), oid2.toString() );
+            assertEquals( oid.toString(), oid2.toString() );
         }
         catch ( DecoderException de )
         {
-            Assert.fail();
+            fail();
         }
     }
 
     /**
      * Test OID Equals
      */
+    @Test
     public void testOidEquals() throws DecoderException
     {
         OID oid1 = new OID();
@@ -371,6 +384,7 @@
     /**
      * Test OID Equals
      */
+    @Test
     public void testOidEqualsPerf() throws DecoderException
     {
         String s1 = "1.2.840.113554.1.2.2.1.2.840.113554.1.2.2.1.2.840.113554.1.2.2";

Modified: directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/PrimitivesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/PrimitivesTest.java?rev=754793&r1=754792&r2=754793&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/PrimitivesTest.java
(original)
+++ directory/shared/branches/shared-replication/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/PrimitivesTest.java
Sun Mar 15 23:50:04 2009
@@ -20,12 +20,11 @@
 package org.apache.directory.shared.asn1.primitives;
 
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.util.IntegerDecoder;
 import org.apache.directory.shared.asn1.util.IntegerDecoderException;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -33,11 +32,12 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PrimitivesTest extends TestCase
+public class PrimitivesTest
 {
     /**
      * Test the Integer Primitive
      */
+    @Test
     public void testIntegerPrimitive() throws IntegerDecoderException
     {
         Value value = new Value();
@@ -45,55 +45,55 @@
         value.init( 1 );
         value.setData( new byte[]
             { 0x00 } ); // res = 0
-        Assert.assertEquals( 0, IntegerDecoder.parse( value ) );
+        assertEquals( 0, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 1 );
         value.setData( new byte[]
             { 0x01 } ); // res = 1
-        Assert.assertEquals( 1, IntegerDecoder.parse( value ) );
+        assertEquals( 1, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 1 );
         value.setData( new byte[]
             { ( byte ) 0xFF } ); // res = 255
-        Assert.assertEquals( -1, IntegerDecoder.parse( value ) );
+        assertEquals( -1, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 2 );
         value.setData( new byte[]
             { 0x00, 0x01 } ); // res = 1
-        Assert.assertEquals( 1, IntegerDecoder.parse( value ) );
+        assertEquals( 1, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 2 );
         value.setData( new byte[]
             { 0x01, 0x00 } ); // res = 256
-        Assert.assertEquals( 256, IntegerDecoder.parse( value ) );
+        assertEquals( 256, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 2 );
         value.setData( new byte[]
             { 0x01, 0x01 } ); // res = 257
-        Assert.assertEquals( 257, IntegerDecoder.parse( value ) );
+        assertEquals( 257, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 2 );
         value.setData( new byte[]
             { 0x01, ( byte ) 0xFF } ); // res = 511
-        Assert.assertEquals( 511, IntegerDecoder.parse( value ) );
+        assertEquals( 511, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 2 );
         value.setData( new byte[]
             { 0x02, 0x00 } ); // res = 512
-        Assert.assertEquals( 512, IntegerDecoder.parse( value ) );
+        assertEquals( 512, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 3 );
         value.setData( new byte[]
             { 0x00, ( byte ) 0xFF, ( byte ) 0xFF } ); // res = 65535
-        Assert.assertEquals( 65535, IntegerDecoder.parse( value ) );
+        assertEquals( 65535, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 4 );
@@ -104,7 +104,7 @@
                                                                                 // - 1
                                                                                 // =
                                                                                 // MaxInt
-        Assert.assertEquals( Integer.MAX_VALUE, IntegerDecoder.parse( value ) );
+        assertEquals( Integer.MAX_VALUE, IntegerDecoder.parse( value ) );
         value.reset();
 
         value.init( 4 );
@@ -114,7 +114,7 @@
                                                                                 // 2^31
                                                                                 // =
                                                                                 // MinInt
-        Assert.assertEquals( Integer.MIN_VALUE, IntegerDecoder.parse( value ) );
+        assertEquals( Integer.MIN_VALUE, IntegerDecoder.parse( value ) );
         value.reset();
     }
 } // end class TLVTagDecoderTest



Mime
View raw message