1 | package de.ugoe.cs.quest.plugin.jfc;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertNotNull;
|
---|
4 | import static org.junit.Assert.assertTrue;
|
---|
5 |
|
---|
6 | import java.io.File;
|
---|
7 | import java.util.Collection;
|
---|
8 | import java.util.List;
|
---|
9 | import java.util.logging.Level;
|
---|
10 |
|
---|
11 | import org.junit.Before;
|
---|
12 | import org.junit.Test;
|
---|
13 |
|
---|
14 | import de.ugoe.cs.quest.eventcore.Event;
|
---|
15 | import de.ugoe.cs.quest.eventcore.guimodel.GUIModel;
|
---|
16 | import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement;
|
---|
17 | import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElement;
|
---|
18 | import de.ugoe.cs.util.console.TextConsole;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * TODO comment
|
---|
22 | *
|
---|
23 | * @version $Revision: $ $Date: $
|
---|
24 | * @author 2011, last modified by $Author: $
|
---|
25 | */
|
---|
26 | public class JFCLogParserTest {
|
---|
27 |
|
---|
28 | /**
|
---|
29 | *
|
---|
30 | */
|
---|
31 | @Before
|
---|
32 | public void setUp() {
|
---|
33 | new TextConsole(Level.FINEST);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | *
|
---|
38 | */
|
---|
39 | @Test
|
---|
40 | public void test() throws Exception {
|
---|
41 | JFCLogParser parser = new JFCLogParser(null);
|
---|
42 | parser.parseFile(new File(ClassLoader.getSystemResource("trace.xml").getFile()));
|
---|
43 | Collection<List<Event>> events = parser.getSequences();
|
---|
44 |
|
---|
45 | assertNotNull(events);
|
---|
46 | assertTrue(events.size() > 0);
|
---|
47 |
|
---|
48 | System.err.println("{");
|
---|
49 | for (List<Event> session : events) {
|
---|
50 | System.err.println(" {");
|
---|
51 | for (Event event : session) {
|
---|
52 | System.err.print(" ");
|
---|
53 | System.err.print(event);
|
---|
54 | System.err.println(",");
|
---|
55 | }
|
---|
56 | System.err.println(" }");
|
---|
57 | }
|
---|
58 | System.err.println("}");
|
---|
59 | System.err.println("\n\n");
|
---|
60 |
|
---|
61 | GUIModel guiModel = parser.getGuiModel();
|
---|
62 | assertNotNull(guiModel);
|
---|
63 |
|
---|
64 | for (IGUIElement root : guiModel.getRootElements()) {
|
---|
65 | dumpGUIElement(root, guiModel, "");
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * TODO: comment
|
---|
71 | *
|
---|
72 | * @param root
|
---|
73 | * @param guiModel
|
---|
74 | */
|
---|
75 | private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
|
---|
76 | assertTrue(guiElement instanceof JFCGUIElement);
|
---|
77 |
|
---|
78 | System.err.print(indent);
|
---|
79 | System.err.print(guiElement);
|
---|
80 |
|
---|
81 | List<IGUIElement> children = guiModel.getChildren(guiElement);
|
---|
82 |
|
---|
83 | if ((children != null) && (children.size() > 0)) {
|
---|
84 | System.err.println(" {");
|
---|
85 |
|
---|
86 | for (IGUIElement child : children) {
|
---|
87 | dumpGUIElement(child, guiModel, indent + " ");
|
---|
88 | }
|
---|
89 |
|
---|
90 | System.err.print(indent);
|
---|
91 | System.err.print("}");
|
---|
92 | }
|
---|
93 |
|
---|
94 | System.err.println();
|
---|
95 | }
|
---|
96 |
|
---|
97 | }
|
---|