This avoids printing multiple "(...)" lines in succession.
(The test is made a little more change-resistant by removing the
expected line number.)
Change-Id: I9ede5d0d15afecb06c61cbe2b2c5a70967616280
Signed-off-by: Stephen Kitt <skitt@redhat.com>
}
private void printStackTraceElements(PrintStream ps, String indent, List<StackTraceElement> stackTraceElements) {
}
private void printStackTraceElements(PrintStream ps, String indent, List<StackTraceElement> stackTraceElements) {
- stackTraceElements.forEach(line -> {
- if (isStackTraceElementInteresting(line)) {
- ps.println(indent + line);
- } else {
+ boolean ellipsis = false;
+ for (final StackTraceElement stackTraceElement : stackTraceElements) {
+ if (isStackTraceElementInteresting(stackTraceElement)) {
+ ps.println(indent + stackTraceElement);
+ ellipsis = false;
+ } else if (!ellipsis) {
ps.println(indent + "(...)");
ps.println(indent + "(...)");
}
private boolean isStackTraceElementInteresting(StackTraceElement element) {
}
private boolean isStackTraceElementInteresting(StackTraceElement element) {
assertThat(printReturnValue).isTrue();
// Assert expections about stack trace
assertThat(printReturnValue).isTrue();
// Assert expections about stack trace
- assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java:41)");
+ assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java");
assertThat(output).doesNotContain(TracingBroker.class.getName());
assertThat(output).doesNotContain(TracingBroker.class.getName());
+ String previousLine = "";
+ for (String line : output.split("\n")) {
+ if (line.contains("(...")) {
+ assertThat(previousLine.contains("(...)")).isFalse();
+ }
+ previousLine = line;
+ }
+
// We don't do any verify/times on the mocks,
// because the main point of the test is just to verify that
// printOpenTransactions runs through without any exceptions
// We don't do any verify/times on the mocks,
// because the main point of the test is just to verify that
// printOpenTransactions runs through without any exceptions