Last change
on this file since 703 was
703,
checked in by pharms, 12 years ago
|
- moved some test utilities to dedicated test utilities project
|
File size:
1.3 KB
|
Rev | Line | |
---|
[703] | 1 | // Module : $RCSfile: CommandRunner.java,v $ |
---|
| 2 | // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 29.08.2012 $ |
---|
| 3 | // Project : quest-test-utils |
---|
| 4 | // Creation : 2012 by pharms |
---|
| 5 | // Copyright : Patrick Harms, 2012 |
---|
| 6 | package de.ugoe.cs.quest.test; |
---|
| 7 | |
---|
| 8 | import static org.junit.Assert.fail; |
---|
| 9 | |
---|
| 10 | import java.util.ArrayList; |
---|
| 11 | import java.util.List; |
---|
| 12 | |
---|
| 13 | import de.ugoe.cs.util.console.Command; |
---|
| 14 | |
---|
| 15 | /** |
---|
| 16 | * <p> |
---|
| 17 | * TODO comment |
---|
| 18 | * </p> |
---|
| 19 | * |
---|
| 20 | * @version $Revision: $ $Date: 29.08.2012$ |
---|
| 21 | * @author 2012, last modified by $Author: pharms$ |
---|
| 22 | */ |
---|
| 23 | public class CommandRunner { |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * <p> |
---|
| 27 | * prevent instantiation |
---|
| 28 | * </p> |
---|
| 29 | */ |
---|
| 30 | private CommandRunner() { |
---|
| 31 | // just to prevent instantiation |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | public static void runCommand(Class<? extends Command> commandType, Object... parameters) { |
---|
| 35 | Command command; |
---|
| 36 | try { |
---|
| 37 | command = commandType.newInstance(); |
---|
| 38 | } |
---|
| 39 | catch (Exception e) { |
---|
| 40 | fail("could not instantiate command"); |
---|
| 41 | return; // just added to prevent compiler warning. But the fail will already throw an |
---|
| 42 | // exception |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | List<Object> params = new ArrayList<Object>(); |
---|
| 46 | |
---|
| 47 | for (Object parameter : parameters) { |
---|
| 48 | params.add(parameter); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | command.run(params); |
---|
| 52 | } |
---|
| 53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.