1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package name.angoca.zemucan.main;
30
31 import name.angoca.zemucan.AbstractZemucanException;
32 import name.angoca.zemucan.tools.configurator.Configurator;
33 import name.angoca.zemucan.tools.test.RandomTestRunner;
34 import name.angoca.zemucan.ui.api.AbstractInterfaceController;
35 import name.angoca.zemucan.ui.api.InputReaderException;
36 import name.angoca.zemucan.ui.impl.jline.ImplementationJlineInterfaceController;
37 import name.angoca.zemucan.ui.impl.system.ImplementationSystemInterfaceController;
38
39 import org.junit.Assert;
40 import org.junit.Test;
41 import org.junit.runner.RunWith;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 @RunWith(RandomTestRunner.class)
61 public final class MainTest {
62
63
64
65
66
67
68
69 @Test(expected = AssertionError.class)
70 public void testControllerNull() throws InputReaderException {
71 Main.getInterfaceControllerType(null);
72 }
73
74
75
76
77
78
79
80 @Test(expected = AssertionError.class)
81 public void testControllerNull1() throws InputReaderException {
82 final String[] args = new String[] { null };
83 Main.getInterfaceControllerType(args);
84 }
85
86
87
88
89 @Test
90 public void testGetControllerDefault() {
91 final String[] args = new String[] {};
92 final int actual = Main.getInterfaceControllerType(args);
93 final int expected = Main.ID_JLINE;
94 Assert.assertEquals("Interface controller type", expected,
95 actual);
96 }
97
98
99
100
101 @Test
102 public void testGetControllerJline() {
103 final String[] args = new String[] { Main.VALUE_JLINE };
104 final int actual = Main.getInterfaceControllerType(args);
105 final int expected = Main.ID_JLINE;
106 Assert.assertEquals("Interface controller type", expected,
107 actual);
108 }
109
110
111
112
113 @Test
114 public void testGetControllerOther() {
115 final String[] args = new String[] { "Other" };
116 final int actual = Main.getInterfaceControllerType(args);
117 final int expected = Main.ID_JLINE;
118 Assert.assertEquals("Interface controller type", expected,
119 actual);
120 }
121
122
123
124
125 @Test
126 public void testGetControllerSystem() {
127 final String[] args = new String[] { Main.VALUE_SYSTEM };
128 final int actual = Main.getInterfaceControllerType(args);
129 final int expected = Main.ID_SYSTEM;
130 Assert.assertEquals("Interface controller type", expected,
131 actual);
132 }
133
134
135
136
137
138
139 @Test
140 public void testMainParamEmpty() throws AbstractZemucanException {
141 }
142
143
144
145
146
147
148 @Test
149 public void testMainParamH() throws AbstractZemucanException {
150 final String[] args = new String[] { "-h" };
151 new Main(args);
152 }
153
154
155
156
157
158
159 @Test
160 public void testMainParamHelp() throws AbstractZemucanException {
161 final String[] args = new String[] { "--help" };
162 new Main(args);
163 }
164
165
166
167
168
169
170 @Test
171 public void testMainParamJline() throws AbstractZemucanException {
172 }
173
174
175
176
177
178
179 @Test(expected = AssertionError.class)
180 public void testMainParamNull1() throws AbstractZemucanException {
181 new Main(null);
182 }
183
184
185
186
187
188
189 @Test(expected = AssertionError.class)
190 public void testMainParamNull2() throws AbstractZemucanException {
191 final String[] args = new String[] { null };
192 new Main(args);
193 }
194
195
196
197
198
199
200 @Test
201 public void testMainParamSlashH() throws AbstractZemucanException {
202 final String[] args = new String[] { "/h" };
203 new Main(args);
204 }
205
206
207
208
209
210
211 @Test
212 public void testMainParamSystem() throws AbstractZemucanException {
213 }
214
215
216
217
218
219
220
221 @Test
222 public void testPrepareJline() throws AbstractZemucanException {
223 final int type = Main.ID_JLINE;
224
225 final AbstractInterfaceController controller = Main.prepare(type);
226 Assert.assertTrue("Interface jline",
227 controller instanceof ImplementationJlineInterfaceController);
228 }
229
230
231
232
233
234
235
236 @Test
237 public void testPrepareNoPrompt() throws InputReaderException {
238 Configurator.getInstance().deleteProperty(Main.PROMPT_PROPERTY);
239 Main.prepare(Main.ID_SYSTEM);
240 }
241
242
243
244
245
246
247
248 @Test(expected = AssertionError.class)
249 public void testPrepareNull() throws InputReaderException {
250 Main.prepare(-1);
251 }
252
253
254
255
256
257
258
259 @Test
260 public void testPrepareSystem() throws AbstractZemucanException {
261 final int type = Main.ID_SYSTEM;
262
263 final AbstractInterfaceController controller = Main.prepare(type);
264 Assert.assertTrue("Interface system",
265 controller instanceof ImplementationSystemInterfaceController);
266 }
267 }