[1113] | 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 | |
---|
[964] | 15 | package de.ugoe.cs.autoquest.plugin.jfc;
|
---|
| 16 |
|
---|
| 17 | import static org.junit.Assert.assertNotNull;
|
---|
| 18 | import static org.junit.Assert.assertTrue;
|
---|
| 19 |
|
---|
| 20 | import java.io.File;
|
---|
| 21 | import java.util.Collection;
|
---|
| 22 | import java.util.List;
|
---|
| 23 | import java.util.logging.Level;
|
---|
| 24 |
|
---|
| 25 | import org.junit.Before;
|
---|
| 26 | import org.junit.Test;
|
---|
| 27 |
|
---|
| 28 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 29 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
|
---|
| 30 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
|
---|
| 31 | import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
|
---|
| 32 | import de.ugoe.cs.util.console.TextConsole;
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
[1426] | 35 | * @author Fabian Glaser
|
---|
[964] | 36 | */
|
---|
| 37 | public class JFCSimplifiedLogParserTest {
|
---|
| 38 |
|
---|
| 39 | /**
|
---|
| 40 | *
|
---|
| 41 | */
|
---|
| 42 | @Before
|
---|
| 43 | public void setUp() {
|
---|
| 44 | new TextConsole(Level.FINEST);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
[1058] | 48 | * Test that parses regular log file.
|
---|
[964] | 49 | */
|
---|
| 50 | @Test
|
---|
[1058] | 51 | public void testParseRegularLog() throws Exception {
|
---|
[964] | 52 | JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null);
|
---|
[1058] | 53 | parser.parseFile(new File(ClassLoader.getSystemResource("freemind_regularTrace.xml")
|
---|
| 54 | .getFile()));
|
---|
[964] | 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 | /**
|
---|
[1058] | 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 | /**
|
---|
[1426] | 116 | *
|
---|
[964] | 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 | }
|
---|