[927] | 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. |
---|
[784] | 14 | |
---|
[927] | 15 | |
---|
[664] | 16 | package de.ugoe.cs.util.console.defaultcommands; |
---|
[663] | 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; |
---|
[664] | 28 | import de.ugoe.cs.util.console.defaultcommands.CMDlistCommands; |
---|
[663] | 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 | } |
---|
[784] | 39 | |
---|
[663] | 40 | @Test |
---|
| 41 | public void test() { |
---|
[2281] | 42 | CommandExecuter.getInstance().addCommandPackage("de.ugoe.cs.util.console.defaultcommands", this.getClass().getClassLoader()); |
---|
[663] | 43 | CMDlistCommands command = new CMDlistCommands(); |
---|
| 44 | command.run(null); |
---|
[784] | 45 | |
---|
[663] | 46 | assertTrue(commands.size() > 0); |
---|
[784] | 47 | |
---|
[663] | 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 | } |
---|