Sync with 5.4.0
[deliverable/titan.core.git] / titan_executor_api / TITAN_Executor_API_test / src / org / eclipse / titan / executorapi / test / JniExecutorAsyncErrorIllegalArgTest.java
CommitLineData
970ed795 1/******************************************************************************
3abe9331 2 * Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8package org.eclipse.titan.executorapi.test;
9
10import static org.junit.Assert.fail;
11
12import org.eclipse.titan.executorapi.JniExecutor;
13import org.eclipse.titan.executorapi.exception.JniExecutorIllegalArgumentException;
14import org.eclipse.titan.executorapi.exception.JniExecutorWrongStateException;
15import org.junit.Test;
16
17/**
18 * Testing all the JniExecutor methods in all the stable states with illegal arguments.
19 * If method is callable in the given state and 1 or more arguments are illegal (null, empty string, filename for a non-existent file, ...),
20 * JniExecutorIllegalArgException is expected.
21 */
22public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTest {
23
24 private void testIllegalArgAddHostController( final JniExecutor je ) {
25 try {
26 je.addHostController( null );
27 fail("JniExecutorIllegalArgumentException expected");
28 } catch (JniExecutorIllegalArgumentException e) {
29 //expected
30 } catch (JniExecutorWrongStateException e) {
31 fail();
32 }
33 }
34
35 private void testIllegalArgSetConfigFileName( final JniExecutor je ) {
36 try {
37 je.setConfigFileName( null );
38 fail("JniExecutorIllegalArgumentException expected");
39 } catch (JniExecutorIllegalArgumentException e) {
40 //expected
41 } catch (JniExecutorWrongStateException e) {
42 fail();
43 }
44
45 try {
46 je.setConfigFileName( "" );
47 fail("JniExecutorIllegalArgumentException expected");
48 } catch (JniExecutorIllegalArgumentException e) {
49 //expected
50 } catch (JniExecutorWrongStateException e) {
51 fail();
52 }
53 }
54
55 private void testIllegalArgSetObserver( final JniExecutor je, final TestData td ) {
56 try {
57 je.setObserver(td.mObserver);
58 je.setObserver(null);
59 // any observer including null is a valid argument
60 } catch (JniExecutorWrongStateException e) {
61 fail();
62 }
63 }
64
65 private void testIllegalArgExecuteControl( final JniExecutor je ) {
66 try {
67 je.executeControl(null);
68 fail("JniExecutorIllegalArgumentException expected");
69 } catch (JniExecutorIllegalArgumentException e) {
70 //expected
71 } catch (JniExecutorWrongStateException e) {
72 fail();
73 }
74
75 try {
76 je.executeControl("");
77 fail("JniExecutorIllegalArgumentException expected");
78 } catch (JniExecutorIllegalArgumentException e) {
79 //expected
80 } catch (JniExecutorWrongStateException e) {
81 fail();
82 }
83 }
84
85 private void testIllegalArgExecuteTestcase( final JniExecutor je, final TestData td ) {
86 try {
87 je.executeTestcase( null, td.mTestcases.get(0));
88 fail("JniExecutorIllegalArgumentException expected");
89 } catch (JniExecutorIllegalArgumentException e) {
90 //expected
91 } catch (JniExecutorWrongStateException e) {
92 fail();
93 }
94 try {
95 je.executeTestcase( "", td.mTestcases.get(0));
96 fail("JniExecutorIllegalArgumentException expected");
97 } catch (JniExecutorIllegalArgumentException e) {
98 //expected
99 } catch (JniExecutorWrongStateException e) {
100 fail();
101 }
102 try {
103 je.executeTestcase( td.mModule, null);
104 fail("JniExecutorIllegalArgumentException expected");
105 } catch (JniExecutorIllegalArgumentException e) {
106 //expected
107 } catch (JniExecutorWrongStateException e) {
108 fail();
109 }
110 try {
111 je.executeTestcase( td.mModule, "");
112 fail("JniExecutorIllegalArgumentException expected");
113 } catch (JniExecutorIllegalArgumentException e) {
114 //expected
115 } catch (JniExecutorWrongStateException e) {
116 fail();
117 }
118 }
119
120 private void testIllegalArgExecuteCfg( final JniExecutor je ) {
121 try {
122 je.executeCfg( -1 );
123 fail("JniExecutorIllegalArgumentException expected");
124 } catch (JniExecutorIllegalArgumentException e) {
125 //expected
126 } catch (JniExecutorWrongStateException e) {
127 fail();
128 }
129
130 try {
131 final int executeCfgLen = je.getExecuteCfgLen();
132 je.executeCfg( executeCfgLen );
133 fail("JniExecutorIllegalArgumentException expected");
134 } catch (JniExecutorIllegalArgumentException e) {
135 //expected
136 } catch (JniExecutorWrongStateException e) {
137 fail();
138 }
139 }
140
141 /**
142 * disconnected (before init())
143 */
144 @Test
145 public void testExecutorIllegalArgDisconnected() {
146 //nothing to test in disconnected state
147 }
148
149 /**
150 * connected MC_INACTIVE state (after init())
151 */
152 @Test
153 public void testExecutorIllegalArgInactive() {
154 final TestData td = createTestData1();
155 final JniExecutor je = JniExecutor.getInstance();
156
157 gotoInactive(je, td);
158
159 // we are now in connected MC_INACTIVE, test all the functions, which has argument
160 testIllegalArgAddHostController(je);
161 testIllegalArgSetConfigFileName(je);
162 testIllegalArgSetObserver(je, td);
163
164 // --------------
165 je.shutdownSession();
166 je.waitForCompletion();
167 }
168
169 /**
170 * MC_LISTENING state (after startSession())
171 */
172 @Test
173 public void testExecutorIllegalArgListening() {
174 final TestData td = createTestData1();
175 final JniExecutor je = JniExecutor.getInstance();
176
177 gotoListening(je, td);
178
179 // we are now in MC_LISTENING, test all the functions, which has argument
180 testIllegalArgAddHostController(je);
181 testIllegalArgSetObserver(je, td);
182
183 // --------------
184 je.shutdownSession();
185 je.waitForCompletion();
186 }
187
188 /**
189 * MC_HC_CONNECTED after startHostControllers()
190 */
191 @Test
192 public void testExecutorIllegalArgHcConnected() {
193 final TestData td = createTestData1();
194 final JniExecutor je = JniExecutor.getInstance();
195
196 gotoHcConnected(je, td);
197
198 // we are now in MC_HC_CONNECTED, test all the functions, which has argument
199 testIllegalArgSetObserver(je, td);
200
201 // --------------
202 je.shutdownSession();
203 je.waitForCompletion();
204 }
205
206 /**
207 * MC_LISTENING_CONFIGURED state (after configure())
208 */
209 @Test
210 public void testExecutorIllegalArgListeningConfigured() {
211 final TestData td = createTestData1();
212 final JniExecutor je = JniExecutor.getInstance();
213
214 gotoListeningConfigured(je, td);
215
216 // we are now in MC_LISTENING_CONFIGURED, test all the functions, which has argument
217 testIllegalArgAddHostController(je);
218 testIllegalArgSetObserver(je, td);
219
220 // --------------
221 je.shutdownSession();
222 je.waitForCompletion();
223 }
224
225 /**
226 * MC_ACTIVE after configure()
227 */
228 @Test
229 public void testExecutorIllegalArgActive() {
230 final TestData td = createTestData1();
231 final JniExecutor je = JniExecutor.getInstance();
232
233 gotoActive(je, td);
234
235 // we are now in MC_ACTIVE, test all the functions, which has argument
236 testIllegalArgSetObserver(je, td);
237
238 // --------------
239 je.shutdownSession();
240 je.waitForCompletion();
241 }
242
243 /**
244 * MC_READY after createMTC()
245 */
246 @Test
247 public void testExecutorIllegalArgReady() {
248 final TestData td = createTestData1();
249 final JniExecutor je = JniExecutor.getInstance();
250
251 gotoReady(je, td);
252
253 // we are now in MC_READY, test all the functions, which has argument
254 testIllegalArgSetObserver(je, td);
255 testIllegalArgExecuteControl(je);
256 testIllegalArgExecuteTestcase(je, td);
257 testIllegalArgExecuteCfg(je);
258
259 // --------------
260 je.shutdownSession();
261 je.waitForCompletion();
262 }
263}
This page took 0.04425 seconds and 5 git commands to generate.