Skip to content

Commit 128cd76

Browse files
committed
add unittest for #83
1 parent 31d5e84 commit 128cd76

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderSun1_6_0.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.tagtraum.perf.gcviewer.imp;
22

3+
import static org.hamcrest.Matchers.is;
34
import static org.junit.Assert.assertEquals;
5+
import static org.junit.Assert.assertThat;
46
import static org.junit.Assert.assertTrue;
57

68
import java.io.ByteArrayInputStream;
@@ -862,4 +864,29 @@ public void testPromotionFailedWithReference() throws Exception {
862864
assertEquals("main type", "GC--", model.get(0).getExtendedType().getName());
863865
assertEquals("detail type", "PSYoungGen", model.get(0).details().next().getExtendedType().getName());
864866
}
867+
868+
@Test
869+
public void testCmsGcLocker() throws Exception {
870+
TestLogHandler handler = new TestLogHandler();
871+
handler.setLevel(Level.WARNING);
872+
IMP_LOGGER.addHandler(handler);
873+
DATA_READER_FACTORY_LOGGER.addHandler(handler);
874+
875+
ByteArrayInputStream in = new ByteArrayInputStream(
876+
("2269.664: [CMS-concurrent-sweep-start]"
877+
+ "\n2270.039: [GC 2270.039: [ParNew: 3686400K->3686400K(3686400K), 0.0000270 secs] 19876932K->19876932K(20070400K), 0.0000980 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]"
878+
+ "\nGC locker: Trying a full collection because scavenge failed"
879+
+ "\n2270.039: [Full GC 2270.039: [CMS2281.247: [CMS-concurrent-sweep: 11.558/11.583 secs] [Times: user=13.89 sys=0.08, real=11.58 secs]"
880+
+ "\n (concurrent mode failure): 16190532K->14091936K(16384000K), 64.4965310 secs] 19876932K->14091936K(20070400K), [CMS Perm : 111815K->111803K(262144K)], 64.4966380 secs] [Times: user=64.41 sys=0.00, real=64.50 secs]"
881+
+ "\n2334.567: [GC [1 CMS-initial-mark: 14091936K(16384000K)] 14164705K(20070400K), 0.0180200 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]"
882+
+ "\n2334.587: [CMS-concurrent-mark-start]"
883+
).getBytes());
884+
885+
final DataReader reader = new DataReaderSun1_6_0(in, GcLogType.SUN1_6);
886+
GCModel model = reader.read();
887+
888+
assertThat("count", model.size(), is(6));
889+
assertThat("parse warning count", handler.getCount(), is(0));
890+
}
891+
865892
}

0 commit comments

Comments
 (0)