Changeset 1058 for trunk


Ignore:
Timestamp:
02/01/13 12:16:47 (12 years ago)
Author:
fglaser
Message:
  • Bug in JFCSimplifiedLogParser fixed, which caused violation of event order during parsing
  • Test of JFCSimplifiedLogParser extended to cover handling of events that have no registered target while being parsed.
Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-jfc-test/src/test/java/de/ugoe/cs/autoquest/plugin/jfc/JFCSimplifiedLogParserTest.java

    r1027 r1058  
     1 
    12package de.ugoe.cs.autoquest.plugin.jfc; 
    23 
     
    3536 
    3637    /** 
    37      * 
     38     * Test that parses regular log file. 
    3839     */ 
    3940    @Test 
    40     public void test() throws Exception { 
     41    public void testParseRegularLog() throws Exception { 
    4142        JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null); 
    42         parser.parseFile(new File(ClassLoader.getSystemResource("newtrace2.log").getFile())); 
     43        parser.parseFile(new File(ClassLoader.getSystemResource("freemind_regularTrace.xml") 
     44                                  .getFile())); 
     45        Collection<List<Event>> events = parser.getSequences(); 
     46 
     47        assertNotNull(events); 
     48        assertTrue(events.size() > 0); 
     49 
     50        System.err.println("{"); 
     51        for (List<Event> session : events) { 
     52            System.err.println("  {"); 
     53            for (Event event : session) { 
     54                System.err.print("    "); 
     55                System.err.print(event); 
     56                System.err.println(","); 
     57            } 
     58            System.err.println("  }"); 
     59        } 
     60        System.err.println("}"); 
     61        System.err.println("\n\n"); 
     62 
     63        GUIModel guiModel = parser.getGuiModel(); 
     64        assertNotNull(guiModel); 
     65 
     66        for (IGUIElement root : guiModel.getRootElements()) { 
     67            dumpGUIElement(root, guiModel, ""); 
     68        } 
     69    } 
     70 
     71    /** 
     72     * Test that parses a log file that contains events that have no registered targets when parsed. 
     73     */ 
     74    @Test 
     75    public void testParseLogEventsWithoutTargets() throws Exception { 
     76        JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null); 
     77        parser.parseFile(new File(ClassLoader 
     78                                  .getSystemResource("argouml_traceEventsWithoutTargets.xml").getFile())); 
    4379        Collection<List<Event>> events = parser.getSequences(); 
    4480 
  • trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/JFCSimplifiedLogParser.java

    r1051 r1058  
    274274        } 
    275275        if (!eventsWithoutTargets.isEmpty()) { 
    276             Console.printerr("Some events reference GUI elments that are not part of logfile. +" 
    277                 + "These events have been ignored."); 
     276            Console.printerr("Some events reference GUI elements that are not part of logfile. " + 
     277                        "These events have been parsed without target."); 
    278278        } 
    279279    } 
     
    406406                    event.setTarget(guiElement); 
    407407                    guiElement.markUsed(); 
    408                     currentSequence.add(event); 
    409408                } 
    410409                eventsWithoutTargets.remove(currentGUIElementHash); 
     
    419418                IGUIElement currentGUIElement; 
    420419                currentGUIElement = currentGUIElementTree.find(currentEventSource); 
    421  
     420                Event event; 
    422421                // in some rare cases the target GUI element of the event is not 
    423422                // known yet 
    424423                if (currentGUIElement == null) { 
    425                     Event event = 
    426                         new Event(instantiateInteraction(currentEventId, currentEventParameters)); 
    427                     event.setTimestamp(currentEventTimestamp); 
    428  
     424                    event = new Event(instantiateInteraction(currentEventId, currentEventParameters)); 
    429425                    List<Event> eventList = eventsWithoutTargets.get(currentEventSource); 
    430426                    if (eventList == null) { 
     
    435431                } 
    436432                else { 
    437                     Event event = 
    438                         new Event(instantiateInteraction(currentEventId, currentEventParameters), 
     433                    event = new Event(instantiateInteraction(currentEventId, currentEventParameters), 
    439434                                  currentGUIElement); 
    440                     event.setTimestamp(currentEventTimestamp); 
    441435                    JFCGUIElement currentEventTarget = (JFCGUIElement) event.getTarget(); 
    442436                    currentEventTarget.markUsed(); 
    443  
    444                     currentSequence.add(event); 
    445                 } 
     437                } 
     438                event.setTimestamp(currentEventTimestamp); 
     439                currentSequence.add(event); 
    446440 
    447441                currentEventParameters = null; 
Note: See TracChangeset for help on using the changeset viewer.