source: trunk/autoquest-plugin-jfc-test/src/test/java/de/ugoe/cs/autoquest/plugin/jfc/JFCSimplifiedLogParserTest.java @ 1426

Last change on this file since 1426 was 1426, checked in by pharms, 10 years ago
  • removed some TODOs
  • Property svn:mime-type set to text/plain
File size: 4.4 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.plugin.jfc;
16
17import static org.junit.Assert.assertNotNull;
18import static org.junit.Assert.assertTrue;
19
20import java.io.File;
21import java.util.Collection;
22import java.util.List;
23import java.util.logging.Level;
24
25import org.junit.Before;
26import org.junit.Test;
27
28import de.ugoe.cs.autoquest.eventcore.Event;
29import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
30import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
31import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
32import de.ugoe.cs.util.console.TextConsole;
33
34/**
35 * @author Fabian Glaser
36 */
37public class JFCSimplifiedLogParserTest {
38
39    /**
40     *
41     */
42    @Before
43    public void setUp() {
44        new TextConsole(Level.FINEST);
45    }
46
47    /**
48     * Test that parses regular log file.
49     */
50    @Test
51    public void testParseRegularLog() throws Exception {
52        JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null);
53        parser.parseFile(new File(ClassLoader.getSystemResource("freemind_regularTrace.xml")
54                                  .getFile()));
55        Collection<List<Event>> events = parser.getSequences();
56
57        assertNotNull(events);
58        assertTrue(events.size() > 0);
59
60        System.err.println("{");
61        for (List<Event> session : events) {
62            System.err.println("  {");
63            for (Event event : session) {
64                System.err.print("    ");
65                System.err.print(event);
66                System.err.println(",");
67            }
68            System.err.println("  }");
69        }
70        System.err.println("}");
71        System.err.println("\n\n");
72
73        GUIModel guiModel = parser.getGuiModel();
74        assertNotNull(guiModel);
75
76        for (IGUIElement root : guiModel.getRootElements()) {
77            dumpGUIElement(root, guiModel, "");
78        }
79    }
80
81    /**
82     * Test that parses a log file that contains events that have no registered targets when parsed.
83     */
84    @Test
85    public void testParseLogEventsWithoutTargets() throws Exception {
86        JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null);
87        parser.parseFile(new File(ClassLoader
88                                  .getSystemResource("argouml_traceEventsWithoutTargets.xml").getFile()));
89        Collection<List<Event>> events = parser.getSequences();
90
91        assertNotNull(events);
92        assertTrue(events.size() > 0);
93
94        System.err.println("{");
95        for (List<Event> session : events) {
96            System.err.println("  {");
97            for (Event event : session) {
98                System.err.print("    ");
99                System.err.print(event);
100                System.err.println(",");
101            }
102            System.err.println("  }");
103        }
104        System.err.println("}");
105        System.err.println("\n\n");
106
107        GUIModel guiModel = parser.getGuiModel();
108        assertNotNull(guiModel);
109
110        for (IGUIElement root : guiModel.getRootElements()) {
111            dumpGUIElement(root, guiModel, "");
112        }
113    }
114
115    /**
116     *
117     */
118    private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
119        assertTrue(guiElement instanceof JFCGUIElement);
120
121        System.err.print(indent);
122        System.err.print(guiElement);
123
124        List<IGUIElement> children = guiModel.getChildren(guiElement);
125
126        if ((children != null) && (children.size() > 0)) {
127            System.err.println(" {");
128
129            for (IGUIElement child : children) {
130                dumpGUIElement(child, guiModel, indent + "  ");
131            }
132
133            System.err.print(indent);
134            System.err.print("}");
135        }
136
137        System.err.println();
138    }
139
140}
Note: See TracBrowser for help on using the repository browser.