harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r556832 - /harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java
Date Tue, 17 Jul 2007 07:17:52 GMT
Author: tonywu
Date: Tue Jul 17 00:17:49 2007
New Revision: 556832

URL: http://svn.apache.org/viewvc?view=rev&rev=556832
Log:
Refactor testcases, make it more clear

Modified:
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java?view=diff&rev=556832&r1=556831&r2=556832
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java
Tue Jul 17 00:17:49 2007
@@ -17,11 +17,8 @@
 
 package org.apache.harmony.sql.tests.java.sql;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-
 import junit.framework.TestCase;
+import static java.sql.Types.*;
 
 public class TypesTest extends TestCase {
 
@@ -29,73 +26,35 @@
      * Public statics test
      */
     public void testPublicStatics() {
-
-        HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
-        thePublicStatics.put("BOOLEAN", new Integer(16));
-        thePublicStatics.put("DATALINK", new Integer(70));
-        thePublicStatics.put("REF", new Integer(2006));
-        thePublicStatics.put("CLOB", new Integer(2005));
-        thePublicStatics.put("BLOB", new Integer(2004));
-        thePublicStatics.put("ARRAY", new Integer(2003));
-        thePublicStatics.put("STRUCT", new Integer(2002));
-        thePublicStatics.put("DISTINCT", new Integer(2001));
-        thePublicStatics.put("JAVA_OBJECT", new Integer(2000));
-        thePublicStatics.put("OTHER", new Integer(1111));
-        thePublicStatics.put("NULL", new Integer(0));
-        thePublicStatics.put("LONGVARBINARY", new Integer(-4));
-        thePublicStatics.put("VARBINARY", new Integer(-3));
-        thePublicStatics.put("BINARY", new Integer(-2));
-        thePublicStatics.put("TIMESTAMP", new Integer(93));
-        thePublicStatics.put("TIME", new Integer(92));
-        thePublicStatics.put("DATE", new Integer(91));
-        thePublicStatics.put("LONGVARCHAR", new Integer(-1));
-        thePublicStatics.put("VARCHAR", new Integer(12));
-        thePublicStatics.put("CHAR", new Integer(1));
-        thePublicStatics.put("DECIMAL", new Integer(3));
-        thePublicStatics.put("NUMERIC", new Integer(2));
-        thePublicStatics.put("DOUBLE", new Integer(8));
-        thePublicStatics.put("REAL", new Integer(7));
-        thePublicStatics.put("FLOAT", new Integer(6));
-        thePublicStatics.put("BIGINT", new Integer(-5));
-        thePublicStatics.put("INTEGER", new Integer(4));
-        thePublicStatics.put("SMALLINT", new Integer(5));
-        thePublicStatics.put("TINYINT", new Integer(-6));
-        thePublicStatics.put("BIT", new Integer(-7));
-
-        Class<?> typesClass;
-        try {
-            typesClass = Class.forName("java.sql.Types");
-        } catch (ClassNotFoundException e) {
-            fail("java.sql.Types class not found!");
-            return;
-        } // end try
-
-        Field[] theFields = typesClass.getDeclaredFields();
-        int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
-                + Modifier.FINAL;
-
-        int countPublicStatics = 0;
-        for (Field element : theFields) {
-            String fieldName = element.getName();
-            int theMods = element.getModifiers();
-            if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
-                try {
-                    Object fieldValue = element.get(null);
-                    Object expectedValue = thePublicStatics.get(fieldName);
-                    if (expectedValue == null) {
-                        fail("Field " + fieldName + " missing!");
-                    } // end
-                    assertEquals("Field " + fieldName + " value mismatch: ",
-                            expectedValue, fieldValue);
-                    assertEquals("Field " + fieldName + " modifier mismatch: ",
-                            requiredModifier, theMods);
-                    countPublicStatics++;
-                } catch (IllegalAccessException e) {
-                    fail("Illegal access to Field " + fieldName);
-                } // end try
-            } // end if
-        } // end for
-
-    } // end method testPublicStatics
-
-} // end class TypesTest
+        assertEquals(ARRAY, 2003);
+        assertEquals(BIGINT, -5);
+        assertEquals(BINARY, -2);
+        assertEquals(BIT, -7);
+        assertEquals(BLOB, 2004);
+        assertEquals(BOOLEAN, 16);
+        assertEquals(CHAR, 1);
+        assertEquals(CLOB, 2005);
+        assertEquals(DATALINK, 70);
+        assertEquals(DATE, 91);
+        assertEquals(DECIMAL, 3);
+        assertEquals(DISTINCT, 2001);
+        assertEquals(DOUBLE, 8);
+        assertEquals(FLOAT, 6);
+        assertEquals(INTEGER, 4);
+        assertEquals(JAVA_OBJECT, 2000);
+        assertEquals(LONGVARBINARY, -4);
+        assertEquals(LONGVARCHAR, -1);
+        assertEquals(NULL, 0);
+        assertEquals(NUMERIC, 2);
+        assertEquals(OTHER, 1111);
+        assertEquals(REAL, 7);
+        assertEquals(REF, 2006);
+        assertEquals(SMALLINT, 5);
+        assertEquals(STRUCT, 2002);
+        assertEquals(TIME, 92);
+        assertEquals(TIMESTAMP, 93);
+        assertEquals(TINYINT, -6);
+        assertEquals(VARBINARY, -3);
+        assertEquals(VARCHAR, 12);
+    }
+}



Mime
View raw message