diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 5bdc32d9a2ca811cb5d19c4081118e58c738c43d..fecad196da72f8239d93904bd2e259e0473ba22c 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,10 +65,13 @@ public class GenericTypeResolverTests { @Test public void methodReturnTypes() { - assertEquals(Integer.class, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)); - assertEquals(String.class, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)); + assertEquals(Integer.class, + resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)); + assertEquals(String.class, + resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)); assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)); - assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)); + assertEquals(null, + resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)); } /** @@ -135,20 +138,22 @@ public class GenericTypeResolverTests { */ @Test public void testResolveType() { - Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class); - MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0); - assertEquals(MyInterfaceType.class, - resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap())); - - Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage", MyInterfaceType[].class); - MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0); - assertEquals(MyInterfaceType[].class, - resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap())); - - Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage", Object[].class); - MethodParameter genericArrMessageMethodParam = new MethodParameter(genericArrMessageMethod, 0); - Map varMap = getTypeVariableMap(MySimpleTypeWithMethods.class); - assertEquals(Integer[].class, resolveType(genericArrMessageMethodParam.getGenericParameterType(), varMap)); + Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class); + MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0); + assertEquals(MyInterfaceType.class, + resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap())); + + Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage", + MyInterfaceType[].class); + MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0); + assertEquals(MyInterfaceType[].class, + resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap())); + + Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage", + Object[].class); + MethodParameter genericArrMessageMethodParam = new MethodParameter(genericArrMessageMethod, 0); + Map varMap = getTypeVariableMap(MySimpleTypeWithMethods.class); + assertEquals(Integer[].class, resolveType(genericArrMessageMethodParam.getGenericParameterType(), varMap)); } @@ -171,26 +176,44 @@ public class GenericTypeResolverTests { } public static class MyTypeWithMethods { - public MyInterfaceType integer() { return null; } - public MySimpleInterfaceType string() { return null; } - public Object object() { return null; } + + public MyInterfaceType integer() { + return null; + } + + public MySimpleInterfaceType string() { + return null; + } + + public Object object() { + return null; + } + @SuppressWarnings("rawtypes") - public MyInterfaceType raw() { return null; } - public String notParameterized() { return null; } - public String notParameterizedWithArguments(Integer x, Boolean b) { return null; } + public MyInterfaceType raw() { + return null; + } + + public String notParameterized() { + return null; + } + + public String notParameterizedWithArguments(Integer x, Boolean b) { + return null; + } /** - * Simulates a factory method that wraps the supplied object in a proxy - * of the same type. + * Simulates a factory method that wraps the supplied object in a proxy of the + * same type. */ public static T createProxy(T object) { return null; } /** - * Similar to {@link #createProxy(Object)} but adds an additional argument - * before the argument of type {@code T}. Note that they may potentially - * be of the same time when invoked! + * Similar to {@link #createProxy(Object)} but adds an additional argument before + * the argument of type {@code T}. Note that they may potentially be of the same + * time when invoked! */ public static T createNamedProxy(String name, T object) { return null; @@ -204,8 +227,8 @@ public class GenericTypeResolverTests { } /** - * Similar to {@link #createMock(Class)} but adds an additional method - * argument before the parameterized argument. + * Similar to {@link #createMock(Class)} but adds an additional method argument + * before the parameterized argument. */ public static T createNamedMock(String name, Class toMock) { return null; @@ -220,8 +243,8 @@ public class GenericTypeResolverTests { } /** - * Extract some value of the type supported by the interface (i.e., by - * a concrete, non-generic implementation of the interface). + * Extract some value of the type supported by the interface (i.e., by a concrete, + * non-generic implementation of the interface). */ public static T extractValueFrom(MyInterfaceType myInterfaceType) { return null;