Index: trunk/autoquest-plugin-uml-test/src/test/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtilsTest.java
===================================================================
--- trunk/autoquest-plugin-uml-test/src/test/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtilsTest.java	(revision 1927)
+++ trunk/autoquest-plugin-uml-test/src/test/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtilsTest.java	(revision 1929)
@@ -17,4 +17,5 @@
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.util.Collection;
 import java.util.HashSet;
@@ -29,5 +30,7 @@
 //import static org.junit.Assert.*;
 
-import org.apache.commons.lang.SerializationUtils;
+
+
+
 import org.eclipse.uml2.uml.Interaction;
 import org.eclipse.uml2.uml.Model;
@@ -43,7 +46,9 @@
 import de.ugoe.cs.autoquest.plugin.http.SOAPUtils;
 import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType;
+import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType;
 import de.ugoe.cs.autoquest.testgeneration.RandomWalkGenerator;
 import de.ugoe.cs.autoquest.usageprofiles.FirstOrderMarkovModel;
 import de.ugoe.cs.autoquest.usageprofiles.IStochasticProcess;
+import de.ugoe.cs.util.SerializationUtils;
 import de.ugoe.cs.util.console.TextConsole;
 
@@ -58,26 +63,29 @@
 
     private final static String OUTPUT_DIR = "target/tmp/test-outputs/";
-    
+
+    private final static boolean DELETE_OUTPUTS = false;
+
     // for RLUS
     private final static TestData deda_1 = new TestData("deda_rlus_properties.prop",
-                                                      "deda_usagejournal.log",
-                                                      "deda_rlus_usageprofile.dat",
-                                                      "deda_model.uml",
-                                                      "deda_rlus_model_testsuite.uml",
-                                                      "deda_rlus_model_scheduling.uml");
+                                                        "deda_usagejournal.log",
+                                                        "deda_rlus_usageprofile.dat",
+                                                        "deda_model.uml",
+                                                        "deda_rlus_model_testsuite.uml",
+                                                        "deda_rlus_model_scheduling.uml");
 
     // for IXS
     private final static TestData deda_2 = new TestData("deda_ixs_properties.prop",
-                                                           "deda_usagejournal.log",
-                                                           "deda_ixs_usageprofile.dat",
-                                                           "deda_model.uml",
-                                                           "deda_ixs_model_testsuite.uml",
-                                                           "deda_ixs_model_scheduling.uml");
-
-    private final static TestData ita_1 = new TestData("ita_properties.prop", "ita_usagejournal.log",
-                                                     "ita_usageprofile.dat", "ita_model.uml",
-                                                     "ita_model_testsuite.uml",
-                                                     "ita_model_scheduling.uml");
-    
+                                                        "deda_usagejournal.log",
+                                                        "deda_ixs_usageprofile.dat",
+                                                        "deda_model.uml",
+                                                        "deda_ixs_model_testsuite.uml",
+                                                        "deda_ixs_model_scheduling.uml");
+
+    private final static TestData ita_1 = new TestData("ita_properties.prop",
+                                                       "ita_usagejournal.log",
+                                                       "ita_usageprofile.dat", "ita_model.uml",
+                                                       "ita_model_testsuite.uml",
+                                                       "ita_model_scheduling.uml");
+
     private static class TestData {
         public final String propertiesFile;
@@ -89,9 +97,9 @@
 
         public TestData(String propertiesFile,
-                String usageJournalFile,
-                String usageProfileFile,
-                String dslModelFile,
-                String testSuiteFile,
-                String schedulingFile)
+                        String usageJournalFile,
+                        String usageProfileFile,
+                        String dslModelFile,
+                        String testSuiteFile,
+                        String schedulingFile)
         {
             this.propertiesFile = propertiesFile;
@@ -101,5 +109,5 @@
             this.testSuiteFile = testSuiteFile;
             this.schedulingFile = schedulingFile;
-            
+
         }
 
@@ -119,10 +127,12 @@
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        new TextConsole(Level.FINE);
+        new TextConsole(Level.SEVERE);
     }
 
     @After
     public void tearDown() throws Exception {
-        deleteFiles(new File(OUTPUT_DIR));
+        if (DELETE_OUTPUTS) {
+            deleteFiles(new File(OUTPUT_DIR));
+        }
     }
 
@@ -130,5 +140,5 @@
     public void testCreateUMLTransitionSequence_ITA_1() throws Exception {
         TestData testdata = ita_1;
-        
+
         Properties properties = loadProperties(testdata);
         Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties);
@@ -137,10 +147,9 @@
 
         StateMachine stateMachine =
-                (StateMachine) model.getPackagedElement("StateMachineTransportService", true,
-                                                        UMLPackage.Literals.STATE_MACHINE, true);
-
-           
+            (StateMachine) model.getPackagedElement("StateMachineTransportService", true,
+                                                    UMLPackage.Literals.STATE_MACHINE, true);
+
         Collection<List<Event>> umlSequences = new LinkedList<>();
-        
+
         // remove everything but transport from sequences
         for (List<Event> sequence : sequences) {
@@ -159,5 +168,5 @@
     public void testConvertStateMachineToUsageProfile__ITA_1() throws Exception {
         TestData testdata = ita_1;
-        
+
         Properties properties = loadProperties(testdata);
         Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties);
@@ -190,10 +199,10 @@
         createInteractionFromEventSequenceWorkflow(deda_1);
     }
-    
+
     @Test
     public void testCreateInteractionFromEventSequence_DEDA_2() throws Exception {
         createInteractionFromEventSequenceWorkflow(deda_2);
     }
-    
+
     @Test
     public void testCreateInteractionFromEventSequence_ITA_1() throws Exception {
@@ -205,5 +214,5 @@
         calculateUsageScoreWorkflow(deda_1);
     }
-    
+
     @Test
     public void testCalculateUsageScore_DEDA_2() throws Exception {
@@ -211,5 +220,4 @@
     }
 
-    
     @Test
     public void testCalculateUsageScore_ITA_1() throws Exception {
@@ -221,10 +229,10 @@
         createSchedulingWorkflow(deda_1);
     }
-    
+
     @Test
     public void testCreateScheduling_DEDA_2() throws Exception {
         createSchedulingWorkflow(deda_2);
     }
-    
+
     @Test
     public void testCreateScheduling_ITA() throws Exception {
@@ -236,5 +244,4 @@
         validateModelWithLogWorkflow(deda_1);
     }
-    
 
     @Test
@@ -247,12 +254,14 @@
         validateModelWithLogWorkflow(ita_1);
     }
-    
+
     private void validateModelWithLogWorkflow(TestData testdata) throws Exception {
         Properties properties = loadProperties(testdata);
         Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties);
-        Model model = ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
-        
+        Model model =
+            ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
+
         // run validation
-        int violations = UMLUtils.validateModelWithLog(sequences, model, properties.getProperty("test.context"));
+        int violations =
+            UMLUtils.validateModelWithLog(sequences, model, properties.getProperty("test.context"));
         if (violations == 0) {
             System.out.println("No problems found.");
@@ -262,98 +271,110 @@
         }
     }
-    
+
     private void createInteractionFromEventSequenceWorkflow(TestData testdata) throws Exception {
         Properties properties = loadProperties(testdata);
         Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties);
-        Model model = ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
-        
+        Model model =
+            ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
+
         // create a test case for each observed sequence
-        int i=0;
-        for( List<Event> sequence : sequences ) {
-            UMLUtils.createInteractionFromEventSequence(sequence, model, properties.getProperty("testcases.prefix")+"_"+i,
-                    properties.getProperty("test.context"));
+        int i = 0;
+        for (List<Event> sequence : sequences) {
+            UMLUtils.createInteractionFromEventSequence(sequence, model,
+                                                        properties.getProperty("testcases.prefix") +
+                                                            "_" + i,
+                                                        properties.getProperty("test.context"));
             i++;
         }
-    }
-    
+
+        ModelUtils.writeModelToFile(model, OUTPUT_DIR + testdata.testSuiteFile);
+    }
+
     private void calculateUsageScoreWorkflow(TestData testdata) throws Exception {
         Properties properties = loadProperties(testdata);
         Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties);
         Model model =
-            ModelUtils.loadModel(ClassLoader
-                .getSystemResourceAsStream(testdata.dslModelFile));
-        IStochasticProcess usageProfile = createUsageProfile(sequences);
-        Collection<List<Event>> generatedSequences = createRandomSequences(usageProfile, properties);
-        
+            ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
+        IStochasticProcess usageProfile = createUsageProfile(testdata, sequences);
+        Collection<List<Event>> generatedSequences =
+            createRandomSequences(usageProfile, properties);
+
         int i = 1;
+        List<Interaction> interactions = new LinkedList<>();
         int[] lengths = new int[generatedSequences.size()];
         for (List<Event> sequence : generatedSequences) {
-            UMLUtils.createInteractionFromEventSequence(sequence, model, properties.getProperty("testcases.prefix")+"_"+i,
-                                                        properties.getProperty("test.context"));
+            interactions.add(UMLUtils.createInteractionFromEventSequence(sequence, model,
+                                                        properties.getProperty("testcases.prefix") +
+                                                            "_" + i,
+                                                        properties.getProperty("test.context")));
             lengths[i - 1] = sequence.size();
             i++;
         }
-        for (int j = 0; j < generatedSequences.size(); j++) {
-            Interaction interaction =
-                (Interaction) model.getPackagedElement(properties.getProperty("testcases.prefix") + j, true,
-                                                       UMLPackage.Literals.INTERACTION, true);
-            double usageScore = UMLUtils.calculateUsageScore(interaction, usageProfile);
+        for (int j = 0; j < interactions.size(); j++) {
+            double usageScore = UMLUtils.calculateUsageScore(interactions.get(j), usageProfile);
             System.out.format("usage score %02d: %.2f \t %d\n", j + 1, usageScore, lengths[j]);
         }
     }
-    
+
     private void createSchedulingWorkflow(TestData testdata) throws Exception {
         Properties properties = loadProperties(testdata);
         Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties);
-        Model model = ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
-        IStochasticProcess usageProfile = createUsageProfile(sequences);
-        Collection<List<Event>> generatedSequences = createRandomSequences(usageProfile, properties);
+        Model model =
+            ModelUtils.loadModel(ClassLoader.getSystemResourceAsStream(testdata.dslModelFile));
+        IStochasticProcess usageProfile = createUsageProfile(testdata, sequences);
+        Collection<List<Event>> generatedSequences =
+            createRandomSequences(usageProfile, properties);
         int i = 1;
         for (List<Event> sequence : generatedSequences) {
-            UMLUtils.createInteractionFromEventSequence(sequence, model, properties.getProperty("testcases.prefix")+"_"+i,
+            UMLUtils.createInteractionFromEventSequence(sequence, model,
+                                                        properties.getProperty("testcases.prefix") +
+                                                            "_" + i,
                                                         properties.getProperty("test.context"));
             i++;
         }
-        
-        UMLUtils.createScheduling(model, usageProfile, null);
-
-        //ModelUtils.writeModelToFile(model, OUTPUT_DIR + "testCreateScheduling_1_result.uml");
-    }
-    
+
+        UMLUtils.createScheduling(model, usageProfile, properties.getProperty("test.context"));
+
+        ModelUtils.writeModelToFile(model, OUTPUT_DIR + testdata.schedulingFile);
+    }
+
     private Properties loadProperties(TestData testdata) throws Exception {
         Properties properties = new Properties();
-        properties.load(new FileInputStream(ClassLoader.getSystemResource(testdata.propertiesFile).getFile()));
+        properties.load(new FileInputStream(ClassLoader.getSystemResource(testdata.propertiesFile)
+            .getFile()));
         return properties;
     }
-    
-    private Collection<List<Event>> loadAndPreprocessUsageJournal(TestData testdata, Properties properties) throws Exception {
+
+    private Collection<List<Event>> loadAndPreprocessUsageJournal(TestData testdata,
+                                                                  Properties properties)
+        throws Exception
+    {
         // load usage journal
         HTTPLogParser parser =
             new HTTPLogParser(new File(ClassLoader.getSystemResource(testdata.propertiesFile)
                 .getFile()));
-        parser
-            .parseFile(new File(ClassLoader
-                .getSystemResource(testdata.usageJournalFile)
-                .getFile()));
+        parser.parseFile(new File(ClassLoader.getSystemResource(testdata.usageJournalFile)
+            .getFile()));
         Collection<List<Event>> sequences = parser.getSequences();
 
-        // remove non SOAP events
+        // remove non SOAP events and convert to SimpleSOAPEventType
+        Collection<List<Event>> simpleSOAPSequences = new LinkedList<>();
         for (List<Event> sequence : sequences) {
-            SOAPUtils.removeNonSOAPEvents(sequence);
-        }
-        
+            simpleSOAPSequences.add(SOAPUtils.convertToSimpleSOAPEvent(sequence, true));
+        }
+
         // remove calls to ingored services
         Set<String> ignoredServices = new HashSet<>();
         String ignoredServicesString = properties.getProperty("test.ignored.services");
-        if( ignoredServicesString!=null ) {
-            for( String service : ignoredServicesString.split(",") ) {
+        if (ignoredServicesString != null) {
+            for (String service : ignoredServicesString.split(",")) {
                 ignoredServices.add(service.trim());
             }
         }
-        
-        for (List<Event> sequence : sequences) {
+
+        for (List<Event> sequence : simpleSOAPSequences) {
             for (Iterator<Event> eventIter = sequence.iterator(); eventIter.hasNext();) {
                 Event event = eventIter.next();
-                SOAPEventType eventType = (SOAPEventType) event.getType();
+                SimpleSOAPEventType eventType = (SimpleSOAPEventType) event.getType();
                 if (ignoredServices.contains(eventType.getServiceName())) {
                     eventIter.remove();
@@ -361,27 +382,32 @@
             }
         }
-        return sequences;
-    }
-    
-    private IStochasticProcess createUsageProfile(Collection<List<Event>> sequences) throws Exception {
-        Collection<List<Event>> simpleSOAPSequences = new LinkedList<>();
-        for (List<Event> sequence : sequences) {
-            simpleSOAPSequences.add(SOAPUtils.convertToSimpleSOAPEvent(sequence, true));
-        }
-
+        return simpleSOAPSequences;
+    }
+
+    private IStochasticProcess createUsageProfile(TestData testdata, Collection<List<Event>> sequences)
+        throws Exception
+    {
         FirstOrderMarkovModel usageProfile = new FirstOrderMarkovModel(new Random(1));
-        usageProfile.train(simpleSOAPSequences);
+        usageProfile.train(sequences);
+        FileOutputStream fos = new FileOutputStream(OUTPUT_DIR + testdata.usageProfileFile);
+        SerializationUtils.serialize(usageProfile, fos);
+        fos.close();
         return usageProfile;
     }
-    
-    private Collection<List<Event>> createRandomSequences(IStochasticProcess usageProfile, Properties properties) throws Exception {
+
+    private Collection<List<Event>> createRandomSequences(IStochasticProcess usageProfile,
+                                                          Properties properties) throws Exception
+    {
         int numberOfTestCases = Integer.parseInt(properties.getProperty("testcases.number"));
         int testCaseMinLength = Integer.parseInt(properties.getProperty("testcases.minlenth", "1"));
-        int testCaseMaxLength = Integer.parseInt(properties.getProperty("testcases.maxlenth", "100"));
+        int testCaseMaxLength =
+            Integer.parseInt(properties.getProperty("testcases.maxlenth", "100"));
         int maxIter = numberOfTestCases * 100;
-        RandomWalkGenerator testGenerator = new RandomWalkGenerator(numberOfTestCases, testCaseMinLength, testCaseMaxLength, true, maxIter);
+        RandomWalkGenerator testGenerator =
+            new RandomWalkGenerator(numberOfTestCases, testCaseMinLength, testCaseMaxLength, true,
+                                    maxIter);
         return testGenerator.generateTestSuite(usageProfile);
     }
-    
+
     private void deleteFiles(File file) {
         if (file.exists()) {
