Polishing
This commit is contained in:
parent
d611c7484f
commit
c256af4ef7
|
|
@ -38,64 +38,66 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class TypePatternClassFilterTests {
|
||||
class TypePatternClassFilterTests {
|
||||
|
||||
@Test
|
||||
public void testInvalidPattern() {
|
||||
// should throw - pattern must be recognized as invalid
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new TypePatternClassFilter("-"));
|
||||
void nullPattern() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new TypePatternClassFilter(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidPatternMatching() {
|
||||
void invalidPattern() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new TypePatternClassFilter("-"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void invocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Exception {
|
||||
assertThatIllegalStateException().isThrownBy(() -> new TypePatternClassFilter().matches(String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void validPatternMatching() {
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
|
||||
assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue();
|
||||
assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue();
|
||||
assertThat(tpcf.matches(IOther.class)).as("Must match: in package").isTrue();
|
||||
|
||||
assertThat(tpcf.matches(DeepBean.class)).as("Must be excluded: in wrong package").isFalse();
|
||||
assertThat(tpcf.matches(BeanFactory.class)).as("Must be excluded: in wrong package").isFalse();
|
||||
assertThat(tpcf.matches(DefaultListableBeanFactory.class)).as("Must be excluded: in wrong package").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubclassMatching() {
|
||||
void subclassMatching() {
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.ITestBean+");
|
||||
|
||||
assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue();
|
||||
assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue();
|
||||
assertThat(tpcf.matches(CountingTestBean.class)).as("Must match: in package").isTrue();
|
||||
|
||||
assertThat(tpcf.matches(IOther.class)).as("Must be excluded: not subclass").isFalse();
|
||||
assertThat(tpcf.matches(DefaultListableBeanFactory.class)).as("Must be excluded: not subclass").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndOrNotReplacement() {
|
||||
void andOrNotReplacement() {
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String");
|
||||
assertThat(tpcf.matches(Number.class)).as("matches Number").isFalse();
|
||||
assertThat(tpcf.matches(Object.class)).as("matches Object").isTrue();
|
||||
assertThat(tpcf.matches(String.class)).as("matchesString").isTrue();
|
||||
|
||||
tpcf = new TypePatternClassFilter("java.lang.Number+ and java.lang.Float");
|
||||
assertThat(tpcf.matches(Float.class)).as("matches Float").isTrue();
|
||||
assertThat(tpcf.matches(Double.class)).as("matches Double").isFalse();
|
||||
|
||||
tpcf = new TypePatternClassFilter("java.lang.Number+ and not java.lang.Float");
|
||||
assertThat(tpcf.matches(Float.class)).as("matches Float").isFalse();
|
||||
assertThat(tpcf.matches(Double.class)).as("matches Double").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTypePatternWithNullArgument() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new TypePatternClassFilter(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Exception {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new TypePatternClassFilter().matches(String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
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.*");
|
||||
|
|
@ -105,7 +107,7 @@ public class TypePatternClassFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
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.*");
|
||||
|
|
@ -115,7 +117,7 @@ public class TypePatternClassFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue