wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r1028041 - in /incubator/wink/trunk/wink-server/src: main/java/org/apache/wink/server/internal/registry/ test/java/org/apache/wink/server/internal/registry/
Date Wed, 27 Oct 2010 17:13:27 GMT
Author: jramos
Date: Wed Oct 27 17:13:27 2010
New Revision: 1028041

URL: http://svn.apache.org/viewvc?rev=1028041&view=rev
Log:
Fix a CTS failure when using a List parameter annotated with PathParam

Modified:
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/ValueConvertorTest.java

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java?rev=1028041&r1=1028040&r2=1028041&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
Wed Oct 27 17:13:27 2010
@@ -26,6 +26,7 @@ import java.lang.reflect.Member;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -501,13 +502,8 @@ public class ServerInjectableFactory ext
             decodeValues(values);
 
             try {
-                // does not make sense to support List as a PathParam method
-                // parameter, so, we get the last value:
-                if (values.size() > 0) {
-                    return getConvertor().convert(values.get(values.size() - 1));
-                } else {
-                    return getConvertor().convert(values);
-                }
+                Collections.reverse(values);
+                return getConvertor().convert(values);
             } catch (ConversionException e) {
                 throw new WebApplicationException(e.getCause(), Response.Status.NOT_FOUND);
             }

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java?rev=1028041&r1=1028040&r2=1028041&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
Wed Oct 27 17:13:27 2010
@@ -95,12 +95,25 @@ public class InjectableDataTest extends 
             assertEquals(1, p.size());
             assertEquals("a b+c", p.get(0));
         }
+        
+        @GET
+        @Path("multiValueList/{m}/{m}/{m}/{m}/{m}")
+        @Produces
+        public void getMultiValueList(@PathParam("m") List<String> m) {
+            assertEquals(5, m.size());
+            assertEquals("a", m.get(4));
+            assertEquals("b", m.get(3));
+            assertEquals("c", m.get(2));
+            assertEquals("d", m.get(1));
+            assertEquals("e", m.get(0));
+        }
 
         @GET
         @Path("simpleListMulti/{p:.*/.*}")
         @Produces
         public void getSimpleListMulti(@PathParam("p") List<String> p) {
-            assertEquals(1, p.size());
+            assertEquals(2, p.size());
+            assertEquals("a b+c", p.get(1));
             assertEquals("a/b", p.get(0));
         }
 
@@ -965,7 +978,7 @@ public class InjectableDataTest extends 
             MockHttpServletResponse mockResponse = invoke(mockRequest);
             assertEquals(204, mockResponse.getStatus());
         } catch (Exception e) {
-            e.printStackTrace();
+            e.printStackTrace(System.out);
             fail("method invocation failed");
         }
     }
@@ -977,6 +990,7 @@ public class InjectableDataTest extends 
         assertInvocation("pathParam/a%20b+c/encoded");
         assertInvocation("pathParam/a%20b+c/default");
         assertInvocation("pathParam/a%20b+c/simpleList");
+        assertInvocation("pathParam/a%20b+c/multiValueList/a/b/c/d/e");
         assertInvocation("pathParam/a%20b+c/simpleListMulti/a;m=1/b");
         assertInvocation("pathParam/a%20b+c/encodedList");
         assertInvocation("pathParam/a%20b+c/defaultList");

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/ValueConvertorTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/ValueConvertorTest.java?rev=1028041&r1=1028040&r2=1028041&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/ValueConvertorTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/ValueConvertorTest.java
Wed Oct 27 17:13:27 2010
@@ -414,6 +414,7 @@ public class ValueConvertorTest extends 
         public void getListInteger(@PathParam("p") List<Integer> p) {
             List<Integer> list = new ArrayList<Integer>();
             list.add(2);
+            list.add(1);
             assertEquals(list, p);
         }
 
@@ -430,6 +431,7 @@ public class ValueConvertorTest extends 
         public void getListString(@PathParam("p") List<String> p) {
             List<String> list = new ArrayList<String>();
             list.add("2");
+            list.add("1");
             assertEquals(list, p);
         }
 
@@ -446,6 +448,7 @@ public class ValueConvertorTest extends 
         public void getListStringConstructor(@PathParam("p") List<StringConstructorClass>
p) {
             List<StringConstructorClass> list = new ArrayList<StringConstructorClass>();
             list.add(new StringConstructorClass("2"));
+            list.add(new StringConstructorClass("1"));
             assertEquals(list, p);
         }
 
@@ -462,6 +465,7 @@ public class ValueConvertorTest extends 
         public void getListValueOf(@PathParam("p") List<ValueOfClass> p) {
             List<ValueOfClass> list = new ArrayList<ValueOfClass>();
             list.add(ValueOfClass.valueOf("2"));
+            list.add(ValueOfClass.valueOf("1"));
             assertEquals(list, p);
         }
 
@@ -480,6 +484,7 @@ public class ValueConvertorTest extends 
         public void getSetInteger(@PathParam("p") Set<Integer> p) {
             Set<Integer> list = new HashSet<Integer>();
             list.add(2);
+            list.add(1);
             assertEquals(list, p);
         }
 
@@ -496,6 +501,7 @@ public class ValueConvertorTest extends 
         public void getSetString(@PathParam("p") Set<String> p) {
             Set<String> list = new HashSet<String>();
             list.add("2");
+            list.add("1");
             assertEquals(list, p);
         }
 
@@ -512,6 +518,7 @@ public class ValueConvertorTest extends 
         public void getSetStringConstructor(@PathParam("p") Set<StringConstructorClass>
p) {
             Set<StringConstructorClass> list = new HashSet<StringConstructorClass>();
             list.add(new StringConstructorClass("2"));
+            list.add(new StringConstructorClass("1"));
             assertEquals(list, p);
         }
 
@@ -528,6 +535,7 @@ public class ValueConvertorTest extends 
         public void getSetValueOf(@PathParam("p") Set<ValueOfClass> p) {
             Set<ValueOfClass> list = new HashSet<ValueOfClass>();
             list.add(ValueOfClass.valueOf("2"));
+            list.add(ValueOfClass.valueOf("1"));
             assertEquals(list, p);
         }
 
@@ -546,6 +554,7 @@ public class ValueConvertorTest extends 
         public void getSortedSetInteger(@PathParam("p") SortedSet<Integer> p) {
             SortedSet<Integer> list = new TreeSet<Integer>();
             list.add(2);
+            list.add(1);
             assertEquals(list, p);
         }
 
@@ -562,6 +571,7 @@ public class ValueConvertorTest extends 
         public void getSortedSetString(@PathParam("p") SortedSet<String> p) {
             SortedSet<String> list = new TreeSet<String>();
             list.add("2");
+            list.add("1");
             assertEquals(list, p);
         }
 
@@ -578,6 +588,7 @@ public class ValueConvertorTest extends 
         public void getSortedSetStringConstructor(@PathParam("p") SortedSet<StringConstructorClass>
p) {
             SortedSet<StringConstructorClass> list = new TreeSet<StringConstructorClass>();
             list.add(new StringConstructorClass("2"));
+            list.add(new StringConstructorClass("1"));
             assertEquals(list, p);
         }
 
@@ -594,6 +605,7 @@ public class ValueConvertorTest extends 
         public void getSortedSetValueOf(@PathParam("p") SortedSet<ValueOfClass> p)
{
             SortedSet<ValueOfClass> list = new TreeSet<ValueOfClass>();
             list.add(ValueOfClass.valueOf("2"));
+            list.add(ValueOfClass.valueOf("1"));
             assertEquals(list, p);
         }
 
@@ -619,7 +631,7 @@ public class ValueConvertorTest extends 
             MockHttpServletResponse mockResponse = invoke(mockRequest);
             assertEquals(204, mockResponse.getStatus());
         } catch (Exception e) {
-            e.printStackTrace();
+            e.printStackTrace(System.out);
             fail("method invocation failed");
         }
     }
@@ -631,7 +643,7 @@ public class ValueConvertorTest extends 
             MockHttpServletResponse mockResponse = invoke(mockRequest);
             assertEquals(status, mockResponse.getStatus());
         } catch (IOException e) {
-            e.printStackTrace();
+            e.printStackTrace(System.out);
             fail("method invocation failed");
         }
     }



Mime
View raw message