Merge branch '5.1.x'
This commit is contained in:
@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Rod Johnson
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class TypePatternClassFilterTests {
|
||||
|
||||
@@ -93,4 +94,34 @@ public class TypePatternClassFilterTests {
|
||||
new TypePatternClassFilter().matches(String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
|
||||
|
||||
assertThat(filter1).isEqualTo(filter2);
|
||||
assertThat(filter1).isNotEqualTo(filter3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
|
||||
|
||||
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
|
||||
assertThat(filter1.hashCode()).isNotEqualTo(filter3.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
|
||||
assertThat(filter1.toString())
|
||||
.isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.tests.sample.beans.*");
|
||||
assertThat(filter1.toString()).isEqualTo(filter2.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
class ClassFiltersTests {
|
||||
|
||||
@@ -49,6 +50,8 @@ class ClassFiltersTests {
|
||||
ClassFilter union = ClassFilters.union(exceptionFilter, interfaceFilter);
|
||||
assertThat(union.matches(RuntimeException.class)).isTrue();
|
||||
assertThat(union.matches(TestBean.class)).isTrue();
|
||||
assertThat(union.toString())
|
||||
.matches("^.+UnionClassFilter: \\[.+RootClassFilter: .+Exception, .+RootClassFilter: .+TestBean\\]$");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,6 +62,8 @@ class ClassFiltersTests {
|
||||
assertThat(intersection.matches(RuntimeException.class)).isFalse();
|
||||
assertThat(intersection.matches(TestBean.class)).isFalse();
|
||||
assertThat(intersection.matches(NestedRuntimeException.class)).isTrue();
|
||||
assertThat(intersection.toString())
|
||||
.matches("^.+IntersectionClassFilter: \\[.+RootClassFilter: .+Exception, .+RootClassFilter: .+NestedRuntimeException\\]$");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,14 @@ public class ControlFlowPointcutTests {
|
||||
assertThat(new ControlFlowPointcut(One.class, "getAge").hashCode() == new ControlFlowPointcut(One.class).hashCode()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertThat(new ControlFlowPointcut(One.class).toString())
|
||||
.isEqualTo(ControlFlowPointcut.class.getName() + ": class = " + One.class.getName() + "; methodName = null");
|
||||
assertThat(new ControlFlowPointcut(One.class, "getAge").toString())
|
||||
.isEqualTo(ControlFlowPointcut.class.getName() + ": class = " + One.class.getName() + "; methodName = getAge");
|
||||
}
|
||||
|
||||
public class One {
|
||||
int getAge(ITestBean proxied) {
|
||||
return proxied.getAge();
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RootClassFilter}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.1.10
|
||||
*/
|
||||
class RootClassFilterTests {
|
||||
|
||||
private final ClassFilter filter1 = new RootClassFilter(Exception.class);
|
||||
private final ClassFilter filter2 = new RootClassFilter(Exception.class);
|
||||
private final ClassFilter filter3 = new RootClassFilter(ITestBean.class);
|
||||
|
||||
|
||||
@Test
|
||||
void matches() {
|
||||
assertThat(filter1.matches(Exception.class)).isTrue();
|
||||
assertThat(filter1.matches(RuntimeException.class)).isTrue();
|
||||
assertThat(filter1.matches(Error.class)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEquals() {
|
||||
assertThat(filter1).isEqualTo(filter2);
|
||||
assertThat(filter1).isNotEqualTo(filter3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHashCode() {
|
||||
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
|
||||
assertThat(filter1.hashCode()).isNotEqualTo(filter3.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString() {
|
||||
assertThat(filter1.toString()).isEqualTo("org.springframework.aop.support.RootClassFilter: java.lang.Exception");
|
||||
assertThat(filter1.toString()).isEqualTo(filter2.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aop.support;
|
||||
package org.springframework.aop.support.annotation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Unit tests for {@link AnnotationMatchingPointcut}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.2
|
||||
* @since 5.1.10
|
||||
*/
|
||||
class AnnotationMatchingPointcutTests {
|
||||
|
||||
@Test
|
||||
void classLevelPointCuts() {
|
||||
void classLevelPointcuts() {
|
||||
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, true);
|
||||
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, true);
|
||||
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class);
|
||||
@@ -59,7 +59,7 @@ class AnnotationMatchingPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void methodLevelPointCuts() {
|
||||
void methodLevelPointcuts() {
|
||||
Pointcut pointcut1 = new AnnotationMatchingPointcut(null, Qualifier.class, true);
|
||||
Pointcut pointcut2 = new AnnotationMatchingPointcut(null, Qualifier.class, true);
|
||||
Pointcut pointcut3 = new AnnotationMatchingPointcut(null, Qualifier.class);
|
||||
@@ -74,8 +74,7 @@ class AnnotationMatchingPointcutTests {
|
||||
assertThat(pointcut3.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
|
||||
|
||||
assertThat(pointcut1).isEqualTo(pointcut2);
|
||||
// TODO Uncomment the following once AnnotationMethodMatcher.equals(Object) has been fixed.
|
||||
// assertThat(pointcut1).isNotEqualTo(pointcut3);
|
||||
assertThat(pointcut1).isNotEqualTo(pointcut3);
|
||||
assertThat(pointcut1.hashCode()).isEqualTo(pointcut2.hashCode());
|
||||
// #1 and #3 have equivalent hash codes even though equals() returns false.
|
||||
assertThat(pointcut1.hashCode()).isEqualTo(pointcut3.hashCode());
|
||||
@@ -83,7 +82,7 @@ class AnnotationMatchingPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void classLevelAndMethodLevelPointCuts() {
|
||||
void classLevelAndMethodLevelPointcuts() {
|
||||
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class, true);
|
||||
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class, true);
|
||||
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class);
|
||||
Reference in New Issue
Block a user