struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1185159 [2/2] - in /struts/struts2/branches/new_conversion: core/src/main/java/org/apache/struts2/util/ core/src/test/java/org/apache/struts2/util/ core/src/test/java/org/apache/struts2/views/jsp/ui/ core/src/test/resources/org/apache/stru...
Date Mon, 17 Oct 2011 13:27:45 GMT
Modified: struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java?rev=1185159&r1=1185158&r2=1185159&view=diff
==============================================================================
--- struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java
(original)
+++ struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java
Mon Oct 17 13:27:43 2011
@@ -170,27 +170,27 @@ public class XWorkBasicConverterTest ext
         assertTrue(basicConverter.isInRange(-1.2, "-1.2", Double.class));
         assertTrue(basicConverter.isInRange(1.5, "1.5", Double.class));
 
-        Object value = basicConverter.convertValue("-1.3", double.class);
+        Object value = basicConverter.convertValue(null,  "-1.3", double.class);
         assertNotNull(value);
         assertEquals(-1.3, value);
 
-        value = basicConverter.convertValue("1.8", double.class);
+        value = basicConverter.convertValue(null,  "1.8", double.class);
         assertNotNull(value);
         assertEquals(1.8, value);
 
-        value = basicConverter.convertValue("-1.9", double.class);
+        value = basicConverter.convertValue(null,  "-1.9", double.class);
         assertNotNull(value);
         assertEquals(-1.9, value);
 
-        value = basicConverter.convertValue("1.7", Double.class);
+        value = basicConverter.convertValue(null,  "1.7", Double.class);
         assertNotNull(value);
         assertEquals(1.7, value);
 
-        value = basicConverter.convertValue("0.0", Double.class);
+        value = basicConverter.convertValue(null,  "0.0", Double.class);
         assertNotNull(value);
         assertEquals(0.0, value);
 
-        value = basicConverter.convertValue("0.0", double.class);
+        value = basicConverter.convertValue(null,  "0.0", double.class);
         assertNotNull(value);
         assertEquals(0.0, value);
     }
@@ -201,25 +201,25 @@ public class XWorkBasicConverterTest ext
         assertTrue(basicConverter.isInRange(-1.65, "-1.65", Float.class));
         assertTrue(basicConverter.isInRange(1.9876, "1.9876", float.class));
 
-        Float value = (Float) basicConverter.convertValue("-1.444401", Float.class);
+        Float value = (Float) basicConverter.convertValue(null,  "-1.444401", Float.class);
         assertNotNull(value);
         assertEquals(Float.valueOf("-1.444401"), value);
 
-        value = (Float) basicConverter.convertValue("1.46464989", Float.class);
+        value = (Float) basicConverter.convertValue(null,  "1.46464989", Float.class);
         assertNotNull(value);
         assertEquals(Float.valueOf(1.46464989f), value);
     }
 
     public void testNegativeFloatValue() throws Exception {
         XWorkBasicConverter basicConverter = new XWorkBasicConverter();
-        Object convertedObject = basicConverter.convertValue("-94.1231233", Float.class);
+        Object convertedObject = basicConverter.convertValue(null,  "-94.1231233", Float.class);
         assertTrue(convertedObject instanceof Float);
         assertEquals(-94.1231233f, ((Float) convertedObject).floatValue(), 0.0001);
     }
 
     public void testPositiveFloatValue() throws Exception {
         XWorkBasicConverter basicConverter = new XWorkBasicConverter();
-        Object convertedObject = basicConverter.convertValue("94.1231233", Float.class);
+        Object convertedObject = basicConverter.convertValue(null,  "94.1231233", Float.class);
         assertTrue(convertedObject instanceof Float);
         assertEquals(94.1231233f, ((Float) convertedObject).floatValue(), 0.0001);
     }
@@ -227,21 +227,21 @@ public class XWorkBasicConverterTest ext
 
     public void testNegativeDoubleValue() throws Exception {
         XWorkBasicConverter basicConverter = new XWorkBasicConverter();
-        Object convertedObject = basicConverter.convertValue("-94.1231233", Double.class);
+        Object convertedObject = basicConverter.convertValue(null,  "-94.1231233", Double.class);
         assertTrue(convertedObject instanceof Double);
         assertEquals(-94.1231233d, ((Double) convertedObject).doubleValue(), 0.0001);
     }
 
     public void testPositiveDoubleValue() throws Exception {
         XWorkBasicConverter basicConverter = new XWorkBasicConverter();
-        Object convertedObject = basicConverter.convertValue("94.1231233", Double.class);
+        Object convertedObject = basicConverter.convertValue(null,  "94.1231233", Double.class);
         assertTrue(convertedObject instanceof Double);
         assertEquals(94.1231233d, ((Double) convertedObject).doubleValue(), 0.0001);
     }
 
     public void testNestedEnumValue() throws Exception {
         XWorkBasicConverter basicConverter = new XWorkBasicConverter();
-        Object convertedObject = basicConverter.convertValue(ParentClass.NestedEnum.TEST.name(),
ParentClass.NestedEnum.class);
+        Object convertedObject = basicConverter.convertValue(null,  ParentClass.NestedEnum.TEST.name(),
ParentClass.NestedEnum.class);
         assertTrue(convertedObject instanceof ParentClass.NestedEnum);
         assertEquals(ParentClass.NestedEnum.TEST, convertedObject);
     }

Modified: struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java?rev=1185159&r1=1185158&r2=1185159&view=diff
==============================================================================
--- struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
(original)
+++ struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
Mon Oct 17 13:27:43 2011
@@ -15,7 +15,12 @@
  */
 package com.opensymphony.xwork2.conversion.impl;
 
-import com.opensymphony.xwork2.*;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ModelDrivenAction;
+import com.opensymphony.xwork2.SimpleAction;
+import com.opensymphony.xwork2.TestBean;
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.conversion.TypeConverter;
 import com.opensymphony.xwork2.ognl.OgnlValueStack;
 import com.opensymphony.xwork2.test.ModelDrivenAction2;
 import com.opensymphony.xwork2.test.User;
@@ -25,7 +30,6 @@ import com.opensymphony.xwork2.util.Foo;
 import com.opensymphony.xwork2.util.FurColor;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
 import ognl.OgnlException;
-import ognl.OgnlRuntime;
 
 import java.io.IOException;
 import java.math.BigDecimal;
@@ -35,7 +39,16 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
 
 
 /**
@@ -122,7 +135,7 @@ public class XWorkConverterTest extends 
         ognlStackContext.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, "bean.birth");
 
         String[] value = new String[]{"invalid date"};
-        assertEquals("Conversion should have failed.", OgnlRuntime.NoConversionPossible,
converter.convertValue(ognlStackContext, action.getBean(), null, "birth", value, Date.class));
+        assertEquals("Conversion should have failed.", TypeConverter.NO_CONVERSION_POSSIBLE,
converter.convertValue(ognlStackContext, action.getBean(), null, "birth", value, Date.class));
         stack.pop();
 
         Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
@@ -141,7 +154,7 @@ public class XWorkConverterTest extends 
         ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
 
         String[] value = new String[]{"invalid date"};
-        assertEquals("Conversion should have failed.", OgnlRuntime.NoConversionPossible,
converter.convertValue(ognlStackContext, action, null, "date", value, Date.class));
+        assertEquals("Conversion should have failed.", TypeConverter.NO_CONVERSION_POSSIBLE,
converter.convertValue(ognlStackContext, action, null, "date", value, Date.class));
         stack.pop();
 
         Map conversionErrors = (Map) ognlStackContext.get(ActionContext.CONVERSION_ERRORS);
@@ -160,7 +173,7 @@ public class XWorkConverterTest extends 
         ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
 
         String[] value = new String[]{"invalid date"};
-        assertEquals("Conversion should have failed.", OgnlRuntime.NoConversionPossible,
converter.convertValue(ognlStackContext, action, null, "birth", value, Date.class));
+        assertEquals("Conversion should have failed.", TypeConverter.NO_CONVERSION_POSSIBLE,
converter.convertValue(ognlStackContext, action, null, "birth", value, Date.class));
         stack.pop();
         stack.pop();
 
@@ -175,18 +188,18 @@ public class XWorkConverterTest extends 
         // see XW-341
         String dateStr = "13/01/2005"; // us date format is used in context
         Object res = converter.convertValue(context, null, null, null, dateStr, Date.class);
-        assertEquals(res, OgnlRuntime.NoConversionPossible);
+        assertEquals(res, TypeConverter.NO_CONVERSION_POSSIBLE);
 
         dateStr = "02/30/2005"; // us date format is used in context
         res = converter.convertValue(context, null, null, null, dateStr, Date.class);
-        assertEquals(res, OgnlRuntime.NoConversionPossible);
+        assertEquals(res, TypeConverter.NO_CONVERSION_POSSIBLE);
 
         // and test a date that is passable
         SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
         dateStr = "12/31/2005"; // us date format
         res = converter.convertValue(context, null, null, null, dateStr, Date.class);
         Date date = format.parse(dateStr);
-        assertNotSame(res, OgnlRuntime.NoConversionPossible);
+        assertNotSame(res, TypeConverter.NO_CONVERSION_POSSIBLE);
         assertEquals(date, res);
     }
 
@@ -240,12 +253,11 @@ public class XWorkConverterTest extends 
         Map ognlStackContext = stack.getContext();
         ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
 
-        assertEquals("Conversion should have failed.", OgnlRuntime.NoConversionPossible,
converter.convertValue(ognlStackContext, action.getBean(), null, "count", "111.1", int.class));
+        assertEquals("Conversion should have failed.", 111, converter.convertValue(ognlStackContext,
action.getBean(), null, "count", "111.1", int.class));
         stack.pop();
 
         Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
-        assertNotNull(conversionErrors);
-        assertTrue(conversionErrors.size() == 1);
+        assertNull(conversionErrors);
     }
 
     public void testStringArrayToCollection() {
@@ -432,128 +444,128 @@ public class XWorkConverterTest extends 
     }
 
     public void testOverflows() {
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Double.MAX_VALUE + "1", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Double.MIN_VALUE + "-1", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Double.MAX_VALUE + "1", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Double.MIN_VALUE + "-1", Double.class));
-
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Float.MAX_VALUE + "1", float.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Float.MIN_VALUE + "-1", float.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Float.MAX_VALUE + "1", Float.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Float.MIN_VALUE + "-1", Float.class));
-
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Integer.MAX_VALUE + "1", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Integer.MIN_VALUE + "-1", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Integer.MAX_VALUE + "1", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Integer.MIN_VALUE + "-1", Integer.class));
-
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Byte.MAX_VALUE + "1", byte.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Byte.MIN_VALUE + "-1", byte.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Byte.MAX_VALUE + "1", Byte.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Byte.MIN_VALUE + "-1", Byte.class));
-
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Short.MAX_VALUE + "1", short.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Short.MIN_VALUE + "-1", short.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Short.MAX_VALUE + "1", Short.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Short.MIN_VALUE + "-1", Short.class));
-
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Long.MAX_VALUE + "1", long.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Long.MIN_VALUE + "-1", long.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Long.MAX_VALUE + "1", Long.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, Long.MIN_VALUE + "-1", Long.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Double.MAX_VALUE + "1", double.class));
+        assertEquals(Double.MIN_VALUE, converter.convertValue(context, null, null, null,
Double.MIN_VALUE + "-1", double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Double.MAX_VALUE + "1", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Double.MIN_VALUE + "-1", Double.class));
+
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Float.MAX_VALUE + "1", float.class));
+        assertEquals(Float.MIN_VALUE, converter.convertValue(context, null, null, null, Float.MIN_VALUE
+ "-1", float.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Float.MAX_VALUE + "1", Float.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Float.MIN_VALUE + "-1", Float.class));
+
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Integer.MAX_VALUE + "1", int.class));
+        assertEquals(Integer.MIN_VALUE, converter.convertValue(context, null, null, null,
Integer.MIN_VALUE + "-1", int.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Integer.MAX_VALUE + "1", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Integer.MIN_VALUE + "-1", Integer.class));
+
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Byte.MAX_VALUE + "1", byte.class));
+        assertEquals(Byte.MIN_VALUE, converter.convertValue(context, null, null, null, Byte.MIN_VALUE
+ "-1", byte.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Byte.MAX_VALUE + "1", Byte.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Byte.MIN_VALUE + "-1", Byte.class));
+
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Short.MAX_VALUE + "1", short.class));
+        assertEquals(Short.MIN_VALUE, converter.convertValue(context, null, null, null, Short.MIN_VALUE
+ "-1", short.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Short.MAX_VALUE + "1", Short.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Short.MIN_VALUE + "-1", Short.class));
+
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Long.MAX_VALUE + "1", long.class));
+        assertEquals(Long.MIN_VALUE, converter.convertValue(context, null, null, null, Long.MIN_VALUE
+ "-1", long.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Long.MAX_VALUE + "1", Long.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, Long.MIN_VALUE + "-1", Long.class));
     }
 
     public void testStringToInt() {
-        assertEquals(new Integer(123), converter.convertValue(context, null, null, null,
"123", int.class));
+        assertEquals(123, converter.convertValue(context, null, null, null, "123", int.class));
         context.put(ActionContext.LOCALE, Locale.US);
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123.12", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,23", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", int.class));
+        assertEquals(123, converter.convertValue(context, null, null, null, "123.12", int.class));
+        assertEquals(123, converter.convertValue(context, null, null, null, "123aa", int.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", int.class));
+        assertEquals(1234, converter.convertValue(context, null, null, null, "1,234", int.class));
+        assertEquals(123, converter.convertValue(context, null, null, null, "1,23", int.class));
+        assertEquals(1234, converter.convertValue(context, null, null, null, "1,234.12",
int.class));
+        assertEquals(1, converter.convertValue(context, null, null, null, "1.234", int.class));
+        assertEquals(1, converter.convertValue(context, null, null, null, "1.234,12", int.class));
         context.put(ActionContext.LOCALE, Locale.GERMANY);
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123.12", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,23", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234", int.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", int.class));
+        assertEquals(12312, converter.convertValue(context, null, null, null, "123.12", int.class));
+        assertEquals(123, converter.convertValue(context, null, null, null, "123aa", int.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", int.class));
+        assertEquals(1, converter.convertValue(context, null, null, null, "1,234", int.class));
+        assertEquals(1, converter.convertValue(context, null, null, null, "1,23", int.class));
+        assertEquals(1, converter.convertValue(context, null, null, null, "1,234.12", int.class));
+        assertEquals(1234, converter.convertValue(context, null, null, null, "1.234", int.class));
+        assertEquals(1234, converter.convertValue(context, null, null, null, "1.234,12",
int.class));
     }
 
 
     public void testStringToInteger() {
         assertEquals(new Integer(123), converter.convertValue(context, null, null, null,
"123", Integer.class));
         context.put(ActionContext.LOCALE, Locale.US);
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123.12", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "123.12", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "123aa", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", Integer.class));
         assertEquals(new Integer(1234), converter.convertValue(context, null, null, null,
"1,234", Integer.class));
         // WRONG: locale separator is wrongly placed
         assertEquals(new Integer(123), converter.convertValue(context, null, null, null,
"1,23", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1,234.12", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1.234", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1.234,12", Integer.class));
 
         context.put(ActionContext.LOCALE, Locale.GERMANY);
         // WRONG: locale separator is wrongly placed
         assertEquals(new Integer(12312), converter.convertValue(context, null, null, null,
"123.12", Integer.class));
         assertEquals(new Integer(1234), converter.convertValue(context, null, null, null,
"1.234", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,23", Integer.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "123aa", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1,234", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1,234.12", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1,23", Integer.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1.234,12", Integer.class));
     }
 
     public void testStringToPrimitiveDouble() {
-        assertEquals(new Double(123), converter.convertValue(context, null, null, null, "123",
double.class));
+        assertEquals(123.0, converter.convertValue(context, null, null, null, "123", double.class));
         context.put(ActionContext.LOCALE, Locale.US);
-        assertEquals(new Double(123.12), converter.convertValue(context, null, null, null,
"123.12", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,23", double.class));
-        assertEquals(new Double(1.234), converter.convertValue(context, null, null, null,
"1.234", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", double.class));
+        assertEquals(123.12, converter.convertValue(context, null, null, null, "123.12",
double.class));
+        assertEquals(123.0, converter.convertValue(context, null, null, null, "123aa", double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", double.class));
+        assertEquals(1234.0, converter.convertValue(context, null, null, null, "1,234", double.class));
+        assertEquals(1234.12, converter.convertValue(context, null, null, null, "1,234.12",
double.class));
+        assertEquals(123.0, converter.convertValue(context, null, null, null, "1,23", double.class));
+        assertEquals(1.234, converter.convertValue(context, null, null, null, "1.234", double.class));
+        assertEquals(1.234, converter.convertValue(context, null, null, null, "1.234,12",
double.class));
 
         context.put(ActionContext.LOCALE, Locale.GERMANY);
-        assertEquals(new Double(123.12), converter.convertValue(context, null, null, null,
"123.12", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,23", double.class));
-        assertEquals(new Double(1.234), converter.convertValue(context, null, null, null,
"1.234", double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", double.class));
+        assertEquals(12312.0, converter.convertValue(context, null, null, null, "123.12",
double.class));
+        assertEquals(123.0, converter.convertValue(context, null, null, null, "123aa", double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", double.class));
+        assertEquals(1.234, converter.convertValue(context, null, null, null, "1,234", double.class));
+        assertEquals(1.234, converter.convertValue(context, null, null, null, "1,234.12",
double.class));
+        assertEquals(1.23, converter.convertValue(context, null, null, null, "1,23", double.class));
+        assertEquals(1234.0, converter.convertValue(context, null, null, null, "1.234", double.class));
+        assertEquals(1234.12, converter.convertValue(context, null, null, null, "1.234,12",
double.class));
     }
 
     public void testStringToDouble() {
         assertEquals(new Double(123), converter.convertValue(context, null, null, null, "123",
Double.class));
         context.put(ActionContext.LOCALE, Locale.US);
         assertEquals(new Double(123.12), converter.convertValue(context, null, null, null,
"123.12", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "123aa", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", Double.class));
         assertEquals(new Double(1234), converter.convertValue(context, null, null, null,
"1,234", Double.class));
         assertEquals(new Double(1234.12), converter.convertValue(context, null, null, null,
"1,234.12", Double.class));
         // WRONG: locale separator is wrongly placed 
         assertEquals(new Double(123), converter.convertValue(context, null, null, null, "1,23",
Double.class));
         assertEquals(new Double(1.234), converter.convertValue(context, null, null, null,
"1.234", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1.234,12", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1.234,12", Double.class));
 
         context.put(ActionContext.LOCALE, Locale.GERMANY);
         // WRONG: locale separator is wrongly placed
         assertEquals(new Double(12312), converter.convertValue(context, null, null, null,
"123.12", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "123aa", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "aa123", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "123aa", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "aa123", Double.class));
         assertEquals(new Double(1.234), converter.convertValue(context, null, null, null,
"1,234", Double.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "1,234.12", Double.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "1,234.12", Double.class));
         assertEquals(new Double(1.23), converter.convertValue(context, null, null, null,
"1,23", Double.class));
         assertEquals(new Double(1234), converter.convertValue(context, null, null, null,
"1.234", Double.class));
         assertEquals(new Double(1234.12), converter.convertValue(context, null, null, null,
"1.234,12", Double.class));
@@ -562,8 +574,8 @@ public class XWorkConverterTest extends 
     
     public void testStringToEnum() {
         assertEquals(FurColor.BLACK, converter.convertValue(context, null, null, null, "BLACK",
FurColor.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "black", FurColor.class));
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, null,
null, null, "red", FurColor.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "black", FurColor.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
null, null, null, "red", FurColor.class));
     }
 
     // Testing for null result on non-primitive Number types supplied as empty String or

@@ -614,9 +626,9 @@ public class XWorkConverterTest extends 
         Class clazz2 = (Class) converter.convertValue(context, "com.opensymphony.xwork2.util.Bar",
Class.class);
         assertEquals(Bar.class.getName(), clazz2.getName());
 
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, "com.opensymphony.xwork2.util.IDoNotExist",
Class.class));
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
"com.opensymphony.xwork2.util.IDoNotExist", Class.class));
 
-        assertEquals(OgnlRuntime.NoConversionPossible, converter.convertValue(context, new
Bar(), Class.class)); // only supports string values
+        assertEquals(TypeConverter.NO_CONVERSION_POSSIBLE, converter.convertValue(context,
new Bar(), Class.class)); // only supports string values
     }
 
     public void testConvertBoolean() {

Modified: struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java?rev=1185159&r1=1185158&r2=1185159&view=diff
==============================================================================
--- struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
(original)
+++ struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
Mon Oct 17 13:27:43 2011
@@ -286,7 +286,7 @@ public class OgnlUtilTest extends XWorkT
         props.put("aLong", "123a");
 
         ognlUtil.setProperties(props, foo, context);
-        assertEquals(0, foo.getALong());
+        assertEquals(123L, foo.getALong());
     }
 
     /**

Modified: struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java?rev=1185159&r1=1185158&r2=1185159&view=diff
==============================================================================
--- struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
(original)
+++ struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
Mon Oct 17 13:27:43 2011
@@ -15,16 +15,29 @@
  */
 package com.opensymphony.xwork2.ognl;
 
-import com.opensymphony.xwork2.*;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.SimpleAction;
+import com.opensymphony.xwork2.TestBean;
+import com.opensymphony.xwork2.TextProvider;
+import com.opensymphony.xwork2.XWorkException;
+import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
 import com.opensymphony.xwork2.test.TestBean2;
-import com.opensymphony.xwork2.util.*;
+import com.opensymphony.xwork2.util.Bar;
+import com.opensymphony.xwork2.util.BarJunior;
+import com.opensymphony.xwork2.util.Cat;
+import com.opensymphony.xwork2.util.CompoundRoot;
+import com.opensymphony.xwork2.util.Dog;
 import com.opensymphony.xwork2.util.Foo;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
 import ognl.PropertyAccessor;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -118,7 +131,7 @@ public class OgnlValueStackTest extends 
         vs.findValue("barJunior.title", true);
     }
 
-     public void testSuccessFailOnErrorOnInheritedPropertiesWithMethods() {
+    public void testSuccessFailOnErrorOnInheritedPropertiesWithMethods() {
         //this shuld not fail as the property is defined on a parent class
         OgnlValueStack vs = createValueStack();
 
@@ -560,16 +573,9 @@ public class OgnlValueStackTest extends 
         stack.setDevMode("true");
         stack.push(action);
 
-        try {
-            stack.setValue("bar", "3x");
-            fail("Attempt to set 'bar' int property to '3x' should result in RuntimeException");
-        }
-        catch (RuntimeException re) {
-            assertTrue(true);
-        }
+        stack.setValue("bar", "3x");
 
-        Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
-        assertTrue(conversionErrors.containsKey("bar"));
+        assertEquals(3, action.getBar());
     }
 
     public void testPrimitiveSettingWithInvalidValueAddsFieldErrorInNonDevMode() {
@@ -580,8 +586,7 @@ public class OgnlValueStackTest extends 
         stack.push(action);
         stack.setValue("bar", "3x");
 
-        Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
-        assertTrue(conversionErrors.containsKey("bar"));
+        assertEquals(3, action.getBar());
     }
 
 

Modified: struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java?rev=1185159&r1=1185158&r2=1185159&view=diff
==============================================================================
--- struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
(original)
+++ struts/struts2/branches/new_conversion/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
Mon Oct 17 13:27:43 2011
@@ -6,6 +6,7 @@ import com.opensymphony.xwork2.config.pr
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -22,16 +23,14 @@ public class DoubleRangeValidatorTest ex
     private DoubleRangeFieldValidator val;
 
     public void testRangeValidationWithError() throws Exception {
-        // must set a locale to US as error message contains a locale dependent number (see
XW-490)
-        Locale defLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-        
-        ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME,
null);
+        Map<String, Object> context = new HashMap<String, Object>();
+        context.put(ActionContext.LOCALE, Locale.US);
+
+        ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME,
null, context);
         proxy.execute();
         assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
 
         Map<String, List<String>> errors = ((ValidationAware) proxy.getAction()).getFieldErrors();
-        Iterator it = errors.entrySet().iterator();
 
         List<String> errorMessages = errors.get("percentage");
         assertNotNull("Expected double range validation error message.", errorMessages);
@@ -40,8 +39,6 @@ public class DoubleRangeValidatorTest ex
         String errorMessage = errorMessages.get(0);
         assertNotNull("Expecting: percentage must be between 0.1 and 10.1, current value
is 100.0123.", errorMessage);
         assertEquals("percentage must be between 0.1 and 10.1, current value is 100.0123.",
errorMessage);
-
-        Locale.setDefault(defLocale);
     }
 
     public void testRangeValidationNoError() throws Exception {



Mime
View raw message