forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-7436 Add empty statistics for SingleDuration to avoid NPE
(cherry picked from commit fa338b6)
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
debezium-core/src/test/java/io/debezium/util/StopwatchTest.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,40 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.util; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
import io.debezium.doc.FixFor; | ||
|
||
public class StopwatchTest { | ||
|
||
@FixFor("DBZ-7436") | ||
@Test | ||
public void whenCallingDurationsOnAStartedStopwatchItShouldNotFailWithANPE() { | ||
|
||
Stopwatch reusable = Stopwatch.reusable(); | ||
|
||
reusable.start(); | ||
|
||
String reusableStopWatchResults = reusable.durations().toString(); | ||
|
||
Stopwatch.StopwatchSet multiple = Stopwatch.multiple(); | ||
|
||
Stopwatch stopwatch = multiple.create(); | ||
|
||
String multipleStopWatchResults = stopwatch.durations().toString(); | ||
|
||
Stopwatch accumulating = Stopwatch.accumulating(); | ||
|
||
String accumulatingStopWatchResults = accumulating.durations().toString(); | ||
|
||
assertThat(reusableStopWatchResults).isEqualTo(" 0.00000s total; 0 samples; 0.00000s avg; 0.00000s min; 0.00000s max"); | ||
assertThat(multipleStopWatchResults).isEqualTo(" 0.00000s total; 0 samples; 0.00000s avg; 0.00000s min; 0.00000s max"); | ||
assertThat(accumulatingStopWatchResults).isEqualTo(" 0.00000s total; 0 samples; 0.00000s avg; 0.00000s min; 0.00000s max"); | ||
} | ||
} |