Author: sergeyb Date: Tue Jul 23 17:19:10 2013 New Revision: 1506167 URL: http://svn.apache.org/r1506167 Log: Merged revisions 1506150 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
................ r1506150 | sergeyb | 2013-07-23 17:38:07 +0100 (Tue, 23 Jul 2013) | 9 lines Merged revisions 1506144 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1506144 | sergeyb | 2013-07-23 17:19:22 +0100 (Tue, 23 Jul 2013) | 1 line [CXF-5146] More work to do with having Typevariables recognized by Jackson ........ ................ Modified: cxf/branches/2.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1506150 Merged /cxf/trunk:r1506144 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Tue Jul 23 17:19:10 2013 @@ -24,7 +24,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -580,11 +579,9 @@ public class ClientProxyImpl extends Abs return r; } - Type genericType = method.getGenericReturnType(); - if (genericType instanceof TypeVariable) { - genericType = InjectionUtils.getSuperType(method.getDeclaringClass(), - (TypeVariable<?>)genericType); - } + Type genericType = + InjectionUtils.processGenericTypeIfNeeded(method.getDeclaringClass(), + method.getGenericReturnType()); return readBody(r, outMessage, @@ -645,7 +642,8 @@ public class ClientProxyImpl extends Abs try { if (bodyIndex != -1) { Type paramType = method.getGenericParameterTypes()[bodyIndex]; - + paramType = InjectionUtils.processGenericTypeIfNeeded(method.getDeclaringClass(), + paramType); writeBody(body, outMessage, body.getClass(), paramType, anns, headers, os); } else { Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Tue Jul 23 17:19:10 2013 @@ -412,7 +412,7 @@ public class WebClient extends AbstractC public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod, Object body, Class<T> memberClass) { Response r = doInvoke(httpMethod, body, null, - Collection.class, new ParameterizedCollectionType<T>(memberClass)); + Collection.class, new ParameterizedCollectionType(memberClass)); return CastUtils.cast((Collection<?>)r.getEntity(), memberClass); } @@ -423,7 +423,7 @@ public class WebClient extends AbstractC * @return JAX-RS Response */ public <T> Response postCollection(Object collection, Class<T> memberClass) { - return doInvoke("POST", collection, new ParameterizedCollectionType<T>(memberClass), + return doInvoke("POST", collection, new ParameterizedCollectionType(memberClass), Response.class, Response.class); } @@ -436,7 +436,7 @@ public class WebClient extends AbstractC */ public <T1, T2> T2 postCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { - Response r = doInvoke("POST", collection, new ParameterizedCollectionType<T1>(memberClass), + Response r = doInvoke("POST", collection, new ParameterizedCollectionType(memberClass), responseClass, responseClass); return responseClass.cast(responseClass == Response.class ? r : r.getEntity()); } @@ -451,8 +451,8 @@ public class WebClient extends AbstractC public <T1, T2> Collection<? extends T2> postAndGetCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass) { - Response r = doInvoke("POST", collection, new ParameterizedCollectionType<T1>(memberClass), - Collection.class, new ParameterizedCollectionType<T2>(responseClass)); + Response r = doInvoke("POST", collection, new ParameterizedCollectionType(memberClass), + Collection.class, new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); } @@ -466,7 +466,7 @@ public class WebClient extends AbstractC public <T> Collection<? extends T> postObjectGetCollection(Object body, Class<T> responseClass) { Response r = doInvoke("POST", body, null, Collection.class, - new ParameterizedCollectionType<T>(responseClass)); + new ParameterizedCollectionType(responseClass)); return CastUtils.cast((Collection<?>)r.getEntity(), responseClass); } Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Tue Jul 23 17:19:10 2013 @@ -24,7 +24,6 @@ import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Date; @@ -209,11 +208,11 @@ public class JAXRSOutInterceptor extends } Class<?> targetType = getRawResponseClass(responseObj); Type genericType = getGenericResponseType(invoked, responseObj, targetType); - if (genericType instanceof TypeVariable) { - genericType = InjectionUtils.getSuperType(ori.getClassResourceInfo().getServiceClass(), - (TypeVariable<?>)genericType); + if (ori != null) { + genericType = InjectionUtils.processGenericTypeIfNeeded( + ori.getClassResourceInfo().getServiceClass(), genericType); } - + Annotation[] annotations = invoked != null ? invoked.getAnnotations() : new Annotation[]{}; MessageBodyWriter<?> writer = null; Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Tue Jul 23 17:19:10 2013 @@ -1174,4 +1174,17 @@ public final class InjectionUtils { } } } + + public static Type processGenericTypeIfNeeded(Class<?> cls, Type type) { + if (type instanceof TypeVariable) { + return InjectionUtils.getSuperType(cls, (TypeVariable<?>)type); + } else if (type instanceof ParameterizedType + && ((ParameterizedType)type).getActualTypeArguments()[0] instanceof TypeVariable + && isSupportedCollectionOrArray(getRawType(type))) { + return new ParameterizedCollectionType(InjectionUtils.getActualType(type, 0)); + } else { + return type; + } + } + } Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Tue Jul 23 17:19:10 2013 @@ -26,7 +26,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -556,21 +555,20 @@ public final class JAXRSUtils { Method method = ori.getMethodToInvoke(); - Class<?>[] parameterTypes = method.getParameterTypes(); - Parameter[] paramsInfo = ori.getParameters().toArray(new Parameter[]{}); Method annotatedMethod = ori.getAnnotatedMethod(); - Type[] genericParameterTypes = annotatedMethod == null ? method.getGenericParameterTypes() - : annotatedMethod.getGenericParameterTypes(); - Annotation[][] anns = annotatedMethod == null ? null : annotatedMethod.getParameterAnnotations(); + Method actualMethod = annotatedMethod == null ? method : annotatedMethod; + + Class<?>[] parameterTypes = actualMethod.getParameterTypes(); + Parameter[] paramsInfo = ori.getParameters().toArray(new Parameter[ori.getParameters().size()]); + + Type[] genericParameterTypes = actualMethod.getGenericParameterTypes(); + Annotation[][] anns = actualMethod.getParameterAnnotations(); List<Object> params = new ArrayList<Object>(parameterTypes.length); for (int i = 0; i < parameterTypes.length; i++) { Class<?> param = parameterTypes[i]; - Type genericParam = genericParameterTypes[i]; - if (genericParam instanceof TypeVariable) { - genericParam = InjectionUtils.getSuperType(ori.getClassResourceInfo().getServiceClass(), - (TypeVariable<?>)genericParam); - } + Type genericParam = InjectionUtils.processGenericTypeIfNeeded( + ori.getClassResourceInfo().getServiceClass(), genericParameterTypes[i]); if (param == Object.class) { param = (Class<?>)genericParam; } else if (genericParam == Object.class) { Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java Tue Jul 23 17:19:10 2013 @@ -23,11 +23,11 @@ import java.lang.reflect.ParameterizedTy import java.lang.reflect.Type; import java.util.Collection; -public final class ParameterizedCollectionType<T> implements ParameterizedType { - private final Class<T> collectionMemberClass; +public final class ParameterizedCollectionType implements ParameterizedType { + private final Class<?> collectionMemberClass; private final Type[] typeArgs; - public ParameterizedCollectionType(Class<T> collectionMemberClass) { + public ParameterizedCollectionType(Class<?> collectionMemberClass) { this.collectionMemberClass = collectionMemberClass; this.typeArgs = new Type[] {collectionMemberClass}; } Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Tue Jul 23 17:19:10 2013 @@ -369,7 +369,7 @@ public class JAXBElementProviderTest ext TagVO2 tag = new TagVO2("a", "b"); List<TagVO2> tags = Collections.singletonList(tag); ByteArrayOutputStream bos = new ByteArrayOutputStream(); - provider.writeTo(tags, List.class, new ParameterizedCollectionType<TagVO2>(TagVO2.class), + provider.writeTo(tags, List.class, new ParameterizedCollectionType(TagVO2.class), new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(), bos); assertTrue(bos.toString().contains("prefix:thetag")); assertFalse(bos.toString().contains("ns1:thetag")); Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original) +++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Tue Jul 23 17:19:10 2013 @@ -134,7 +134,8 @@ public class JAXRSUtilsTest extends Asse headers.putSingle("Content-Type", ct); messageImpl.put(Message.PROTOCOL_HEADERS, headers); messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes())); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals("2 form params should've been identified", 2, params.size()); assertEquals("First Form Parameter not matched correctly", @@ -710,7 +711,8 @@ public class JAXRSUtilsTest extends Asse MessageImpl messageImpl = new MessageImpl(); messageImpl.put(Message.QUERY_STRING, "query=24&query2"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(4, params.size()); @@ -727,7 +729,8 @@ public class JAXRSUtilsTest extends Asse MessageImpl messageImpl = new MessageImpl(); messageImpl.put(Message.QUERY_STRING, "query=1&query=2"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -743,7 +746,8 @@ public class JAXRSUtilsTest extends Asse MessageImpl messageImpl = new MessageImpl(); messageImpl.put(Message.QUERY_STRING, "query=1&query=2"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -761,7 +765,8 @@ public class JAXRSUtilsTest extends Asse Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "query2=query2Value&query2=query2Value2&query3=1&query3=2&query4"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(6, params.size()); @@ -806,7 +811,8 @@ public class JAXRSUtilsTest extends Asse MultivaluedMap<String, String> headers = new MetadataMap<String, String>(); headers.add("Cookie", "c1=c1Value"); messageImpl.put(Message.PROTOCOL_HEADERS, headers); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(params.size(), 2); @@ -825,7 +831,8 @@ public class JAXRSUtilsTest extends Asse headers.add("Cookie", "c1=c1Value; c2=c2Value"); headers.add("Cookie", "c3=c3Value"); messageImpl.put(Message.PROTOCOL_HEADERS, headers); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(params.size(), 3); @@ -841,7 +848,8 @@ public class JAXRSUtilsTest extends Asse UUID u = UUID.randomUUID(); Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "p1=" + u.toString() + "&p2=1&p3=2"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(3, params.size()); @@ -857,7 +865,8 @@ public class JAXRSUtilsTest extends Asse Method m = Customer.class.getMethod("testFromValueParam", argType); Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "p1=Europe%2FLondon"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -874,7 +883,8 @@ public class JAXRSUtilsTest extends Asse Method m = Customer.class.getMethod("testCustomerParam", argType); messageImpl.put(Message.QUERY_STRING, "p1=Fred&p2=Barry&p3=Jack&p4=John"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(3, params.size()); @@ -904,7 +914,8 @@ public class JAXRSUtilsTest extends Asse Method m = Customer.class.getMethod("testLocaleParam", argType); messageImpl.put(Message.QUERY_STRING, "p1=en_us"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -922,7 +933,8 @@ public class JAXRSUtilsTest extends Asse Method m = Customer.class.getMethod("testCustomerParam", argType); messageImpl.put(Message.QUERY_STRING, "p3=jack"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(3, params.size()); @@ -938,7 +950,8 @@ public class JAXRSUtilsTest extends Asse Method m = Customer.class.getMethod("testCustomerParam2", argType); messageImpl.put(Message.QUERY_STRING, "p1=Fred&p1=Barry"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -954,9 +967,10 @@ public class JAXRSUtilsTest extends Asse Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "p1=1"); try { - JAXRSUtils.processParameters(new OperationResourceInfo(m, null), - null, - messageImpl); + JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), + null, + messageImpl); fail("HashMap can not be handled as parameter"); } catch (WebApplicationException ex) { assertEquals(500, ex.getResponse().getStatus()); @@ -974,9 +988,10 @@ public class JAXRSUtilsTest extends Asse MessageImpl messageImpl = new MessageImpl(); messageImpl.put(Message.QUERY_STRING, "p1=3"); try { - JAXRSUtils.processParameters(new OperationResourceInfo(m, null), - null, - messageImpl); + JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), + null, + messageImpl); fail("CustomerGender have no instance with name 3"); } catch (WebApplicationException ex) { assertEquals(404, ex.getResponse().getStatus()); @@ -1011,7 +1026,8 @@ public class JAXRSUtilsTest extends Asse Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "a=aValue"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -1026,7 +1042,8 @@ public class JAXRSUtilsTest extends Asse Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "a=aValue"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -1041,7 +1058,8 @@ public class JAXRSUtilsTest extends Asse Message messageImpl = createMessage(); messageImpl.put(Message.QUERY_STRING, "a=aValue"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @@ -1136,7 +1154,8 @@ public class JAXRSUtilsTest extends Asse String body = "a=aValue&b=123&cb=true"; messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes())); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals("Bean should be created", 1, params.size()); @@ -1186,7 +1205,8 @@ public class JAXRSUtilsTest extends Asse messageImpl.put(Message.PROTOCOL_HEADERS, headers); String body = "g.b=1&g.b=2"; messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes())); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals("Bean should be created", 1, params.size()); @@ -1205,7 +1225,8 @@ public class JAXRSUtilsTest extends Asse MessageImpl simpleMessageImpl, MultivaluedMap<String, String> complexValues, MessageImpl complexMessageImpl) throws Exception { - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), simpleValues, simpleMessageImpl); assertEquals("Bean should be created", 1, params.size()); @@ -1215,9 +1236,10 @@ public class JAXRSUtilsTest extends Asse assertEquals("aValue", cb.getA()); assertEquals(new Long(123), cb.getB()); - params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), - complexValues, - complexMessageImpl); + params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), + complexValues, + complexMessageImpl); assertEquals("Bean should be created", 1, params.size()); Customer.CustomerBean cb1 = (Customer.CustomerBean)params.get(0); assertNotNull(cb1); @@ -1296,7 +1318,8 @@ public class JAXRSUtilsTest extends Asse messageImpl.put(Message.QUERY_STRING, "query=first&query2=second&query3=3&query4=true&query5"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals("First Query Parameter of multiple was not matched correctly", "first", params.get(0)); @@ -1319,7 +1342,8 @@ public class JAXRSUtilsTest extends Asse MessageImpl messageImpl = new MessageImpl(); messageImpl.put(Message.REQUEST_URI, "/foo;p4=0;p3=3/bar;p1=1;p2/baz;p4=4;p4=5;p5"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals("5 Matrix params should've been identified", 6, params.size()); @@ -1348,7 +1372,8 @@ public class JAXRSUtilsTest extends Asse messageImpl.put(Message.REQUEST_URI, "/bar%20foo;p4=0%201"); MultivaluedMap<String, String> values = new MetadataMap<String, String>(); values.add("ps", "bar%20foo;p4=0%201"); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), values, messageImpl); assertEquals("2 params should've been identified", 2, params.size()); @@ -1383,7 +1408,8 @@ public class JAXRSUtilsTest extends Asse } messageImpl.put(Message.PROTOCOL_HEADERS, headers); messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes())); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals("2 form params should've been identified", 2, params.size()); @@ -1414,7 +1440,8 @@ public class JAXRSUtilsTest extends Asse } }); - List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), + List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, + new ClassResourceInfo(Customer.class)), new MetadataMap<String, String>(), messageImpl); assertEquals("3 params should've been identified", 3, params.size()); Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java Tue Jul 23 17:19:10 2013 @@ -21,7 +21,9 @@ package org.apache.cxf.systest.jaxrs; import java.io.ByteArrayOutputStream; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.PostConstruct; @@ -98,6 +100,16 @@ public class BookStoreSpring { } @SuppressWarnings("unchecked") + @GET + @Path("/books/superbooks") + @Produces("application/json") + public <T extends Book> List<T> getSuperBookCollectionJson() { + SuperBook book = new SuperBook("SuperBook", 999L); + + return Collections.singletonList((T)book); + } + + @SuppressWarnings("unchecked") @POST @Path("/books/superbook") @Consumes("application/json") @@ -106,6 +118,18 @@ public class BookStoreSpring { return (T)(SuperBook)book; } + @SuppressWarnings("unchecked") + @POST + @Path("/books/superbooks") + @Consumes("application/json") + @Produces("application/json") + public <T extends Book> List<T> echoSuperBookCollectionJson(List<T> book) { + if (book.get(0) instanceof SuperBook) { + return book; + } + throw new WebApplicationException(400); + } + @POST @Path("/books/xsitype") @Produces("application/xml") Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1506167&r1=1506166&r2=1506167&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java Tue Jul 23 17:19:10 2013 @@ -24,6 +24,7 @@ import java.net.URL; import java.net.URLConnection; import java.util.Collection; import java.util.Collections; +import java.util.List; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; @@ -75,6 +76,29 @@ public class JAXRSClientServerResourceJa } @Test + public void testGetSuperBookCollectionProxy() throws Exception { + + String endpointAddress = + "http://localhost:" + PORT + "/webapp/store2"; + BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class, + Collections.singletonList(new JacksonJsonProvider())); + List<SuperBook> books = proxy.getSuperBookCollectionJson(); + assertEquals(999L, books.get(0).getId()); + } + + @Test + public void testEchoSuperBookCollectionProxy() throws Exception { + + String endpointAddress = + "http://localhost:" + PORT + "/webapp/store2"; + BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class, + Collections.singletonList(new JacksonJsonProvider())); + List<SuperBook> books = + proxy.echoSuperBookCollectionJson(Collections.singletonList(new SuperBook("Super", 124L))); + assertEquals(124L, books.get(0).getId()); + } + + @Test public void testEchoSuperBookProxy() throws Exception { String endpointAddress = @@ -98,6 +122,20 @@ public class JAXRSClientServerResourceJa Book book = collection.iterator().next(); assertEquals(123L, book.getId()); } + + @Test + public void testGetCollectionOfSuperBooks() throws Exception { + + String endpointAddress = + "http://localhost:" + PORT + "/webapp/store2/books/superbooks"; + WebClient wc = WebClient.create(endpointAddress, + Collections.singletonList(new JacksonJsonProvider())); + wc.accept("application/json"); + Collection<? extends Book> collection = wc.getCollection(Book.class); + assertEquals(1, collection.size()); + Book book = collection.iterator().next(); + assertEquals(999L, book.getId()); + } private String getStringFromInputStream(InputStream in) throws Exception {
