[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 | /**
|
---|
| 35 | * TODO comment
|
---|
| 36 | *
|
---|
| 37 | * @version $Revision: $ $Date: $
|
---|
| 38 | * @author 2011, last modified by $Author: $
|
---|
| 39 | */
|
---|
| 40 | public class JFCSimplifiedLogParserTest {
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | *
|
---|
| 44 | */
|
---|
| 45 | @Before
|
---|
| 46 | public void setUp() {
|
---|
| 47 | new TextConsole(Level.FINEST);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | /**
|
---|
[1058] | 51 | * Test that parses regular log file.
|
---|
[964] | 52 | */
|
---|
| 53 | @Test
|
---|
[1058] | 54 | public void testParseRegularLog() throws Exception {
|
---|
[964] | 55 | JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null);
|
---|
[1058] | 56 | parser.parseFile(new File(ClassLoader.getSystemResource("freemind_regularTrace.xml")
|
---|
| 57 | .getFile()));
|
---|
[964] | 58 | Collection<List<Event>> events = parser.getSequences();
|
---|
| 59 |
|
---|
| 60 | assertNotNull(events);
|
---|
| 61 | assertTrue(events.size() > 0);
|
---|
| 62 |
|
---|
| 63 | System.err.println("{");
|
---|
| 64 | for (List<Event> session : events) {
|
---|
| 65 | System.err.println(" {");
|
---|
| 66 | for (Event event : session) {
|
---|
| 67 | System.err.print(" ");
|
---|
| 68 | System.err.print(event);
|
---|
| 69 | System.err.println(",");
|
---|
| 70 | }
|
---|
| 71 | System.err.println(" }");
|
---|
| 72 | }
|
---|
| 73 | System.err.println("}");
|
---|
| 74 | System.err.println("\n\n");
|
---|
| 75 |
|
---|
| 76 | GUIModel guiModel = parser.getGuiModel();
|
---|
| 77 | assertNotNull(guiModel);
|
---|
| 78 |
|
---|
| 79 | for (IGUIElement root : guiModel.getRootElements()) {
|
---|
| 80 | dumpGUIElement(root, guiModel, "");
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
[1058] | 85 | * Test that parses a log file that contains events that have no registered targets when parsed.
|
---|
| 86 | */
|
---|
| 87 | @Test
|
---|
| 88 | public void testParseLogEventsWithoutTargets() throws Exception {
|
---|
| 89 | JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null);
|
---|
| 90 | parser.parseFile(new File(ClassLoader
|
---|
| 91 | .getSystemResource("argouml_traceEventsWithoutTargets.xml").getFile()));
|
---|
| 92 | Collection<List<Event>> events = parser.getSequences();
|
---|
| 93 |
|
---|
| 94 | assertNotNull(events);
|
---|
| 95 | assertTrue(events.size() > 0);
|
---|
| 96 |
|
---|
| 97 | System.err.println("{");
|
---|
| 98 | for (List<Event> session : events) {
|
---|
| 99 | System.err.println(" {");
|
---|
| 100 | for (Event event : session) {
|
---|
| 101 | System.err.print(" ");
|
---|
| 102 | System.err.print(event);
|
---|
| 103 | System.err.println(",");
|
---|
| 104 | }
|
---|
| 105 | System.err.println(" }");
|
---|
| 106 | }
|
---|
| 107 | System.err.println("}");
|
---|
| 108 | System.err.println("\n\n");
|
---|
| 109 |
|
---|
| 110 | GUIModel guiModel = parser.getGuiModel();
|
---|
| 111 | assertNotNull(guiModel);
|
---|
| 112 |
|
---|
| 113 | for (IGUIElement root : guiModel.getRootElements()) {
|
---|
| 114 | dumpGUIElement(root, guiModel, "");
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | /**
|
---|
[964] | 119 | * TODO: comment
|
---|
| 120 | *
|
---|
| 121 | * @param root
|
---|
| 122 | * @param guiModel
|
---|
| 123 | */
|
---|
| 124 | private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
|
---|
| 125 | assertTrue(guiElement instanceof JFCGUIElement);
|
---|
| 126 |
|
---|
| 127 | System.err.print(indent);
|
---|
| 128 | System.err.print(guiElement);
|
---|
| 129 |
|
---|
| 130 | List<IGUIElement> children = guiModel.getChildren(guiElement);
|
---|
| 131 |
|
---|
| 132 | if ((children != null) && (children.size() > 0)) {
|
---|
| 133 | System.err.println(" {");
|
---|
| 134 |
|
---|
| 135 | for (IGUIElement child : children) {
|
---|
| 136 | dumpGUIElement(child, guiModel, indent + " ");
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | System.err.print(indent);
|
---|
| 140 | System.err.print("}");
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | System.err.println();
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | }
|
---|