Skip to content

Commit

Permalink
fix UsingGetStackTraceTest (KengoTODA#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Mar 14, 2018
1 parent 33f4abd commit d8ae99b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 41 deletions.
2 changes: 1 addition & 1 deletion test-case/src/main/java/pkg/UsingGetStackTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class UsingGetStackTrace {
private final Logger logger = LoggerFactory.getLogger(getClass());

void method(RuntimeException ex) {
logger.error("Failed to determine The Answer to Life, The Universe and Everything; {}", 27, ex.getStackTrace());
logger.error("Failed to determine The Answer to Life, The Universe and Everything: {}; cause: {}", 27, ex.getStackTrace());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package jp.skypencil.findbugs.slf4j;

import com.youdevise.fbplugins.tdd4fb.DetectorAssert;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.Detector;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.collect.Multimap;
import java.util.Collections;
import java.util.Map;
import org.junit.jupiter.api.Test;
import pkg.UsingGetStackTrace;

/**
* Test for {@link ManualGetStackTraceDetector}.
Expand All @@ -15,11 +16,10 @@ public class UsingGetStackTraceTest {

@Test
public void testExceptionMethods() throws Exception {
BugReporter bugReporter = DetectorAssert.bugReporterForTesting();
Detector detector = new ManualGetStackTraceDetector(bugReporter);
DetectorAssert.assertNoBugsReported(UsingGetStackTrace.class, detector, bugReporter);
DetectorAssert.assertBugReported(UsingGetStackTrace.class, detector, bugReporter, new BugInstanceMatcher(
bugInstance -> bugInstance.getBugPattern().getAbbrev().equals("SLF4J_GET_STACK_TRACE")));
Map<String, Integer> expected = Collections.singletonMap("SLF4J_GET_STACK_TRACE", 1);
Multimap<String, String> longMessages = new XmlParser().expect(pkg.UsingGetStackTrace.class, expected);
assertThat(longMessages).containsEntry("SLF4J_GET_STACK_TRACE",
"Do not have use Throwable#getStackTrace. It is enough to provide throwable instance as the last argument, then binding will log its message.");
}

}

0 comments on commit d8ae99b

Please sign in to comment.