Fixed ClassFilterAwareUnionMethodMatcher equals implementation

Issue: SPR-10604
This commit is contained in:
Juergen Hoeller
2013-08-02 10:34:28 +02:00
parent 9e20a25607
commit f329140dd4
2 changed files with 32 additions and 10 deletions

View File

@@ -43,6 +43,7 @@ public final class MethodMatchersTests {
private final Method IOTHER_ABSQUATULATE;
public MethodMatchersTests() throws Exception {
EXCEPTION_GETMESSAGE = Exception.class.getMethod("getMessage", (Class[]) null);
ITESTBEAN_GETAGE = ITestBean.class.getMethod("getAge", (Class[]) null);
@@ -50,6 +51,7 @@ public final class MethodMatchersTests {
IOTHER_ABSQUATULATE = IOther.class.getMethod("absquatulate", (Class[]) null);
}
@Test
public void testDefaultMatchesAll() throws Exception {
MethodMatcher defaultMm = MethodMatcher.TRUE;
@@ -99,23 +101,33 @@ public final class MethodMatchersTests {
assertTrue("Matched setAge method", union.matches(ITESTBEAN_SETAGE, TestBean.class));
assertTrue("Matched getAge method", union.matches(ITESTBEAN_GETAGE, TestBean.class));
assertFalse("Didn't matched absquatulate method", union.matches(IOTHER_ABSQUATULATE, TestBean.class));
}
@Test
public void testUnionEquals() {
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();
assertTrue(first.equals(second));
assertTrue(second.equals(first));
}
public static class StartsWithMatcher extends StaticMethodMatcher {
private String prefix;
private final String prefix;
public StartsWithMatcher(String s) {
this.prefix = s;
}
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getName().startsWith(prefix);
}
}
private static class TestDynamicMethodMatcherWhichMatches extends DynamicMethodMatcher {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
return true;
@@ -123,6 +135,7 @@ public final class MethodMatchersTests {
}
private static class TestDynamicMethodMatcherWhichDoesNotMatch extends DynamicMethodMatcher {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
return false;