cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1452235 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Date Mon, 04 Mar 2013 10:20:50 GMT
Author: sergeyb
Date: Mon Mar  4 10:20:49 2013
New Revision: 1452235

URL: http://svn.apache.org/r1452235
Log:
Merged revisions 1452230 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1452230 | sergeyb | 2013-03-04 10:18:03 +0000 (Mon, 04 Mar 2013) | 1 line
  
  One more test to check parameter converters
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1452230

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1452235&r1=1452234&r2=1452235&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
Mon Mar  4 10:20:49 2013
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxrs;
 
+import java.io.Serializable;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -206,6 +207,10 @@ public class Customer extends AbstractCu
         
     }
     
+    public void testGenericObjectParam(@QueryParam("p1") Query<String> query) {
+        
+    }
+    
     public void testXmlAdapter(@QueryParam("a") 
                                @XmlJavaTypeAdapter(CustomerBeanAdapter.class) 
                                CustomerBean cb) {
@@ -533,4 +538,16 @@ public class Customer extends AbstractCu
         }
     }
     
+    public static class Query<T> implements Serializable {
+        
+        private static final long serialVersionUID = -1600323678121423761L;
+        private T entity;
+        public Query(T entity) {
+            this.entity = entity;
+        }
+        
+        public T getEntity() {
+            return entity;
+        }
+    }
 };

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1452235&r1=1452234&r2=1452235&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Mon Mar  4 10:20:49 2013
@@ -54,6 +54,7 @@ import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.Customer.CustomerContext;
+import org.apache.cxf.jaxrs.Customer.Query;
 import org.apache.cxf.jaxrs.Customer2;
 import org.apache.cxf.jaxrs.CustomerApplication;
 import org.apache.cxf.jaxrs.CustomerGender;
@@ -884,6 +885,24 @@ public class JAXRSUtilsTest extends Asse
     }
     
     @Test
+    public void testQueryParameter() throws Exception {
+        Message messageImpl = createMessage();
+        ProviderFactory.getInstance(messageImpl).registerUserProvider(
+            new GenericObjectParameterHandler());
+        Class<?>[] argType = {Query.class};
+        Method m = Customer.class.getMethod("testGenericObjectParam", argType);
+        
+        messageImpl.put(Message.QUERY_STRING, "p1=thequery");
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+                                                           null, 
+                                                           messageImpl);
+        assertEquals(1, params.size());
+        @SuppressWarnings("unchecked")
+        Query<String> query = (Query<String>)params.get(0);
+        assertEquals("thequery", query.getEntity());
+    }
+    
+    @Test
     public void testConstructorFirstAndParameterHandler() throws Exception {
         Message messageImpl = createMessage();
         ProviderFactory.getInstance(messageImpl).registerUserProvider(
@@ -1859,4 +1878,31 @@ public class JAXRSUtilsTest extends Asse
         }
         
     }
+    
+    private static class GenericObjectParameterHandler implements ParamConverterProvider,

+        ParamConverter<Query<String>> {
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public <T> ParamConverter<T> getConverter(Class<T> cls, Type arg1,
Annotation[] arg2) {
+            if (cls == Query.class) {
+                return (ParamConverter<T>)this;
+            } else {
+                return null;
+            }
+        }
+        
+        public Query<String> fromString(String s) {
+            return new Query<String>(s);
+        }
+
+        @Override
+        public String toString(Query<String> arg0) throws IllegalArgumentException
{
+            // TODO Auto-generated method stub
+            return null;
+        }
+        
+    }
+    
+    
 }



Mime
View raw message