2323
2424import org .aopalliance .intercept .MethodInterceptor ;
2525import org .aopalliance .intercept .MethodInvocation ;
26- import org .aspectj .weaver .tools .PointcutPrimitive ;
27- import org .aspectj .weaver .tools .UnsupportedPointcutPrimitiveException ;
2826import org .junit .jupiter .api .BeforeEach ;
2927import org .junit .jupiter .api .Test ;
3028import test .annotation .EmptySpringAnnotation ;
4139import org .springframework .beans .testfixture .beans .subpkg .DeepBean ;
4240
4341import static org .assertj .core .api .Assertions .assertThat ;
44- import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
4542import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
4643import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
4744
@@ -174,25 +171,25 @@ private void testWithinPackage(boolean matchSubpackages) throws SecurityExceptio
174171 @ Test
175172 public void testFriendlyErrorOnNoLocationClassMatching () {
176173 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" );
180177 }
181178
182179 @ Test
183180 public void testFriendlyErrorOnNoLocation2ArgMatching () {
184181 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" );
188185 }
189186
190187 @ Test
191188 public void testFriendlyErrorOnNoLocation3ArgMatching () {
192189 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" );
196193 }
197194
198195
@@ -209,8 +206,10 @@ public void testMatchWithArgs() throws Exception {
209206 // not currently testable in a reliable fashion
210207 //assertDoesNotMatchStringClass(classFilter);
211208
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 ();
214213 assertThat (methodMatcher .matches (getAge , TestBean .class )).as ("Should not match getAge" ).isFalse ();
215214 assertThat (methodMatcher .isRuntime ()).as ("Should be a runtime match" ).isTrue ();
216215 }
@@ -245,7 +244,7 @@ public void testDynamicMatchingProxy() {
245244 @ Test
246245 public void testInvalidExpression () {
247246 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 ));
249248 }
250249
251250 private TestBean getAdvisedProxy (String pointcutExpression , CallCountingInterceptor interceptor ) {
@@ -275,9 +274,7 @@ private void assertMatchesTestBeanClass(ClassFilter classFilter) {
275274 @ Test
276275 public void testWithUnsupportedPointcutPrimitive () {
277276 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 ();
281278 }
282279
283280 @ Test
0 commit comments