|
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertThat; |
4 | 4 |
|
| 5 | +import java.io.ByteArrayInputStream; |
5 | 6 | import java.io.ByteArrayOutputStream; |
6 | 7 | import java.io.IOException; |
7 | 8 | import java.net.MalformedURLException; |
8 | 9 | import java.net.URL; |
9 | 10 | import java.text.NumberFormat; |
10 | 11 |
|
11 | 12 | import com.tagtraum.perf.gcviewer.exp.impl.SummaryDataWriter; |
| 13 | +import com.tagtraum.perf.gcviewer.imp.DataReader; |
| 14 | +import com.tagtraum.perf.gcviewer.imp.DataReaderSun1_6_0; |
| 15 | +import com.tagtraum.perf.gcviewer.imp.GcLogType; |
12 | 16 | import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type; |
13 | 17 | import com.tagtraum.perf.gcviewer.model.GCEvent; |
14 | 18 | import com.tagtraum.perf.gcviewer.model.GCModel; |
| 19 | +import com.tagtraum.perf.gcviewer.model.GcResourceFile; |
15 | 20 | import com.tagtraum.perf.gcviewer.util.MemoryFormat; |
16 | 21 |
|
17 | 22 | import org.hamcrest.Matchers; |
@@ -112,4 +117,27 @@ public void testWriteWithPerm() throws IOException { |
112 | 117 | assertThat("totalPermUsedMax", csv, Matchers.containsString("totalPermUsedMax; " + memoryFormatter.formatToFormatted(73727).getValue() + "; M")); |
113 | 118 | assertThat("totalPermUsedMaxpc", csv, Matchers.containsString("totalPermUsedMaxpc; " + percentFormatter.format(100.0) + "; %")); |
114 | 119 | } |
| 120 | + |
| 121 | + @Test |
| 122 | + public void testWriteWithPromotion() throws IOException { |
| 123 | + ByteArrayInputStream in = new ByteArrayInputStream( |
| 124 | + ("2011-01-25T17:10:16.889+0100: 12076.859: [GC 12076.859: [ParNew2011-01-25T17:10:16.896+0100: 12076.866: [CMS-concurrent-abortable-preclean: 0.929/4.899 secs] [Times: user=2.13 sys=0.04, real=4.90 secs]" + |
| 125 | + "\n" + |
| 126 | + "\nDesired survivor size 720896 bytes, new threshold 1 (max 4)" + |
| 127 | + "\n- age 1: 1058016 bytes, 1058016 total" + |
| 128 | + "\n: 13056K->1408K(13056K), 0.0128277 secs] 131480K->122757K(141328K), 0.0131346 secs] [Times: user=0.15 sys=0.00, real=0.01 secs]") |
| 129 | + .getBytes()); |
| 130 | + DataReader reader = new DataReaderSun1_6_0(new GcResourceFile("byteArray"), in, GcLogType.SUN1_6); |
| 131 | + GCModel model = reader.read(); |
| 132 | + model.setURL(new URL("file", "localhost", "test-file")); |
| 133 | + |
| 134 | + ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| 135 | + SummaryDataWriter objectUnderTest = new SummaryDataWriter(output); |
| 136 | + |
| 137 | + objectUnderTest.write(model); |
| 138 | + |
| 139 | + String csv = output.toString(); |
| 140 | + |
| 141 | + assertThat("avgPromotion", csv, Matchers.containsString("avgPromotion; " + memoryFormatter.formatToFormatted(2925).getValue() + "; K")); |
| 142 | + } |
115 | 143 | } |
0 commit comments