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

Last change on this file since 411 was 244, checked in by sherbold, 13 years ago
  • changed some uses of Console.println, Console.traceln and Console.printerrln to one of the other streams for a more consistent use of the different output streams
  • 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.CommandHelpers;
10import de.ugoe.cs.eventbench.data.Event;
11import de.ugoe.cs.eventbench.data.GlobalDataContainer;
12import de.ugoe.cs.eventbench.efg.GUITARTestCaseParser;
13import de.ugoe.cs.util.console.Command;
14import de.ugoe.cs.util.console.Console;
15
16/**
17 * <p>
18 * Command to load a set of sequences from a set of GUITAR test cases.
19 * </p>
20 *
21 * @author Steffen Herbold
22 * @version 1.0
23 */
24public class CMDefgTestCasesToSequences implements Command {
25
26        /*
27         * (non-Javadoc)
28         *
29         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
30         */
31        @Override
32        public void run(List<Object> parameters) {
33                String foldername;
34                String sequencesName;
35                String efgFileName = null;
36                try {
37                        foldername = (String) parameters.get(0);
38                        sequencesName = (String) parameters.get(1);
39                        if (parameters.size() >= 3) {
40                                efgFileName = (String) parameters.get(2);
41                        }
42                } catch (Exception e) {
43                        throw new InvalidParameterException();
44                }
45
46                File folder = new File(foldername);
47                // TODO would be more robust with filter
48                File[] testcaseFiles = folder.listFiles();
49                Collection<List<Event<?>>> sequences = new LinkedList<List<Event<?>>>();
50                GUITARTestCaseParser parser;
51                if (efgFileName == null) {
52                        parser = new GUITARTestCaseParser();
53                } else {
54                        parser = new GUITARTestCaseParser(efgFileName);
55                }
56                for (File testcaseFile : testcaseFiles) {
57                        Console.traceln("Loading from file "
58                                        + testcaseFile.getAbsolutePath());
59                        sequences.add(parser.parseTestCaseFile(testcaseFile));
60                }
61                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
62                        CommandHelpers.dataOverwritten(sequencesName);
63                }
64
65        }
66
67        /*
68         * (non-Javadoc)
69         *
70         * @see de.ugoe.cs.util.console.Command#help()
71         */
72        @Override
73        public void help() {
74                Console.println("Usage: efgTestCasesToSequences <folder> <sequencesName> {<efgFileName>}");
75        }
76
77}
Note: See TracBrowser for help on using the repository browser.