23
23
24
24
import org .aopalliance .intercept .MethodInterceptor ;
25
25
import org .aopalliance .intercept .MethodInvocation ;
26
- import org .aspectj .weaver .tools .PointcutPrimitive ;
27
- import org .aspectj .weaver .tools .UnsupportedPointcutPrimitiveException ;
28
26
import org .junit .jupiter .api .BeforeEach ;
29
27
import org .junit .jupiter .api .Test ;
30
28
import test .annotation .EmptySpringAnnotation ;
41
39
import org .springframework .beans .testfixture .beans .subpkg .DeepBean ;
42
40
43
41
import static org .assertj .core .api .Assertions .assertThat ;
44
- import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
45
42
import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
46
43
import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
47
44
@@ -174,25 +171,25 @@ private void testWithinPackage(boolean matchSubpackages) throws SecurityExceptio
174
171
@ Test
175
172
public void testFriendlyErrorOnNoLocationClassMatching () {
176
173
AspectJExpressionPointcut pc = new AspectJExpressionPointcut ();
177
- assertThatIllegalStateException (). isThrownBy (() ->
178
- pc .matches (ITestBean .class ))
179
- .withMessageContaining ("expression" );
174
+ assertThatIllegalStateException ()
175
+ . isThrownBy (() -> pc . getClassFilter () .matches (ITestBean .class ))
176
+ .withMessageContaining ("expression" );
180
177
}
181
178
182
179
@ Test
183
180
public void testFriendlyErrorOnNoLocation2ArgMatching () {
184
181
AspectJExpressionPointcut pc = new AspectJExpressionPointcut ();
185
- assertThatIllegalStateException (). isThrownBy (() ->
186
- pc .matches (getAge , ITestBean .class ))
187
- .withMessageContaining ("expression" );
182
+ assertThatIllegalStateException ()
183
+ . isThrownBy (() -> pc . getMethodMatcher () .matches (getAge , ITestBean .class ))
184
+ .withMessageContaining ("expression" );
188
185
}
189
186
190
187
@ Test
191
188
public void testFriendlyErrorOnNoLocation3ArgMatching () {
192
189
AspectJExpressionPointcut pc = new AspectJExpressionPointcut ();
193
- assertThatIllegalStateException (). isThrownBy (() ->
194
- pc .matches (getAge , ITestBean .class , (Object []) null ))
195
- .withMessageContaining ("expression" );
190
+ assertThatIllegalStateException ()
191
+ . isThrownBy (() -> pc . getMethodMatcher () .matches (getAge , ITestBean .class , (Object []) null ))
192
+ .withMessageContaining ("expression" );
196
193
}
197
194
198
195
@@ -209,8 +206,10 @@ public void testMatchWithArgs() throws Exception {
209
206
// not currently testable in a reliable fashion
210
207
//assertDoesNotMatchStringClass(classFilter);
211
208
212
- assertThat (methodMatcher .matches (setSomeNumber , TestBean .class , 12D )).as ("Should match with setSomeNumber with Double input" ).isTrue ();
213
- assertThat (methodMatcher .matches (setSomeNumber , TestBean .class , 11 )).as ("Should not match setSomeNumber with Integer input" ).isFalse ();
209
+ assertThat (methodMatcher .matches (setSomeNumber , TestBean .class , 12D ))
210
+ .as ("Should match with setSomeNumber with Double input" ).isTrue ();
211
+ assertThat (methodMatcher .matches (setSomeNumber , TestBean .class , 11 ))
212
+ .as ("Should not match setSomeNumber with Integer input" ).isFalse ();
214
213
assertThat (methodMatcher .matches (getAge , TestBean .class )).as ("Should not match getAge" ).isFalse ();
215
214
assertThat (methodMatcher .isRuntime ()).as ("Should be a runtime match" ).isTrue ();
216
215
}
@@ -245,7 +244,7 @@ public void testDynamicMatchingProxy() {
245
244
@ Test
246
245
public void testInvalidExpression () {
247
246
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)" ;
248
- assertThatIllegalArgumentException ().isThrownBy (getPointcut (expression ):: getClassFilter ); // call to getClassFilter forces resolution
247
+ assertThatIllegalArgumentException ().isThrownBy (() -> getPointcut (expression ). getClassFilter (). matches ( Object . class ));
249
248
}
250
249
251
250
private TestBean getAdvisedProxy (String pointcutExpression , CallCountingInterceptor interceptor ) {
@@ -275,9 +274,7 @@ private void assertMatchesTestBeanClass(ClassFilter classFilter) {
275
274
@ Test
276
275
public void testWithUnsupportedPointcutPrimitive () {
277
276
String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())" ;
278
- assertThatExceptionOfType (UnsupportedPointcutPrimitiveException .class )
279
- .isThrownBy (() -> getPointcut (expression ).getClassFilter ()) // call to getClassFilter forces resolution...
280
- .satisfies (ex -> assertThat (ex .getUnsupportedPrimitive ()).isEqualTo (PointcutPrimitive .CALL ));
277
+ assertThat (getPointcut (expression ).getClassFilter ().matches (Object .class )).isFalse ();
281
278
}
282
279
283
280
@ Test
0 commit comments