1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | |
---|
16 | package de.ugoe.cs.util.console.defaultcommands; |
---|
17 | |
---|
18 | import static org.junit.Assert.*; |
---|
19 | |
---|
20 | import java.util.ArrayList; |
---|
21 | import java.util.List; |
---|
22 | |
---|
23 | import org.junit.Before; |
---|
24 | import org.junit.Test; |
---|
25 | |
---|
26 | import de.ugoe.cs.util.console.CommandExecuter; |
---|
27 | import de.ugoe.cs.util.console.Console; |
---|
28 | import de.ugoe.cs.util.console.defaultcommands.CMDlistCommands; |
---|
29 | import de.ugoe.cs.util.console.listener.IOutputListener; |
---|
30 | |
---|
31 | public class CMDlistCommandsTest implements IOutputListener { |
---|
32 | |
---|
33 | private List<String> commands = new ArrayList<String>(); |
---|
34 | |
---|
35 | @Before |
---|
36 | public void setUp() throws Exception { |
---|
37 | Console.getInstance().registerOutputListener(this); |
---|
38 | } |
---|
39 | |
---|
40 | @Test |
---|
41 | public void test() { |
---|
42 | CommandExecuter.getInstance().addCommandPackage("de.ugoe.cs.util.console.defaultcommands"); |
---|
43 | CMDlistCommands command = new CMDlistCommands(); |
---|
44 | command.run(null); |
---|
45 | |
---|
46 | assertTrue(commands.size() > 0); |
---|
47 | |
---|
48 | for (String cmd : commands) { |
---|
49 | assertNotNull(cmd); |
---|
50 | assertTrue(cmd.length() > 0); |
---|
51 | System.out.print(cmd); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | @Override |
---|
56 | public void outputMsg(String newMessage) { |
---|
57 | commands.add(newMessage); |
---|
58 | } |
---|
59 | |
---|
60 | } |
---|