commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1185712 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
Date Tue, 18 Oct 2011 15:11:02 GMT
Author: ggregory
Date: Tue Oct 18 15:11:02 2011
New Revision: 1185712

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

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

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java?rev=1185712&r1=1185711&r2=1185712&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java
Tue Oct 18 15:11:02 2011
@@ -16,20 +16,19 @@
  */
 package org.apache.commons.lang3.builder;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.math.BigInteger;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * Unit tests {@link org.apache.commons.lang3.builder.CompareToBuilder}.
  *
  * @version $Id$
  */
-public class CompareToBuilderTest extends TestCase {
-
-    public CompareToBuilderTest(String name) {
-        super(name);
-    }
+public class CompareToBuilderTest {
 
     //-----------------------------------------------------------------------
 
@@ -93,6 +92,7 @@ public class CompareToBuilderTest extend
         }
     }
     
+    @Test
     public void testReflectionCompare() {
         TestObject o1 = new TestObject(4);
         TestObject o2 = new TestObject(4);
@@ -103,6 +103,7 @@ public class CompareToBuilderTest extend
         assertTrue(CompareToBuilder.reflectionCompare(o2, o1) > 0);
     }
 
+    @Test
     public void testReflectionCompareEx1() {
         TestObject o1 = new TestObject(4);
         try {
@@ -113,6 +114,7 @@ public class CompareToBuilderTest extend
         fail();
     }
 
+    @Test
     public void testReflectionCompareEx2() {
         TestObject o1 = new TestObject(4);
         Object o2 = new Object();
@@ -122,10 +124,12 @@ public class CompareToBuilderTest extend
         } catch (ClassCastException ex) {}
     }
 
+    @Test
     public void testReflectionHierarchyCompare() {
         testReflectionHierarchyCompare(false, null);
     }
     
+    @Test
     public void testReflectionHierarchyCompareExcludeFields() {
         String[] excludeFields = new String[] { "b" };
         testReflectionHierarchyCompare(true, excludeFields);
@@ -145,6 +149,7 @@ public class CompareToBuilderTest extend
         assertXYZCompareOrder(x, y, z, true, excludeFields);
     }
     
+    @Test
     public void testReflectionHierarchyCompareTransients() {
         testReflectionHierarchyCompare(true, null);
 
@@ -177,7 +182,7 @@ public class CompareToBuilderTest extend
         assertTrue(0 < CompareToBuilder.reflectionCompare(z, y, testTransients, null,
excludeFields));
     }
     
-    public void testReflectionHierarchyCompare(boolean testTransients, String[] excludeFields)
{
+    private void testReflectionHierarchyCompare(boolean testTransients, String[] excludeFields)
{
         TestObject to1 = new TestObject(1);
         TestObject to2 = new TestObject(2);
         TestObject to3 = new TestObject(3);
@@ -209,7 +214,7 @@ public class CompareToBuilderTest extend
      * @param testTransients Whether to include transients in the comparison
      * @param excludeFields fields to exclude
      */
-    public void assertReflectionCompareContract(Object x, Object y, Object z, boolean testTransients,
String[] excludeFields) {
+    private void assertReflectionCompareContract(Object x, Object y, Object z, boolean testTransients,
String[] excludeFields) {
 
         // signum
         assertTrue(reflectionCompareSignum(x, y, testTransients, excludeFields) == -reflectionCompareSignum(y,
x, testTransients, excludeFields));
@@ -243,6 +248,7 @@ public class CompareToBuilderTest extend
         return BigInteger.valueOf(CompareToBuilder.reflectionCompare(lhs, rhs, testTransients)).signum();
     }
     
+    @Test
     public void testAppendSuper() {
         TestObject o1 = new TestObject(4);
         TestObject o2 = new TestObject(5);
@@ -257,6 +263,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().appendSuper(1).append(o1, o2).toComparison() >
0);
     }
     
+    @Test
     public void testObject() {
         TestObject o1 = new TestObject(4);
         TestObject o2 = new TestObject(4);
@@ -271,6 +278,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, o1).toComparison() < 0);
     }
     
+    @Test
     public void testObjectBuild() {
         TestObject o1 = new TestObject(4);
         TestObject o2 = new TestObject(4);
@@ -285,6 +293,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, o1).build() < 0);
     }
 
+    @Test
     public void testObjectEx2() {
         TestObject o1 = new TestObject(4);
         Object o2 = new Object();
@@ -294,6 +303,7 @@ public class CompareToBuilderTest extend
         } catch (ClassCastException ex) {}
     }
 
+    @Test
     public void testObjectComparator() {
         String o1 = "Fred";
         String o2 = "Fred";
@@ -311,6 +321,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, o1, String.CASE_INSENSITIVE_ORDER).toComparison()
< 0);
     }
     
+    @Test
     public void testObjectComparatorNull() {
         String o1 = "Fred";
         String o2 = "Fred";
@@ -325,6 +336,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, o1, null).toComparison() < 0);
     }
 
+    @Test
     public void testLong() {
         long o1 = 1L;
         long o2 = 2L;
@@ -337,6 +349,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(Long.MIN_VALUE, o1).toComparison() <
0);
     }
 
+    @Test
     public void testInt() {
         int o1 = 1;
         int o2 = 2;
@@ -349,6 +362,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(Integer.MIN_VALUE, o1).toComparison() <
0);
     }
 
+    @Test
     public void testShort() {
         short o1 = 1;
         short o2 = 2;
@@ -361,6 +375,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(Short.MIN_VALUE, o1).toComparison() <
0);
     }
 
+    @Test
     public void testChar() {
         char o1 = 1;
         char o2 = 2;
@@ -373,6 +388,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(Character.MIN_VALUE, o1).toComparison()
< 0);
     }
 
+    @Test
     public void testByte() {
         byte o1 = 1;
         byte o2 = 2;
@@ -385,6 +401,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(Byte.MIN_VALUE, o1).toComparison() <
0);
     }
 
+    @Test
     public void testDouble() {
         double o1 = 1;
         double o2 = 2;
@@ -405,6 +422,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(0.0, -0.0).toComparison() > 0);
     }
 
+    @Test
     public void testFloat() {
         float o1 = 1;
         float o2 = 2;
@@ -425,6 +443,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(0.0, -0.0).toComparison() > 0);
     }
 
+    @Test
     public void testBoolean() {
         boolean o1 = true;
         boolean o2 = false;
@@ -434,6 +453,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(o2, o1).toComparison() < 0);
     }
 
+    @Test
     public void testObjectArray() {
         TestObject[] obj1 = new TestObject[2];
         obj1[0] = new TestObject(4);
@@ -460,6 +480,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testLongArray() {
         long[] obj1 = new long[2];
         obj1[0] = 5L;
@@ -486,6 +507,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testIntArray() {
         int[] obj1 = new int[2];
         obj1[0] = 5;
@@ -512,6 +534,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testShortArray() {
         short[] obj1 = new short[2];
         obj1[0] = 5;
@@ -538,6 +561,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testCharArray() {
         char[] obj1 = new char[2];
         obj1[0] = 5;
@@ -564,6 +588,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testByteArray() {
         byte[] obj1 = new byte[2];
         obj1[0] = 5;
@@ -590,6 +615,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testDoubleArray() {
         double[] obj1 = new double[2];
         obj1[0] = 5;
@@ -616,6 +642,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testFloatArray() {
         float[] obj1 = new float[2];
         obj1[0] = 5;
@@ -642,6 +669,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testBooleanArray() {
         boolean[] obj1 = new boolean[2];
         obj1[0] = true;
@@ -668,6 +696,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiLongArray() {
         long[][] array1 = new long[2][2];
         long[][] array2 = new long[2][2];
@@ -691,6 +720,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiIntArray() {
         int[][] array1 = new int[2][2];
         int[][] array2 = new int[2][2];
@@ -714,6 +744,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiShortArray() {
         short[][] array1 = new short[2][2];
         short[][] array2 = new short[2][2];
@@ -737,6 +768,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiCharArray() {
         char[][] array1 = new char[2][2];
         char[][] array2 = new char[2][2];
@@ -760,6 +792,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiByteArray() {
         byte[][] array1 = new byte[2][2];
         byte[][] array2 = new byte[2][2];
@@ -783,6 +816,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
     
+    @Test
     public void testMultiFloatArray() {
         float[][] array1 = new float[2][2];
         float[][] array2 = new float[2][2];
@@ -806,6 +840,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiDoubleArray() {
         double[][] array1 = new double[2][2];
         double[][] array2 = new double[2][2];
@@ -829,6 +864,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMultiBooleanArray() {
         boolean[][] array1 = new boolean[2][2];
         boolean[][] array2 = new boolean[2][2];
@@ -852,6 +888,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testRaggedArray() {
         long array1[][] = new long[2][];
         long array2[][] = new long[2][];
@@ -879,6 +916,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testMixedArray() {
         Object array1[] = new Object[2];
         Object array2[] = new Object[2];
@@ -904,6 +942,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0);
     }
 
+    @Test
     public void testObjectArrayHiddenByObject() {
         TestObject[] array1 = new TestObject[2];
         array1[0] = new TestObject(4);
@@ -930,6 +969,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testLongArrayHiddenByObject() {
         long[] array1 = new long[2];
         array1[0] = 5L;
@@ -954,6 +994,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testIntArrayHiddenByObject() {
         int[] array1 = new int[2];
         array1[0] = 5;
@@ -978,6 +1019,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testShortArrayHiddenByObject() {
         short[] array1 = new short[2];
         array1[0] = 5;
@@ -1002,6 +1044,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testCharArrayHiddenByObject() {
         char[] array1 = new char[2];
         array1[0] = 5;
@@ -1026,6 +1069,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testByteArrayHiddenByObject() {
         byte[] array1 = new byte[2];
         array1[0] = 5;
@@ -1050,6 +1094,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testDoubleArrayHiddenByObject() {
         double[] array1 = new double[2];
         array1[0] = 5;
@@ -1074,6 +1119,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testFloatArrayHiddenByObject() {
         float[] array1 = new float[2];
         array1[0] = 5;
@@ -1098,6 +1144,7 @@ public class CompareToBuilderTest extend
         assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0);
     }
 
+    @Test
     public void testBooleanArrayHiddenByObject() {
         boolean[] array1 = new boolean[2];
         array1[0] = true;



Mime
View raw message