Index: trunk/autoquest-generic-event-monitor-test/pom.xml
===================================================================
--- trunk/autoquest-generic-event-monitor-test/pom.xml	(revision 2273)
+++ trunk/autoquest-generic-event-monitor-test/pom.xml	(revision 2286)
@@ -22,10 +22,10 @@
     </properties>
     <dependencies>
-        <!--dependency>
+        <dependency>
             <groupId>de.ugoe.cs.autoquest</groupId>
-            <artifactId>autoquest-plugin-generic-events</artifactId>
+            <artifactId>autoquest-plugin-genericevents</artifactId>
             <version>${project.parent.version}</version>
             <scope>test</scope>
-        </dependency-->
+        </dependency>
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
Index: trunk/autoquest-generic-event-monitor-test/src/test/java/de/ugoe/cs/autoquest/genericeventmonitor/GenericEventMonitorTest.java
===================================================================
--- trunk/autoquest-generic-event-monitor-test/src/test/java/de/ugoe/cs/autoquest/genericeventmonitor/GenericEventMonitorTest.java	(revision 2273)
+++ trunk/autoquest-generic-event-monitor-test/src/test/java/de/ugoe/cs/autoquest/genericeventmonitor/GenericEventMonitorTest.java	(revision 2286)
@@ -17,5 +17,14 @@
 import static org.junit.Assert.*;
 
+import java.lang.String;
+
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.http.HttpEntity;
@@ -29,5 +38,11 @@
 import org.junit.Test;
 
+import de.ugoe.cs.autoquest.eventcore.Event;
+import de.ugoe.cs.autoquest.eventcore.HierarchicalEventTargetModel;
+import de.ugoe.cs.autoquest.eventcore.IEventTarget;
+import de.ugoe.cs.autoquest.eventcore.StringEventType;
 import de.ugoe.cs.autoquest.genericeventmonitor.GenericEventMonitor;
+import de.ugoe.cs.autoquest.plugin.genericevents.GenericEventLogParser;
+import de.ugoe.cs.autoquest.plugin.genericevents.eventCore.GenericEventTarget;
 import de.ugoe.cs.util.console.TextConsole;
 
@@ -138,61 +153,37 @@
         assertTrue(logFile.exists());
         
-        /*HTMLLogParser parser = new HTMLLogParser(null);
+        GenericEventLogParser parser = new GenericEventLogParser(new HashSet<String>());
         
         parser.parseFile(logFile);
         
         // check the GUI model
-        GUIModel guiModel = parser.getGuiModel();
+        HierarchicalEventTargetModel<GenericEventTarget> guiModel = parser.getHierarchicalEventTargetModel();
         assertNotNull(guiModel);
         
-        List<IGUIElement> nodes = guiModel.getRootElements();
+        List<GenericEventTarget> nodes = guiModel.getRootElements();
         assertNotNull(nodes);
         assertEquals(1, nodes.size());
         
-        // get server node
-        IGUIElement node = nodes.get(0);
+        // get root node
+        GenericEventTarget node = nodes.get(0);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLServer);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
+        assertEquals("target1", node.getStringIdentifier());
+        assertEquals("Generic Event", node.getPlatform());
         
         nodes = guiModel.getChildren(node);
         assertNotNull(nodes);
-        assertEquals(1, nodes.size());
-        
-        // get document node
+        assertEquals(2, nodes.size());
+        
+        // get children node
         node = nodes.get(0);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLDocument);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
-        
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(1, nodes.size());
-        
-        // get html node
-        node = nodes.get(0);
+        assertTrue("target2".equals(node.getStringIdentifier()) || "target3".equals(node.getStringIdentifier()));
+        assertEquals("Generic Event", node.getPlatform());
+        
+        node = nodes.get(1);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLPageElement);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
-        
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(1, nodes.size()); // only one child as the head tag should have been ignored
-        
-        // get body node
-        node = nodes.get(0);
-        assertNotNull(node);
-        assertTrue(node instanceof HTMLPageElement);
-        assertEquals("HTML", node.getPlatform());
-        assertTrue(node.isUsed());
-
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(0, nodes.size());
-        
-        // check the sequences
+        assertTrue("target2".equals(node.getStringIdentifier()) || "target3".equals(node.getStringIdentifier()));
+        assertEquals("Generic Event", node.getPlatform());
+        
         Collection<List<Event>> sequences = parser.getSequences();
         
@@ -208,5 +199,14 @@
         assertEquals(1, sequence.size());
         
-        assertEvent(sequence.get(0), 12345, MouseClick.class, node, 194, 7);*/
+        IEventTarget target = null;
+        for (IEventTarget candidate : nodes) {
+            if ("target2".equals(candidate.getStringIdentifier())) {
+                target = candidate;
+                break;
+            }
+        }
+        
+        assertEvent(sequence.get(0), "gaze", target);
+        
     }
 
@@ -231,8 +231,4 @@
             "      \"children\":" +
             "      [ {" +
-            "          \"targetId\":\"head\"," +
-            "          \"index\":\"0\"," +
-            "        }," +
-            "        {" +
             "          \"tagName\":\"body\"," +
             "          \"targetId\":\"gsr\"," +
@@ -353,22 +349,22 @@
         assertTrue(logFile.exists());
         
-        /*HTMLLogParser parser = new HTMLLogParser(null);
+        
+        GenericEventLogParser parser = new GenericEventLogParser(new HashSet<String>());
         
         parser.parseFile(logFile);
         
         // check the GUI model
-        GUIModel guiModel = parser.getGuiModel();
+        HierarchicalEventTargetModel<GenericEventTarget> guiModel = parser.getHierarchicalEventTargetModel();
         assertNotNull(guiModel);
         
-        List<IGUIElement> nodes = guiModel.getRootElements();
+        List<GenericEventTarget> nodes = guiModel.getRootElements();
         assertNotNull(nodes);
         assertEquals(1, nodes.size());
         
-        // get server node
-        IGUIElement node = nodes.get(0);
+        // get root node
+        GenericEventTarget node = nodes.get(0);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLServer);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
+        assertEquals("html", node.getStringIdentifier());
+        assertEquals("Generic Event", node.getPlatform());
         
         nodes = guiModel.getChildren(node);
@@ -376,60 +372,28 @@
         assertEquals(1, nodes.size());
         
-        // get document node
-        node = nodes.get(0);
-        assertNotNull(node);
-        assertTrue(node instanceof HTMLDocument);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
-        
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(1, nodes.size());
-        
-        // get html node
-        node = nodes.get(0);
-        assertNotNull(node);
-        assertTrue(node instanceof HTMLPageElement);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
-        
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(1, nodes.size()); // only one child as the head tag should have been ignored
-        
-        // get body node
-        IGUIElement body = nodes.get(0);
+        // get root child node
+        GenericEventTarget body = nodes.get(0);
         assertNotNull(body);
-        assertTrue(body instanceof HTMLPageElement);
-        assertEquals("HTML", body.getPlatform());
-        assertTrue(body.isUsed());
-
+        assertEquals("gsr", body.getStringIdentifier());
+        assertEquals("Generic Event", body.getPlatform());
+        
         nodes = guiModel.getChildren(body);
         assertNotNull(nodes);
-        
-        // wait for all 10 GUI elements on the same page to be logged although only 9 are used
         assertEquals(10, nodes.size());
         
-        Map<String, IGUIElement> inputs = new HashMap<>();
-        
-        // get input nodes
-        for (int i = 0; i < nodes.size(); i++) {
-            node = nodes.get(i);
-            assertNotNull(node);
-            assertTrue(node instanceof HTMLPageElement);
-            assertEquals("HTML", node.getPlatform());
+        // get children node
+        Map<String, GenericEventTarget> inputs = new HashMap<>();
+        
+        for (GenericEventTarget candidate: nodes) {
+            assertNotNull(candidate);
+            assertTrue(candidate.getStringIdentifier().startsWith("input"));
+            assertEquals("Generic Event", candidate.getPlatform());
             
-            if (!"input9".equals(((HTMLPageElement) node).getHtmlId())) {
-                assertTrue(node.isUsed());
-            }
-            else {
-                assertFalse(node.isUsed());
-            }
-            
-            inputs.put(((HTMLPageElement) node).getHtmlId(), node);
-
-            assertNotNull(guiModel.getChildren(node));
-            assertEquals(0, guiModel.getChildren(node).size());
-        }
+            inputs.put(candidate.getStringIdentifier(), candidate);
+
+            assertNotNull(guiModel.getChildren(candidate));
+            assertEquals(0, guiModel.getChildren(candidate).size());
+        }
+        
         
         // check the sequences
@@ -447,14 +411,14 @@
         assertEquals(10, sequence.size());
         
-        assertEvent(sequence.get(0), 1, MouseClick.class, inputs.get("input1"), 194, 7);
-        assertEvent(sequence.get(1), 2, MouseDoubleClick.class, inputs.get("input2"), 194, 7);
-        assertEvent(sequence.get(2), 3, KeyboardFocusChange.class, inputs.get("input3"), 0, 0);
-        assertEvent(sequence.get(3), 4, MouseClick.class, inputs.get("input4"), 125, 14);
-        assertEvent(sequence.get(4), 5, KeyboardFocusChange.class, inputs.get("input5"), 0, 0);
-        assertEvent(sequence.get(5), 6, KeyboardFocusChange.class, inputs.get("input6"), 0, 0);
-        assertEvent(sequence.get(6), 7, KeyboardFocusChange.class, inputs.get("input7"), 0, 0);
-        assertEvent(sequence.get(7), 8, MouseClick.class, inputs.get("input8"), 255, 4);
-        assertEvent(sequence.get(8), 9, Scroll.class, body, 0, 0);
-        assertEvent(sequence.get(9), 10, MouseClick.class, inputs.get("input10"), 516, 154);*/
+        assertEvent(sequence.get(0), "onclick", inputs.get("input1"));
+        assertEvent(sequence.get(1), "ondblclick", inputs.get("input2"));
+        assertEvent(sequence.get(2), "onfocus", inputs.get("input3"));
+        assertEvent(sequence.get(3), "onclick", inputs.get("input4"));
+        assertEvent(sequence.get(4), "onfocus", inputs.get("input5"));
+        assertEvent(sequence.get(5), "onfocus", inputs.get("input6"));
+        assertEvent(sequence.get(6), "onfocus", inputs.get("input7"));
+        assertEvent(sequence.get(7), "onclick", inputs.get("input8"));
+        assertEvent(sequence.get(8), "onscroll", inputs.get("input9"));
+        assertEvent(sequence.get(9), "onclick", inputs.get("input10"));
 
     }
@@ -466,4 +430,5 @@
     public void testSeveralSessions() throws Exception {
         String clientId = "123";
+        String appId = "456";
        
         String message =
@@ -472,28 +437,29 @@
             "    \"clientInfos\": {" +
             "      \"clientId\":\"" + clientId + "\"," +
-            "      \"userAgent\":\"Agent\"," +
-            "      \"title\":\"Title\"," +
-            "      \"url\":\"http://host/path\"" +
+            "      \"appId\":\"" + appId + "\"," +
             "    }," +
-            "    \"guiModel\": {" +
-            "      \"tagName\":\"html\"," +
-            "      \"index\":\"0\"," +
+            "    \"targetStructure\": [{" +
+            "      \"targetId\":\"target1\"," +
+            "      \"param1\":\"value1\"," +
+            "      \"param3\":\"value3\"," +
+            "      \"param2\":\"value2\"," +
             "      \"children\":" +
             "      [ {" +
-            "          \"tagName\":\"head\"," +
+            "          \"targetId\":\"target3\"," +
             "          \"index\":\"0\"," +
             "        }," +
             "        {" +
-            "          \"tagName\":\"body\"," +
+            "          \"targetId\":\"target2\"," +
             "          \"htmlId\":\"gsr\"," +
             "        }" +
             "      ]" +
-            "    }," +
+            "    }]," +
             "    \"events\":" +
             "    [ {" +
             "        \"time\":\"12345\"," +
-            "        \"path\":\"/html[0]/body(htmlId=gsr)\"," +
-            "        \"type\":\"onclick\"" +
-            "        \"coordinates\": [\"194\", \"7\"]" +
+            "        \"targetId\":\"target2\"," +
+            "        \"type\":\"gaze\"," +
+            "        \"xcoordinate\": \"194\"," +
+            "        \"ycoordinate\": \"12\"" +
             "      }" +
             "    ]" +
@@ -517,10 +483,10 @@
         genericEventMonitor = null;
         
-        /*HTMLLogParser parser = new HTMLLogParser(null);
+        GenericEventLogParser parser = new GenericEventLogParser(new HashSet<String>());
         
         // assert 9 already rotated log files
         for (int i = 0; i < numberOfSessions; i++) {
-            File logFile = new File(LOG_FILE_DIR + File.separator + "host" + File.separator +
-                                    clientId + File.separator + "htmlmonitor_" + clientId + "_00" +
+            File logFile = new File(LOG_FILE_DIR + File.separator + appId + File.separator +
+                                    clientId + File.separator + "genericevents_" + clientId + "_00" +
                                     i + ".log");
        
@@ -531,54 +497,32 @@
 
         // check the GUI model
-        GUIModel guiModel = parser.getGuiModel();
+        HierarchicalEventTargetModel<GenericEventTarget> guiModel = parser.getHierarchicalEventTargetModel();
         assertNotNull(guiModel);
         
-        List<IGUIElement> nodes = guiModel.getRootElements();
+        List<GenericEventTarget> nodes = guiModel.getRootElements();
         assertNotNull(nodes);
         assertEquals(1, nodes.size());
         
-        // get server node
-        IGUIElement node = nodes.get(0);
+        // get root node
+        GenericEventTarget node = nodes.get(0);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLServer);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
+        assertEquals("target1", node.getStringIdentifier());
+        assertEquals("Generic Event", node.getPlatform());
         
         nodes = guiModel.getChildren(node);
         assertNotNull(nodes);
-        assertEquals(1, nodes.size());
-        
-        // get document node
+        assertEquals(2, nodes.size());
+        
+        // get children node
         node = nodes.get(0);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLDocument);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
-        
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(1, nodes.size());
-        
-        // get html node
-        node = nodes.get(0);
+        assertTrue("target2".equals(node.getStringIdentifier()) || "target3".equals(node.getStringIdentifier()));
+        assertEquals("Generic Event", node.getPlatform());
+        
+        node = nodes.get(1);
         assertNotNull(node);
-        assertTrue(node instanceof HTMLPageElement);
-        assertEquals("HTML", node.getPlatform());
-        assertFalse(node.isUsed());
-        
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(1, nodes.size()); // only one child as the head tag should have been ignored
-        
-        // get body node
-        node = nodes.get(0);
-        assertNotNull(node);
-        assertTrue(node instanceof HTMLPageElement);
-        assertEquals("HTML", node.getPlatform());
-        assertTrue(node.isUsed());
-
-        nodes = guiModel.getChildren(node);
-        assertNotNull(nodes);
-        assertEquals(0, nodes.size());
+        assertTrue("target2".equals(node.getStringIdentifier()) || "target3".equals(node.getStringIdentifier()));
+        assertEquals("Generic Event", node.getPlatform());
+        
         
         // check the sequences
@@ -590,4 +534,12 @@
         Iterator<List<Event>> iterator = sequences.iterator();
         
+        IEventTarget target = null;
+        for (IEventTarget candidate : nodes) {
+            if ("target2".equals(candidate.getStringIdentifier())) {
+                target = candidate;
+                break;
+            }
+        }
+        
         while (iterator.hasNext()) {
             List<Event> sequence = iterator.next();
@@ -595,7 +547,126 @@
             assertNotNull(sequence);
             assertEquals(1, sequence.size());
+            
+            assertEvent(sequence.get(0), "gaze", target);
+        }
+        
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testManyRequestsInOneSession() throws Exception {
+        int noOfMessages = 100;
+        int noOfEventsPerMessage = 1000;
+        String clientId = "123";
+        String appId = "456";
        
-            assertEvent(sequence.get(0), 12345, MouseClick.class, node, 194, 7);
-        }*/
+        List<String> messages = new ArrayList<>();
+        
+        int eventId = 0;
+        
+        for (int i = 0; i < noOfMessages; i++) {
+            StringBuffer message = new StringBuffer(
+                "{" +
+                "  \"message\": {" +
+                "    \"clientInfos\": {" +
+                "      \"clientId\":\"" + clientId + "\"," +
+                "      \"appId\":\"" + appId + "\"," +
+                "    }," +
+                "    \"targetStructure\": [{" +
+                "      \"targetId\":\"target1\"," +
+                "      \"children\":" +
+                "      [ {" +
+                "          \"targetId\":\"target2\"," +
+                "        }" +
+                "      ]" +
+                "    }]," +
+                "    \"events\":" +
+                "    [");
+            
+            for (int j = 0; j < noOfEventsPerMessage; j++) {
+                message.append(
+                    "      {" +
+                    "        \"time\":\"" + eventId++ + "\"," +
+                    "        \"targetId\":\"target2\"," +
+                    "        \"type\":\"gaze\"," +
+                    "      },");
+            }
+
+            message.append(
+                "    ]" +
+                "  }" +
+                "}");
+            
+            messages.add(message.toString());
+        }
+        
+        List<Thread> threads = new ArrayList<>();
+        
+        for (String message : messages) {
+            threads.add(sendMessage(message));
+        }
+        
+        for (Thread thread : threads) {
+            thread.join();
+        }
+        
+        genericEventMonitor.stop();
+        genericEventMonitor = null;
+        
+        GenericEventLogParser parser = new GenericEventLogParser(new HashSet<String>());
+        
+        File logFile = new File(LOG_FILE_DIR + File.separator + appId + File.separator +
+                                clientId + File.separator + "genericevents_" + clientId + "_000.log");
+       
+        assertTrue(logFile.exists());
+       
+        parser.parseFile(logFile);
+
+        // check the GUI model
+        HierarchicalEventTargetModel<GenericEventTarget> guiModel = parser.getHierarchicalEventTargetModel();
+        assertNotNull(guiModel);
+        
+        List<GenericEventTarget> nodes = guiModel.getRootElements();
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        
+        // get root node
+        GenericEventTarget node = nodes.get(0);
+        assertNotNull(node);
+        assertEquals("target1", node.getStringIdentifier());
+        assertEquals("Generic Event", node.getPlatform());
+        
+        nodes = guiModel.getChildren(node);
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        
+        // get children node
+        GenericEventTarget target = nodes.get(0);
+        assertNotNull(target);
+        assertEquals("target2", target.getStringIdentifier());
+        assertEquals("Generic Event", target.getPlatform());
+        
+        
+        // check the sequences
+        Collection<List<Event>> sequences = parser.getSequences();
+        
+        assertNotNull(sequences);
+        assertEquals(1, sequences.size());
+        
+        Iterator<List<Event>> iterator = sequences.iterator();
+        
+        while (iterator.hasNext()) {
+            List<Event> sequence = iterator.next();
+        
+            assertNotNull(sequence);
+            assertEquals(noOfMessages * noOfEventsPerMessage, sequence.size());
+            
+            for (Event event : sequence) {
+              assertEvent(event, "gaze", target);
+            }
+        }
+        
     }
 
@@ -605,4 +676,5 @@
     private void sendMessageAndAssertResponse(String message) throws Exception {
         DefaultHttpClient httpclient = new DefaultHttpClient();
+        //HttpPost httpPost = new HttpPost("https://swe-tooling.informatik.uni-goettingen.de/autoquest-genericmonitor/");
         HttpPost httpPost = new HttpPost("http://localhost:" + PORT + "/");
         HttpEntity entity = new StringEntity(message, ContentType.APPLICATION_JSON);
@@ -629,19 +701,32 @@
      *
      */
-    /*private void assertEvent(Event                       event,
-                             int                         timestamp,
-                             Class<? extends IEventType> eventType,
-                             IGUIElement                 eventTarget,
-                             int                         xCoordinate,
-                             int                         yCoordinate)
-    {
-        assertEquals(timestamp, event.getTimestamp());
-        assertTrue(eventType.isInstance(event.getType()));
-        assertEquals(eventTarget, event.getTarget());
-        
-        if (event.getType() instanceof MouseButtonInteraction) {
-            assertEquals(xCoordinate, ((MouseButtonInteraction) event.getType()).getX());
-            assertEquals(yCoordinate, ((MouseButtonInteraction) event.getType()).getY());
-        }
+    private Thread sendMessage(final String message) throws Exception {
+        Thread thread = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    System.out.println("sending data");
+                    sendMessageAndAssertResponse(message);
+                    System.out.println("data send");
+                }
+                catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        
+        thread.start();
+        
+        return thread;
+    }
+
+    
+    /**
+     * 
+     */
+    private void assertEvent(Event event, String name, IEventTarget target) {
+        assertEquals(StringEventType.class, event.getType().getClass());
+        assertEquals(name, ((StringEventType) event.getType()).toString());
+        assertEquals(target, event.getTarget());
     }
 
