You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2009/01/23 07:32:46 UTC
svn commit: r736963 [18/21] - in /ibatis/trunk/java/ibatis-3:
ibatis-3-compat/src/main/java/com/ibatis/common/jdbc/
ibatis-3-compat/src/main/java/com/ibatis/common/resources/
ibatis-3-compat/src/main/java/com/ibatis/common/util/
ibatis-3-compat/src/mai...
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodTest.java Thu Jan 22 22:32:36 2009
@@ -33,51 +33,44 @@
import junit.framework.TestSuite;
import org.apache.ibatis.ognl.objects.Simple;
-public class MethodTest extends OgnlTestCase
-{
- private static Object ROOT = new Simple();
- private static Object[][] TESTS = {
- { "hashCode().doubleValue()", new Double(ROOT.hashCode()) }
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- for (int i = 0; i < TESTS.length; i++) {
- result.addTest(new MethodTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String)TESTS[i][0], TESTS[i][1]));
- }
- return result;
- }
-
- /*===================================================================
- Constructors
- ===================================================================*/
- public MethodTest()
- {
- super();
- }
-
- public MethodTest(String name)
- {
- super(name);
- }
-
- public MethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
- {
- super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
- }
+public class MethodTest extends OgnlTestCase {
+ private static Object ROOT = new Simple();
+ private static Object[][] TESTS = {
+ {"hashCode().doubleValue()", new Double(ROOT.hashCode())}
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
- public MethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
- {
- super(name, root, expressionString, expectedResult, setValue);
+ for (int i = 0; i < TESTS.length; i++) {
+ result.addTest(new MethodTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String) TESTS[i][0], TESTS[i][1]));
}
+ return result;
+ }
- public MethodTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public MethodTest() {
+ super();
+ }
+
+ public MethodTest(String name) {
+ super(name);
+ }
+
+ public MethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public MethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public MethodTest(String name, Object root, String expressionString, Object expectedResult) {
+ super(name, root, expressionString, expectedResult);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodWithConversionTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodWithConversionTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodWithConversionTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/MethodWithConversionTest.java Thu Jan 22 22:32:36 2009
@@ -33,69 +33,62 @@
import junit.framework.TestSuite;
import org.apache.ibatis.ognl.objects.Simple;
-public class MethodWithConversionTest extends OgnlTestCase
-{
- private static Simple SIMPLE = new Simple();
-
- private static Object[][] TESTS = {
- // Method call with conversion
- { SIMPLE, "setValues(new Integer(10), \"10.56\", new Double(34.225))", null },
- { SIMPLE, "stringValue", "10" },
- { SIMPLE, "stringValue", "10", new Character('x'), "x" }, /* set through setValue() */
- { SIMPLE, "setStringValue('x')", null }, /* set by calling setStringValue() directly */
- { SIMPLE, "floatValue", new Float(10.56) },
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- for (int i = 0; i < TESTS.length; i++) {
- if (TESTS[i].length == 3) {
- result.addTest(new MethodWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2]));
- } else {
- if (TESTS[i].length == 4) {
- result.addTest(new MethodWithConversionTest((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 MethodWithConversionTest((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");
- }
- }
- }
- }
- return result;
- }
-
- /*===================================================================
- Constructors
- ===================================================================*/
- public MethodWithConversionTest()
- {
- super();
- }
-
- public MethodWithConversionTest(String name)
- {
- super(name);
- }
-
- public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
- {
- super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
- }
+public class MethodWithConversionTest extends OgnlTestCase {
+ private static Simple SIMPLE = new Simple();
- public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
- {
- super(name, root, expressionString, expectedResult, setValue);
+ private static Object[][] TESTS = {
+ // Method call with conversion
+ {SIMPLE, "setValues(new Integer(10), \"10.56\", new Double(34.225))", null},
+ {SIMPLE, "stringValue", "10"},
+ {SIMPLE, "stringValue", "10", new Character('x'), "x"}, /* set through setValue() */
+ {SIMPLE, "setStringValue('x')", null}, /* set by calling setStringValue() directly */
+ {SIMPLE, "floatValue", new Float(10.56)},
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ if (TESTS[i].length == 3) {
+ result.addTest(new MethodWithConversionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2]));
+ } else {
+ if (TESTS[i].length == 4) {
+ result.addTest(new MethodWithConversionTest((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 MethodWithConversionTest((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");
+ }
+ }
+ }
}
+ return result;
+ }
- public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public MethodWithConversionTest() {
+ super();
+ }
+
+ public MethodWithConversionTest(String name) {
+ super(name);
+ }
+
+ public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult) {
+ super(name, root, expressionString, expectedResult);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NestedMethodTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NestedMethodTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NestedMethodTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NestedMethodTest.java Thu Jan 22 22:32:36 2009
@@ -33,66 +33,59 @@
import junit.framework.TestSuite;
import org.apache.ibatis.ognl.objects.Component;
-public class NestedMethodTest extends OgnlTestCase
-{
- private static Component COMPONENT = new Component();
-
- private static Object[][] TESTS = {
- // Expression in a method call argument
- { COMPONENT, "toDisplay.pictureUrl", COMPONENT.getToDisplay().getPictureUrl() },
- { COMPONENT, "page.createRelativeAsset(toDisplay.pictureUrl)", COMPONENT.getPage().createRelativeAsset(COMPONENT.getToDisplay().getPictureUrl()) },
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- for (int i = 0; i < TESTS.length; i++) {
- if (TESTS[i].length == 3) {
- result.addTest(new NestedMethodTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2]));
- } else {
- if (TESTS[i].length == 4) {
- result.addTest(new NestedMethodTest((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 NestedMethodTest((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");
- }
- }
- }
- }
- return result;
- }
-
- /*===================================================================
- Constructors
- ===================================================================*/
- public NestedMethodTest()
- {
- super();
- }
-
- public NestedMethodTest(String name)
- {
- super(name);
- }
-
- public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
- {
- super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
- }
+public class NestedMethodTest extends OgnlTestCase {
+ private static Component COMPONENT = new Component();
- public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
- {
- super(name, root, expressionString, expectedResult, setValue);
+ private static Object[][] TESTS = {
+ // Expression in a method call argument
+ {COMPONENT, "toDisplay.pictureUrl", COMPONENT.getToDisplay().getPictureUrl()},
+ {COMPONENT, "page.createRelativeAsset(toDisplay.pictureUrl)", COMPONENT.getPage().createRelativeAsset(COMPONENT.getToDisplay().getPictureUrl())},
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ if (TESTS[i].length == 3) {
+ result.addTest(new NestedMethodTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2]));
+ } else {
+ if (TESTS[i].length == 4) {
+ result.addTest(new NestedMethodTest((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 NestedMethodTest((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");
+ }
+ }
+ }
}
+ return result;
+ }
- public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public NestedMethodTest() {
+ super();
+ }
+
+ public NestedMethodTest(String name) {
+ super(name);
+ }
+
+ public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult) {
+ super(name, root, expressionString, expectedResult);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullHandlerTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullHandlerTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullHandlerTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullHandlerTest.java Thu Jan 22 22:32:36 2009
@@ -31,81 +31,72 @@
package org.apache.ibatis.ognl;
import junit.framework.TestSuite;
-import org.apache.ibatis.ognl.OgnlRuntime;
import org.apache.ibatis.ognl.objects.CorrectedObject;
-public class NullHandlerTest extends OgnlTestCase
-{
- private static CorrectedObject CORRECTED = new CorrectedObject();
-
- private static Object[][] TESTS = {
- // NullHandler
- { CORRECTED, "stringValue", "corrected" },
- { CORRECTED, "getStringValue()", "corrected" },
- { CORRECTED, "#root.stringValue", "corrected" },
- { CORRECTED, "#root.getStringValue()", "corrected" },
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- 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 {
- 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");
- }
- }
- }
- }
- return result;
- }
+public class NullHandlerTest extends OgnlTestCase {
+ private static CorrectedObject CORRECTED = new CorrectedObject();
-
- /*===================================================================
- 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);
+ private static Object[][] TESTS = {
+ // NullHandler
+ {CORRECTED, "stringValue", "corrected"},
+ {CORRECTED, "getStringValue()", "corrected"},
+ {CORRECTED, "#root.stringValue", "corrected"},
+ {CORRECTED, "#root.getStringValue()", "corrected"},
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ 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 {
+ 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");
+ }
+ }
+ }
}
+ return result;
+ }
- public NullHandlerTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
- /*===================================================================
- Overridden methods
- ===================================================================*/
- public void setUp()
- {
- super.setUp();
- OgnlRuntime.setNullHandler(CorrectedObject.class, new CorrectedObjectNullHandler("corrected"));
- }
+ /*===================================================================
+ 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
+ ===================================================================*/
+ public void setUp() {
+ super.setUp();
+ OgnlRuntime.setNullHandler(CorrectedObject.class, new CorrectedObjectNullHandler("corrected"));
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullStringCatenationTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullStringCatenationTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullStringCatenationTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NullStringCatenationTest.java Thu Jan 22 22:32:36 2009
@@ -33,67 +33,60 @@
import junit.framework.TestSuite;
import org.apache.ibatis.ognl.objects.Root;
-public class NullStringCatenationTest extends OgnlTestCase
-{
- private static Root ROOT = new Root();
-
- private static Object[][] TESTS = {
- // Null string catenation
- { ROOT, "\"bar\" + null", "barnull" }, /* Catenate null to a string */
- { ROOT, "\"bar\" + nullObject", "barnull" }, /* Catenate null to a string */
- { ROOT, "20.56 + nullObject", NullPointerException.class }, /* Catenate null to a number */
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- 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 {
- 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");
- }
- }
- }
- }
- return result;
- }
-
- /*===================================================================
- 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 class NullStringCatenationTest extends OgnlTestCase {
+ private static Root ROOT = new Root();
- public NullStringCatenationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
- {
- super(name, root, expressionString, expectedResult, setValue);
+ private static Object[][] TESTS = {
+ // Null string catenation
+ {ROOT, "\"bar\" + null", "barnull"}, /* Catenate null to a string */
+ {ROOT, "\"bar\" + nullObject", "barnull"}, /* Catenate null to a string */
+ {ROOT, "20.56 + nullObject", NullPointerException.class}, /* Catenate null to a number */
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ 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 {
+ 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");
+ }
+ }
+ }
}
+ return result;
+ }
- public NullStringCatenationTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
+ /*===================================================================
+ 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);
+ }
+
+ public NullStringCatenationTest(String name, Object root, String expressionString, Object expectedResult) {
+ super(name, root, expressionString, expectedResult);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumberFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumberFormatExceptionTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumberFormatExceptionTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumberFormatExceptionTest.java Thu Jan 22 22:32:36 2009
@@ -30,87 +30,81 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.math.*;
import junit.framework.TestSuite;
-import org.apache.ibatis.ognl.OgnlException;
import org.apache.ibatis.ognl.objects.Simple;
-public class NumberFormatExceptionTest extends OgnlTestCase
-{
- private static Simple SIMPLE = new Simple();
-
- 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) }, /* set float to 10.0f */
- { SIMPLE, "floatValue", new Float(10f), "x10x", OgnlException.class }, /* set float to invalid format string, should yield OgnlException */
-
- { SIMPLE, "intValue", new Integer(0), new Integer(34), new Integer(34) }, /* set int to 34 */
- { SIMPLE, "intValue", new Integer(34), "foobar", OgnlException.class }, /* set int to invalid format string, should yield OgnlException */
- { SIMPLE, "intValue", new Integer(34), "", OgnlException.class }, /* set int to empty string, should yield 0gnlException */
- { SIMPLE, "intValue", new Integer(34), " \t", OgnlException.class }, /* set int to whitespace-only string, should yield 0gnlException */
- { SIMPLE, "intValue", new Integer(34), " \t1234\t\t", new Integer(1234) }, /* set int to whitespace-laden valid string, should yield 1234 */
-
- { SIMPLE, "bigIntValue", BigInteger.valueOf(0), BigInteger.valueOf(34), BigInteger.valueOf(34) }, /* set bigint to 34 */
- { SIMPLE, "bigIntValue", BigInteger.valueOf(34), null, null }, /* set bigint to null string, should yield 0 */
- { SIMPLE, "bigIntValue", null, "", OgnlException.class }, /* set bigint to empty string, should yield 0gnlException */
- { SIMPLE, "bigIntValue", null, "foobar", OgnlException.class }, /* set bigint to invalid format string, should yield OgnlException */
-
- { SIMPLE, "bigDecValue", new BigDecimal(0.0), new BigDecimal(34.55), new BigDecimal(34.55) }, /* set bigdec to 34.55 */
- { SIMPLE, "bigDecValue", new BigDecimal(34.55), null, null }, /* set bigdec to null string, should yield 0.0 */
- { SIMPLE, "bigDecValue", null, "", OgnlException.class }, /* set bigdec to empty string, should yield 0gnlException */
- { SIMPLE, "bigDecValue", null, "foobar", OgnlException.class }, /* set bigdec to invalid format string, should yield OgnlException */
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- for (int i = 0; i < TESTS.length; i++) {
- if (TESTS[i].length == 3) {
- result.addTest(new NumberFormatExceptionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2]));
- } else {
- 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");
- }
- }
- }
- }
- return result;
- }
+import java.math.BigDecimal;
+import java.math.BigInteger;
- /*===================================================================
- 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 class NumberFormatExceptionTest extends OgnlTestCase {
+ private static Simple SIMPLE = new Simple();
- public NumberFormatExceptionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
- {
- super(name, root, expressionString, expectedResult, setValue);
+ 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)}, /* set float to 10.0f */
+ {SIMPLE, "floatValue", new Float(10f), "x10x", OgnlException.class}, /* set float to invalid format string, should yield OgnlException */
+
+ {SIMPLE, "intValue", new Integer(0), new Integer(34), new Integer(34)}, /* set int to 34 */
+ {SIMPLE, "intValue", new Integer(34), "foobar", OgnlException.class}, /* set int to invalid format string, should yield OgnlException */
+ {SIMPLE, "intValue", new Integer(34), "", OgnlException.class}, /* set int to empty string, should yield 0gnlException */
+ {SIMPLE, "intValue", new Integer(34), " \t", OgnlException.class}, /* set int to whitespace-only string, should yield 0gnlException */
+ {SIMPLE, "intValue", new Integer(34), " \t1234\t\t", new Integer(1234)}, /* set int to whitespace-laden valid string, should yield 1234 */
+
+ {SIMPLE, "bigIntValue", BigInteger.valueOf(0), BigInteger.valueOf(34), BigInteger.valueOf(34)}, /* set bigint to 34 */
+ {SIMPLE, "bigIntValue", BigInteger.valueOf(34), null, null}, /* set bigint to null string, should yield 0 */
+ {SIMPLE, "bigIntValue", null, "", OgnlException.class}, /* set bigint to empty string, should yield 0gnlException */
+ {SIMPLE, "bigIntValue", null, "foobar", OgnlException.class}, /* set bigint to invalid format string, should yield OgnlException */
+
+ {SIMPLE, "bigDecValue", new BigDecimal(0.0), new BigDecimal(34.55), new BigDecimal(34.55)}, /* set bigdec to 34.55 */
+ {SIMPLE, "bigDecValue", new BigDecimal(34.55), null, null}, /* set bigdec to null string, should yield 0.0 */
+ {SIMPLE, "bigDecValue", null, "", OgnlException.class}, /* set bigdec to empty string, should yield 0gnlException */
+ {SIMPLE, "bigDecValue", null, "foobar", OgnlException.class}, /* set bigdec to invalid format string, should yield OgnlException */
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ if (TESTS[i].length == 3) {
+ result.addTest(new NumberFormatExceptionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2]));
+ } else {
+ 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");
+ }
+ }
+ }
}
+ return result;
+ }
- public NumberFormatExceptionTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
+ /*===================================================================
+ 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);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumericConversionTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumericConversionTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumericConversionTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/NumericConversionTest.java Thu Jan 22 22:32:36 2009
@@ -30,197 +30,192 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.math.BigDecimal;
-import java.math.BigInteger;
import junit.framework.TestSuite;
-import org.apache.ibatis.ognl.OgnlException;
-import org.apache.ibatis.ognl.OgnlOps;
-public class NumericConversionTest extends OgnlTestCase
-{
- private static Object[][] TESTS = {
- /* To Integer.class */
- { "55", Integer.class, new Integer(55) },
- { new Integer(55), Integer.class, new Integer(55) },
- { new Double(55), Integer.class, new Integer(55) },
- { Boolean.TRUE, Integer.class, new Integer(1) },
- { new Byte((byte)55), Integer.class, new Integer(55) },
- { new Character((char)55), Integer.class, new Integer(55) },
- { new Short((short)55), Integer.class, new Integer(55) },
- { new Long(55), Integer.class, new Integer(55) },
- { new Float(55), Integer.class, new Integer(55) },
- { new BigInteger("55"), Integer.class, new Integer(55) },
- { new BigDecimal("55"), Integer.class, new Integer(55) },
-
- /* To Double.class */
- { "55.1234", Double.class, new Double(55.1234) },
- { new Integer(55), Double.class, new Double(55) },
- { new Double(55.1234), Double.class, new Double(55.1234) },
- { Boolean.TRUE, Double.class, new Double(1) },
- { new Byte((byte)55), Double.class, new Double(55) },
- { new Character((char)55), Double.class, new Double(55) },
- { new Short((short)55), Double.class, new Double(55) },
- { new Long(55), Double.class, new Double(55) },
- { new Float(55.1234), Double.class, new Double(55.1234), new Integer(4) },
- { new BigInteger("55"), Double.class, new Double(55) },
- { new BigDecimal("55.1234"), Double.class, new Double(55.1234) },
-
- /* To Boolean.class */
- { "true", Boolean.class, Boolean.TRUE },
- { new Integer(55), Boolean.class, Boolean.TRUE },
- { new Double(55), Boolean.class, Boolean.TRUE },
- { Boolean.TRUE, Boolean.class, Boolean.TRUE },
- { new Byte((byte)55), Boolean.class, Boolean.TRUE },
- { new Character((char)55), Boolean.class, Boolean.TRUE },
- { new Short((short)55), Boolean.class, Boolean.TRUE },
- { new Long(55), Boolean.class, Boolean.TRUE },
- { new Float(55), Boolean.class, Boolean.TRUE },
- { new BigInteger("55"), Boolean.class, Boolean.TRUE },
- { new BigDecimal("55"), Boolean.class, Boolean.TRUE },
-
- /* To Byte.class */
- { "55", Byte.class, new Byte((byte)55) },
- { new Integer(55), Byte.class, new Byte((byte)55) },
- { new Double(55), Byte.class, new Byte((byte)55) },
- { Boolean.TRUE, Byte.class, new Byte((byte)1) },
- { new Byte((byte)55), Byte.class, new Byte((byte)55) },
- { new Character((char)55), Byte.class, new Byte((byte)55) },
- { new Short((short)55), Byte.class, new Byte((byte)55) },
- { new Long(55), Byte.class, new Byte((byte)55) },
- { new Float(55), Byte.class, new Byte((byte)55) },
- { new BigInteger("55"), Byte.class, new Byte((byte)55) },
- { new BigDecimal("55"), Byte.class, new Byte((byte)55) },
-
- /* To Character.class */
- { "55", Character.class, new Character((char)55) },
- { new Integer(55), Character.class, new Character((char)55) },
- { new Double(55), Character.class, new Character((char)55) },
- { Boolean.TRUE, Character.class, new Character((char)1) },
- { new Byte((byte)55), Character.class, new Character((char)55) },
- { new Character((char)55), Character.class, new Character((char)55) },
- { new Short((short)55), Character.class, new Character((char)55) },
- { new Long(55), Character.class, new Character((char)55) },
- { new Float(55), Character.class, new Character((char)55) },
- { new BigInteger("55"), Character.class, new Character((char)55) },
- { new BigDecimal("55"), Character.class, new Character((char)55) },
-
- /* To Short.class */
- { "55", Short.class, new Short((short)55) },
- { new Integer(55), Short.class, new Short((short)55) },
- { new Double(55), Short.class, new Short((short)55) },
- { Boolean.TRUE, Short.class, new Short((short)1) },
- { new Byte((byte)55), Short.class, new Short((short)55) },
- { new Character((char)55), Short.class, new Short((short)55) },
- { new Short((short)55), Short.class, new Short((short)55) },
- { new Long(55), Short.class, new Short((short)55) },
- { new Float(55), Short.class, new Short((short)55) },
- { new BigInteger("55"), Short.class, new Short((short)55) },
- { new BigDecimal("55"), Short.class, new Short((short)55) },
-
- /* To Long.class */
- { "55", Long.class, new Long(55) },
- { new Integer(55), Long.class, new Long(55) },
- { new Double(55), Long.class, new Long(55) },
- { Boolean.TRUE, Long.class, new Long(1) },
- { new Byte((byte)55), Long.class, new Long(55) },
- { new Character((char)55), Long.class, new Long(55) },
- { new Short((short)55), Long.class, new Long(55) },
- { new Long(55), Long.class, new Long(55) },
- { new Float(55), Long.class, new Long(55) },
- { new BigInteger("55"), Long.class, new Long(55) },
- { new BigDecimal("55"), Long.class, new Long(55) },
-
- /* To Float.class */
- { "55.1234", Float.class, new Float(55.1234) },
- { new Integer(55), Float.class, new Float(55) },
- { new Double(55.1234), Float.class, new Float(55.1234) },
- { Boolean.TRUE, Float.class, new Float(1) },
- { new Byte((byte)55), Float.class, new Float(55) },
- { new Character((char)55), Float.class, new Float(55) },
- { new Short((short)55), Float.class, new Float(55) },
- { new Long(55), Float.class, new Float(55) },
- { new Float(55.1234), Float.class, new Float(55.1234) },
- { new BigInteger("55"), Float.class, new Float(55) },
- { new BigDecimal("55.1234"), Float.class, new Float(55.1234) },
-
- /* To BigInteger.class */
- { "55", BigInteger.class, new BigInteger("55") },
- { new Integer(55), BigInteger.class, new BigInteger("55") },
- { new Double(55), BigInteger.class, new BigInteger("55") },
- { Boolean.TRUE, BigInteger.class, new BigInteger("1") },
- { new Byte((byte)55), BigInteger.class, new BigInteger("55") },
- { new Character((char)55), BigInteger.class, new BigInteger("55") },
- { new Short((short)55), BigInteger.class, new BigInteger("55") },
- { new Long(55), BigInteger.class, new BigInteger("55") },
- { new Float(55), BigInteger.class, new BigInteger("55") },
- { new BigInteger("55"), BigInteger.class, new BigInteger("55") },
- { new BigDecimal("55"), BigInteger.class, new BigInteger("55") },
-
- /* To BigDecimal.class */
- { "55.1234", BigDecimal.class, new BigDecimal("55.1234") },
- { new Integer(55), BigDecimal.class, new BigDecimal("55") },
- { new Double(55.1234), BigDecimal.class, new BigDecimal("55.1234"), new Integer(4) },
- { Boolean.TRUE, BigDecimal.class, new BigDecimal("1") },
- { new Byte((byte)55), BigDecimal.class, new BigDecimal("55") },
- { new Character((char)55), BigDecimal.class, new BigDecimal("55") },
- { new Short((short)55), BigDecimal.class, new BigDecimal("55") },
- { new Long(55), BigDecimal.class, new BigDecimal("55") },
- { new Float(55.1234), BigDecimal.class, new BigDecimal("55.1234"), new Integer(4) },
- { new BigInteger("55"), BigDecimal.class, new BigDecimal("55") },
- { new BigDecimal("55.1234"), BigDecimal.class, new BigDecimal("55.1234") },
- };
-
- private Object value;
- private Class toClass;
- private Object expectedValue;
- private int scale;
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- 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));
- }
- return result;
- }
+import java.math.BigDecimal;
+import java.math.BigInteger;
- /*===================================================================
- Constructors
- ===================================================================*/
- public NumericConversionTest(Object value, Class toClass, Object expectedValue, int scale)
- {
- super(value + " [" + value.getClass().getName() + "] -> " + toClass.getName() + " == " + expectedValue + " [" + expectedValue.getClass().getName() + "]" + ((scale >= 0) ? (" (to within " + scale + " decimal places)") : ""));
- this.value = value;
- this.toClass = toClass;
- this.expectedValue = expectedValue;
- this.scale = scale;
+public class NumericConversionTest extends OgnlTestCase {
+ private static Object[][] TESTS = {
+ /* To Integer.class */
+ {"55", Integer.class, new Integer(55)},
+ {new Integer(55), Integer.class, new Integer(55)},
+ {new Double(55), Integer.class, new Integer(55)},
+ {Boolean.TRUE, Integer.class, new Integer(1)},
+ {new Byte((byte) 55), Integer.class, new Integer(55)},
+ {new Character((char) 55), Integer.class, new Integer(55)},
+ {new Short((short) 55), Integer.class, new Integer(55)},
+ {new Long(55), Integer.class, new Integer(55)},
+ {new Float(55), Integer.class, new Integer(55)},
+ {new BigInteger("55"), Integer.class, new Integer(55)},
+ {new BigDecimal("55"), Integer.class, new Integer(55)},
+
+ /* To Double.class */
+ {"55.1234", Double.class, new Double(55.1234)},
+ {new Integer(55), Double.class, new Double(55)},
+ {new Double(55.1234), Double.class, new Double(55.1234)},
+ {Boolean.TRUE, Double.class, new Double(1)},
+ {new Byte((byte) 55), Double.class, new Double(55)},
+ {new Character((char) 55), Double.class, new Double(55)},
+ {new Short((short) 55), Double.class, new Double(55)},
+ {new Long(55), Double.class, new Double(55)},
+ {new Float(55.1234), Double.class, new Double(55.1234), new Integer(4)},
+ {new BigInteger("55"), Double.class, new Double(55)},
+ {new BigDecimal("55.1234"), Double.class, new Double(55.1234)},
+
+ /* To Boolean.class */
+ {"true", Boolean.class, Boolean.TRUE},
+ {new Integer(55), Boolean.class, Boolean.TRUE},
+ {new Double(55), Boolean.class, Boolean.TRUE},
+ {Boolean.TRUE, Boolean.class, Boolean.TRUE},
+ {new Byte((byte) 55), Boolean.class, Boolean.TRUE},
+ {new Character((char) 55), Boolean.class, Boolean.TRUE},
+ {new Short((short) 55), Boolean.class, Boolean.TRUE},
+ {new Long(55), Boolean.class, Boolean.TRUE},
+ {new Float(55), Boolean.class, Boolean.TRUE},
+ {new BigInteger("55"), Boolean.class, Boolean.TRUE},
+ {new BigDecimal("55"), Boolean.class, Boolean.TRUE},
+
+ /* To Byte.class */
+ {"55", Byte.class, new Byte((byte) 55)},
+ {new Integer(55), Byte.class, new Byte((byte) 55)},
+ {new Double(55), Byte.class, new Byte((byte) 55)},
+ {Boolean.TRUE, Byte.class, new Byte((byte) 1)},
+ {new Byte((byte) 55), Byte.class, new Byte((byte) 55)},
+ {new Character((char) 55), Byte.class, new Byte((byte) 55)},
+ {new Short((short) 55), Byte.class, new Byte((byte) 55)},
+ {new Long(55), Byte.class, new Byte((byte) 55)},
+ {new Float(55), Byte.class, new Byte((byte) 55)},
+ {new BigInteger("55"), Byte.class, new Byte((byte) 55)},
+ {new BigDecimal("55"), Byte.class, new Byte((byte) 55)},
+
+ /* To Character.class */
+ {"55", Character.class, new Character((char) 55)},
+ {new Integer(55), Character.class, new Character((char) 55)},
+ {new Double(55), Character.class, new Character((char) 55)},
+ {Boolean.TRUE, Character.class, new Character((char) 1)},
+ {new Byte((byte) 55), Character.class, new Character((char) 55)},
+ {new Character((char) 55), Character.class, new Character((char) 55)},
+ {new Short((short) 55), Character.class, new Character((char) 55)},
+ {new Long(55), Character.class, new Character((char) 55)},
+ {new Float(55), Character.class, new Character((char) 55)},
+ {new BigInteger("55"), Character.class, new Character((char) 55)},
+ {new BigDecimal("55"), Character.class, new Character((char) 55)},
+
+ /* To Short.class */
+ {"55", Short.class, new Short((short) 55)},
+ {new Integer(55), Short.class, new Short((short) 55)},
+ {new Double(55), Short.class, new Short((short) 55)},
+ {Boolean.TRUE, Short.class, new Short((short) 1)},
+ {new Byte((byte) 55), Short.class, new Short((short) 55)},
+ {new Character((char) 55), Short.class, new Short((short) 55)},
+ {new Short((short) 55), Short.class, new Short((short) 55)},
+ {new Long(55), Short.class, new Short((short) 55)},
+ {new Float(55), Short.class, new Short((short) 55)},
+ {new BigInteger("55"), Short.class, new Short((short) 55)},
+ {new BigDecimal("55"), Short.class, new Short((short) 55)},
+
+ /* To Long.class */
+ {"55", Long.class, new Long(55)},
+ {new Integer(55), Long.class, new Long(55)},
+ {new Double(55), Long.class, new Long(55)},
+ {Boolean.TRUE, Long.class, new Long(1)},
+ {new Byte((byte) 55), Long.class, new Long(55)},
+ {new Character((char) 55), Long.class, new Long(55)},
+ {new Short((short) 55), Long.class, new Long(55)},
+ {new Long(55), Long.class, new Long(55)},
+ {new Float(55), Long.class, new Long(55)},
+ {new BigInteger("55"), Long.class, new Long(55)},
+ {new BigDecimal("55"), Long.class, new Long(55)},
+
+ /* To Float.class */
+ {"55.1234", Float.class, new Float(55.1234)},
+ {new Integer(55), Float.class, new Float(55)},
+ {new Double(55.1234), Float.class, new Float(55.1234)},
+ {Boolean.TRUE, Float.class, new Float(1)},
+ {new Byte((byte) 55), Float.class, new Float(55)},
+ {new Character((char) 55), Float.class, new Float(55)},
+ {new Short((short) 55), Float.class, new Float(55)},
+ {new Long(55), Float.class, new Float(55)},
+ {new Float(55.1234), Float.class, new Float(55.1234)},
+ {new BigInteger("55"), Float.class, new Float(55)},
+ {new BigDecimal("55.1234"), Float.class, new Float(55.1234)},
+
+ /* To BigInteger.class */
+ {"55", BigInteger.class, new BigInteger("55")},
+ {new Integer(55), BigInteger.class, new BigInteger("55")},
+ {new Double(55), BigInteger.class, new BigInteger("55")},
+ {Boolean.TRUE, BigInteger.class, new BigInteger("1")},
+ {new Byte((byte) 55), BigInteger.class, new BigInteger("55")},
+ {new Character((char) 55), BigInteger.class, new BigInteger("55")},
+ {new Short((short) 55), BigInteger.class, new BigInteger("55")},
+ {new Long(55), BigInteger.class, new BigInteger("55")},
+ {new Float(55), BigInteger.class, new BigInteger("55")},
+ {new BigInteger("55"), BigInteger.class, new BigInteger("55")},
+ {new BigDecimal("55"), BigInteger.class, new BigInteger("55")},
+
+ /* To BigDecimal.class */
+ {"55.1234", BigDecimal.class, new BigDecimal("55.1234")},
+ {new Integer(55), BigDecimal.class, new BigDecimal("55")},
+ {new Double(55.1234), BigDecimal.class, new BigDecimal("55.1234"), new Integer(4)},
+ {Boolean.TRUE, BigDecimal.class, new BigDecimal("1")},
+ {new Byte((byte) 55), BigDecimal.class, new BigDecimal("55")},
+ {new Character((char) 55), BigDecimal.class, new BigDecimal("55")},
+ {new Short((short) 55), BigDecimal.class, new BigDecimal("55")},
+ {new Long(55), BigDecimal.class, new BigDecimal("55")},
+ {new Float(55.1234), BigDecimal.class, new BigDecimal("55.1234"), new Integer(4)},
+ {new BigInteger("55"), BigDecimal.class, new BigDecimal("55")},
+ {new BigDecimal("55.1234"), BigDecimal.class, new BigDecimal("55.1234")},
+ };
+
+ private Object value;
+ private Class toClass;
+ private Object expectedValue;
+ private int scale;
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ 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));
}
+ return result;
+ }
- /*===================================================================
- Overridden methods
- ===================================================================*/
- protected void runTest() throws OgnlException
- {
- Object result;
-
- result = OgnlOps.convertValue(value, toClass);
- if (!isEqual(result, expectedValue)) {
- if (scale >= 0) {
- double scalingFactor = Math.pow(10, scale),
- v1 = ((Number)value).doubleValue() * scalingFactor,
- v2 = ((Number)expectedValue).doubleValue() * scalingFactor;
-
- assertTrue((int)v1 == (int)v2);
- } else {
- fail();
- }
- }
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public NumericConversionTest(Object value, Class toClass, Object expectedValue, int scale) {
+ super(value + " [" + value.getClass().getName() + "] -> " + toClass.getName() + " == " + expectedValue + " [" + expectedValue.getClass().getName() + "]" + ((scale >= 0) ? (" (to within " + scale + " decimal places)") : ""));
+ this.value = value;
+ this.toClass = toClass;
+ this.expectedValue = expectedValue;
+ this.scale = scale;
+ }
+
+ /*===================================================================
+ Overridden methods
+ ===================================================================*/
+ protected void runTest() throws OgnlException {
+ Object result;
+
+ result = OgnlOps.convertValue(value, toClass);
+ if (!isEqual(result, expectedValue)) {
+ if (scale >= 0) {
+ double scalingFactor = Math.pow(10, scale),
+ v1 = ((Number) value).doubleValue() * scalingFactor,
+ v2 = ((Number) expectedValue).doubleValue() * scalingFactor;
+
+ assertTrue((int) v1 == (int) v2);
+ } else {
+ fail();
+ }
}
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedPropertyTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedPropertyTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedPropertyTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedPropertyTest.java Thu Jan 22 22:32:36 2009
@@ -31,75 +31,67 @@
package org.apache.ibatis.ognl;
import junit.framework.TestSuite;
-import org.apache.ibatis.ognl.OgnlException;
import org.apache.ibatis.ognl.objects.ObjectIndexed;
-public class ObjectIndexedPropertyTest extends OgnlTestCase
-{
- private static ObjectIndexed OBJECT_INDEXED = new ObjectIndexed();
-
- private static Object[][] TESTS = {
- // Arbitrary indexed properties
- { OBJECT_INDEXED, "attributes[\"bar\"]", "baz" }, /* get non-indexed property through attributes Map */
- { OBJECT_INDEXED, "attribute[\"foo\"]", "bar" }, /* get indexed property */
- { OBJECT_INDEXED, "attribute[\"bar\"]", "baz", "newValue", "newValue" }, /* set indexed property */
- { OBJECT_INDEXED, "attribute[\"bar\"]", "newValue" }, /* get indexed property back to confirm */
- { OBJECT_INDEXED, "attributes[\"bar\"]", "newValue" }, /* get property back through Map to confirm */
- { OBJECT_INDEXED, "attribute[\"other\"].attribute[\"bar\"]", "baz" }, /* get indexed property from indexed, then through other */
- { OBJECT_INDEXED, "attribute[\"other\"].attributes[\"bar\"]", "baz" }, /* get property back through Map to confirm */
- { OBJECT_INDEXED, "attribute[$]", OgnlException.class }, /* illegal DynamicSubscript access to object indexed property */
- };
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- TestSuite result = new TestSuite();
-
- 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 {
- 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");
- }
- }
- }
- }
- return result;
- }
-
- /*===================================================================
- 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 class ObjectIndexedPropertyTest extends OgnlTestCase {
+ private static ObjectIndexed OBJECT_INDEXED = new ObjectIndexed();
- public ObjectIndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
- {
- super(name, root, expressionString, expectedResult, setValue);
+ private static Object[][] TESTS = {
+ // Arbitrary indexed properties
+ {OBJECT_INDEXED, "attributes[\"bar\"]", "baz"}, /* get non-indexed property through attributes Map */
+ {OBJECT_INDEXED, "attribute[\"foo\"]", "bar"}, /* get indexed property */
+ {OBJECT_INDEXED, "attribute[\"bar\"]", "baz", "newValue", "newValue"}, /* set indexed property */
+ {OBJECT_INDEXED, "attribute[\"bar\"]", "newValue"}, /* get indexed property back to confirm */
+ {OBJECT_INDEXED, "attributes[\"bar\"]", "newValue"}, /* get property back through Map to confirm */
+ {OBJECT_INDEXED, "attribute[\"other\"].attribute[\"bar\"]", "baz"}, /* get indexed property from indexed, then through other */
+ {OBJECT_INDEXED, "attribute[\"other\"].attributes[\"bar\"]", "baz"}, /* get property back through Map to confirm */
+ {OBJECT_INDEXED, "attribute[$]", OgnlException.class}, /* illegal DynamicSubscript access to object indexed property */
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+
+ 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 {
+ 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");
+ }
+ }
+ }
}
+ return result;
+ }
- public ObjectIndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult)
- {
- super(name, root, expressionString, expectedResult);
- }
+ /*===================================================================
+ 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: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedTest.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ObjectIndexedTest.java Thu Jan 22 22:32:36 2009
@@ -2,211 +2,176 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.ibatis.ognl.Ognl;
-import org.apache.ibatis.ognl.OgnlContext;
-import org.apache.ibatis.ognl.OgnlException;
-import org.apache.ibatis.ognl.OgnlRuntime;
-import org.apache.ibatis.ognl.SimpleNode;
-
-public class ObjectIndexedTest extends TestCase
-{
- protected OgnlContext context;
-
- /*===================================================================
- Public static classes
- ===================================================================*/
- public static interface TestInterface
- {
- String getSunk(String index);
- void setSunk(String index, String sunk);
- }
-
- public static class Test1 extends Object implements TestInterface
- {
- public String getSunk(String index)
- {
- return "foo";
- }
-
- public void setSunk(String index, String sunk)
- {
- /* do nothing */
- }
- }
-
- public static class Test2 extends Test1
- {
- public String getSunk(String index)
- {
- return "foo";
- }
-
- public void setSunk(String index, String sunk)
- {
- /* do nothing */
- }
- }
-
- public static class Test3 extends Test1
- {
- public String getSunk(String index)
- {
- return "foo";
- }
-
- public void setSunk(String index, String sunk)
- {
- /* do nothing */
- }
-
- public String getSunk(Object index)
- {
- return null;
- }
- }
-
- public static class Test4 extends Test1
- {
- public String getSunk(String index)
- {
- return "foo";
- }
-
- public void setSunk(String index, String sunk)
- {
- /* do nothing */
- }
-
- public void setSunk(Object index, String sunk)
- {
- /* do nothing */
- }
- }
-
- public static class Test5 extends Test1
- {
- public String getSunk(String index)
- {
- return "foo";
- }
-
- public void setSunk(String index, String sunk)
- {
- /* do nothing */
- }
-
- public String getSunk(Object index)
- {
- return null;
- }
-
- public void setSunk(Object index, String sunk)
- {
- /* do nothing */
- }
- }
-
- /*===================================================================
- Public static methods
- ===================================================================*/
- public static TestSuite suite()
- {
- return new TestSuite(ObjectIndexedTest.class);
- }
-
- /*===================================================================
- Constructors
- ===================================================================*/
- public ObjectIndexedTest()
- {
- super();
- }
-
- public ObjectIndexedTest(String name)
- {
- super(name);
- }
-
- /*===================================================================
- Public methods
- ===================================================================*/
- public void testPropertyDescriptorReflection() throws Exception
- {
- OgnlRuntime.getPropertyDescriptor(java.util.AbstractList.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.AbstractSequentialList.class, "");
- OgnlRuntime.getPropertyDescriptor(java.lang.reflect.Array.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.ArrayList.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.BitSet.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.Calendar.class, "");
- OgnlRuntime.getPropertyDescriptor(java.lang.reflect.Field.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.LinkedList.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.List.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.Iterator.class, "");
- OgnlRuntime.getPropertyDescriptor(java.lang.ThreadLocal.class, "");
- OgnlRuntime.getPropertyDescriptor(java.net.URL.class, "");
- OgnlRuntime.getPropertyDescriptor(java.util.Vector.class, "");
- }
-
- public void testObjectIndexAccess() throws OgnlException
- {
- SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]");
-
- context.put("ka", new Test1());
- Ognl.getValue(expression, context, "aksdj");
- }
-
- public void testObjectIndexInSubclass() throws OgnlException
- {
- SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]");
-
- context.put("ka", new Test2());
- Ognl.getValue(expression, context, "aksdj");
- }
-
- public void testMultipleObjectIndexGetters() throws OgnlException
- {
- SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]");
-
- context.put("ka", new Test3());
- try {
- Ognl.getValue(expression, context, new Test3());
- fail();
- } catch (OgnlException ex) {
- /* Should throw */
- }
- }
-
- public void testMultipleObjectIndexSetters() throws OgnlException
- {
- SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]");
-
- context.put("ka", new Test4());
- try {
- Ognl.getValue(expression, context, "aksdj");
- fail();
- } catch (OgnlException ex) {
- /* Should throw */
- }
- }
-
- public void testMultipleObjectIndexMethodPairs() throws OgnlException
- {
- SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]");
-
- context.put("ka", new Test5());
- try {
- Ognl.getValue(expression, context, "aksdj");
- fail();
- } catch (OgnlException ex) {
- /* Should throw */
- }
- }
-
- /*===================================================================
- Overridden methods
- ===================================================================*/
- protected void setUp()
- {
- context = (OgnlContext)Ognl.createDefaultContext(null);
+
+public class ObjectIndexedTest extends TestCase {
+ protected OgnlContext context;
+
+ /*===================================================================
+ Public static classes
+ ===================================================================*/
+ public static interface TestInterface {
+ String getSunk(String index);
+
+ void setSunk(String index, String sunk);
+ }
+
+ public static class Test1 extends Object implements TestInterface {
+ public String getSunk(String index) {
+ return "foo";
+ }
+
+ public void setSunk(String index, String sunk) {
+ /* do nothing */
+ }
+ }
+
+ public static class Test2 extends Test1 {
+ public String getSunk(String index) {
+ return "foo";
+ }
+
+ public void setSunk(String index, String sunk) {
+ /* do nothing */
+ }
+ }
+
+ public static class Test3 extends Test1 {
+ public String getSunk(String index) {
+ return "foo";
+ }
+
+ public void setSunk(String index, String sunk) {
+ /* do nothing */
+ }
+
+ public String getSunk(Object index) {
+ return null;
+ }
+ }
+
+ public static class Test4 extends Test1 {
+ public String getSunk(String index) {
+ return "foo";
+ }
+
+ public void setSunk(String index, String sunk) {
+ /* do nothing */
+ }
+
+ public void setSunk(Object index, String sunk) {
+ /* do nothing */
+ }
+ }
+
+ public static class Test5 extends Test1 {
+ public String getSunk(String index) {
+ return "foo";
}
+
+ public void setSunk(String index, String sunk) {
+ /* do nothing */
+ }
+
+ public String getSunk(Object index) {
+ return null;
+ }
+
+ public void setSunk(Object index, String sunk) {
+ /* do nothing */
+ }
+ }
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite() {
+ return new TestSuite(ObjectIndexedTest.class);
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public ObjectIndexedTest() {
+ super();
+ }
+
+ public ObjectIndexedTest(String name) {
+ super(name);
+ }
+
+ /*===================================================================
+ Public methods
+ ===================================================================*/
+ public void testPropertyDescriptorReflection() throws Exception {
+ OgnlRuntime.getPropertyDescriptor(java.util.AbstractList.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.AbstractSequentialList.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.lang.reflect.Array.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.ArrayList.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.BitSet.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.Calendar.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.lang.reflect.Field.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.LinkedList.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.List.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.Iterator.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.lang.ThreadLocal.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.net.URL.class, "");
+ OgnlRuntime.getPropertyDescriptor(java.util.Vector.class, "");
+ }
+
+ public void testObjectIndexAccess() throws OgnlException {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression("#ka.sunk[#root]");
+
+ context.put("ka", new Test1());
+ Ognl.getValue(expression, context, "aksdj");
+ }
+
+ public void testObjectIndexInSubclass() throws OgnlException {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression("#ka.sunk[#root]");
+
+ context.put("ka", new Test2());
+ Ognl.getValue(expression, context, "aksdj");
+ }
+
+ public void testMultipleObjectIndexGetters() throws OgnlException {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression("#ka.sunk[#root]");
+
+ context.put("ka", new Test3());
+ try {
+ Ognl.getValue(expression, context, new Test3());
+ fail();
+ } catch (OgnlException ex) {
+ /* Should throw */
+ }
+ }
+
+ public void testMultipleObjectIndexSetters() throws OgnlException {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression("#ka.sunk[#root]");
+
+ context.put("ka", new Test4());
+ try {
+ Ognl.getValue(expression, context, "aksdj");
+ fail();
+ } catch (OgnlException ex) {
+ /* Should throw */
+ }
+ }
+
+ public void testMultipleObjectIndexMethodPairs() throws OgnlException {
+ SimpleNode expression = (SimpleNode) Ognl.parseExpression("#ka.sunk[#root]");
+
+ context.put("ka", new Test5());
+ try {
+ Ognl.getValue(expression, context, "aksdj");
+ fail();
+ } catch (OgnlException ex) {
+ /* Should throw */
+ }
+ }
+
+ /*===================================================================
+ Overridden methods
+ ===================================================================*/
+ protected void setUp() {
+ context = (OgnlContext) Ognl.createDefaultContext(null);
+ }
}
\ No newline at end of file