|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2016 the original author or authors. |
| 2 | + * Copyright 2002-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -34,60 +34,54 @@ public class AutowireUtilsTests {
|
34 | 34 |
|
35 | 35 | @Test
|
36 | 36 | public void genericMethodReturnTypes() {
|
37 |
| - Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized", new Class[]{}); |
| 37 | + Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized"); |
38 | 38 | assertEquals(String.class,
|
39 | 39 | AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[]{}, getClass().getClassLoader()));
|
40 | 40 |
|
41 |
| - Method notParameterizedWithArguments = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterizedWithArguments", |
42 |
| - new Class[] { Integer.class, Boolean.class }); |
| 41 | + Method notParameterizedWithArguments = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterizedWithArguments", Integer.class, Boolean.class); |
43 | 42 | assertEquals(String.class,
|
44 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterizedWithArguments, new Object[] { 99, true }, getClass().getClassLoader())); |
| 43 | + AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterizedWithArguments, new Object[] {99, true}, getClass().getClassLoader())); |
45 | 44 |
|
46 |
| - Method createProxy = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createProxy", new Class[] { Object.class }); |
| 45 | + Method createProxy = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createProxy", Object.class); |
47 | 46 | assertEquals(String.class,
|
48 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createProxy, new Object[] { "foo" }, getClass().getClassLoader())); |
| 47 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createProxy, new Object[] {"foo"}, getClass().getClassLoader())); |
49 | 48 |
|
50 |
| - Method createNamedProxyWithDifferentTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy", |
51 |
| - new Class[] { String.class, Object.class }); |
| 49 | + Method createNamedProxyWithDifferentTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy", String.class, Object.class); |
52 | 50 | assertEquals(Long.class,
|
53 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDifferentTypes, new Object[] { "enigma", 99L }, getClass().getClassLoader())); |
| 51 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDifferentTypes, new Object[] {"enigma", 99L}, getClass().getClassLoader())); |
54 | 52 |
|
55 |
| - Method createNamedProxyWithDuplicateTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy", |
56 |
| - new Class[] { String.class, Object.class }); |
| 53 | + Method createNamedProxyWithDuplicateTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy", String.class, Object.class); |
57 | 54 | assertEquals(String.class,
|
58 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDuplicateTypes, new Object[] { "enigma", "foo" }, getClass().getClassLoader())); |
| 55 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDuplicateTypes, new Object[] {"enigma", "foo"}, getClass().getClassLoader())); |
59 | 56 |
|
60 |
| - Method createMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createMock", new Class[] { Class.class }); |
| 57 | + Method createMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createMock", Class.class); |
61 | 58 | assertEquals(Runnable.class,
|
62 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] { Runnable.class }, getClass().getClassLoader())); |
| 59 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] {Runnable.class}, getClass().getClassLoader())); |
63 | 60 | assertEquals(Runnable.class,
|
64 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] { Runnable.class.getName() }, getClass().getClassLoader())); |
| 61 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] {Runnable.class.getName()}, getClass().getClassLoader())); |
65 | 62 |
|
66 |
| - Method createNamedMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedMock", new Class[] { String.class, |
67 |
| - Class.class }); |
| 63 | + Method createNamedMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedMock", String.class, Class.class); |
68 | 64 | assertEquals(Runnable.class,
|
69 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedMock, new Object[] { "foo", Runnable.class }, getClass().getClassLoader())); |
| 65 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedMock, new Object[] {"foo", Runnable.class}, getClass().getClassLoader())); |
70 | 66 |
|
71 |
| - Method createVMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createVMock", |
72 |
| - new Class[] { Object.class, Class.class }); |
| 67 | + Method createVMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createVMock", Object.class, Class.class); |
73 | 68 | assertEquals(Runnable.class,
|
74 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(createVMock, new Object[] { "foo", Runnable.class }, getClass().getClassLoader())); |
| 69 | + AutowireUtils.resolveReturnTypeForFactoryMethod(createVMock, new Object[] {"foo", Runnable.class}, getClass().getClassLoader())); |
75 | 70 |
|
76 | 71 | // Ideally we would expect String.class instead of Object.class, but
|
77 | 72 | // resolveReturnTypeForFactoryMethod() does not currently support this form of
|
78 | 73 | // look-up.
|
79 |
| - Method extractValueFrom = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractValueFrom", |
80 |
| - new Class[] { MyInterfaceType.class }); |
| 74 | + Method extractValueFrom = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractValueFrom", MyInterfaceType.class); |
81 | 75 | assertEquals(Object.class,
|
82 |
| - AutowireUtils.resolveReturnTypeForFactoryMethod(extractValueFrom, new Object[] { new MySimpleInterfaceType() }, getClass().getClassLoader())); |
| 76 | + AutowireUtils.resolveReturnTypeForFactoryMethod(extractValueFrom, new Object[] {new MySimpleInterfaceType()}, getClass().getClassLoader())); |
83 | 77 |
|
84 | 78 | // Ideally we would expect Boolean.class instead of Object.class, but this
|
85 | 79 | // information is not available at run-time due to type erasure.
|
86 | 80 | Map<Integer, Boolean> map = new HashMap<>();
|
87 | 81 | map.put(0, false);
|
88 | 82 | map.put(1, true);
|
89 |
| - Method extractMagicValue = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractMagicValue", new Class[] { Map.class }); |
90 |
| - assertEquals(Object.class, AutowireUtils.resolveReturnTypeForFactoryMethod(extractMagicValue, new Object[] { map }, getClass().getClassLoader())); |
| 83 | + Method extractMagicValue = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractMagicValue", Map.class); |
| 84 | + assertEquals(Object.class, AutowireUtils.resolveReturnTypeForFactoryMethod(extractMagicValue, new Object[] {map}, getClass().getClassLoader())); |
91 | 85 | }
|
92 | 86 |
|
93 | 87 |
|
|
0 commit comments