diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepParserRulesTest.java index 0a1819d..2638118 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepParserRulesTest.java @@ -4,6 +4,8 @@ package com.microsoft.gctoolkit.parser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class ConcurrentMarkSweepParserRulesTest implements CMSPatterns { @@ -13,14 +15,14 @@ public class ConcurrentMarkSweepParserRulesTest implements CMSPatterns { */ @Test public void testCMSParseRules() { - assertTrue( rules.length == lines.length, "Number of rules differs from the numbers of log entries"); + assertEquals(rules.length, lines.length, "Number of rules differs from the numbers of log entries"); for (int i = 0; i < rules.length; i++) { for (int j = 0; j < lines.length; j++) { int captured = CommonTestHelper.captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, "rule " + i + " is greedy in that is captured dataset " + j); + assertEquals(0, captured, "rule " + i + " is greedy in that is captured dataset " + j); } } } @@ -44,7 +46,7 @@ public class ConcurrentMarkSweepParserRulesTest implements CMSPatterns { private void evaluate(GCParseRule rule, String string, boolean dump) { //The IDE eats messages printed to the log file.. thus this information *is* printed to stout GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { System.out.println("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepPhaseParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepPhaseParserRulesTest.java index ac62d95..0014593 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepPhaseParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/ConcurrentMarkSweepPhaseParserRulesTest.java @@ -6,6 +6,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class ConcurrentMarkSweepPhaseParserRulesTest implements CMSPatterns { @@ -18,7 +20,7 @@ public class ConcurrentMarkSweepPhaseParserRulesTest implements CMSPatterns { for (int j = 0; j < lines.length; j++) { GCLogTrace trace = rules[i].parse(lines[j]); if (trace != null) { - assertTrue(i == j, i + " captured " + j); + assertEquals(i, j, i + " captured " + j); } else { assertTrue(i != j, i + " captured " + j); } @@ -43,7 +45,7 @@ public class ConcurrentMarkSweepPhaseParserRulesTest implements CMSPatterns { private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCParserRulesTest.java index e45ac62..daf4762 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCParserRulesTest.java @@ -6,6 +6,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class G1GCParserRulesTest implements G1GCPatterns { @@ -18,9 +20,9 @@ public class G1GCParserRulesTest implements G1GCPatterns { for (int j = 0; j < lines.length; j++) { int captured = CommonTestHelper.captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } @@ -30,14 +32,14 @@ public class G1GCParserRulesTest implements G1GCPatterns { //@Test public void testSingeRule() { int index = 35; - assertTrue(CommonTestHelper.captureTest(rules[index], lines[index]) == 1); + assertEquals(1, CommonTestHelper.captureTest(rules[index], lines[index])); } private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCUnifiedParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCUnifiedParserRulesTest.java index 60f3f4f..8e95e4b 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCUnifiedParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/G1GCUnifiedParserRulesTest.java @@ -9,6 +9,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; import static com.microsoft.gctoolkit.parser.CommonTestHelper.captureTest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class G1GCUnifiedParserRulesTest implements UnifiedG1GCPatterns { @@ -21,9 +23,9 @@ public class G1GCUnifiedParserRulesTest implements UnifiedG1GCPatterns { for (int j = 0; j < lines.length; j++) { int captured = captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } @@ -41,14 +43,14 @@ public class G1GCUnifiedParserRulesTest implements UnifiedG1GCPatterns { //@Test public void testSingeRule() { int index = 0; - assertTrue(captureTest(rules[index], lines[index]) == lines[index].length); + assertEquals(captureTest(rules[index], lines[index]), lines[index].length); } private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/IncrementialConcurrentMarkSweepParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/IncrementialConcurrentMarkSweepParserRulesTest.java index 2f3479a..dd42894 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/IncrementialConcurrentMarkSweepParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/IncrementialConcurrentMarkSweepParserRulesTest.java @@ -6,7 +6,9 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class IncrementialConcurrentMarkSweepParserRulesTest implements ICMSPatterns { @@ -42,9 +44,9 @@ public class IncrementialConcurrentMarkSweepParserRulesTest implements ICMSPatte for (int k = 0; k < lines[j].length; k++) { GCLogTrace trace = rules[i].parse(lines[j][k]); if (trace != null) { - assertTrue(i == j, "rule @" + i + " matched record @" + j + ":" + k); + assertEquals(i, j, "rule @" + i + " matched record @" + j + ":" + k); } else { - assertTrue(i != j, "Rule missed @" + i + ":" + k); + assertNotEquals(i , j, "Rule missed @" + i + ":" + k); } } @@ -53,7 +55,7 @@ public class IncrementialConcurrentMarkSweepParserRulesTest implements ICMSPatte private void evaluate(GCParseRule rule, String string, boolean debugging) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (debugging) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/ParallelParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/ParallelParserRulesTest.java index 88f3d44..53b1a3b 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/ParallelParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/ParallelParserRulesTest.java @@ -7,7 +7,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; import static com.microsoft.gctoolkit.parser.CommonTestHelper.captureTest; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ParallelParserRulesTest implements ParallelPatterns { @@ -19,9 +20,9 @@ public class ParallelParserRulesTest implements ParallelPatterns { for (int j = 0; j < lines.length; j++) { int captured = captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } } @@ -42,7 +43,7 @@ public class ParallelParserRulesTest implements ParallelPatterns { private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { trace.notYetImplemented(); // LOGGER.fine("matches groups " + trace.groupCount()); diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/ShenandoahParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/ShenandoahParserRulesTest.java index 7521209..b12cd2e 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/ShenandoahParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/ShenandoahParserRulesTest.java @@ -7,6 +7,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class ShenandoahParserRulesTest implements ShenandoahPatterns { @@ -19,9 +21,9 @@ public class ShenandoahParserRulesTest implements ShenandoahPatterns { for (int j = 0; j < lines.length; j++) { int captured = captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } @@ -43,14 +45,14 @@ public class ShenandoahParserRulesTest implements ShenandoahPatterns { //@Test public void testSingeRule() { int index = 9; - assertTrue(captureTest(rules[index], lines[index]) == lines[index].length); + assertEquals(captureTest(rules[index], lines[index]), lines[index].length); } private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/UnifiedGenerationalParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/UnifiedGenerationalParserRulesTest.java index 21c293d..38fab7a 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/UnifiedGenerationalParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/UnifiedGenerationalParserRulesTest.java @@ -9,6 +9,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; import static com.microsoft.gctoolkit.parser.CommonTestHelper.captureTest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class UnifiedGenerationalParserRulesTest implements UnifiedGenerationalPatterns { @@ -21,9 +23,9 @@ public class UnifiedGenerationalParserRulesTest implements UnifiedGenerationalPa for (int j = 0; j < lines.length; j++) { int captured = captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } @@ -42,14 +44,14 @@ public class UnifiedGenerationalParserRulesTest implements UnifiedGenerationalPa //@Test public void testSingeRule() { int index = 0; - assertTrue(captureTest(rules[index], lines[index]) == 4); + assertEquals(4, captureTest(rules[index], lines[index])); } private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserRulesTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserRulesTest.java index 4947fe6..eaffdfe 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserRulesTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserRulesTest.java @@ -8,6 +8,8 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class ZGCParserRulesTest implements ZGCPatterns { @@ -20,9 +22,9 @@ public class ZGCParserRulesTest implements ZGCPatterns { for (int j = 0; j < lines.length; j++) { int captured = captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } @@ -52,14 +54,14 @@ public class ZGCParserRulesTest implements ZGCPatterns { //@Test public void testSingeRule() { int index = 14; - assertTrue(captureTest(rules[index], lines[index]) == lines[index].length); + assertEquals(captureTest(rules[index], lines[index]), lines[index].length); } private void evaluate(GCParseRule rule, String string, boolean dump) { GCLogTrace trace = rule.parse(string); - assertTrue(trace != null); + assertNotNull(trace); if (dump) { LOGGER.fine("matches groups " + trace.groupCount()); for (int i = 0; i <= trace.groupCount(); i++) { diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserTest.java index e1c5f9e..c25b122 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/ZGCParserTest.java @@ -6,14 +6,16 @@ import com.microsoft.gctoolkit.event.zgc.OccupancySummary; import com.microsoft.gctoolkit.event.zgc.ReclaimSummary; import com.microsoft.gctoolkit.event.zgc.ZGCCycle; import com.microsoft.gctoolkit.event.zgc.ZGCMemoryPoolSummary; -import com.microsoft.gctoolkit.parser.ZGCParser; import com.microsoft.gctoolkit.parser.jvm.LoggingDiary; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + public class ZGCParserTest { @@ -59,61 +61,61 @@ public class ZGCParserTest { ZGCParser parser = new ZGCParser(new LoggingDiary(), event -> { try { ZGCCycle zgc = (ZGCCycle) event; - Assertions.assertEquals(toInt(0.038d,1000), toInt(zgc.getDuration(),1000)); - Assertions.assertEquals(toInt(3.558d, 1000), toInt(zgc.getDateTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals("Warmup", zgc.getGCCause().getLabel()); + assertEquals(toInt(0.038d,1000), toInt(zgc.getDuration(),1000)); + assertEquals(toInt(3.558d, 1000), toInt(zgc.getDateTimeStamp().getTimeStamp(), 1000)); + assertEquals("Warmup", zgc.getGCCause().getLabel()); // Durations - Assertions.assertEquals(toInt(3.558d, 1000), toInt(zgc.getPauseMarkStartTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.558d, 1000), toInt(zgc.getConcurrentMarkTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.573d, 1000), toInt(zgc.getPauseMarkEndTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.574d, 1000), toInt(zgc.getConcurrentProcessNonStrongReferencesTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.577d, 1000), toInt(zgc.getConcurrentResetRelocationSetTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.578d, 1000), toInt(zgc.getConcurrentSelectRelocationSetTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.582d, 1000), toInt(zgc.getPauseRelocateStartTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals(toInt(3.583d, 1000), toInt(zgc.getConcurrentRelocateTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.558d, 1000), toInt(zgc.getPauseMarkStartTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.558d, 1000), toInt(zgc.getConcurrentMarkTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.573d, 1000), toInt(zgc.getPauseMarkEndTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.574d, 1000), toInt(zgc.getConcurrentProcessNonStrongReferencesTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.577d, 1000), toInt(zgc.getConcurrentResetRelocationSetTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.578d, 1000), toInt(zgc.getConcurrentSelectRelocationSetTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.582d, 1000), toInt(zgc.getPauseRelocateStartTimeStamp().getTimeStamp(), 1000)); + assertEquals(toInt(3.583d, 1000), toInt(zgc.getConcurrentRelocateTimeStamp().getTimeStamp(), 1000)); - Assertions.assertEquals( toInt(0.460d, 1000), toInt(zgc.getPauseMarkStartDuration(), 1000)); - Assertions.assertEquals(toInt(14.621d, 1000), toInt(zgc.getConcurrentMarkDuration(), 1000)); - Assertions.assertEquals( toInt(0.830d, 1000), toInt(zgc.getPauseMarkEndDuration(), 1000)); - Assertions.assertEquals( toInt(3.654d, 1000), toInt(zgc.getConcurrentProcessNonStrongReferencesDuration(), 1000)); - Assertions.assertEquals( toInt(0.194d, 1000), toInt(zgc.getConcurrentResetRelocationSetDuration(), 1000)); - Assertions.assertEquals( toInt(3.193d, 1000), toInt(zgc.getConcurrentSelectRelocationSetDuration(), 1000)); - Assertions.assertEquals( toInt(0.794d, 1000), toInt(zgc.getPauseRelocateStartDuration(), 1000)); - Assertions.assertEquals(toInt(12.962d, 1000), toInt(zgc.getConcurrentRelocateDuration(), 1000)); + assertEquals( toInt(0.460d, 1000), toInt(zgc.getPauseMarkStartDuration(), 1000)); + assertEquals(toInt(14.621d, 1000), toInt(zgc.getConcurrentMarkDuration(), 1000)); + assertEquals( toInt(0.830d, 1000), toInt(zgc.getPauseMarkEndDuration(), 1000)); + assertEquals( toInt(3.654d, 1000), toInt(zgc.getConcurrentProcessNonStrongReferencesDuration(), 1000)); + assertEquals( toInt(0.194d, 1000), toInt(zgc.getConcurrentResetRelocationSetDuration(), 1000)); + assertEquals( toInt(3.193d, 1000), toInt(zgc.getConcurrentSelectRelocationSetDuration(), 1000)); + assertEquals( toInt(0.794d, 1000), toInt(zgc.getPauseRelocateStartDuration(), 1000)); + assertEquals(toInt(12.962d, 1000), toInt(zgc.getConcurrentRelocateDuration(), 1000)); //Memory - Assertions.assertTrue(checkZGCMemoryPoolSummary(zgc.getMarkStart(), 936L, 42L, 3160L, 894)); //1074L, 1074L, 1074L)); - Assertions.assertTrue(checkZGCMemoryPoolSummary(zgc.getMarkEnd(), 1074L, 42L, 3084L, 970L)); - Assertions.assertTrue(checkZGCMemoryPoolSummary(zgc.getRelocateStart(),1074L, 42L, 3852L, 202L)); - Assertions.assertTrue(checkZGCMemoryPoolSummary(zgc.getRelocateEnd(), 1074L, 42L, 3868L, 186L)); + assertTrue(checkZGCMemoryPoolSummary(zgc.getMarkStart(), 936L, 42L, 3160L, 894)); //1074L, 1074L, 1074L)); + assertTrue(checkZGCMemoryPoolSummary(zgc.getMarkEnd(), 1074L, 42L, 3084L, 970L)); + assertTrue(checkZGCMemoryPoolSummary(zgc.getRelocateStart(),1074L, 42L, 3852L, 202L)); + assertTrue(checkZGCMemoryPoolSummary(zgc.getRelocateEnd(), 1074L, 42L, 3868L, 186L)); - Assertions.assertTrue(checkOccupancySummary(zgc.getLive(), 8L, 8L, 8L)); - Assertions.assertTrue(checkOccupancySummary(zgc.getAllocated(), 172L, 172L, 376L)); - Assertions.assertTrue(checkOccupancySummary(zgc.getGarbage(), 885L, 117L, 5L)); + assertTrue(checkOccupancySummary(zgc.getLive(), 8L, 8L, 8L)); + assertTrue(checkOccupancySummary(zgc.getAllocated(), 172L, 172L, 376L)); + assertTrue(checkOccupancySummary(zgc.getGarbage(), 885L, 117L, 5L)); - Assertions.assertTrue(checkReclaimSummary(zgc.getReclaimed(), 768L, 880L)); - Assertions.assertTrue(checkReclaimSummary(zgc.getMemorySummary(), 894L, 186L)); + assertTrue(checkReclaimSummary(zgc.getReclaimed(), 768L, 880L)); + assertTrue(checkReclaimSummary(zgc.getMemorySummary(), 894L, 186L)); - Assertions.assertTrue(zgc.getLoadAverageAt(1) == 4.28); - Assertions.assertTrue(zgc.getLoadAverageAt(5) == 3.95); - Assertions.assertTrue(zgc.getLoadAverageAt(15) == 3.22); + assertEquals(4.28, zgc.getLoadAverageAt(1)); + assertEquals(3.95, zgc.getLoadAverageAt(5)); + assertEquals(3.22, zgc.getLoadAverageAt(15)); - Assertions.assertTrue(zgc.getMMU(2) == 32.7); - Assertions.assertTrue(zgc.getMMU(5) == 60.8); - Assertions.assertTrue(zgc.getMMU(10) == 80.4); - Assertions.assertTrue(zgc.getMMU(20) == 85.4); - Assertions.assertTrue(zgc.getMMU(50) == 90.8); - Assertions.assertTrue(zgc.getMMU(100) == 95.4); + assertEquals(32.7, zgc.getMMU(2)); + assertEquals(60.8, zgc.getMMU(5)); + assertEquals(80.4, zgc.getMMU(10)); + assertEquals(85.4, zgc.getMMU(20)); + assertEquals(90.8, zgc.getMMU(50)); + assertEquals(95.4, zgc.getMMU(100)); } catch (Throwable t) { - Assertions.fail(t); + fail(t); } eventCreated.set(true); }); Arrays.stream(eventLogEntries).forEach(parser::receive); - Assertions.assertTrue(eventCreated.get()); + assertTrue(eventCreated.get()); } diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/diary/CommandLineFlagsLogDiaryTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/diary/CommandLineFlagsLogDiaryTest.java index 5d4417b..5fe952a 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/diary/CommandLineFlagsLogDiaryTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/diary/CommandLineFlagsLogDiaryTest.java @@ -7,6 +7,7 @@ import com.microsoft.gctoolkit.parser.jvm.LoggingDiary; import com.microsoft.gctoolkit.parser.jvm.PreUnifiedJVMConfiguration; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; public class CommandLineFlagsLogDiaryTest { @@ -43,22 +44,22 @@ public class CommandLineFlagsLogDiaryTest { assertTrue(diary.isGenerational()); assertTrue(diary.hasPrintReferenceGC()); - assertTrue(!diary.isDefNew()); - assertTrue(!diary.isSerialFull()); - assertTrue(!diary.isICMS()); - assertTrue(!diary.isPSYoung()); - assertTrue(!diary.isPSOldGen()); - assertTrue(!diary.isG1GC()); - assertTrue(!diary.isZGC()); - assertTrue(!diary.isShenandoah()); - assertTrue(!diary.isCMSDebugLevel1()); - assertTrue(!diary.isApplicationStoppedTime()); - assertTrue(!diary.isApplicationRunningTime()); - assertTrue(!diary.isJDK70()); - assertTrue(!diary.isPre70_40()); - assertTrue(!diary.isPrintHeapAtGC()); - assertTrue(!diary.isRSetStats()); - assertTrue(!diary.isMaxTenuringThresholdViolation()); + assertFalse(diary.isDefNew()); + assertFalse(diary.isSerialFull()); + assertFalse(diary.isICMS()); + assertFalse(diary.isPSYoung()); + assertFalse(diary.isPSOldGen()); + assertFalse(diary.isG1GC()); + assertFalse(diary.isZGC()); + assertFalse(diary.isShenandoah()); + assertFalse(diary.isCMSDebugLevel1()); + assertFalse(diary.isApplicationStoppedTime()); + assertFalse(diary.isApplicationRunningTime()); + assertFalse(diary.isJDK70()); + assertFalse(diary.isPre70_40()); + assertFalse(diary.isPrintHeapAtGC()); + assertFalse(diary.isRSetStats()); + assertFalse(diary.isMaxTenuringThresholdViolation()); } @Test @@ -72,26 +73,26 @@ public class CommandLineFlagsLogDiaryTest { assertTrue(diary.isAdaptiveSizing()); assertTrue(diary.isPrintGCDetails()); assertTrue(diary.isTenuringDistribution()); - assertTrue(!diary.isCMS()); - assertTrue(!diary.isParNew()); + assertFalse(diary.isCMS()); + assertFalse(diary.isParNew()); assertTrue(diary.isGenerational()); assertTrue(diary.hasPrintReferenceGC()); - assertTrue(!diary.isDefNew()); - assertTrue(!diary.isSerialFull()); - assertTrue(!diary.isICMS()); + assertFalse(diary.isDefNew()); + assertFalse(diary.isSerialFull()); + assertFalse(diary.isICMS()); assertTrue(diary.isPSYoung()); assertTrue(diary.isPSOldGen()); - assertTrue(!diary.isG1GC()); - assertTrue(!diary.isG1GC()); - assertTrue(!diary.isZGC()); - assertTrue(!diary.isCMSDebugLevel1()); - assertTrue(!diary.isApplicationStoppedTime()); - assertTrue(!diary.isApplicationRunningTime()); - assertTrue(!diary.isJDK70()); - assertTrue(!diary.isPre70_40()); - assertTrue(!diary.isPrintHeapAtGC()); - assertTrue(!diary.isRSetStats()); - assertTrue(!diary.isMaxTenuringThresholdViolation()); + assertFalse(diary.isG1GC()); + assertFalse(diary.isG1GC()); + assertFalse(diary.isZGC()); + assertFalse(diary.isCMSDebugLevel1()); + assertFalse(diary.isApplicationStoppedTime()); + assertFalse(diary.isApplicationRunningTime()); + assertFalse(diary.isJDK70()); + assertFalse(diary.isPre70_40()); + assertFalse(diary.isPrintHeapAtGC()); + assertFalse(diary.isRSetStats()); + assertFalse(diary.isMaxTenuringThresholdViolation()); } } diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/G1GCPatternsTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/G1GCPatternsTest.java index 23bc8a4..e329aba 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/G1GCPatternsTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/G1GCPatternsTest.java @@ -10,7 +10,6 @@ import java.util.logging.Logger; import static com.microsoft.gctoolkit.parser.CommonTestHelper.captureTest; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; public class G1GCPatternsTest implements G1GCPatterns { @@ -22,9 +21,9 @@ public class G1GCPatternsTest implements G1GCPatterns { for (int j = 0; j < lines.length; j++) { int captured = captureTest(rules[i], lines[j]); if (i == j) { - assertTrue(captured == lines[j].length, i + " failed to captured it's lines"); + assertEquals(captured, lines[j].length, i + " failed to captured it's lines"); } else { - assertTrue(captured == 0, i + " captured " + j); + assertEquals(0, captured, i + " captured " + j); } } } diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/GenerationalParserTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/GenerationalParserTest.java index 72d6fa5..b0dfb00 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/GenerationalParserTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/GenerationalParserTest.java @@ -21,7 +21,8 @@ import org.junit.jupiter.api.Test; import java.util.ArrayList; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; public class GenerationalParserTest extends ParserTest { @@ -82,19 +83,19 @@ public class GenerationalParserTest extends ParserTest { assertMemoryPoolValues(parNew.getHeap(), 16000, 81280, 1725, 81280); assertMemoryPoolValues(parNew.getYoung(), 16000, 18624, 1725, 18624); assertMemoryPoolValues(parNew.getTenured(), 0, 81280 - 18624, 0, 81280 - 18624); - assertTrue(parNew.getDuration() == 0.0167922); + assertEquals(0.0167922, parNew.getDuration()); SystemGC full = (SystemGC) collection.get(1); assertMemoryPoolValues(full.getHeap(), 4654, 81280, 1602, 81280); assertMemoryPoolValues(full.getYoung(), 4654, 81280 - 62656, 0, 81280 - 62656); assertMemoryPoolValues(full.getTenured(), 0, 81280 - 18624, 1602, 62656); - assertTrue(full.getDuration() == 0.0712086); + assertEquals(0.0712086, full.getDuration()); parNew = (ParNew) collection.get(2); - assertTrue(parNew.getHeap().getSizeAfterCollection() == 81280); + assertEquals(81280, parNew.getHeap().getSizeAfterCollection()); parNew = (ParNew) collection.get(3); - assertTrue(parNew.getHeap().getSizeAfterCollection() == 81280); + assertEquals(81280, parNew.getHeap().getSizeAfterCollection()); } @Test @@ -138,15 +139,15 @@ public class GenerationalParserTest extends ParserTest { feedParser(parser, lines); PSYoungGen psYoungGen = (PSYoungGen) collection.get(0); - assertTrue(psYoungGen.getGCCause() == GCCause.ALLOCATION_FAILURE); - assertTrue(psYoungGen.getDuration() == 0.0485326); + assertSame(psYoungGen.getGCCause(), GCCause.ALLOCATION_FAILURE); + assertEquals(0.0485326, psYoungGen.getDuration()); assertMemoryPoolValues(psYoungGen.getHeap(), 610571, 819712, 581588, 819712); assertMemoryPoolValues(psYoungGen.getTenured(), 610571 - 232960, 819712 - 232960, 581588 - 116224, 819712 - 232960); assertMemoryPoolValues(psYoungGen.getYoung(), 232960, 232960, 116224, 232960); FullGC fullGC = (FullGC) collection.get(1); - assertTrue(fullGC.getGCCause() == GCCause.ADAPTIVE_SIZE_POLICY); - assertTrue(fullGC.getDuration() == 0.0449697); + assertSame(fullGC.getGCCause(), GCCause.ADAPTIVE_SIZE_POLICY); + assertEquals(0.0449697, fullGC.getDuration()); // todo: value of heap size before collection is 808448 should be 819712. // Parser is not tracking previous size and since we're not doing anything with it at the moment... assertMemoryPoolValues(fullGC.getHeap(), 581588, 808448, 194938, 808448); @@ -176,18 +177,18 @@ public class GenerationalParserTest extends ParserTest { feedParser(parser, lines); ParNew parNew = (ParNew) collection.get(0); - assertTrue(parNew.getGCCause() == GCCause.GC_LOCKER); + assertSame(parNew.getGCCause(), GCCause.GC_LOCKER); assertMemoryPoolValues(parNew.getHeap(), 35230, 354944, 38078, 354944); assertMemoryPoolValues(parNew.getYoung(), 32671, 349568, 35386, 349568); assertMemoryPoolValues(parNew.getTenured(), 35230 - 32671, 354944 - 349568, 38078 - 35386, 354944 - 349568); - assertTrue(parNew.getDuration() == 0.0082790); + assertEquals(0.0082790, parNew.getDuration()); InitialMark initialMark = (InitialMark) collection.get(1); - assertTrue(initialMark.getGCCause() == GCCause.CMS_INITIAL_MARK); + assertSame(initialMark.getGCCause(), GCCause.CMS_INITIAL_MARK); CMSRemark cmsRemark = (CMSRemark) collection.get(2); - assertTrue(cmsRemark.getGCCause() == GCCause.CMS_FINAL_REMARK); - assertTrue(cmsRemark.getDuration() == 0.0699640); + assertSame(cmsRemark.getGCCause(), GCCause.CMS_FINAL_REMARK); + assertEquals(0.0699640, cmsRemark.getDuration()); } @Test @@ -215,12 +216,12 @@ public class GenerationalParserTest extends ParserTest { assertMemoryPoolValues(parNew.getHeap(), 1856305, 1965056, 851287, 1965056); assertMemoryPoolValues(parNew.getYoung(), 1143174, 1188864, 132096, 1188864); assertMemoryPoolValues(parNew.getTenured(), 1856305 - 1143174, 1965056 - 1188864, 851287 - 132096, 1965056 - 1188864); - assertTrue(parNew.getDuration() == 0.1554100); + assertEquals(0.1554100, parNew.getDuration()); InitialMark initialMark = (InitialMark) collection.get(1); - assertTrue(initialMark.getDuration() == 0.1976100); + assertEquals(0.1976100, initialMark.getDuration()); CMSRemark cmsRemark = (CMSRemark) collection.get(2); - assertTrue(cmsRemark.getDuration() == 0.6306470); + assertEquals(0.6306470, cmsRemark.getDuration()); } } diff --git a/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/JVMPatternsTest.java b/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/JVMPatternsTest.java index 5748892..a3f9fb9 100644 --- a/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/JVMPatternsTest.java +++ b/parser/src/test/java/com/microsoft/gctoolkit/parser/patterns/JVMPatternsTest.java @@ -2,11 +2,10 @@ // Licensed under the MIT License. package com.microsoft.gctoolkit.parser.patterns; -import com.microsoft.gctoolkit.parser.GCParseRule; import com.microsoft.gctoolkit.parser.JVMPatterns; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class JVMPatternsTest implements JVMPatterns { @@ -16,25 +15,25 @@ public class JVMPatternsTest implements JVMPatterns { String string; string = "2014-06-18T11:21:33.592+0200: 215483,566: Application time: 0,0001550 seconds"; - assertTrue(APPLICATION_TIME.parse(string) != null); + assertNotNull(APPLICATION_TIME.parse(string)); string = "2016-10-10T14:53:38.731+0100: 968823.430: Total time for which application threads were stopped: 0.0152181 seconds, Stopping threads took: 0.0001862 seconds"; - assertTrue(APPLICATION_STOP_TIME_WITH_STOPPING_TIME.parse(string) != null); + assertNotNull(APPLICATION_STOP_TIME_WITH_STOPPING_TIME.parse(string)); string = "TLAB: gc thread: 0x00007f2f64119800 [id: 27349] desired_size: 1024KB slow allocs: 0 refill waste: 16384B alloc: 0.01526 51200KB refills: 1 waste 99.8% gc: 1046944B slow: 0B fast: 0B"; - assertTrue(TLAB_CONT.parse(string) != null); + assertNotNull(TLAB_CONT.parse(string)); string = "TLAB totals: thrds: 25 refills: 3201 max: 3155 slow allocs: 821 max 799 waste: 0.7% gc: 19037968B max: 1048456B slow: 3914672B max: 3899656B fast: 0B max: 0B"; - assertTrue(TLAB_TOTALS.parse(string) != null); + assertNotNull(TLAB_TOTALS.parse(string)); string = "2016-10-09T01:00:57.051+0800: 50.628: [GC TLAB: gc thread: 0x00007f2f0c00d800 [id: 27957] desired_size: 1024KB slow allocs: 0 refill waste: 16384B alloc: 0.01526 51200KB refills: 1 waste 97.7% gc: 1024928B slow: 0B fast: 0B"; - assertTrue(TLAB_START.parse(string) != null); + assertNotNull(TLAB_START.parse(string)); string = "Total time for which application threads were stopped: 0.0006115 seconds, Stopping threads took: 0.0003832 seconds"; - assertTrue(UNIFIED_LOGGING_APPLICATION_STOP_TIME_WITH_STOPPING_TIME.parse(string) != null); + assertNotNull(UNIFIED_LOGGING_APPLICATION_STOP_TIME_WITH_STOPPING_TIME.parse(string)); string = "Safepoint \"G1CollectForAllocation\", Time since last: 295590960 ns, Reaching safepoint: 238882 ns, At safepoint: 23888872 ns, Total: 24127754 ns)"; - assertTrue(UNIFIED_LOGGING_G1_SAFEPOINT.parse(string) != null); + assertNotNull(UNIFIED_LOGGING_G1_SAFEPOINT.parse(string)); } }