|
40 | 40 | * |
41 | 41 | * @author Ramnivas Laddad |
42 | 42 | * @author Chris Beams |
| 43 | + * @author Yanming Zhou |
43 | 44 | */ |
44 | 45 | class AfterReturningGenericTypeMatchingTests { |
45 | 46 |
|
@@ -107,77 +108,74 @@ void returnTypeLowerBoundMatching() { |
107 | 108 | assertThat(counterAspect.getTestBeanInvocationsCount).isEqualTo(0); |
108 | 109 | } |
109 | 110 |
|
110 | | -} |
111 | | - |
| 111 | + static class GenericReturnTypeVariationClass { |
112 | 112 |
|
113 | | -class GenericReturnTypeVariationClass { |
| 113 | + public Collection<String> getStrings() { |
| 114 | + return new ArrayList<>(); |
| 115 | + } |
114 | 116 |
|
115 | | - public Collection<String> getStrings() { |
116 | | - return new ArrayList<>(); |
117 | | - } |
| 117 | + public Collection<Integer> getIntegers() { |
| 118 | + return new ArrayList<>(); |
| 119 | + } |
118 | 120 |
|
119 | | - public Collection<Integer> getIntegers() { |
120 | | - return new ArrayList<>(); |
121 | | - } |
| 121 | + public Collection<TestBean> getTestBeans() { |
| 122 | + return new ArrayList<>(); |
| 123 | + } |
122 | 124 |
|
123 | | - public Collection<TestBean> getTestBeans() { |
124 | | - return new ArrayList<>(); |
| 125 | + public Collection<Employee> getEmployees() { |
| 126 | + return new ArrayList<>(); |
| 127 | + } |
125 | 128 | } |
126 | 129 |
|
127 | | - public Collection<Employee> getEmployees() { |
128 | | - return new ArrayList<>(); |
129 | | - } |
130 | | -} |
131 | | - |
| 130 | + @Aspect |
| 131 | + static class CounterAspect { |
132 | 132 |
|
133 | | -@Aspect |
134 | | -class CounterAspect { |
| 133 | + int getRawsInvocationsCount; |
135 | 134 |
|
136 | | - int getRawsInvocationsCount; |
| 135 | + int getStringsInvocationsCount; |
137 | 136 |
|
138 | | - int getStringsInvocationsCount; |
| 137 | + int getIntegersInvocationsCount; |
139 | 138 |
|
140 | | - int getIntegersInvocationsCount; |
| 139 | + int getNumbersInvocationsCount; |
141 | 140 |
|
142 | | - int getNumbersInvocationsCount; |
| 141 | + int getTestBeanInvocationsCount; |
143 | 142 |
|
144 | | - int getTestBeanInvocationsCount; |
| 143 | + @Pointcut("execution(* org.springframework.aop.aspectj.generic.AfterReturningGenericTypeMatchingTests.GenericReturnTypeVariationClass.*(..))") |
| 144 | + public void anyTestMethod() { |
| 145 | + } |
145 | 146 |
|
146 | | - @Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericReturnTypeVariationClass.*(..))") |
147 | | - public void anyTestMethod() { |
148 | | - } |
| 147 | + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
| 148 | + public void incrementGetRawsInvocationsCount(Collection<?> ret) { |
| 149 | + getRawsInvocationsCount++; |
| 150 | + } |
149 | 151 |
|
150 | | - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
151 | | - public void incrementGetRawsInvocationsCount(Collection<?> ret) { |
152 | | - getRawsInvocationsCount++; |
153 | | - } |
| 152 | + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
| 153 | + public void incrementGetStringsInvocationsCount(Collection<String> ret) { |
| 154 | + getStringsInvocationsCount++; |
| 155 | + } |
154 | 156 |
|
155 | | - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
156 | | - public void incrementGetStringsInvocationsCount(Collection<String> ret) { |
157 | | - getStringsInvocationsCount++; |
158 | | - } |
| 157 | + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
| 158 | + public void incrementGetIntegersInvocationsCount(Collection<Integer> ret) { |
| 159 | + getIntegersInvocationsCount++; |
| 160 | + } |
159 | 161 |
|
160 | | - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
161 | | - public void incrementGetIntegersInvocationsCount(Collection<Integer> ret) { |
162 | | - getIntegersInvocationsCount++; |
163 | | - } |
| 162 | + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
| 163 | + public void incrementGetNumbersInvocationsCount(Collection<? extends Number> ret) { |
| 164 | + getNumbersInvocationsCount++; |
| 165 | + } |
164 | 166 |
|
165 | | - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
166 | | - public void incrementGetNumbersInvocationsCount(Collection<? extends Number> ret) { |
167 | | - getNumbersInvocationsCount++; |
168 | | - } |
| 167 | + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
| 168 | + public void incrementTestBeanInvocationsCount(Collection<? super TestBean> ret) { |
| 169 | + getTestBeanInvocationsCount++; |
| 170 | + } |
169 | 171 |
|
170 | | - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") |
171 | | - public void incrementTestBeanInvocationsCount(Collection<? super TestBean> ret) { |
172 | | - getTestBeanInvocationsCount++; |
| 172 | + public void reset() { |
| 173 | + getRawsInvocationsCount = 0; |
| 174 | + getStringsInvocationsCount = 0; |
| 175 | + getIntegersInvocationsCount = 0; |
| 176 | + getNumbersInvocationsCount = 0; |
| 177 | + getTestBeanInvocationsCount = 0; |
| 178 | + } |
173 | 179 | } |
174 | 180 |
|
175 | | - public void reset() { |
176 | | - getRawsInvocationsCount = 0; |
177 | | - getStringsInvocationsCount = 0; |
178 | | - getIntegersInvocationsCount = 0; |
179 | | - getNumbersInvocationsCount = 0; |
180 | | - getTestBeanInvocationsCount = 0; |
181 | | - } |
182 | 181 | } |
183 | | - |
0 commit comments