-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#394 AnnotationClassFilter no longer uses ctClass.getClassFile().getA…
…ttributes() as this may throw a RuntimeException when CtClass is frozen
- Loading branch information
Showing
3 changed files
with
50 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
japicmp/src/test/java/japicmp/filter/AnnotationClassFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package japicmp.filter; | ||
|
||
import japicmp.util.CtClassBuilder; | ||
import javassist.ClassPool; | ||
import javassist.CtClass; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class AnnotationClassFilterTest { | ||
|
||
@Test | ||
public void testMatchesAnnotation() { | ||
AnnotationClassFilter annotationClassFilter = new AnnotationClassFilter("@japicmp.Exclude"); | ||
CtClass ctClass = CtClassBuilder.create() | ||
.name("japicmp.ExcludeMe") | ||
.withAnnotation("japicmp.Exclude") | ||
.addToClassPool(new ClassPool()); | ||
|
||
boolean matches = annotationClassFilter.matches(ctClass); | ||
|
||
assertThat(matches, is(true)); | ||
} | ||
|
||
@Test | ||
public void testMatchesNotAnnotation() { | ||
AnnotationClassFilter annotationClassFilter = new AnnotationClassFilter("@japicmp.Exclude"); | ||
CtClass ctClass = CtClassBuilder.create() | ||
.name("japicmp.ExcludeMeNot") | ||
.addToClassPool(new ClassPool()); | ||
ctClass.defrost(); | ||
|
||
boolean matches = annotationClassFilter.matches(ctClass); | ||
|
||
assertThat(matches, is(false)); | ||
} | ||
} |