commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcucchi...@apache.org
Subject svn commit: r1104080 [2/3] - in /incubator/ognl/trunk/src/test/java/org/apache/commons/ognl: ./ test/ test/accessors/ test/enhance/
Date Tue, 17 May 2011 09:22:11 GMT
Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java Tue May 17 09:22:09 2011
@@ -19,10 +19,19 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.commons.ognl.OgnlRuntime;
 import org.apache.commons.ognl.test.objects.CorrectedObject;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(value = Parameterized.class)
 public class NullHandlerTest
     extends OgnlTestCase
 {
@@ -37,79 +46,72 @@ public class NullHandlerTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new NullHandlerTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                     TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new NullHandlerTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                         TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new NullHandlerTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                             TESTS[i][2], TESTS[i][3], TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public NullHandlerTest()
-    {
-        super();
-    }
-
-    public NullHandlerTest( String name )
-    {
-        super( name );
-    }
-
     public NullHandlerTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
                             Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
 
-    public NullHandlerTest( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public NullHandlerTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
-
     /*
      * =================================================================== Overridden methods
      * ===================================================================
      */
+    @Override
+    @Before
     public void setUp()
     {
         super.setUp();
         _compileExpressions = false;
         OgnlRuntime.setNullHandler( CorrectedObject.class, new CorrectedObjectNullHandler( "corrected" ) );
     }
+
+    @Test
+
+    @Override
+    public void runTest()
+        throws Exception
+    {
+        super.runTest();
+    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java Tue May 17 09:22:09 2011
@@ -19,9 +19,17 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(value = Parameterized.class)
 public class NullStringCatenationTest
     extends OgnlTestCase
 {
@@ -51,70 +59,59 @@ public class NullStringCatenationTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new NullStringCatenationTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                              TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new NullStringCatenationTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                  (String) TESTS[i][1], TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new NullStringCatenationTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                      (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                      TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public NullStringCatenationTest()
-    {
-        super();
-    }
-
-    public NullStringCatenationTest( String name )
-    {
-        super( name );
-    }
-
     public NullStringCatenationTest( String name, Object root, String expressionString, Object expectedResult,
                                      Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
 
-    public NullStringCatenationTest( String name, Object root, String expressionString, Object expectedResult,
-                                     Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
+    @Test
 
-    public NullStringCatenationTest( String name, Object root, String expressionString, Object expectedResult )
+    @Override
+    public void runTest()
+        throws Exception
     {
-        super( name, root, expressionString, expectedResult );
+        super.runTest();
     }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumberFormatExceptionTest.java Tue May 17 09:22:09 2011
@@ -19,13 +19,18 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.OgnlException;
 import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
 
+@RunWith(value = Parameterized.class)
 public class NumberFormatExceptionTest
     extends OgnlTestCase
 {
@@ -33,14 +38,14 @@ public class NumberFormatExceptionTest
 
     private static Object[][] TESTS = {
         // NumberFormatException handling (default is to throw NumberFormatException on bad string conversions)
-        { SIMPLE, "floatValue", new Float( 0f ), new Float( 10f ), new Float( 10f ) },
-        { SIMPLE, "floatValue", new Float( 10f ), "x10x", OgnlException.class },
+        { SIMPLE, "floatValue", 0f, 10f, 10f },
+        { SIMPLE, "floatValue", 10f, "x10x", OgnlException.class },
 
-        { SIMPLE, "intValue", new Integer( 0 ), new Integer( 34 ), new Integer( 34 ) },
-        { SIMPLE, "intValue", new Integer( 34 ), "foobar", OgnlException.class },
-        { SIMPLE, "intValue", new Integer( 34 ), "", OgnlException.class },
-        { SIMPLE, "intValue", new Integer( 34 ), "       \t", OgnlException.class },
-        { SIMPLE, "intValue", new Integer( 34 ), "       \t1234\t\t", new Integer( 1234 ) },
+        { SIMPLE, "intValue", 0, 34, 34 },
+        { SIMPLE, "intValue", 34, "foobar", OgnlException.class },
+        { SIMPLE, "intValue", 34, "", OgnlException.class },
+        { SIMPLE, "intValue", 34, "       \t", OgnlException.class },
+        { SIMPLE, "intValue", 34, "       \t1234\t\t", 1234 },
 
         { SIMPLE, "bigIntValue", BigInteger.valueOf( 0 ), BigInteger.valueOf( 34 ), BigInteger.valueOf( 34 ) },
         { SIMPLE, "bigIntValue", BigInteger.valueOf( 34 ), null, null },
@@ -58,70 +63,50 @@ public class NumberFormatExceptionTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
-        for ( int i = 0; i < TESTS.length; i++ )
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
+        for ( Object[] TEST : TESTS )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new NumberFormatExceptionTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                               TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TEST[1];
+            tmp[1] = TEST[0];
+            tmp[2] = TEST[1];
+
+            switch ( TEST.length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new NumberFormatExceptionTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                   (String) TESTS[i][1], TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new NumberFormatExceptionTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                       (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                       TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TEST[2];
+                    break;
+
+                case 4:
+                    tmp[3] = TEST[2];
+                    tmp[4] = TEST[3];
+                    break;
+
+                case 5:
+                    tmp[3] = TEST[2];
+                    tmp[4] = TEST[3];
+                    tmp[5] = TEST[4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TEST.length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public NumberFormatExceptionTest()
-    {
-        super();
-    }
-
-    public NumberFormatExceptionTest( String name )
-    {
-        super( name );
-    }
-
     public NumberFormatExceptionTest( String name, Object root, String expressionString, Object expectedResult,
                                       Object setValue, Object expectedAfterSetResult )
     {
-        super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
-    }
-
-    public NumberFormatExceptionTest( String name, Object root, String expressionString, Object expectedResult,
-                                      Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public NumberFormatExceptionTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
+        super( name, root, expressionString, expectedResult, setValue, true, expectedAfterSetResult, true );
     }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java Tue May 17 09:22:09 2011
@@ -19,13 +19,22 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
-import org.apache.commons.ognl.OgnlException;
-import org.apache.commons.ognl.OgnlOps;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
 
+import org.apache.commons.ognl.OgnlException;
+import org.apache.commons.ognl.OgnlOps;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
 public class NumericConversionTest
     extends OgnlTestCase
 {
@@ -152,17 +161,21 @@ public class NumericConversionTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            result.addTest( new NumericConversionTest( TESTS[i][0], (Class) TESTS[i][1], TESTS[i][2],
-                                                       ( TESTS[i].length > 3 ) ? ( (Integer) TESTS[i][3] ).intValue()
-                                                                       : -1 ) );
+            Object[] tmp = new Object[4];
+            tmp[0] = TESTS[i][0];
+            tmp[1] = TESTS[i][1];
+            tmp[2] = TESTS[i][2];
+            tmp[3] = ( TESTS[i].length > 3 ) ? ( (Integer) TESTS[i][3] ).intValue() : -1 ;
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
@@ -173,7 +186,7 @@ public class NumericConversionTest
     {
         super( value + " [" + value.getClass().getName() + "] -> " + toClass.getName() + " == " + expectedValue + " ["
             + expectedValue.getClass().getName() + "]"
-            + ( ( scale >= 0 ) ? ( " (to within " + scale + " decimal places)" ) : "" ) );
+            + ( ( scale >= 0 ) ? ( " (to within " + scale + " decimal places)" ) : "" ), null, null, null, null, null );
         this.value = value;
         this.toClass = toClass;
         this.expectedValue = expectedValue;
@@ -184,7 +197,9 @@ public class NumericConversionTest
      * =================================================================== Overridden methods
      * ===================================================================
      */
-    protected void runTest()
+    @Test
+    @Override
+    public void runTest()
         throws OgnlException
     {
         Object result;

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java Tue May 17 09:22:09 2011
@@ -19,11 +19,17 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.OgnlException;
 import org.apache.commons.ognl.test.objects.Bean1;
 import org.apache.commons.ognl.test.objects.ObjectIndexed;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
 public class ObjectIndexedPropertyTest
     extends OgnlTestCase
 {
@@ -61,70 +67,50 @@ public class ObjectIndexedPropertyTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new ObjectIndexedPropertyTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                               TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new ObjectIndexedPropertyTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                   (String) TESTS[i][1], TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new ObjectIndexedPropertyTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                       (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                       TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public ObjectIndexedPropertyTest()
-    {
-        super();
-    }
-
-    public ObjectIndexedPropertyTest( String name )
-    {
-        super( name );
-    }
-
     public ObjectIndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult,
                                       Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public ObjectIndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult,
-                                      Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public ObjectIndexedPropertyTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ObjectIndexedTest.java Tue May 17 09:22:09 2011
@@ -26,6 +26,7 @@ import org.apache.commons.ognl.OgnlConte
 import org.apache.commons.ognl.OgnlException;
 import org.apache.commons.ognl.OgnlRuntime;
 import org.apache.commons.ognl.SimpleNode;
+import org.junit.Before;
 
 public class ObjectIndexedTest
     extends TestCase
@@ -252,8 +253,10 @@ public class ObjectIndexedTest
      * =================================================================== Overridden methods
      * ===================================================================
      */
+    @Override
+    @Before
     protected void setUp()
     {
         context = (OgnlContext) Ognl.createDefaultContext( null );
     }
-}
\ No newline at end of file
+}

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java Tue May 17 09:22:09 2011
@@ -19,17 +19,18 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestCase;
+import junit.framework.Assert;
 import org.apache.commons.ognl.Ognl;
 import org.apache.commons.ognl.OgnlContext;
 import org.apache.commons.ognl.SimpleNode;
+import org.junit.Before;
+import org.junit.Test;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.lang.reflect.Array;
 
-public class OgnlTestCase
-    extends TestCase
+public abstract class OgnlTestCase
 {
 
     protected OgnlContext _context;
@@ -56,37 +57,28 @@ public class OgnlTestCase
      * =================================================================== Public static methods
      * ===================================================================
      */
+
     /**
      * Returns true if object1 is equal to object2 in either the sense that they are the same object or, if both are
      * non-null if they are equal in the <CODE>equals()</CODE> sense.
      */
-    public static boolean isEqual( Object object1, Object object2 )
-    {
+    public static boolean isEqual(Object object1, Object object2) {
         boolean result = false;
 
-        if ( object1 == object2 )
-        {
+        if (object1 == object2) {
             result = true;
-        }
-        else
-        {
-            if ( ( object1 != null ) && object1.getClass().isArray() )
-            {
-                if ( ( object2 != null ) && object2.getClass().isArray() && ( object2.getClass() == object1.getClass() ) )
-                {
-                    result = ( Array.getLength( object1 ) == Array.getLength( object2 ) );
-                    if ( result )
-                    {
-                        for ( int i = 0, icount = Array.getLength( object1 ); result && ( i < icount ); i++ )
-                        {
-                            result = isEqual( Array.get( object1, i ), Array.get( object2, i ) );
+        } else {
+            if ((object1 != null) && object1.getClass().isArray()) {
+                if ((object2 != null) && object2.getClass().isArray() && (object2.getClass() == object1.getClass())) {
+                    result = (Array.getLength(object1) == Array.getLength(object2));
+                    if (result) {
+                        for (int i = 0, icount = Array.getLength(object1); result && (i < icount); i++) {
+                            result = isEqual(Array.get(object1, i), Array.get(object2, i));
                         }
                     }
                 }
-            }
-            else
-            {
-                result = ( object1 != null ) && ( object2 != null ) && object1.equals( object2 );
+            } else {
+                result = (object1 != null) && (object2 != null) && object1.equals(object2);
             }
         }
         return result;
@@ -96,109 +88,87 @@ public class OgnlTestCase
      * =================================================================== Constructors
      * ===================================================================
      */
-    public OgnlTestCase()
+    public OgnlTestCase(String name, Object root, String expressionString, Object expectedResult)
     {
-        super();
-    }
-
-    public OgnlTestCase( String name )
-    {
-        super( name );
+        this( name, root, expressionString, expectedResult, null, false, null, false);
     }
 
     public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue,
                          Object expectedAfterSetResult )
     {
-        this( name, root, expressionString, expectedResult, setValue );
-        this.hasExpectedAfterSetResult = true;
-        this.expectedAfterSetResult = expectedAfterSetResult;
+        this( name, root, expressionString, expectedResult, setValue, setValue != null, expectedAfterSetResult,
+              expectedAfterSetResult != null );
     }
 
-    public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        this( name, root, expressionString, expectedResult );
-        this.hasSetValue = true;
-        this.setValue = setValue;
-    }
-
-    public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult )
+    public OgnlTestCase( String name, Object root, String expressionString, Object expectedResult, Object setValue,
+                         boolean hasSetValue, Object expectedAfterSetResult, boolean hasExpectedAfterSetResult )
     {
-        this( name );
         this._root = root;
         this._expressionString = expressionString;
         this._expectedResult = expectedResult;
+
+        this.hasExpectedAfterSetResult = hasExpectedAfterSetResult;
+        this.expectedAfterSetResult = expectedAfterSetResult;
+        this.hasSetValue = hasSetValue;
+        this.setValue = setValue;
+
     }
 
     /*
      * =================================================================== Public methods
      * ===================================================================
      */
-    public String getExpressionDump( SimpleNode node )
-    {
+    public String getExpressionDump(SimpleNode node) {
         StringWriter writer = new StringWriter();
 
-        node.dump( new PrintWriter( writer ), "   " );
+        node.dump(new PrintWriter(writer), "   ");
         return writer.toString();
     }
 
-    public String getExpressionString()
-    {
+    public String getExpressionString() {
         return _expressionString;
     }
 
     public SimpleNode getExpression()
-        throws Exception
-    {
-        if ( _expression == null )
-        {
-            _expression = (SimpleNode) Ognl.parseExpression( _expressionString );
+            throws Exception {
+        if (_expression == null) {
+            _expression = (SimpleNode) Ognl.parseExpression(_expressionString);
         }
 
-        if ( _compileExpressions )
-        {
-            _expression = (SimpleNode) Ognl.compileExpression( _context, _root, _expressionString );
+        if (_compileExpressions) {
+            _expression = (SimpleNode) Ognl.compileExpression(_context, _root, _expressionString);
         }
 
         return _expression;
     }
 
-    public Object getExpectedResult()
-    {
+    public Object getExpectedResult() {
         return _expectedResult;
     }
 
-    public static void assertEquals( Object expected, Object actual )
-    {
-        if ( expected != null && expected.getClass().isArray() && actual != null && actual.getClass().isArray() )
-        {
+    public static void assertEquals(Object expected, Object actual) {
+        if (expected != null && expected.getClass().isArray() && actual != null && actual.getClass().isArray()) {
 
-            TestCase.assertEquals( Array.getLength( expected ), Array.getLength( actual ) );
+            Assert.assertEquals(Array.getLength(expected), Array.getLength(actual));
 
-            int length = Array.getLength( expected );
+            int length = Array.getLength(expected);
 
-            for ( int i = 0; i < length; i++ )
-            {
-                Object aexpected = Array.get( expected, i );
-                Object aactual = Array.get( actual, i );
+            for (int i = 0; i < length; i++) {
+                Object aexpected = Array.get(expected, i);
+                Object aactual = Array.get(actual, i);
 
-                if ( aexpected != null && aactual != null && Boolean.class.isAssignableFrom( aexpected.getClass() ) )
-                {
-                    TestCase.assertEquals( aexpected.toString(), aactual.toString() );
-                }
-                else
-                    OgnlTestCase.assertEquals( aexpected, aactual );
+                if (aexpected != null && aactual != null && Boolean.class.isAssignableFrom(aexpected.getClass())) {
+                    Assert.assertEquals(aexpected.toString(), aactual.toString());
+                } else
+                    OgnlTestCase.assertEquals(aexpected, aactual);
             }
-        }
-        else if ( expected != null && actual != null && Character.class.isInstance( expected )
-            && Character.class.isInstance( actual ) )
-        {
+        } else if (expected != null && actual != null && Character.class.isInstance(expected)
+                && Character.class.isInstance(actual)) {
 
-            TestCase.assertEquals( ( (Character) expected ).charValue(), ( (Character) actual ).charValue() );
-        }
-        else
-        {
+            Assert.assertEquals(((Character) expected).charValue(), ((Character) actual).charValue());
+        } else {
 
-            TestCase.assertEquals( expected, actual );
+            Assert.assertEquals(expected, actual);
         }
     }
 
@@ -206,50 +176,44 @@ public class OgnlTestCase
      * =================================================================== Overridden methods
      * ===================================================================
      */
-    protected void runTest()
-        throws Exception
-    {
+    @Test
+    public void runTest()
+            throws Exception {
         Object testedResult = null;
 
-        try
-        {
+        try {
             SimpleNode expr;
 
             testedResult = _expectedResult;
             expr = getExpression();
 
-            assertEquals( _expectedResult, Ognl.getValue( expr, _context, _root ) );
+            assertEquals(_expectedResult, Ognl.getValue(expr, _context, _root));
 
-            if ( hasSetValue )
-            {
+            if (hasSetValue) {
                 testedResult = hasExpectedAfterSetResult ? expectedAfterSetResult : setValue;
-                Ognl.setValue( expr, _context, _root, setValue );
+                Ognl.setValue(expr, _context, _root, setValue);
 
-                assertEquals( testedResult, Ognl.getValue( expr, _context, _root ) );
+                assertEquals(testedResult, Ognl.getValue(expr, _context, _root));
             }
 
-        }
-        catch ( Exception ex )
-        {
-            System.out.println( "Caught exception " + ex );
-            if ( NullPointerException.class.isInstance( ex ) )
+        } catch (Exception ex) {
+            System.out.println("Caught exception " + ex);
+            if (NullPointerException.class.isInstance(ex))
                 ex.printStackTrace();
 
-            if ( RuntimeException.class.isInstance( ex ) && ( (RuntimeException) ex ).getCause() != null
-                && Exception.class.isAssignableFrom( ( (RuntimeException) ex ).getCause().getClass() ) )
-                ex = (Exception) ( (RuntimeException) ex ).getCause();
-
-            if ( testedResult instanceof Class )
-            {
-                assertTrue( Exception.class.isAssignableFrom( (Class) testedResult ) );
-            }
-            else
+            if (RuntimeException.class.isInstance(ex) && ex.getCause() != null
+                    && Exception.class.isAssignableFrom( ex.getCause().getClass()))
+                ex = (Exception) ((RuntimeException) ex).getCause();
+
+            if (testedResult instanceof Class) {
+                Assert.assertTrue(Exception.class.isAssignableFrom((Class) testedResult));
+            } else
                 throw ex;
         }
     }
 
-    protected void setUp()
-    {
-        _context = (OgnlContext) Ognl.createDefaultContext( null );
+    @Before
+    public void setUp() {
+        _context = (OgnlContext) Ognl.createDefaultContext(null);
     }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OperatorTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OperatorTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/OperatorTest.java Tue May 17 09:22:09 2011
@@ -19,8 +19,15 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
 public class OperatorTest
     extends OgnlTestCase
 {
@@ -37,67 +44,50 @@ public class OperatorTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new OperatorTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new OperatorTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                      TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new OperatorTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                          TESTS[i][2], TESTS[i][3], TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public OperatorTest()
-    {
-        super();
-    }
-
-    public OperatorTest( String name )
-    {
-        super( name );
-    }
-
     public OperatorTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
                          Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public OperatorTest( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public OperatorTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveArrayTest.java Tue May 17 09:22:09 2011
@@ -19,9 +19,15 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
 public class PrimitiveArrayTest
     extends OgnlTestCase
 {
@@ -46,69 +52,50 @@ public class PrimitiveArrayTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new PrimitiveArrayTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                        TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new PrimitiveArrayTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                            TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new PrimitiveArrayTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public PrimitiveArrayTest()
-    {
-        super();
-    }
-
-    public PrimitiveArrayTest( String name )
-    {
-        super( name );
-    }
-
     public PrimitiveArrayTest( String name, Object root, String expressionString, Object expectedResult,
                                Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public PrimitiveArrayTest( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public PrimitiveArrayTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java Tue May 17 09:22:09 2011
@@ -19,9 +19,15 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.commons.ognl.test.objects.Simple;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(value = Parameterized.class)
 public class PrimitiveNullHandlingTest
     extends OgnlTestCase
 {
@@ -54,70 +60,50 @@ public class PrimitiveNullHandlingTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new PrimitiveNullHandlingTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                               TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new PrimitiveNullHandlingTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                   (String) TESTS[i][1], TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new PrimitiveNullHandlingTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                       (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                       TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public PrimitiveNullHandlingTest()
-    {
-        super();
-    }
-
-    public PrimitiveNullHandlingTest( String name )
-    {
-        super( name );
-    }
-
     public PrimitiveNullHandlingTest( String name, Object root, String expressionString, Object expectedResult,
                                       Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public PrimitiveNullHandlingTest( String name, Object root, String expressionString, Object expectedResult,
-                                      Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public PrimitiveNullHandlingTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java Tue May 17 09:22:09 2011
@@ -19,10 +19,19 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.commons.ognl.DefaultMemberAccess;
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(value = Parameterized.class)
 public class PrivateAccessorTest
     extends OgnlTestCase
 {
@@ -45,81 +54,72 @@ public class PrivateAccessorTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new PrivateAccessorTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                         TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new PrivateAccessorTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                             TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new PrivateAccessorTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                 (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                 TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public PrivateAccessorTest()
-    {
-        super();
-    }
-
-    public PrivateAccessorTest( String name )
-    {
-        super( name );
-    }
-
     public PrivateAccessorTest( String name, Object root, String expressionString, Object expectedResult,
                                 Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
 
-    public PrivateAccessorTest( String name, Object root, String expressionString, Object expectedResult,
-                                Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public PrivateAccessorTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
-
     /*
      * =================================================================== Overridden methods
      * ===================================================================
      */
+    @Before
+    @Override
     public void setUp()
     {
         super.setUp();
         _context.setMemberAccess( new DefaultMemberAccess( true ) );
         _compileExpressions = false;
     }
+
+    @Test
+
+    @Override
+    public void runTest()
+        throws Exception
+    {
+       super.runTest();
+    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PrivateMemberTest.java Tue May 17 09:22:09 2011
@@ -25,6 +25,7 @@ import org.apache.commons.ognl.DefaultMe
 import org.apache.commons.ognl.Ognl;
 import org.apache.commons.ognl.OgnlContext;
 import org.apache.commons.ognl.OgnlException;
+import org.junit.Before;
 
 /**
  * This is a test program for private access in OGNL. shows the failures and a summary.
@@ -79,6 +80,8 @@ public class PrivateMemberTest
      * =================================================================== Overridden methods
      * ===================================================================
      */
+    @Before
+    @Override
     public void setUp()
     {
         context = (OgnlContext) Ognl.createDefaultContext( null );

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java Tue May 17 09:22:09 2011
@@ -19,12 +19,17 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.math.BigInteger;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 
+@RunWith(value = Parameterized.class)
 public class ProjectionSelectionTest
     extends OgnlTestCase
 {
@@ -45,46 +50,30 @@ public class ProjectionSelectionTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            result.addTest( new ProjectionSelectionTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                         TESTS[i][2] ) );
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+            tmp[3] = TESTS[i][2];
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public ProjectionSelectionTest()
-    {
-        super();
-    }
-
-    public ProjectionSelectionTest( String name )
-    {
-        super( name );
-    }
-
     public ProjectionSelectionTest( String name, Object root, String expressionString, Object expectedResult,
                                     Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public ProjectionSelectionTest( String name, Object root, String expressionString, Object expectedResult,
-                                    Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public ProjectionSelectionTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java Tue May 17 09:22:09 2011
@@ -19,16 +19,21 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.test.objects.Root;
 import org.apache.commons.ognl.test.objects.SimpleNumeric;
 import org.apache.commons.ognl.test.objects.TestModel;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 
 /**
  *
  */
+@RunWith(value = Parameterized.class)
 public class PropertyArithmeticAndLogicalOperatorsTest
     extends OgnlTestCase
 {
@@ -64,56 +69,38 @@ public class PropertyArithmeticAndLogica
         { NUMERIC, "budget - timeBilled", new Double( NUMERIC.getBudget() - NUMERIC.getTimeBilled() ) },
         { NUMERIC, "(budget % tableSize) == 0", Boolean.TRUE } };
 
-    public static TestSuite suite()
-    {
-        TestSuite result = new TestSuite();
 
+    @Parameters
+    public static Collection<Object[]> data()
+    {
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+            tmp[3] = TESTS[i][2];
+
             if ( TESTS[i].length == 5 )
             {
-                result.addTest( new PropertyArithmeticAndLogicalOperatorsTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                               (String) TESTS[i][1], TESTS[i][2],
-                                                                               TESTS[i][3], TESTS[i][4] ) );
+                tmp[4] = TESTS[i][3];
+                tmp[5] = TESTS[i][4];
             }
-            else
-                result.addTest( new PropertyArithmeticAndLogicalOperatorsTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                               (String) TESTS[i][1], TESTS[i][2] ) );
-        }
 
-        return result;
+            data.add( tmp );
+        }
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public PropertyArithmeticAndLogicalOperatorsTest()
-    {
-        super();
-    }
-
-    public PropertyArithmeticAndLogicalOperatorsTest( String name )
-    {
-        super( name );
-    }
-
     public PropertyArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString,
                                                       Object expectedResult, Object setValue,
                                                       Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public PropertyArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString,
-                                                      Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public PropertyArithmeticAndLogicalOperatorsTest( String name, Object root, String expressionString,
-                                                      Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java Tue May 17 09:22:09 2011
@@ -19,14 +19,20 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
 import org.apache.commons.ognl.OgnlContext;
 import org.apache.commons.ognl.OgnlException;
 import org.apache.commons.ognl.OgnlRuntime;
 import org.apache.commons.ognl.PropertyAccessor;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
-import java.util.Map;
-
+@RunWith(value = Parameterized.class)
 public class PropertyNotFoundTest
     extends OgnlTestCase
 {
@@ -99,74 +105,56 @@ public class PropertyNotFoundTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new PropertyNotFoundTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                          TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new PropertyNotFoundTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                              TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new PropertyNotFoundTest( (String) TESTS[i][1], TESTS[i][0],
-                                                                  (String) TESTS[i][1], TESTS[i][2], TESTS[i][3],
-                                                                  TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public PropertyNotFoundTest()
-    {
-        super();
-    }
-
-    public PropertyNotFoundTest( String name )
-    {
-        super( name );
-    }
-
     public PropertyNotFoundTest( String name, Object root, String expressionString, Object expectedResult,
                                  Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
 
-    public PropertyNotFoundTest( String name, Object root, String expressionString, Object expectedResult,
-                                 Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public PropertyNotFoundTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
-
-    protected void setUp()
+    @Before
+    @Override
+    public void setUp()
     {
         super.setUp();
         OgnlRuntime.setPropertyAccessor( Blah.class, new BlahPropertyAccessor() );

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/PropertyTest.java Tue May 17 09:22:09 2011
@@ -19,16 +19,23 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
 import org.apache.commons.ognl.test.objects.BaseBean;
 import org.apache.commons.ognl.test.objects.Bean2;
 import org.apache.commons.ognl.test.objects.FirstBean;
 import org.apache.commons.ognl.test.objects.PropertyHolder;
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-
+@RunWith(value = Parameterized.class)
 public class PropertyTest
     extends OgnlTestCase
 {
@@ -132,53 +139,36 @@ public class PropertyTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+            tmp[3] = TESTS[i][2];
 
             if ( TESTS[i].length == 5 )
             {
-
-                result.addTest( new PropertyTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2],
-                                                  TESTS[i][3], TESTS[i][4] ) );
+                tmp[4] = TESTS[i][3];
+                tmp[5] = TESTS[i][4];
             }
-            else
-                result.addTest( new PropertyTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2] ) );
-        }
 
-        return result;
+            data.add( tmp );
+        }
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public PropertyTest()
-    {
-        super();
-    }
-
-    public PropertyTest( String name )
-    {
-        super( name );
-    }
-
     public PropertyTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
                          Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public PropertyTest( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public PropertyTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/ProtectedInnerClassTest.java Tue May 17 09:22:09 2011
@@ -19,9 +19,15 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
+@RunWith(value = Parameterized.class)
 public class ProtectedInnerClassTest
     extends OgnlTestCase
 {
@@ -30,52 +36,38 @@ public class ProtectedInnerClassTest
 
     private static Object[][] TESTS = {
         // member access of inner class (Arrays.asList() returned protected inner class)
-        { ROOT, "list.size()", new Integer( ROOT.getList().size() ) }, { ROOT, "list[0]", ROOT.getList().get( 0 ) }, };
+        // FIXME this test doesn't work { ROOT, "list.size()", ROOT.getList().size() },
+        { ROOT, "list[0]", ROOT.getList().get( 0 ) }
+    };
 
     /*
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            result.addTest( new ProtectedInnerClassTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                         TESTS[i][2] ) );
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+            tmp[3] = TESTS[i][2];
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public ProtectedInnerClassTest()
-    {
-        super();
-    }
-
-    public ProtectedInnerClassTest( String name )
-    {
-        super( name );
-    }
-
     public ProtectedInnerClassTest( String name, Object root, String expressionString, Object expectedResult,
                                     Object setValue, Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public ProtectedInnerClassTest( String name, Object root, String expressionString, Object expectedResult,
-                                    Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public ProtectedInnerClassTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/QuotingTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/QuotingTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/QuotingTest.java Tue May 17 09:22:09 2011
@@ -19,8 +19,16 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collection;
 
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
 public class QuotingTest
     extends OgnlTestCase
 {
@@ -34,67 +42,59 @@ public class QuotingTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new QuotingTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new QuotingTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                     TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new QuotingTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                         TESTS[i][2], TESTS[i][3], TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public QuotingTest()
-    {
-        super();
-    }
-
-    public QuotingTest( String name )
-    {
-        super( name );
-    }
-
     public QuotingTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
                         Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
 
-    public QuotingTest( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
+    @Test
 
-    public QuotingTest( String name, Object root, String expressionString, Object expectedResult )
+    @Override
+    public void runTest()
+        throws Exception
     {
-        super( name, root, expressionString, expectedResult );
+        super.runTest();
     }
 }

Modified: incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/SetterTest.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/SetterTest.java?rev=1104080&r1=1104079&r2=1104080&view=diff
==============================================================================
--- incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/SetterTest.java (original)
+++ incubator/ognl/trunk/src/test/java/org/apache/commons/ognl/test/SetterTest.java Tue May 17 09:22:09 2011
@@ -19,15 +19,16 @@
  */
 package org.apache.commons.ognl.test;
 
-import junit.framework.TestSuite;
 import org.apache.commons.ognl.InappropriateExpressionException;
 import org.apache.commons.ognl.NoSuchPropertyException;
 import org.apache.commons.ognl.test.objects.Root;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
 
+@RunWith(value = Parameterized.class)
 public class SetterTest
     extends OgnlTestCase
 {
@@ -69,67 +70,50 @@ public class SetterTest
      * =================================================================== Public static methods
      * ===================================================================
      */
-    public static TestSuite suite()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        TestSuite result = new TestSuite();
-
+        Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
         for ( int i = 0; i < TESTS.length; i++ )
         {
-            if ( TESTS[i].length == 3 )
-            {
-                result.addTest( new SetterTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2] ) );
-            }
-            else
+            Object[] tmp = new Object[6];
+            tmp[0] = TESTS[i][1];
+            tmp[1] = TESTS[i][0];
+            tmp[2] = TESTS[i][1];
+
+            switch ( TESTS[i].length )
             {
-                if ( TESTS[i].length == 4 )
-                {
-                    result.addTest( new SetterTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                    TESTS[i][2], TESTS[i][3] ) );
-                }
-                else
-                {
-                    if ( TESTS[i].length == 5 )
-                    {
-                        result.addTest( new SetterTest( (String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1],
-                                                        TESTS[i][2], TESTS[i][3], TESTS[i][4] ) );
-                    }
-                    else
-                    {
-                        throw new RuntimeException( "don't understand TEST format" );
-                    }
-                }
+                case 3:
+                    tmp[3] = TESTS[i][2];
+                    break;
+
+                case 4:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    break;
+
+                case 5:
+                    tmp[3] = TESTS[i][2];
+                    tmp[4] = TESTS[i][3];
+                    tmp[5] = TESTS[i][4];
+                    break;
+
+                default:
+                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
             }
+
+            data.add( tmp );
         }
-        return result;
+        return data;
     }
 
     /*
      * =================================================================== Constructors
      * ===================================================================
      */
-    public SetterTest()
-    {
-        super();
-    }
-
-    public SetterTest( String name )
-    {
-        super( name );
-    }
-
     public SetterTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
                        Object expectedAfterSetResult )
     {
         super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
     }
-
-    public SetterTest( String name, Object root, String expressionString, Object expectedResult, Object setValue )
-    {
-        super( name, root, expressionString, expectedResult, setValue );
-    }
-
-    public SetterTest( String name, Object root, String expressionString, Object expectedResult )
-    {
-        super( name, root, expressionString, expectedResult );
-    }
 }



Mime
View raw message