/
TestTreeReader.java
97 lines (86 loc) · 3.91 KB
/
TestTreeReader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Copyright (C)
* 2008 Jeremy Thomerson <jeremy@thomersonfamily.com>
* 2012 Michael Mosmann <michael@mosmann.de>
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report;
import java.io.IOException;
import junit.framework.Assert;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.util.WildcardListModel;
import org.junit.Test;
import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.ISerializedObjectTree;
import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.TreeReader.Line;
import org.wicketstuff.pageserializer.kryo2.pages.ListViewPage;
public class TestTreeReader
{
@Test
public void lineParser()
{
String textLine = "org.wicketstuff.pageserializer.kryo2.pages.ListViewPage(0) | 141";
Line line = new Line(textLine);
Assert.assertEquals(0, line.indent);
Assert.assertEquals(141, line.size);
Assert.assertEquals(ListViewPage.class, line.type);
Assert.assertEquals("0", line.label);
textLine = " java.lang.Integer | 9";
line = new Line(textLine);
Assert.assertEquals(1, line.indent);
Assert.assertEquals(9, line.size);
Assert.assertEquals(Integer.class, line.type);
Assert.assertEquals(null, line.label);
textLine = " [Ljava.lang.Object; | 2";
line = new Line(textLine);
Assert.assertEquals(1, line.indent);
Assert.assertEquals(2, line.size);
Assert.assertEquals(Object[].class, line.type);
Assert.assertEquals(null, line.label);
textLine = " org.apache.wicket.markup.html.list.ListView(list) | 114";
line = new Line(textLine);
Assert.assertEquals(2, line.indent);
Assert.assertEquals(114, line.size);
Assert.assertEquals(ListView.class, line.type);
Assert.assertEquals("list", line.label);
}
@Test
public void lineLines() throws IOException
{
String lines = "org.wicketstuff.pageserializer.kryo2.pages.ListViewPage(0) | 141\n"
+ " java.lang.Integer | 9\n"
+ " [Ljava.lang.Object; | 2\n"
+ " org.apache.wicket.markup.html.list.ListView(list) | 114\n"
+ " org.apache.wicket.model.util.WildcardListModel | 2\n"
+ " java.util.Arrays$ArrayList | 3\n"
+ " java.lang.String | 4\n"
+ " java.lang.String | 4\n"
+ " java.lang.String | 4\n"
+ " java.lang.Integer | 1\n"
+ " org.apache.wicket.request.mapper.parameter.PageParameters | 3";
ISerializedObjectTree sample = TreeReader.fromString(lines);
Assert.assertEquals("0", sample.label());
Assert.assertEquals(141, sample.size());
Assert.assertEquals(146, sample.childSize());
Assert.assertEquals(WildcardListModel.class, sample.children()
.get(1)
.children()
.get(0)
.children()
.get(0)
.type());
}
}