commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1185705 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
Date Tue, 18 Oct 2011 14:59:56 GMT
Author: ggregory
Date: Tue Oct 18 14:59:56 2011
New Revision: 1185705

URL: http://svn.apache.org/viewvc?rev=1185705&view=rev
Log:
Port to JUnit 4.

Modified:
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java?rev=1185705&r1=1185704&r2=1185705&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
Tue Oct 18 14:59:56 2011
@@ -17,14 +17,18 @@
 
 package org.apache.commons.lang3.builder;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
 
 /**
  * Unit tests {@link org.apache.commons.lang3.builder.HashCodeBuilder}.
  * 
  * @version $Id$
  */
-public class HashCodeBuilderTest extends TestCase {
+public class HashCodeBuilderTest {
 
     /**
      * A reflection test fixture.
@@ -50,12 +54,9 @@ public class HashCodeBuilderTest extends
         }
     }
 
-    public HashCodeBuilderTest(String name) {
-        super(name);
-    }
-
     // -----------------------------------------------------------------------
 
+    @Test
     public void testConstructorEx1() {
         try {
             new HashCodeBuilder(0, 0);
@@ -66,6 +67,7 @@ public class HashCodeBuilderTest extends
         fail();
     }
 
+    @Test
     public void testConstructorEx2() {
         try {
             new HashCodeBuilder(2, 2);
@@ -133,11 +135,13 @@ public class HashCodeBuilderTest extends
         }
     }
 
+    @Test
     public void testReflectionHashCode() {
         assertEquals(17 * 37, HashCodeBuilder.reflectionHashCode(new TestObject(0)));
         assertEquals(17 * 37 + 123456, HashCodeBuilder.reflectionHashCode(new TestObject(123456)));
     }
 
+    @Test
     public void testReflectionHierarchyHashCode() {
         assertEquals(17 * 37 * 37, HashCodeBuilder.reflectionHashCode(new TestSubObject(0,
0, 0)));
         assertEquals(17 * 37 * 37 * 37, HashCodeBuilder.reflectionHashCode(new TestSubObject(0,
0, 0), true));
@@ -147,6 +151,7 @@ public class HashCodeBuilderTest extends
                 123456, 7890, 0), true));
     }
 
+    @Test
     public void testReflectionHierarchyHashCodeEx1() {
         try {
             HashCodeBuilder.reflectionHashCode(0, 0, new TestSubObject(0, 0, 0), true);
@@ -156,6 +161,7 @@ public class HashCodeBuilderTest extends
         fail();
     }
 
+    @Test
     public void testReflectionHierarchyHashCodeEx2() {
         try {
             HashCodeBuilder.reflectionHashCode(2, 2, new TestSubObject(0, 0, 0), true);
@@ -165,6 +171,7 @@ public class HashCodeBuilderTest extends
         fail();
     }
 
+    @Test
     public void testReflectionHashCodeEx1() {
         try {
             HashCodeBuilder.reflectionHashCode(0, 0, new TestObject(0), true);
@@ -174,6 +181,7 @@ public class HashCodeBuilderTest extends
         fail();
     }
 
+    @Test
     public void testReflectionHashCodeEx2() {
         try {
             HashCodeBuilder.reflectionHashCode(2, 2, new TestObject(0), true);
@@ -183,6 +191,7 @@ public class HashCodeBuilderTest extends
         fail();
     }
 
+    @Test
     public void testReflectionHashCodeEx3() {
         try {
             HashCodeBuilder.reflectionHashCode(13, 19, null, true);
@@ -192,12 +201,14 @@ public class HashCodeBuilderTest extends
         fail();
     }
 
+    @Test
     public void testSuper() {
         Object obj = new Object();
         assertEquals(17 * 37 + (19 * 41 + obj.hashCode()), new HashCodeBuilder(17, 37).appendSuper(
                 new HashCodeBuilder(19, 41).append(obj).toHashCode()).toHashCode());
     }
 
+    @Test
     public void testObject() {
         Object obj = null;
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -205,6 +216,7 @@ public class HashCodeBuilderTest extends
         assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
     
+    @Test
     public void testObjectBuild() {
         Object obj = null;
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).build().intValue());
@@ -212,6 +224,7 @@ public class HashCodeBuilderTest extends
         assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).build().intValue());
     }
 
+    @Test
     @SuppressWarnings("cast") // cast is not really needed, keep for consistency
     public void testLong() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long) 0L).toHashCode());
@@ -219,27 +232,32 @@ public class HashCodeBuilderTest extends
                 (long) 123456789L).toHashCode());
     }
 
+    @Test
     @SuppressWarnings("cast") // cast is not really needed, keep for consistency
     public void testInt() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int) 0).toHashCode());
         assertEquals(17 * 37 + 123456, new HashCodeBuilder(17, 37).append((int) 123456).toHashCode());
     }
 
+    @Test
     public void testShort() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short) 0).toHashCode());
         assertEquals(17 * 37 + 12345, new HashCodeBuilder(17, 37).append((short) 12345).toHashCode());
     }
 
+    @Test
     public void testChar() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char) 0).toHashCode());
         assertEquals(17 * 37 + 1234, new HashCodeBuilder(17, 37).append((char) 1234).toHashCode());
     }
 
+    @Test
     public void testByte() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte) 0).toHashCode());
         assertEquals(17 * 37 + 123, new HashCodeBuilder(17, 37).append((byte) 123).toHashCode());
     }
 
+    @Test
     @SuppressWarnings("cast") // cast is not really needed, keep for consistency
     public void testDouble() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double) 0d).toHashCode());
@@ -248,6 +266,7 @@ public class HashCodeBuilderTest extends
         assertEquals(17 * 37 + (int) (l ^ (l >> 32)), new HashCodeBuilder(17, 37).append(d).toHashCode());
     }
 
+    @Test
     @SuppressWarnings("cast") // cast is not really needed, keep for consistency
     public void testFloat() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float) 0f).toHashCode());
@@ -256,11 +275,13 @@ public class HashCodeBuilderTest extends
         assertEquals(17 * 37 + i, new HashCodeBuilder(17, 37).append(f).toHashCode());
     }
 
+    @Test
     public void testBoolean() {
         assertEquals(17 * 37 + 0, new HashCodeBuilder(17, 37).append(true).toHashCode());
         assertEquals(17 * 37 + 1, new HashCodeBuilder(17, 37).append(false).toHashCode());
     }
 
+    @Test
     public void testObjectArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((Object[]) null).toHashCode());
         Object[] obj = new Object[2];
@@ -272,6 +293,7 @@ public class HashCodeBuilderTest extends
                 .toHashCode());
     }
 
+    @Test
     public void testObjectArrayAsObject() {
         Object[] obj = new Object[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -282,6 +304,7 @@ public class HashCodeBuilderTest extends
                 (Object) obj).toHashCode());
     }
 
+    @Test
     public void testLongArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long[]) null).toHashCode());
         long[] obj = new long[2];
@@ -294,6 +317,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testLongArrayAsObject() {
         long[] obj = new long[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -305,6 +329,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testIntArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int[]) null).toHashCode());
         int[] obj = new int[2];
@@ -315,6 +340,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testIntArrayAsObject() {
         int[] obj = new int[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -324,6 +350,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testShortArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short[]) null).toHashCode());
         short[] obj = new short[2];
@@ -334,6 +361,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testShortArrayAsObject() {
         short[] obj = new short[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -343,6 +371,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testCharArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char[]) null).toHashCode());
         char[] obj = new char[2];
@@ -353,6 +382,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testCharArrayAsObject() {
         char[] obj = new char[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -362,6 +392,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testByteArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte[]) null).toHashCode());
         byte[] obj = new byte[2];
@@ -372,6 +403,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testByteArrayAsObject() {
         byte[] obj = new byte[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -381,6 +413,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testDoubleArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double[]) null).toHashCode());
         double[] obj = new double[2];
@@ -395,6 +428,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testDoubleArrayAsObject() {
         double[] obj = new double[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -408,6 +442,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testFloatArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float[]) null).toHashCode());
         float[] obj = new float[2];
@@ -420,6 +455,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testFloatArrayAsObject() {
         float[] obj = new float[2];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
@@ -431,6 +467,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testBooleanArray() {
         assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((boolean[]) null).toHashCode());
         boolean[] obj = new boolean[2];
@@ -441,6 +478,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testBooleanArrayAsObject() {
         boolean[] obj = new boolean[2];
         assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
@@ -450,6 +488,7 @@ public class HashCodeBuilderTest extends
         assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append((Object)
obj).toHashCode());
     }
 
+    @Test
     public void testBooleanMultiArray() {
         boolean[][] obj = new boolean[2][];
         assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
@@ -465,6 +504,7 @@ public class HashCodeBuilderTest extends
         assertEquals((((17 * 37 + 0) * 37 + 1) * 37 + 1), new HashCodeBuilder(17, 37).append(obj).toHashCode());
     }
 
+    @Test
     public void testReflectionHashCodeExcludeFields() throws Exception {
         TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
 
@@ -503,6 +543,7 @@ public class HashCodeBuilderTest extends
     /**
      * Test Objects pointing to each other.
      */
+    @Test
     public void testReflectionObjectCycle() {
         ReflectionTestCycleA a = new ReflectionTestCycleA();
         ReflectionTestCycleB b = new ReflectionTestCycleB();
@@ -535,6 +576,7 @@ public class HashCodeBuilderTest extends
     /**
      * Ensures LANG-520 remains true
      */
+    @Test
     public void testToHashCodeEqualsHashCode() {
         HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
         assertEquals("hashCode() is no longer returning the same value as toHashCode() -
see LANG-520", 



Mime
View raw message