source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/efg/commands/CMDefgTestCasesToSequences.java @ 230

Last change on this file since 230 was 227, checked in by sherbold, 13 years ago
  • extracted class de.ugoe.cs.eventbench.efg.EFGModelGenerator from de.ugoe.cs.eventbench.efg.commands.CMDefgToMM

+ added command efgToDFA

  • extracted class de.ugoe.cs.eventbench.efg.GUITARTestCaseParser from de.ugoe.cs.eventbench.efg.commands.CMDefgTestCasesToSequences
  • Property svn:mime-type set to text/plain
File size: 2.1 KB
Line 
1package de.ugoe.cs.eventbench.efg.commands;
2
3import java.io.File;
4import java.security.InvalidParameterException;
5import java.util.Collection;
6import java.util.LinkedList;
7import java.util.List;
8
9import de.ugoe.cs.eventbench.data.Event;
10import de.ugoe.cs.eventbench.data.GlobalDataContainer;
11import de.ugoe.cs.eventbench.efg.GUITARTestCaseParser;
12import de.ugoe.cs.util.console.Command;
13import de.ugoe.cs.util.console.Console;
14
15/**
16 * <p>
17 * Command to load a set of sequences from a set of GUITAR test cases.
18 * </p>
19 *
20 * @author Steffen Herbold
21 * @version 1.0
22 */
23public class CMDefgTestCasesToSequences implements Command {
24
25        /*
26         * (non-Javadoc)
27         *
28         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
29         */
30        @Override
31        public void run(List<Object> parameters) {
32                String foldername;
33                String sequencesName;
34                String efgFileName = null;
35                try {
36                        foldername = (String) parameters.get(0);
37                        sequencesName = (String) parameters.get(1);
38                        if (parameters.size() >= 3) {
39                                efgFileName = (String) parameters.get(2);
40                        }
41                } catch (Exception e) {
42                        throw new InvalidParameterException();
43                }
44
45                File folder = new File(foldername);
46                // TODO would be more robust with filter
47                File[] testcaseFiles = folder.listFiles();
48                Collection<List<Event<?>>> sequences = new LinkedList<List<Event<?>>>();
49                GUITARTestCaseParser parser;
50                if (efgFileName == null) {
51                        parser = new GUITARTestCaseParser();
52                } else {
53                        parser = new GUITARTestCaseParser(efgFileName);
54                }
55                for (File testcaseFile : testcaseFiles) {
56                        Console.traceln("Loading from file "
57                                        + testcaseFile.getAbsolutePath());
58                        sequences.add(parser.parseTestCaseFile(testcaseFile));
59                }
60                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
61                        Console.traceln("Old data \"" + sequencesName + "\" overwritten");
62                }
63
64        }
65
66        /*
67         * (non-Javadoc)
68         *
69         * @see de.ugoe.cs.util.console.Command#help()
70         */
71        @Override
72        public void help() {
73                Console.println("Usage: efgTestCasesToSequences <folder> <sequencesName> {<efgFileName>}");
74        }
75
76}
Note: See TracBrowser for help on using the repository browser.