Index: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeChecker.java
===================================================================
--- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeChecker.java	(revision 922)
+++ trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeChecker.java	(revision 922)
@@ -0,0 +1,456 @@
+package de.ugoe.cs.autoquest.tasktrees;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import de.ugoe.cs.autoquest.eventcore.gui.TextInput;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeInfo;
+
+/**
+ * TODO comment
+ * 
+ * @version $Revision: $ $Date: 01.04.2012$
+ * @author 2012, last modified by $Author: patrick$
+ */
+public class TaskTreeChecker {
+    
+    /** */
+    private static Pattern taskPattern = Pattern.compile("([^{}]+)\\{|\\}");
+    
+    /** */
+    private static Pattern taskDetailsPattern =
+        Pattern.compile("\\s*(\\w*)\\s*(\\w*)\\s*((\\w*)|(\".*\"))?");
+    
+    /** */
+    private boolean doTrace;
+
+    /**
+     * TODO: comment
+     * 
+     */
+    public TaskTreeChecker() {
+        this(false);
+    }
+
+    /**
+     * TODO: comment
+     * 
+     */
+    public TaskTreeChecker(boolean doTrace) {
+        this.doTrace = doTrace;
+    }
+
+    /**
+     *
+     */
+    public void assertTaskTree(String taskTreeSpec, ITaskTree taskTree) {
+        Map<ITaskTreeNode, Integer> taskMapCopy = new HashMap<ITaskTreeNode, Integer>();
+
+        for (Map.Entry<ITaskTreeNode, ITaskTreeNodeInfo> entry : taskTree.getTaskMap().entrySet()) {
+            if (entry.getValue().getNoOfOccurencesInTree() > 0) {
+                taskMapCopy.put(entry.getKey(), entry.getValue().getNoOfOccurencesInTree());
+            }
+            else {
+                taskMapCopy.put(entry.getKey(), 1);
+            }
+        }
+
+        if (doTrace) {
+            dumpTaskMap(taskMapCopy);
+        }
+
+        TaskSpec task = null;
+
+        Matcher taskMatcher = taskPattern.matcher(taskTreeSpec);
+
+        while (taskMatcher.find()) {
+
+            task = parseTask(taskMatcher);
+            
+            if (task != null) {
+                assertTaskAndChildrenInMapAndRemove(task, taskMapCopy);
+            }
+        }
+
+        assertTrue("more tasks in map, than expected", taskMapCopy.isEmpty());
+    }
+
+    /**
+     * TODO: comment
+     * 
+     * @param taskTree
+     */
+    public void dumpAsCheckString(ITaskTree taskTree) {
+        dumpNodeAsCheckString(taskTree.getRoot(), new int[4], "");
+    }
+
+    /**
+     * TODO: comment
+     * 
+     * @param root
+     * @param string
+     */
+    private void dumpNodeAsCheckString(ITaskTreeNode node, int[] typeCounters, String indent) {
+        System.out.print("       \"");
+        System.out.print(indent);
+
+        if (node instanceof ISequence) {
+            System.out.print("Sequence sequence");
+            System.out.print(typeCounters[0]++);
+            System.out.println(" {\" +");
+        }
+        else if (node instanceof IIteration) {
+            System.out.print("Iteration iteration");
+            System.out.print(typeCounters[1]++);
+            System.out.println(" {\" +");
+        }
+        else if (node instanceof ISelection) {
+            System.out.print("Selection selection");
+            System.out.print(typeCounters[2]++);
+            System.out.println(" {\" +");
+        }
+        else if (node instanceof IEventTask) {
+            if (((IEventTask) node).getEventType() instanceof TextInput) {
+                System.out.print("TextInputEvent textInput");
+                System.out.print(typeCounters[3]++);
+                System.out.print(" \"");
+                System.out.print(((TextInput) ((IEventTask) node).getEventType()).getEnteredText());
+                System.out.print("\"");
+            }
+            else {
+                System.out.print("Event ");
+                System.out.print(((IEventTask) node).getEventType().getName());
+            }
+            System.out.print(" {}\" +");
+        }
+        else {
+            fail("unknown type of node in task tree " + node);
+        }
+
+        for (ITaskTreeNode child : node.getChildren()) {
+            dumpNodeAsCheckString(child, typeCounters, indent + "  ");
+        }
+
+        if (!(node instanceof IEventTask)) {
+            System.out.print("       \"");
+            System.out.print(indent);
+            System.out.print("}\" +");
+        }
+
+        System.out.println();
+    }
+
+    /**
+     * TODO: comment
+     * 
+     * @param taskTree
+     */
+    public void dumpFullTaskTree(ITaskTree taskTree) throws FileNotFoundException {
+        PrintWriter out = null;
+        try {
+            out = new PrintWriter(new FileOutputStream("taskTree.txt"));
+            dumpFullNode(taskTree.getRoot(), out, "", 0);
+        }
+        finally {
+            if (out != null) {
+                out.close();
+            }
+        }
+
+    }
+
+    /**
+     *
+     */
+    private void dumpFullNode(ITaskTreeNode node, PrintWriter out, String indent, int index) {
+        if (node instanceof ISequence) {
+            if (index > 0) {
+                out.println();
+            }
+            out.print(indent);
+            out.println("Sequence {");
+        }
+        else if (node instanceof IIteration) {
+            if (index > 0) {
+                out.println();
+            }
+            out.print(indent);
+            out.println("Iteration {");
+        }
+        else if (node instanceof ISelection) {
+            if (index > 0) {
+                out.println();
+            }
+            out.print(indent);
+            out.println("Selection {");
+        }
+        else if (node instanceof IEventTask) {
+            out.print(indent);
+            out.print(((IEventTask) node).getEventType().getName());
+            out.print(" ");
+            out.print(((IEventTask) node).getEventTarget());
+//            if (((IEventTask) node).getEventTarget() instanceof IGUIElement) {
+//              out.print(" ");
+//              out.print(((IGUIElement) ((IEventTask) node).getEventTarget()).getSpecification());
+//            }
+        }
+        else {
+            fail("unknown type of node in task tree " + node);
+        }
+
+        int i = 0;
+        for (ITaskTreeNode child : node.getChildren()) {
+            dumpFullNode(child, out, indent + "  ", i++);
+        }
+
+        if (!(node instanceof IEventTask)) {
+            out.print(indent);
+            out.print("}");
+        }
+
+        out.println();
+    }
+
+    /**
+     * 
+     */
+    private TaskSpec parseTask(Matcher taskMatcher) {
+        if ("}".equals(taskMatcher.group(1))) {
+            throw new IllegalArgumentException("invalid task specification");
+        }
+        
+        String taskDetails = taskMatcher.group(1);
+        
+        Matcher matcher = taskDetailsPattern.matcher(taskDetails);
+        
+        if (!matcher.find()) {
+            throw new IllegalArgumentException("could not parse task details");
+        }
+
+        TaskSpec task = new TaskSpec();
+        task.type = matcher.group(1);
+        
+        task.name = matcher.group(2);
+        if ((matcher.group(4) != null) && (!"".equals(matcher.group(4).trim()))) {
+            task.name += " " + matcher.group(4).trim();
+        }
+        
+        if ((matcher.group(5) != null) && (!"".equals(matcher.group(5).trim()))) {
+            task.additionalInfo = matcher.group(5).trim();
+        }
+
+        if ("".equals(task.name)) {
+            task.name = null;
+        }
+
+        List<TaskSpec> children = new ArrayList<TaskSpec>();
+        while (taskMatcher.find() && !"}".equals(taskMatcher.group(0))) {
+            children.add(parseTask(taskMatcher));
+        }
+
+        if (children.size() > 0) {
+            task.children = children.toArray(new TaskSpec[children.size()]);
+        }
+
+        return task;
+    }
+
+    /**
+     * @param task
+     * @param taskMapCopy
+     */
+    private void assertTaskAndChildrenInMapAndRemove(TaskSpec                    task,
+                                                     Map<ITaskTreeNode, Integer> taskMap)
+    {
+        for (Map.Entry<ITaskTreeNode, Integer> entry : taskMap.entrySet()) {
+            if (taskSpecEqualsTask(task, entry.getKey())) {
+                if (task.children != null) {
+                    for (TaskSpec child : task.children) {
+                        assertTaskAndChildrenInMapAndRemove(child, taskMap);
+                    }
+                }
+
+                int count = taskMap.get(entry.getKey());
+                if (count == 1) {
+                    taskMap.remove(entry.getKey());
+                }
+                else {
+                    taskMap.put(entry.getKey(), count - 1);
+                }
+                return;
+            }
+        }
+
+        fail("expected task " + task.type + " " + task.name +
+             " not included in task map");
+    }
+
+    /**
+     *
+     */
+    private boolean taskSpecEqualsTask(TaskSpec taskSpec, ITaskTreeNode task) {
+        if (doTrace) {
+            System.err.println("comparing " + taskSpec.name + " with");
+            dumpTask(task, 0, "");
+        }
+
+        if (("Event".equals(taskSpec.type) && (!(task instanceof IEventTask))) ||
+            ("TextInputEvent".equals(taskSpec.type) &&
+             ((!(task instanceof IEventTask)) ||
+              (!(((IEventTask) task).getEventType() instanceof TextInput)))) ||
+            ("Sequence".equals(taskSpec.type) && (!(task instanceof ISequence))) ||
+            ("Selection".equals(taskSpec.type) && (!(task instanceof ISelection))) ||
+            ("Iteration".equals(taskSpec.type) && (!(task instanceof IIteration))))
+        {
+            if (doTrace) {
+                System.err.println("task types do not match: " + taskSpec.type + " != " +
+                    task.getClass().getSimpleName() + "\n");
+            }
+            return false;
+        }
+        else if (!"Event".equals(taskSpec.type) &&
+                 !"TextInputEvent".equals(taskSpec.type) &&
+                 !"Sequence".equals(taskSpec.type) &&
+                 !"Selection".equals(taskSpec.type) &&
+                 !"Iteration".equals(taskSpec.type))
+        {
+            fail("unknown task type " + taskSpec.type + " --> please extend test case");
+        }
+
+        if ("TextInputEvent".equals(taskSpec.type)) {
+            TextInput eventType = (TextInput) ((IEventTask) task).getEventType();
+            if ((taskSpec.additionalInfo != null) &&
+                !"".equals(taskSpec.additionalInfo) &&
+                !(taskSpec.additionalInfo.equals(eventType.getEnteredText())))
+            {
+                if (doTrace) {
+                    System.err.println("expected text \"" + taskSpec.additionalInfo +
+                                       "\" is not equal to the text " + "provided by the task \"" +
+                                       eventType.getEnteredText() + "\"\n");
+                }
+                return false;
+            }
+        }
+        else if ((task instanceof IEventTask) && (((IEventTask) task).getEventType() != null) &&
+                 (!taskSpec.name.equals(((IEventTask) task).getEventType().getName())))
+        {
+            // simple event names do not match. But what about the event name in
+            // combination with the additional info
+            String complexName =
+                taskSpec.name +
+                    (!"".equals(taskSpec.additionalInfo) ? " " + taskSpec.additionalInfo : "");
+
+            if (!complexName.equals(((IEventTask) task).getEventType().getName())) {
+                if (doTrace) {
+                    System.err.println("event names do not match: " + taskSpec.name + " != " +
+                                       ((IEventTask) task).getEventType().getName() + "\n");
+                }
+                return false;
+            }
+        }
+
+        if (((taskSpec.children == null) && (task.getChildren().size() > 0)) ||
+            ((taskSpec.children != null) && (taskSpec.children.length != task.getChildren().size())))
+        {
+            if (doTrace) {
+                System.err.println
+                    ("numbers of children do not match: " +
+                     (taskSpec.children == null ? "0" : taskSpec.children.length) + " != " +
+                     (task.getChildren() == null ? "0" : task.getChildren().size()) + "\n");
+            }
+            return false;
+        }
+
+        Iterator<ITaskTreeNode> children = task.getChildren().iterator();
+        if (taskSpec.children != null) {
+            for (TaskSpec child : taskSpec.children) {
+                if (!taskSpecEqualsTask(child, children.next())) {
+                    if (doTrace) {
+                        System.err.println("one of the children does not match\n");
+                    }
+                    return false;
+                }
+            }
+        }
+
+        if (!children.hasNext()) {
+            if (doTrace) {
+                System.err.println("nodes match\n");
+            }
+            return true;
+        }
+        else {
+            if (doTrace) {
+                System.err.println("number of children does not match\n");
+            }
+            return false;
+        }
+    }
+
+    /**
+   *
+   */
+    private void dumpTaskMap(Map<ITaskTreeNode, Integer> taskMap) {
+        System.err.println();
+        for (Map.Entry<ITaskTreeNode, Integer> entry : taskMap.entrySet()) {
+            dumpTask(entry.getKey(), entry.getValue(), "");
+            System.err.println();
+        }
+    }
+
+    /**
+     *
+     */
+    private void dumpTask(ITaskTreeNode task, int count, String indent) {
+        System.err.print(indent);
+        System.err.print(task);
+        System.err.print(" ");
+        System.err.print(task.getDescription());
+        System.err.print(" ");
+
+        if (count > 0) {
+            System.err.print("(");
+            System.err.print(count);
+            System.err.print(" occurrences)");
+        }
+
+        System.err.println();
+
+        if ((task.getChildren() != null) && (task.getChildren().size() > 0)) {
+            for (ITaskTreeNode child : task.getChildren()) {
+                dumpTask(child, 0, indent + "  ");
+            }
+        }
+    }
+    
+    /**
+     * TODO comment
+     * 
+     * @version $Revision: $ $Date: $
+     * @author 2011, last modified by $Author: $
+     */
+    private class TaskSpec {
+        public String type;
+        public String name;
+        public String additionalInfo;
+        public TaskSpec[] children;
+    }
+
+}
Index: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/CommandRunner.java
===================================================================
--- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/CommandRunner.java	(revision 922)
+++ trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/CommandRunner.java	(revision 922)
@@ -0,0 +1,53 @@
+// Module    : $RCSfile: CommandRunner.java,v $
+// Version   : $Revision: 0.0 $  $Author: pharms $  $Date: 29.08.2012 $
+// Project   : quest-test-utils
+// Creation  : 2012 by pharms
+// Copyright : Patrick Harms, 2012
+package de.ugoe.cs.autoquest.test;
+
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import de.ugoe.cs.util.console.Command;
+
+/**
+ * <p>
+ * TODO comment
+ * </p>
+ * 
+ * @version $Revision: $ $Date: 29.08.2012$
+ * @author 2012, last modified by $Author: pharms$
+ */
+public class CommandRunner {
+
+    /**
+     * <p>
+     * prevent instantiation
+     * </p>
+     */
+    private CommandRunner() {
+        // just to prevent instantiation
+    }
+
+    public static void runCommand(Class<? extends Command> commandType, Object... parameters) {
+        Command command;
+        try {
+            command = commandType.newInstance();
+        }
+        catch (Exception e) {
+            fail("could not instantiate command");
+            return; // just added to prevent compiler warning. But the fail will already throw an
+                    // exception
+        }
+        
+        List<Object> params = new ArrayList<Object>();
+        
+        for (Object parameter : parameters) {
+            params.add(parameter);
+        }
+        
+        command.run(params);
+    }
+}
Index: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyGUIElement.java
===================================================================
--- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyGUIElement.java	(revision 922)
+++ trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyGUIElement.java	(revision 922)
@@ -0,0 +1,81 @@
+
+package de.ugoe.cs.autoquest.test;
+
+import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement;
+import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
+import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
+
+/**
+ * TODO comment
+ * 
+ * @version $Revision: $ $Date: 02.04.2012$
+ * @author 2012, last modified by $Author: patrick$
+ */
+public class DummyGUIElement extends AbstractDefaultGUIElement implements IGUIElement {
+
+    /**  */
+    private static final long serialVersionUID = 1L;
+
+    /** */
+    private String name;
+
+    /**
+     *
+     */
+    public DummyGUIElement(String name) {
+        this(name, null);
+    }
+
+    /**
+     *
+     */
+    public DummyGUIElement(String name, IGUIElement parent) {
+        super(null, parent);
+        this.name = name;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
+     */
+    @Override
+    public String getPlatform() {
+        return "Dummy";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getStringIdentifier()
+     */
+    @Override
+    public String getStringIdentifier() {
+        return name;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.harms.attef.userinteraction.GUIElement#equals(GUIElement)
+     */
+    public boolean equals(IGUIElement other) {
+        return this == other;
+    }
+
+    @Override
+    public void updateSpecification(IGUIElementSpec specToIntegrateElementFor) {
+        // dummy
+    }
+
+}
Index: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyInteraction.java
===================================================================
--- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyInteraction.java	(revision 922)
+++ trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyInteraction.java	(revision 922)
@@ -0,0 +1,83 @@
+package de.ugoe.cs.autoquest.test;
+
+import de.ugoe.cs.autoquest.eventcore.gui.IInteraction;
+
+/**
+ * TODO comment
+ * 
+ * @version $Revision: $ $Date: 02.04.2012$
+ * @author 2012, last modified by $Author: patrick$
+ */
+public class DummyInteraction implements IInteraction {
+    
+    /**  */
+    private static final long serialVersionUID = 1L;
+
+    /** */
+    private int interactionNumber;
+
+    /** */
+    private String interactionType;
+
+    /**
+     * @param interactionNumber
+     * @param interactionType
+     */
+    public DummyInteraction(String interactionType, int interactionNumber) {
+        super();
+        this.interactionNumber = interactionNumber;
+        this.interactionType = interactionType;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.harms.attef.userinteraction.Interaction#getName()
+     */
+    public String getName() {
+        return interactionType;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return interactionType;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
+     */
+    public boolean startsLogicalSequence() {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
+     */
+    public boolean finishesLogicalSequence() {
+        return false;
+    }
+
+    /**
+     * @return the interactionType
+     */
+    public String getInteractionType() {
+        return interactionType;
+    }
+
+    /**
+     * @return the interactionNumber
+     */
+    public int getInteractionNumber() {
+        return interactionNumber;
+    }
+
+}
Index: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyTextField.java
===================================================================
--- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyTextField.java	(revision 922)
+++ trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyTextField.java	(revision 922)
@@ -0,0 +1,23 @@
+package de.ugoe.cs.autoquest.test;
+
+import de.ugoe.cs.autoquest.eventcore.guimodel.ITextField;
+
+/**
+ * TODO comment
+ * 
+ * @version $Revision: $ $Date: 02.04.2012$
+ * @author 2012, last modified by $Author: patrick$
+ */
+public class DummyTextField extends DummyGUIElement implements ITextField {
+
+    /**  */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    public DummyTextField(String name) {
+        super("text field \"" + name + "\"");
+    }
+
+}
Index: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/usageprofiles/MockTrieBasedModel.java
===================================================================
--- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/usageprofiles/MockTrieBasedModel.java	(revision 922)
+++ trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/usageprofiles/MockTrieBasedModel.java	(revision 922)
@@ -0,0 +1,31 @@
+package de.ugoe.cs.autoquest.usageprofiles;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import de.ugoe.cs.autoquest.eventcore.Event;
+import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
+
+public class MockTrieBasedModel extends TrieBasedModel {
+	private static final long serialVersionUID = 1L;
+
+	public MockTrieBasedModel(int markovOrder, Random r) {
+		super(markovOrder, r);
+	}
+
+	@Override
+	public double getProbability(List<Event> context,
+			Event symbol) {
+		List<Event> list = new ArrayList<Event>();
+		if( context.isEmpty() ) {
+			return 2;
+		}
+		list.add(context.get(context.size()-1));
+		if( trie.find(list).getFollowingSymbols().contains(symbol) ) {
+			return 1;
+		} else {
+			return 0;
+		}
+	}
+}
