source: trunk/java-utils-test/src/test/java/de/ugoe/cs/util/console/defaultcommands/CMDlistCommandsTest.java @ 664

Last change on this file since 664 was 664, checked in by sherbold, 12 years ago
  • modified Command.help(): the help now returns a string with its usage instead of writing directly to the console
  • modified listCommands: now writes the help string of each command instead of just the name; this way, the parameters are displayed directly
  • moved listCommands from quest-ui-core to java-utils
File size: 1.8 KB
Line 
1// Module    : $RCSfile: CMDlistCommandsTest.java,v $
2// Version   : $Revision: 0.0 $  $Author: pharms $  $Date: 28.08.2012 $
3// Project   : quest-ui-core-test
4// Creation  : 2012 by pharms
5// Copyright : Patrick Harms, 2012
6package de.ugoe.cs.util.console.defaultcommands;
7
8import static org.junit.Assert.*;
9
10import java.util.ArrayList;
11import java.util.List;
12
13import org.junit.Before;
14import org.junit.Test;
15
16import de.ugoe.cs.util.console.CommandExecuter;
17import de.ugoe.cs.util.console.Console;
18import de.ugoe.cs.util.console.defaultcommands.CMDlistCommands;
19import de.ugoe.cs.util.console.listener.IOutputListener;
20
21/**
22 * <p>
23 * TODO comment
24 * </p>
25 *
26 * @version $Revision: $ $Date: 28.08.2012$
27 * @author 2012, last modified by $Author: pharms$
28 */
29public class CMDlistCommandsTest implements IOutputListener {
30
31    /** */
32    private List<String> commands = new ArrayList<String>();
33
34    /**
35     *
36     */
37    @Before
38    public void setUp() throws Exception {
39        Console.getInstance().registerOutputListener(this);
40    }
41       
42    /**
43     * <p>
44     * TODO: comment
45     * </p>
46     *
47     */
48    @Test
49    public void test() {
50        CommandExecuter.getInstance().addCommandPackage("de.ugoe.cs.quest.ui.commands");
51        CommandExecuter.getInstance().addCommandPackage("de.ugoe.cs.quest.ui.swt.commands");
52        CMDlistCommands command = new CMDlistCommands();
53        command.run(null);
54       
55        assertTrue(commands.size() > 0);
56       
57        for (String cmd : commands) {
58            assertNotNull(cmd);
59            assertTrue(cmd.length() > 0);
60            System.out.print(cmd);
61        }
62    }
63
64    /* (non-Javadoc)
65     * @see de.ugoe.cs.util.console.listener.IOutputListener#outputMsg(java.lang.String)
66     */
67    @Override
68    public void outputMsg(String newMessage) {
69        commands.add(newMessage);
70    }
71
72}
Note: See TracBrowser for help on using the repository browser.