Title: [waffle-scm] [731] trunk/waffle-core/src/test/java/org/codehaus/waffle/testmodel: Improved list value converter tests.

Diff

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/converters/ListValueConverterTest.java (730 => 731)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/converters/ListValueConverterTest.java	2008-06-18 08:26:39 UTC (rev 730)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/converters/ListValueConverterTest.java	2008-06-18 08:40:37 UTC (rev 731)
@@ -1,11 +1,14 @@
 package org.codehaus.waffle.bind.converters;
 
 import static java.text.MessageFormat.format;
+import static org.codehaus.waffle.testmodel.FakeControllerWithListMethods.methodParameterType;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.beans.IntrospectionException;
 import java.util.List;
 
 import ognl.OgnlException;
@@ -20,15 +23,17 @@
 public class ListValueConverterTest extends AbstractValueConverterTest {
 
     @Test
-    public void canAccept() {
+    public void canAccept() throws IntrospectionException {
         ListValueConverter converter = new ListValueConverter(new DefaultMessageResources());
         assertTrue(converter.accept(List.class));
+        assertTrue(converter.accept(methodParameterType("list")));
+        assertFalse(converter.accept(Object.class));
+        assertFalse(converter.accept(methodParameterType("object")));
     }
 
     @Test
     public void canConvertLists() throws OgnlException {
-        DefaultMessageResources resources = new DefaultMessageResources(configuration);
-        ListValueConverter converter = new ListValueConverter(resources);
+        ListValueConverter converter = new ListValueConverter(new DefaultMessageResources());
         // Note: no conversion is done from String to Numbers and the assertion is done on the string representation
         assertCanConvertValueToList(converter, INTEGERS, "-1,-2,-3");
         assertCanConvertValueToList(converter, LONGS, "1000,2000,3000");

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/converters/NumberListValueConverterTest.java (730 => 731)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/converters/NumberListValueConverterTest.java	2008-06-18 08:26:39 UTC (rev 730)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/converters/NumberListValueConverterTest.java	2008-06-18 08:40:37 UTC (rev 731)
@@ -25,17 +25,19 @@
     @Test
     public void canAccept() throws IntrospectionException {
         NumberListValueConverter converter = new NumberListValueConverter(new DefaultMessageResources());
+        assertTrue(converter.accept(List.class));
+        assertTrue(converter.accept(methodParameterType("list")));
         assertTrue(converter.accept(methodParameterType("listOfIntegers")));
         assertTrue(converter.accept(methodParameterType("listOfLongs")));
         assertTrue(converter.accept(methodParameterType("listOfDoubles")));
         assertTrue(converter.accept(methodParameterType("listOfFloats")));
+        assertFalse(converter.accept(Object.class));
         assertFalse(converter.accept(methodParameterType("listOfStrings")));
-    }
+        assertFalse(converter.accept(methodParameterType("object")));            }
 
     @Test
     public void canConvertListsOfNumbers() throws OgnlException, IntrospectionException {
-        DefaultMessageResources resources = new DefaultMessageResources(configuration);
-        NumberListValueConverter converter = new NumberListValueConverter(resources);
+        NumberListValueConverter converter = new NumberListValueConverter(new DefaultMessageResources());
         assertCanConvertValueToList(converter, INTEGERS, "-1,-2,-3", Long.class, "listOfIntegers");
         assertCanConvertValueToList(converter, LONGS, "1000,2000,3000", Long.class, "listOfLongs");
         assertCanConvertValueToList(converter, DOUBLES, "0.10,0.200,0.300", Double.class, "listOfDoubles");
@@ -43,10 +45,15 @@
     }
 
     @Test
+    public void canConvertNonParameterizedList() throws OgnlException, IntrospectionException {
+        NumberListValueConverter converter = new NumberListValueConverter(new DefaultMessageResources());
+        assertCanConvertValueToList(converter, LONGS, "1000,2000,3000", Long.class, "list"); 
+    }
+
+    @Test
     // TODO decide if this behaviour is appropriate or if a bind exception should be thrown
     public void canReturnListOfStringsIfParsingFails() throws OgnlException, IntrospectionException {
-        DefaultMessageResources resources = new DefaultMessageResources(configuration);
-        NumberListValueConverter converter = new NumberListValueConverter(resources);
+        NumberListValueConverter converter = new NumberListValueConverter(new DefaultMessageResources());
         assertCanConvertValueToList(converter, STRINGS, "one,two,three", String.class, "listOfStrings");
     }
 

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/testmodel/FakeControllerWithListMethods.java (730 => 731)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/testmodel/FakeControllerWithListMethods.java	2008-06-18 08:26:39 UTC (rev 730)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/testmodel/FakeControllerWithListMethods.java	2008-06-18 08:40:37 UTC (rev 731)
@@ -18,9 +18,12 @@
         return null;
     }
 
+    @SuppressWarnings("unchecked")
+    public void list(List list){};
     public void listOfStrings(List<String> list){};
     public void listOfIntegers(List<Integer> list){};
     public void listOfLongs(List<Integer> list){};
     public void listOfDoubles(List<Integer> list){};
     public void listOfFloats(List<Integer> list){};
+    public void object(Object object){};
 }
\ No newline at end of file


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to