|
3 | 3 | import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly;
|
4 | 4 | import static org.hamcrest.Matchers.hasItem;
|
5 | 5 |
|
| 6 | +import edu.umd.cs.findbugs.BugCollection; |
| 7 | +import edu.umd.cs.findbugs.test.SpotBugsExtension; |
| 8 | +import edu.umd.cs.findbugs.test.SpotBugsRunner; |
6 | 9 | import org.apache.bcel.Const;
|
7 | 10 |
|
8 | 11 | import static org.hamcrest.MatcherAssert.assertThat;
|
|
13 | 16 | import edu.umd.cs.findbugs.annotations.Confidence;
|
14 | 17 | import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher;
|
15 | 18 | import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder;
|
| 19 | +import org.junit.jupiter.api.condition.DisabledOnJre; |
| 20 | +import org.junit.jupiter.api.condition.JRE; |
| 21 | +import org.junit.jupiter.api.extension.ExtendWith; |
16 | 22 |
|
| 23 | +import java.nio.file.Paths; |
| 24 | + |
| 25 | +@ExtendWith(SpotBugsExtension.class) |
17 | 26 | class FindOverridableMethodCallTest extends AbstractIntegrationTest {
|
| 27 | + @Test |
| 28 | + @DisabledOnJre({ JRE.JAVA_8 }) |
| 29 | + void testIssue2414_java11(SpotBugsRunner spotbugs) { |
| 30 | + BugCollection bugCollection = spotbugs.performAnalysis(Paths.get( |
| 31 | + "../spotbugsTestCases/build/classes/java/java17/overridableMethodCall/Issue2414.class")); |
| 32 | + |
| 33 | + final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() |
| 34 | + .bugType("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR") |
| 35 | + // .inClass("Issue2414") |
| 36 | + // .inMethod(Const.CONSTRUCTOR_NAME) |
| 37 | + // .withConfidence(Confidence.LOW) |
| 38 | + // .atLine(line) |
| 39 | + .build(); |
| 40 | + |
| 41 | + assertThat(bugCollection, containsExactly(1, bugInstanceMatcher)); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + void testIssue2414_java8() { |
| 46 | + performAnalysis("overridableMethodCall/Issue2414.class"); |
| 47 | + |
| 48 | + final BugInstanceMatcher bugInstanceMatcher = new BugInstanceMatcherBuilder() |
| 49 | + .bugType("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR") |
| 50 | + .build(); |
| 51 | + |
| 52 | + assertThat(getBugCollection(), containsExactly(0, bugInstanceMatcher)); |
| 53 | + } |
18 | 54 |
|
19 | 55 | @Test
|
20 | 56 | void testDirectCase() {
|
|
0 commit comments