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