@Test
  public void testCmsMemory() throws Exception {
    final InputStream in = getClass().getResourceAsStream("SampleSun1_6_0CMS.txt");
    final DataReader reader = new DataReaderSun1_6_0(in, GcLogType.SUN1_6);
    GCModel model = reader.read();

    assertEquals("GC count", 41, model.size());
    assertEquals("heap min allocated", 249088, model.getHeapAllocatedSizes().getMin());
    assertEquals("heap max allocated", 249088, model.getHeapAllocatedSizes().getMax());
    assertEquals("young min allocated", 118016, model.getYoungAllocatedSizes().getMin());
    assertEquals("young max allocated", 118016, model.getYoungAllocatedSizes().getMax());
    assertEquals("tenured min allocated", 131072, model.getTenuredAllocatedSizes().getMin());
    assertEquals("tenured max allocated", 131072, model.getTenuredAllocatedSizes().getMax());
    assertEquals("perm min allocated", 21248, model.getPermAllocatedSizes().getMin());
    assertEquals("perm max allocated", 21248, model.getPermAllocatedSizes().getMax());

    assertEquals("heap min used", 80841, model.getHeapUsedSizes().getMin());
    assertEquals("heap max used", 209896, model.getHeapUsedSizes().getMax());
    assertEquals("young min used", 15160, model.getYoungUsedSizes().getMin());
    assertEquals("young max used", 118010, model.getYoungUsedSizes().getMax());
    assertEquals("tenured min used", 0, model.getTenuredUsedSizes().getMin());
    assertEquals("tenured max used", 115034, model.getTenuredUsedSizes().getMax());
    assertEquals("perm min used", 2560, model.getPermUsedSizes().getMin());
    assertEquals("perm max used", 2561, model.getPermUsedSizes().getMax());

    assertEquals("promotion avg", 16998.3846, model.getPromotion().average(), 0.0001);
    assertEquals("promotion total", 220979, model.getPromotion().getSum());
  }
  @Test
  public void testCMSWithoutPrintTimeStamp() throws Exception {
    ByteArrayInputStream in =
        new ByteArrayInputStream(
            ("2012-04-03T20:36:35.035+0200: [GC [ParNew: 16993K->2105K(19136K), 0.0270541 secs] 16993K->16424K(83008K), 0.0272020 secs] [Times: user=0.02 sys=0.05, real=0.03 secs]")
                .getBytes());
    final DataReader reader = new DataReaderSun1_6_0(in, GcLogType.SUN1_6);
    GCModel model = reader.read();

    assertEquals("GC count", 1, model.size());
    assertEquals("heap", 83008, model.getHeapAllocatedSizes().getMax());
    assertEquals("pause", 0.0272020, model.getGCPause().getMax(), 0.00000001);
  }
  @Test
  public void testCMSWithoutPrintTimeStampConcurrentModeFailure() throws Exception {
    ByteArrayInputStream in =
        new ByteArrayInputStream(
            ("2012-04-03T20:36:35.284+0200: [GC [ParNew: 19081K->19081K(19136K), 0.0000205 secs][CMS2012-04-03T20:36:35.285+0200: [CMS-concurrent-abortable-preclean: 0.005/0.150 secs] [Times: user=0.14 sys=0.14, real=0.15 secs]"
                    + "\n (concurrent mode failure): 98182K->3832K(98624K), 0.0195864 secs] 117264K->3832K(117760K), [CMS Perm : 2614K->2613K(21248K)], 0.0199322 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]")
                .getBytes());
    final DataReader reader = new DataReaderSun1_6_0(in, GcLogType.SUN1_6);
    GCModel model = reader.read();

    assertEquals("GC count", 2, model.size());
    assertEquals("heap", 117760, model.getHeapAllocatedSizes().getMax());
    assertEquals("pause", 0.0199322, model.getFullGCPause().getMax(), 0.00000001);
  }
  /** Tests -XX:+PrintTenuringDistribution with -XX:+UseParallelGC */
  @Test
  public void testPSPrintTenuringDistribution() throws Exception {
    ByteArrayInputStream in =
        new ByteArrayInputStream(
            ("2012-04-10T20:58:43.009+0200: 0.690: [GC"
                    + "\nDesired survivor size 89456640 bytes, new threshold 7 (max 15)"
                    + "\n [PSYoungGen: 524288K->35633K(611648K)] 524288K->35633K(2009792K), 0.0240717 secs] [Times: user=0.01 sys=0.03, real=0.02 secs]")
                .getBytes());
    final DataReader reader = new DataReaderSun1_6_0(in, GcLogType.SUN1_6);
    GCModel model = reader.read();

    assertEquals("GC count", 1, model.size());
    assertEquals("heap", 2009792, model.getHeapAllocatedSizes().getMax());
    assertEquals("pause", 0.0240717, model.getGCPause().getMax(), 0.00000001);
  }
  @Test
  public void testPSWithoutPrintTimeStamp() throws Exception {
    ByteArrayInputStream in =
        new ByteArrayInputStream(
            ("2012-04-03T20:35:40.033+0200: [GC [PSYoungGen: 16420K->2657K(19136K)] 16420K->15887K(62848K), 0.0143603 secs] [Times: user=0.02 sys=0.02, real=0.01 secs]"
                    + "\n2012-04-03T20:35:40.056+0200: [GC [PSYoungGen: 19084K->2657K(35584K)] 32314K->32279K(79296K), 0.0236295 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]"
                    + "\n2012-04-03T20:35:40.079+0200: [Full GC [PSYoungGen: 2657K->0K(35584K)] [PSOldGen: 29622K->32262K(67392K)] 32279K->32262K(102976K) [PSPermGen: 2603K->2603K(21248K)], 0.0095147 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]")
                .getBytes());
    final DataReader reader = new DataReaderSun1_6_0(in, GcLogType.SUN1_6);
    GCModel model = reader.read();

    assertEquals("GC count", 3, model.size());
    assertEquals("heap", 102976, model.getHeapAllocatedSizes().getMax());
    assertEquals("pause", 0.0236295, model.getGCPause().getMax(), 0.00000001);
    assertEquals(
        "2nd pause, timeStamp", 0.056 - 0.033, ((GCEvent) model.get(1)).getTimestamp(), 0.00001);
    assertEquals(
        "3nd pause, timeStamp", 0.079 - 0.033, ((GCEvent) model.get(2)).getTimestamp(), 0.00001);
  }