|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.mj.impl.installer; |
|
20 |
|
21 import com.nokia.mj.impl.installer.storagehandler.SuiteInfo; |
|
22 import com.nokia.mj.impl.installer.utils.FileUtils; |
|
23 import com.nokia.mj.impl.installer.utils.InstallerMain; |
|
24 import com.nokia.mj.impl.installer.utils.Log; |
|
25 import com.nokia.mj.impl.installer.utils.Platform; |
|
26 import com.nokia.mj.impl.installer.utils.PlatformUid; |
|
27 import com.nokia.mj.impl.rt.support.ApplicationInfo; |
|
28 import com.nokia.mj.impl.utils.InstallerErrorMessage; |
|
29 import com.nokia.mj.impl.utils.InstallerDetailedErrorMessage; |
|
30 import com.nokia.mj.impl.utils.OtaStatusCode; |
|
31 import com.nokia.mj.impl.utils.Uid; |
|
32 |
|
33 import java.io.IOException; |
|
34 import java.util.Vector; |
|
35 |
|
36 import j2meunit.framework.Test; |
|
37 import j2meunit.framework.TestCase; |
|
38 import j2meunit.framework.TestMethod; |
|
39 import j2meunit.framework.TestSuite; |
|
40 |
|
41 /** |
|
42 * Test cases for InstallerEngine. |
|
43 */ |
|
44 public class InstallerEngineTest extends TestCase implements InstallerMain |
|
45 { |
|
46 private InstallerTestUtils iItu = null; |
|
47 private Vector iDefaultOptions = null; |
|
48 |
|
49 // Begin j2meunit test framework setup |
|
50 |
|
51 public void installerMain(String[] aArgs) |
|
52 { |
|
53 TestSuite suite = new TestSuite(this.getClass().getName()); |
|
54 |
|
55 if (Platform.isLinux()) |
|
56 { |
|
57 // In S60 this would be interactive test, so disable it there. |
|
58 suite.addTest(new InstallerEngineTest("testTrustedJadNonSilentOk", new TestMethod() |
|
59 { |
|
60 public void run(TestCase tc) |
|
61 { |
|
62 ((InstallerEngineTest)tc).testTrustedJadNonSilentOk(); |
|
63 } |
|
64 })); |
|
65 } |
|
66 |
|
67 suite.addTest(new InstallerEngineTest("testMidletMessageOk", new TestMethod() |
|
68 { |
|
69 public void run(TestCase tc) |
|
70 { |
|
71 ((InstallerEngineTest)tc).testMidletMessageOk(); |
|
72 } |
|
73 })); |
|
74 |
|
75 suite.addTest(new InstallerEngineTest("testMidletMessageNok", new TestMethod() |
|
76 { |
|
77 public void run(TestCase tc) |
|
78 { |
|
79 ((InstallerEngineTest)tc).testMidletMessageNok(); |
|
80 } |
|
81 })); |
|
82 |
|
83 suite.addTest(new InstallerEngineTest("testTrustedJadOk", new TestMethod() |
|
84 { |
|
85 public void run(TestCase tc) |
|
86 { |
|
87 ((InstallerEngineTest)tc).testTrustedJadOk(); |
|
88 } |
|
89 })); |
|
90 |
|
91 suite.addTest(new InstallerEngineTest("testTrustedJarOk", new TestMethod() |
|
92 { |
|
93 public void run(TestCase tc) |
|
94 { |
|
95 ((InstallerEngineTest)tc).testTrustedJarOk(); |
|
96 } |
|
97 })); |
|
98 |
|
99 suite.addTest(new InstallerEngineTest("test3AppsOk", new TestMethod() |
|
100 { |
|
101 public void run(TestCase tc) |
|
102 { |
|
103 ((InstallerEngineTest)tc).test3AppsOk(); |
|
104 } |
|
105 })); |
|
106 |
|
107 suite.addTest(new InstallerEngineTest("testDownloadJadOk", new TestMethod() |
|
108 { |
|
109 public void run(TestCase tc) |
|
110 { |
|
111 ((InstallerEngineTest)tc).testDownloadJadOk(); |
|
112 } |
|
113 })); |
|
114 |
|
115 suite.addTest(new InstallerEngineTest("testDownloadJarOk", new TestMethod() |
|
116 { |
|
117 public void run(TestCase tc) |
|
118 { |
|
119 ((InstallerEngineTest)tc).testDownloadJarOk(); |
|
120 } |
|
121 })); |
|
122 |
|
123 suite.addTest(new InstallerEngineTest("testDownloadJadHttpRedirectOk", new TestMethod() |
|
124 { |
|
125 public void run(TestCase tc) |
|
126 { |
|
127 ((InstallerEngineTest)tc).testDownloadJadHttpRedirectOk(); |
|
128 } |
|
129 })); |
|
130 |
|
131 suite.addTest(new InstallerEngineTest("testDownloadJarHttpRedirectOk", new TestMethod() |
|
132 { |
|
133 public void run(TestCase tc) |
|
134 { |
|
135 ((InstallerEngineTest)tc).testDownloadJarHttpRedirectOk(); |
|
136 } |
|
137 })); |
|
138 |
|
139 suite.addTest(new InstallerEngineTest("testDownloadJadHttpRedirectCountExceeded", new TestMethod() |
|
140 { |
|
141 public void run(TestCase tc) |
|
142 { |
|
143 ((InstallerEngineTest)tc).testDownloadJadHttpRedirectCountExceeded(); |
|
144 } |
|
145 })); |
|
146 |
|
147 suite.addTest(new InstallerEngineTest("testDownloadJadHttpAuthNok", new TestMethod() |
|
148 { |
|
149 public void run(TestCase tc) |
|
150 { |
|
151 ((InstallerEngineTest)tc).testDownloadJadHttpAuthNok(); |
|
152 } |
|
153 })); |
|
154 |
|
155 suite.addTest(new InstallerEngineTest("testDownloadJadHttpAuthOk", new TestMethod() |
|
156 { |
|
157 public void run(TestCase tc) |
|
158 { |
|
159 ((InstallerEngineTest)tc).testDownloadJadHttpAuthOk(); |
|
160 } |
|
161 })); |
|
162 |
|
163 suite.addTest(new InstallerEngineTest("testDownloadJadCancel", new TestMethod() |
|
164 { |
|
165 public void run(TestCase tc) |
|
166 { |
|
167 ((InstallerEngineTest)tc).testDownloadJadCancel(); |
|
168 } |
|
169 })); |
|
170 |
|
171 suite.addTest(new InstallerEngineTest("testJadNoName", new TestMethod() |
|
172 { |
|
173 public void run(TestCase tc) |
|
174 { |
|
175 ((InstallerEngineTest)tc).testJadNoName(); |
|
176 } |
|
177 })); |
|
178 |
|
179 suite.addTest(new InstallerEngineTest("testInvalidJar", new TestMethod() |
|
180 { |
|
181 public void run(TestCase tc) |
|
182 { |
|
183 ((InstallerEngineTest)tc).testInvalidJar(); |
|
184 } |
|
185 })); |
|
186 |
|
187 suite.addTest(new InstallerEngineTest("testInvalidPush", new TestMethod() |
|
188 { |
|
189 public void run(TestCase tc) |
|
190 { |
|
191 ((InstallerEngineTest)tc).testInvalidPush(); |
|
192 } |
|
193 })); |
|
194 |
|
195 suite.addTest(new InstallerEngineTest("testNoJad", new TestMethod() |
|
196 { |
|
197 public void run(TestCase tc) |
|
198 { |
|
199 ((InstallerEngineTest)tc).testNoJad(); |
|
200 } |
|
201 })); |
|
202 |
|
203 suite.addTest(new InstallerEngineTest("testNoJar", new TestMethod() |
|
204 { |
|
205 public void run(TestCase tc) |
|
206 { |
|
207 ((InstallerEngineTest)tc).testNoJar(); |
|
208 } |
|
209 })); |
|
210 |
|
211 suite.addTest(new InstallerEngineTest("testNoJavaBinRoot", new TestMethod() |
|
212 { |
|
213 public void run(TestCase tc) |
|
214 { |
|
215 ((InstallerEngineTest)tc).testNoJavaBinRoot(); |
|
216 } |
|
217 })); |
|
218 |
|
219 suite.addTest(new InstallerEngineTest("testBlockUninstall", new TestMethod() |
|
220 { |
|
221 public void run(TestCase tc) |
|
222 { |
|
223 ((InstallerEngineTest)tc).testBlockUninstall(); |
|
224 } |
|
225 })); |
|
226 |
|
227 suite.addTest(new InstallerEngineTest("testOutputCommands", new TestMethod() |
|
228 { |
|
229 public void run(TestCase tc) |
|
230 { |
|
231 ((InstallerEngineTest)tc).testOutputCommands(); |
|
232 } |
|
233 })); |
|
234 |
|
235 suite.addTest(new InstallerEngineTest("testApplicationInfo", new TestMethod() |
|
236 { |
|
237 public void run(TestCase tc) |
|
238 { |
|
239 ((InstallerEngineTest)tc).testApplicationInfo(); |
|
240 } |
|
241 })); |
|
242 |
|
243 suite.addTest(new InstallerEngineTest("testInstallOptions", new TestMethod() |
|
244 { |
|
245 public void run(TestCase tc) |
|
246 { |
|
247 ((InstallerEngineTest)tc).testInstallOptions(); |
|
248 } |
|
249 })); |
|
250 |
|
251 suite.addTest(new InstallerEngineTest("testInstallAuthAndBig", new TestMethod() |
|
252 { |
|
253 public void run(TestCase tc) |
|
254 { |
|
255 ((InstallerEngineTest)tc).testInstallAuthAndBig(); |
|
256 } |
|
257 })); |
|
258 |
|
259 com.nokia.mj.impl.utils.OmjTestRunner.run(suite); |
|
260 } |
|
261 |
|
262 public InstallerEngineTest() |
|
263 { |
|
264 } |
|
265 |
|
266 public InstallerEngineTest(String aTestName, TestMethod aTestMethod) |
|
267 { |
|
268 super(aTestName, aTestMethod); |
|
269 } |
|
270 |
|
271 public void assertFalse(String aMsg, boolean aCondition) |
|
272 { |
|
273 assertTrue(aMsg, !aCondition); |
|
274 } |
|
275 |
|
276 // End j2meunit test framework setup |
|
277 |
|
278 protected void setUp() |
|
279 { |
|
280 iItu = new InstallerTestUtils(); |
|
281 iItu.init(); |
|
282 iDefaultOptions = new Vector(); |
|
283 iDefaultOptions.addElement("-silent"); |
|
284 iDefaultOptions.addElement("-iap=1"); |
|
285 } |
|
286 |
|
287 protected void tearDown() |
|
288 { |
|
289 iItu.destroy(); |
|
290 } |
|
291 |
|
292 public void assertResult(int aResult, int aExpectedResult) |
|
293 { |
|
294 assertTrue("Installer returned " + aResult + |
|
295 ", expected " + aExpectedResult, |
|
296 aResult == aExpectedResult); |
|
297 } |
|
298 |
|
299 public void assertResult(String aMsg, int aResult, int aExpectedResult) |
|
300 { |
|
301 assertTrue(aMsg + ": Installer returned " + aResult + |
|
302 ", expected " + aExpectedResult, |
|
303 aResult == aExpectedResult); |
|
304 } |
|
305 |
|
306 public void assertNoIsDir() |
|
307 { |
|
308 assertTrue("IntegrityService root dir exists", |
|
309 !FileUtils.exists(FileUtils.getIntegrityServiceRoot())); |
|
310 } |
|
311 |
|
312 /** |
|
313 * Makes installation, update and uninstallation for given application. |
|
314 * Does the following steps: |
|
315 * install with cancellation and check that app is not installed, |
|
316 * install and check that app is installed, |
|
317 * update with cancellation and check that app is installed, |
|
318 * update and check that app is installed, |
|
319 * update again and check that app is installed, |
|
320 * uninstall with cancellation and check that app is still installed, |
|
321 * uninstall and check that app is no longer installed. |
|
322 */ |
|
323 public void doInstallUninstall(String aFilename, boolean aIsJad, Vector aInstallOptions) |
|
324 { |
|
325 SuiteInfo suite = null; |
|
326 try |
|
327 { |
|
328 suite = iItu.getNameVendor(aFilename, aIsJad); |
|
329 assertTrue("getNameVendor returns null for " + aFilename, |
|
330 suite != null); |
|
331 } |
|
332 catch (IOException ioe) |
|
333 { |
|
334 ioe.printStackTrace(); |
|
335 assertTrue("getNameVendor throws exception for " + aFilename + |
|
336 ": " + ioe, false); |
|
337 } |
|
338 doInstallUninstall(suite, aFilename, aIsJad, aInstallOptions); |
|
339 } |
|
340 |
|
341 /** |
|
342 * Makes installation, update and uninstallation for given application. |
|
343 * Does the following steps: |
|
344 * install with cancellation and check that app is not installed, |
|
345 * install and check that app is installed, |
|
346 * update with cancellation and check that app is installed, |
|
347 * update and check that app is installed, |
|
348 * uninstall with cancellation and check that app is still installed, |
|
349 * uninstall and check that app is no longer installed. |
|
350 */ |
|
351 public void doInstallUninstall(SuiteInfo aSuite, String aFilename, boolean aIsJad, Vector aInstallOptions) |
|
352 { |
|
353 // Construct install command arguments. |
|
354 Vector installOptions = new Vector(); |
|
355 installOptions.addElement("install"); |
|
356 if (aIsJad) |
|
357 { |
|
358 installOptions.addElement("-jad=" + aFilename); |
|
359 } |
|
360 else |
|
361 { |
|
362 installOptions.addElement("-jar=" + aFilename); |
|
363 } |
|
364 if (aInstallOptions != null) |
|
365 { |
|
366 for (int i = 0; i < aInstallOptions.size(); i++) |
|
367 { |
|
368 installOptions.addElement(aInstallOptions.elementAt(i)); |
|
369 } |
|
370 } |
|
371 String[] args = new String[installOptions.size()]; |
|
372 installOptions.copyInto(args); |
|
373 installOptions.addElement("-forcecancel"); |
|
374 String[] cancelArgs = new String[installOptions.size()]; |
|
375 installOptions.copyInto(cancelArgs); |
|
376 |
|
377 // Check that suite is not installed. |
|
378 assertFalse("exists before installation: " + aFilename, iItu.exists(aSuite)); |
|
379 |
|
380 // Install with cancellation. |
|
381 Log.logOut("InstallerEngineTest.doInstallUninstall: install with cancellation " + aFilename); |
|
382 int result = Installer.mainWithResult(cancelArgs); |
|
383 // Check result code. |
|
384 assertResult(result, Installer.ERR_GENERAL); |
|
385 // Check exception. |
|
386 assertTrue("cancelled installation returns incorrect exception " + |
|
387 Installer.getExecuteException(), |
|
388 iItu.isExceptionReason |
|
389 (Installer.getExecuteException(), |
|
390 InstallerErrorMessage.INST_UNEXPECTED_ERR, |
|
391 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
392 OtaStatusCode.INTERNAL_ERROR)); |
|
393 // Check that suite is not installed. |
|
394 assertFalse("exists after cancelled install: " + aFilename, iItu.exists(aSuite)); |
|
395 // Check that IntegrityService root dir does not exist. |
|
396 assertNoIsDir(); |
|
397 |
|
398 // Install. |
|
399 Log.logOut("InstallerEngineTest.doInstallUninstall: install " + aFilename); |
|
400 result = Installer.mainWithResult(args); |
|
401 // Check result code. |
|
402 assertResult(result, Installer.ERR_NONE); |
|
403 // Check exception. |
|
404 assertTrue("installation returns exception", |
|
405 Installer.getExecuteException() == null); |
|
406 assertTrue("installed app uid not found after installation", Installer.iInstalledApps.length > 0); |
|
407 // Check that suite is installed. |
|
408 assertTrue("does not exist after installation: " + aFilename, iItu.exists(aSuite)); |
|
409 // Check that IntegrityService root dir does not exist. |
|
410 assertNoIsDir(); |
|
411 |
|
412 // List. |
|
413 Log.logOut("InstallerEngineTest.doInstallUninstall: list -v"); |
|
414 result = Installer.mainWithResult(new String[] { "list", "-v" }); |
|
415 assertResult(result, Installer.ERR_NONE); |
|
416 Log.logOut("InstallerEngineTest.doInstallUninstall: list -otastatus"); |
|
417 result = Installer.mainWithResult(new String[] { "list", "-otastatus" }); |
|
418 assertResult(result, Installer.ERR_NONE); |
|
419 |
|
420 // Update with cancellation. |
|
421 Log.logOut("InstallerEngineTest.doInstallUninstall: update with cancellation " + aFilename); |
|
422 result = Installer.mainWithResult(cancelArgs); |
|
423 // Check result code. |
|
424 assertResult(result, Installer.ERR_GENERAL); |
|
425 // Check exception. |
|
426 assertTrue("cancelled update returns incorrect exception " + |
|
427 Installer.getExecuteException(), |
|
428 iItu.isExceptionReason |
|
429 (Installer.getExecuteException(), |
|
430 InstallerErrorMessage.INST_UNEXPECTED_ERR, |
|
431 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
432 OtaStatusCode.INTERNAL_ERROR)); |
|
433 // Check that suite is installed. |
|
434 assertTrue("does not exists after cancelled update: " + aFilename, iItu.exists(aSuite)); |
|
435 // Check that IntegrityService root dir does not exist. |
|
436 assertNoIsDir(); |
|
437 |
|
438 // Update. |
|
439 Log.logOut("InstallerEngineTest.doInstallUninstall: update " + aFilename); |
|
440 result = Installer.mainWithResult(args); |
|
441 // Check result code. |
|
442 assertResult(result, Installer.ERR_NONE); |
|
443 // Check exception. |
|
444 assertTrue("update returns exception", |
|
445 Installer.getExecuteException() == null); |
|
446 assertTrue("installed app uid not found after update", Installer.iInstalledApps.length > 0); |
|
447 // Check that suite is installed. |
|
448 assertTrue("does not exist after update: " + aFilename, iItu.exists(aSuite)); |
|
449 // Check that IntegrityService root dir does not exist. |
|
450 assertNoIsDir(); |
|
451 |
|
452 // Update again. |
|
453 Log.logOut("InstallerEngineTest.doInstallUninstall: 2nd update " + aFilename); |
|
454 result = Installer.mainWithResult(args); |
|
455 // Check result code. |
|
456 assertResult(result, Installer.ERR_NONE); |
|
457 // Check exception. |
|
458 assertTrue("2nd update returns exception", |
|
459 Installer.getExecuteException() == null); |
|
460 assertTrue("installed app uid not found after 2nd update", Installer.iInstalledApps.length > 0); |
|
461 // Check that suite is installed. |
|
462 assertTrue("does not exist after 2nd update: " + aFilename, iItu.exists(aSuite)); |
|
463 // Check that IntegrityService root dir does not exist. |
|
464 assertNoIsDir(); |
|
465 |
|
466 // Construct uninstall command arguments. |
|
467 Vector uninstallOptions = new Vector(); |
|
468 uninstallOptions.addElement("uninstall"); |
|
469 uninstallOptions.addElement("-uid=" + Installer.iInstalledApps[0]); |
|
470 if (aInstallOptions != null) |
|
471 { |
|
472 for (int i = 0; i < aInstallOptions.size(); i++) |
|
473 { |
|
474 uninstallOptions.addElement(aInstallOptions.elementAt(i)); |
|
475 } |
|
476 } |
|
477 args = new String[uninstallOptions.size()]; |
|
478 uninstallOptions.copyInto(args); |
|
479 uninstallOptions.addElement("-forcecancel"); |
|
480 cancelArgs = new String[uninstallOptions.size()]; |
|
481 uninstallOptions.copyInto(cancelArgs); |
|
482 |
|
483 // Uninstall with cancellation. |
|
484 Log.logOut("InstallerEngineTest.doInstallUninstall: uninstall with cancellation " + aFilename); |
|
485 result = Installer.mainWithResult(cancelArgs); |
|
486 // Check result code. |
|
487 assertResult(result, Installer.ERR_GENERAL); |
|
488 // Check exception. |
|
489 assertTrue("cancelled uninstallation returns incorrect exception " + |
|
490 Installer.getExecuteException(), |
|
491 iItu.isExceptionReason |
|
492 (Installer.getExecuteException(), |
|
493 InstallerErrorMessage.UNINST_UNEXPECTED_ERR, |
|
494 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
495 OtaStatusCode.INTERNAL_ERROR)); |
|
496 // Check that suite is still installed. |
|
497 assertTrue("does not exist after cancelled uninstall: " + aFilename, iItu.exists(aSuite)); |
|
498 // Check that IntegrityService root dir does not exist. |
|
499 assertNoIsDir(); |
|
500 |
|
501 // Uninstall. |
|
502 Log.logOut("InstallerEngineTest.doInstallUninstall: uninstall " + aFilename); |
|
503 result = Installer.mainWithResult(args); |
|
504 // Check result code. |
|
505 assertResult(result, Installer.ERR_NONE); |
|
506 // Check exception. |
|
507 assertTrue("installation returns exception", |
|
508 Installer.getExecuteException() == null); |
|
509 // Check that suite is no longer installed. |
|
510 assertTrue("exists after uninstallation: " + aFilename, iItu.doesNotExist(aSuite)); |
|
511 // Check that IntegrityService root dir does not exist. |
|
512 assertNoIsDir(); |
|
513 } |
|
514 |
|
515 public void testTrustedJadNonSilentOk() |
|
516 { |
|
517 Log.logOut("InstallerEngineTest.testTrustedJadNonSilentOk begins"); |
|
518 doInstallUninstall(iItu.getTestDir() + "HelloWorld.jad", true, null); |
|
519 } |
|
520 |
|
521 public void testMidletMessageOk() |
|
522 { |
|
523 Log.logOut("InstallerEngineTest.testMidletMessageOk begins"); |
|
524 doInstallUninstall(new SuiteInfo("HelloWorld", "Nokia"), |
|
525 iItu.getTestDir() + "helloworldmm.jar", |
|
526 false, iDefaultOptions); |
|
527 } |
|
528 |
|
529 public void testMidletMessageNok() |
|
530 { |
|
531 Log.logOut("InstallerEngineTest.testMidletMessageNok begins"); |
|
532 String[] args = new String[] |
|
533 { |
|
534 "install", |
|
535 "-silent", |
|
536 "-jar=" + iItu.getTestDir() + "helloworldmm_invalid.jar", |
|
537 }; |
|
538 int result = Installer.mainWithResult(args); |
|
539 // Check result code. |
|
540 assertResult(result, Installer.ERR_GENERAL); |
|
541 // Check exception |
|
542 assertTrue("failed installation returns incorrect exception " + |
|
543 Installer.getExecuteException(), |
|
544 iItu.isExceptionReason |
|
545 (Installer.getExecuteException(), |
|
546 InstallerErrorMessage.INST_CORRUPT_PKG, |
|
547 InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
|
548 OtaStatusCode.INVALID_JAR)); |
|
549 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
550 } |
|
551 |
|
552 public void testTrustedJadOk() |
|
553 { |
|
554 Log.logOut("InstallerEngineTest.testTrustedJadOk begins"); |
|
555 doInstallUninstall(iItu.getTestDir() + "HelloWorld.jad", true, iDefaultOptions); |
|
556 } |
|
557 |
|
558 public void testTrustedJarOk() |
|
559 { |
|
560 Log.logOut("InstallerEngineTest.testTrustedJarOk begins"); |
|
561 doInstallUninstall(iItu.getTestDir() + "HelloWorld.jar", false, iDefaultOptions); |
|
562 } |
|
563 |
|
564 public void test3AppsOk() |
|
565 { |
|
566 Log.logOut("InstallerEngineTest.test3AppsOk begins"); |
|
567 doInstallUninstall(iItu.getTestDir() + "HelloWorld_3_midlets.jad", true, iDefaultOptions); |
|
568 } |
|
569 |
|
570 public void testDownloadJadOk() |
|
571 { |
|
572 Log.logOut("InstallerEngineTest.testDownloadJadOk begins"); |
|
573 SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP"); |
|
574 doInstallUninstall(suite, "http://195.134.231.83:7070/omjserver/resources/omj/T00000900_JBenchmark2_gcf.jsp", true, iDefaultOptions); |
|
575 } |
|
576 |
|
577 public void testDownloadJarOk() |
|
578 { |
|
579 Log.logOut("InstallerEngineTest.testDownloadJarOk begins"); |
|
580 SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP"); |
|
581 doInstallUninstall(suite, "http://195.134.231.83:7070/omjserver/resources/omj/JBenchmark2.jar", false, iDefaultOptions); |
|
582 } |
|
583 |
|
584 public void testDownloadJadHttpRedirectOk() |
|
585 { |
|
586 Log.logOut("InstallerEngineTest.testDownloadJadHttpRedirectOk begins"); |
|
587 SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP"); |
|
588 doInstallUninstall(suite, "http://195.134.231.83:7070/RedirectServlet/redirect?name=JBenchmark2.jad&count=5", true, iDefaultOptions); |
|
589 } |
|
590 |
|
591 public void testDownloadJarHttpRedirectOk() |
|
592 { |
|
593 Log.logOut("InstallerEngineTest.testDownloadJarHttpRedirectOk begins"); |
|
594 SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP"); |
|
595 doInstallUninstall(suite, "http://195.134.231.83:7070/RedirectServlet/redirect?name=JBenchmark2.jar", false, iDefaultOptions); |
|
596 } |
|
597 |
|
598 public void testDownloadJadHttpAuthOk() |
|
599 { |
|
600 Log.logOut("InstallerEngineTest.testDownloadJadHttpAuthOk begins"); |
|
601 SuiteInfo suite = new SuiteInfo("DS_Snow_http_auth", "DS_Effects"); |
|
602 iDefaultOptions.addElement("-username=guest"); |
|
603 iDefaultOptions.addElement("-password=guest"); |
|
604 doInstallUninstall(suite, "http://195.134.231.83:7070/httpauth/DS_Snow_http_auth.jad", true, iDefaultOptions); |
|
605 } |
|
606 |
|
607 public void testDownloadJadHttpAuthNok() |
|
608 { |
|
609 Log.logOut("InstallerEngineTest.testDownloadJadHttpAuthNok begins"); |
|
610 String[] args = new String[] |
|
611 { |
|
612 "install", |
|
613 "-silent", |
|
614 "-jad=http://195.134.231.83:7070/httpauth/DS_Snow_http_auth.jad", |
|
615 }; |
|
616 int result = Installer.mainWithResult(args); |
|
617 // Check result code. |
|
618 assertResult(result, Installer.ERR_CANCEL); |
|
619 // Check exception |
|
620 assertTrue("failed installation returns incorrect exception " + |
|
621 Installer.getExecuteException(), |
|
622 iItu.isExceptionReason |
|
623 (Installer.getExecuteException(), |
|
624 InstallerErrorMessage.INST_CANCEL, |
|
625 InstallerDetailedErrorMessage.NO_MSG, |
|
626 OtaStatusCode.USER_CANCELLED)); |
|
627 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
628 } |
|
629 |
|
630 public void testDownloadJadHttpRedirectCountExceeded() |
|
631 { |
|
632 Log.logOut("InstallerEngineTest.testDownloadJadHttpRedirectCountExceeded begins"); |
|
633 String[] args = new String[] |
|
634 { |
|
635 "install", |
|
636 "-silent", |
|
637 "-jad=http://195.134.231.83:7070/RedirectServlet/redirect?name=JBenchmark2.jad&count=6", |
|
638 }; |
|
639 int result = Installer.mainWithResult(args); |
|
640 // Check result code. |
|
641 assertResult(result, Installer.ERR_GENERAL); |
|
642 // Check exception |
|
643 assertTrue("failed installation returns incorrect exception " + |
|
644 Installer.getExecuteException(), |
|
645 iItu.isExceptionReason |
|
646 (Installer.getExecuteException(), |
|
647 InstallerErrorMessage.INST_NO_NET, |
|
648 InstallerDetailedErrorMessage.NO_NET, |
|
649 OtaStatusCode.LOSS_OF_SERVICE)); |
|
650 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
651 } |
|
652 |
|
653 public void testDownloadJadCancel() |
|
654 { |
|
655 Log.logOut("InstallerEngineTest.testDownloadJadCancel begins"); |
|
656 Log.log("InstallerEngineTest.testDownloadJadCancel: start"); |
|
657 // Create a thread which sleeps a moment and then cancels installation. |
|
658 new Thread(new Runnable() |
|
659 { |
|
660 public void run() |
|
661 { |
|
662 Log.log("InstallerEngineTest.testDownloadJadCancel: canceler thread starts to wait"); |
|
663 try |
|
664 { |
|
665 Thread.sleep(12000); |
|
666 } |
|
667 catch (InterruptedException ie) |
|
668 { |
|
669 } |
|
670 Log.log("InstallerEngineTest.testDownloadJadCancel: canceler thread calls cancel"); |
|
671 Installer.cancel(); |
|
672 } |
|
673 }).start(); |
|
674 |
|
675 // Start installation which downloads a large file. |
|
676 String[] args = new String[] |
|
677 { |
|
678 "install", |
|
679 "-silent", |
|
680 "-jad=http://195.134.231.83:7070/omjserver/resources/omj/T00000900_JBenchmark2_8mb_gcf.jsp", |
|
681 }; |
|
682 Log.log("InstallerEngineTest.testDownloadJadCancel: installation starts"); |
|
683 int result = Installer.mainWithResult(args); |
|
684 Log.log("InstallerEngineTest.testDownloadJadCancel: installation returned"); |
|
685 // Check result code. |
|
686 assertResult(result, Installer.ERR_CANCEL); |
|
687 // Check exception |
|
688 assertTrue("failed installation returns incorrect exception " + |
|
689 Installer.getExecuteException(), |
|
690 iItu.isExceptionReason |
|
691 (Installer.getExecuteException(), |
|
692 InstallerErrorMessage.INST_CANCEL, |
|
693 InstallerDetailedErrorMessage.NO_MSG, |
|
694 OtaStatusCode.USER_CANCELLED)); |
|
695 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
696 Log.log("InstallerEngineTest.testDownloadJadCancel: end"); |
|
697 } |
|
698 |
|
699 public void testNoJad() |
|
700 { |
|
701 Log.logOut("InstallerEngineTest.testNoJad begins"); |
|
702 String[] args = new String[] |
|
703 { |
|
704 "install", |
|
705 "-silent", |
|
706 "-jad=" + iItu.getTestDir() + "HelloWorld_nonexisting.jad", |
|
707 }; |
|
708 int result = Installer.mainWithResult(args); |
|
709 // Check result code. |
|
710 assertResult(result, Installer.ERR_GENERAL); |
|
711 // Check exception |
|
712 assertTrue("failed installation returns incorrect exception " + |
|
713 Installer.getExecuteException(), |
|
714 iItu.isExceptionReason |
|
715 (Installer.getExecuteException(), |
|
716 InstallerErrorMessage.INST_CORRUPT_PKG, |
|
717 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
718 OtaStatusCode.INVALID_DESCRIPTOR)); |
|
719 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
720 } |
|
721 |
|
722 public void testNoJar() |
|
723 { |
|
724 Log.logOut("InstallerEngineTest.testNoJar begins"); |
|
725 String[] args = new String[] |
|
726 { |
|
727 "install", |
|
728 "-silent", |
|
729 "-jar=" + iItu.getTestDir() + "HelloWorld_nonexisting.jar", |
|
730 }; |
|
731 int result = Installer.mainWithResult(args); |
|
732 // Check result code. |
|
733 assertResult(result, Installer.ERR_GENERAL); |
|
734 // Check exception |
|
735 assertTrue("failed installation returns incorrect exception " + |
|
736 Installer.getExecuteException(), |
|
737 iItu.isExceptionReason |
|
738 (Installer.getExecuteException(), |
|
739 InstallerErrorMessage.INST_CORRUPT_PKG, |
|
740 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
741 OtaStatusCode.INVALID_JAR)); |
|
742 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
743 } |
|
744 |
|
745 public void testJadNoName() |
|
746 { |
|
747 Log.logOut("InstallerEngineTest.testJadNoName begins"); |
|
748 String[] args = new String[] |
|
749 { |
|
750 "install", |
|
751 "-silent", |
|
752 "-jad=" + iItu.getTestDir() + "HelloWorld_NoName.jad", |
|
753 }; |
|
754 int result = Installer.mainWithResult(args); |
|
755 // Check result code. |
|
756 assertResult(result, Installer.ERR_GENERAL); |
|
757 // Check exception |
|
758 assertTrue("failed installation returns incorrect exception " + |
|
759 Installer.getExecuteException(), |
|
760 iItu.isExceptionReason |
|
761 (Installer.getExecuteException(), |
|
762 InstallerErrorMessage.INST_CORRUPT_PKG, |
|
763 InstallerDetailedErrorMessage.ATTR_MISSING, |
|
764 OtaStatusCode.INVALID_DESCRIPTOR)); |
|
765 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
766 } |
|
767 |
|
768 public void testInvalidJar() |
|
769 { |
|
770 Log.logOut("InstallerEngineTest.testInvalidJar begins"); |
|
771 String[] args = new String[] |
|
772 { |
|
773 "install", |
|
774 "-silent", |
|
775 "-jar=" + iItu.getTestDir() + "HelloWorld_NoName.jad", |
|
776 }; |
|
777 int result = Installer.mainWithResult(args); |
|
778 // Check result code. |
|
779 assertResult(result, Installer.ERR_GENERAL); |
|
780 // Check exception |
|
781 assertTrue("failed installation returns incorrect exception " + |
|
782 Installer.getExecuteException(), |
|
783 iItu.isExceptionReason |
|
784 (Installer.getExecuteException(), |
|
785 InstallerErrorMessage.INST_CORRUPT_PKG, |
|
786 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
787 OtaStatusCode.INVALID_JAR)); |
|
788 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
789 } |
|
790 |
|
791 public void testInvalidPush() |
|
792 { |
|
793 Log.logOut("InstallerEngineTest.testInvalidPush begins"); |
|
794 String[] args = new String[] |
|
795 { |
|
796 "install", |
|
797 "-silent", |
|
798 "-jad=" + iItu.getTestDir() + "HelloWorld_invalid_push.jad", |
|
799 }; |
|
800 int result = Installer.mainWithResult(args); |
|
801 // Check result code. |
|
802 assertResult(result, Installer.ERR_GENERAL); |
|
803 // Check exception |
|
804 assertTrue("failed installation returns incorrect exception " + |
|
805 Installer.getExecuteException(), |
|
806 iItu.isExceptionReason |
|
807 (Installer.getExecuteException(), |
|
808 InstallerErrorMessage.INST_PUSH_REG_ERR, |
|
809 InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
|
810 OtaStatusCode.PUSH_REGISTRATION_FAILURE)); |
|
811 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
812 } |
|
813 |
|
814 public void testNoJavaBinRoot() |
|
815 { |
|
816 Log.logOut("InstallerEngineTest.testNoJavaBinRoot begins"); |
|
817 String[] args = new String[] |
|
818 { |
|
819 "install", |
|
820 "-silent", |
|
821 "-jad=" + iItu.getTestDir() + "HelloWorld_nonexisting.jad", |
|
822 }; |
|
823 String javaBinRootName = "JAVA_BIN_ROOT"; |
|
824 String oldJavaBinRoot = System.getProperty(javaBinRootName); |
|
825 System.setProperty(javaBinRootName, ""); |
|
826 int result = Installer.mainWithResult(args); |
|
827 System.setProperty(javaBinRootName, oldJavaBinRoot); |
|
828 // Check result code. |
|
829 assertResult(result, Installer.ERR_NOT_FOUND); |
|
830 // Check exception |
|
831 assertTrue("installation returned exception " + |
|
832 Installer.getExecuteException(), |
|
833 Installer.getExecuteException() == null); |
|
834 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
835 } |
|
836 |
|
837 public void testBlockUninstall() |
|
838 { |
|
839 Log.logOut("InstallerEngineTest.testBlockUninstall begins"); |
|
840 // Get suite info for block uninstall test application. |
|
841 String filename = iItu.getTestDir() + "HelloWorld_block_uninstall.jad"; |
|
842 SuiteInfo suite = null; |
|
843 try |
|
844 { |
|
845 suite = iItu.getNameVendor(filename, true); |
|
846 assertTrue("getNameVendor returns null for " + filename, |
|
847 suite != null); |
|
848 } |
|
849 catch (IOException ioe) |
|
850 { |
|
851 ioe.printStackTrace(); |
|
852 assertTrue("getNameVendor throws exception for " + filename + |
|
853 ": " + ioe, false); |
|
854 } |
|
855 |
|
856 Log.logOut("InstallerEngineTest.testBlockUninstall: Install application whose uninstallation is blocked."); |
|
857 String[] args = new String[] |
|
858 { |
|
859 "install", "-silent", |
|
860 "-jad=" + filename, |
|
861 }; |
|
862 int result = Installer.mainWithResult(args); |
|
863 // Check result code. |
|
864 assertResult("Installing block uninstall app failed", |
|
865 result, Installer.ERR_NONE); |
|
866 // Check exception. |
|
867 assertTrue("installation returns exception", |
|
868 Installer.getExecuteException() == null); |
|
869 assertTrue("installed app uid not found after installation", Installer.iInstalledApps.length > 0); |
|
870 // Check that suite is installed. |
|
871 assertTrue("does not exist after installation", iItu.exists(suite)); |
|
872 // Check that IntegrityService root dir does not exist. |
|
873 assertNoIsDir(); |
|
874 |
|
875 // Save installed application uid. |
|
876 Uid appUid = Installer.iInstalledApps[0]; |
|
877 |
|
878 // List application info. |
|
879 Log.logOut("InstallerEngineTest.testBlockUninstall: list -v"); |
|
880 result = Installer.mainWithResult(new String[] { "list", "-v" }); |
|
881 assertResult(result, Installer.ERR_NONE); |
|
882 |
|
883 Log.logOut("InstallerEngineTest.testBlockUninstall: Try to uninstall application whose uninstallation is blocked."); |
|
884 String[] uninstallArgs = new String[] |
|
885 { |
|
886 "uninstall", "-silent", "-uid=" + appUid, |
|
887 }; |
|
888 result = Installer.mainWithResult(uninstallArgs); |
|
889 // Check result code. |
|
890 assertResult("Uninstalling app whose uninstallation was blocked did not fail", |
|
891 result, Installer.ERR_GENERAL); |
|
892 // Check exception |
|
893 assertTrue("blocked uninstallation returns incorrect exception " + |
|
894 Installer.getExecuteException(), |
|
895 iItu.isExceptionReason |
|
896 (Installer.getExecuteException(), |
|
897 InstallerErrorMessage.UNINST_NOT_ALLOWED, |
|
898 InstallerDetailedErrorMessage.UNINST_BLOCKED, |
|
899 OtaStatusCode.USER_CANCELLED)); |
|
900 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
901 // Check that suite is installed. |
|
902 assertTrue("does not exist after blocked uninstallation", iItu.exists(suite)); |
|
903 // Check that IntegrityService root dir does not exist. |
|
904 assertNoIsDir(); |
|
905 |
|
906 Log.logOut("InstallerEngineTest.testBlockUninstall: Upgrade application with a version whose uninstallation is not blocked."); |
|
907 args = new String[] |
|
908 { |
|
909 "install", "-silent", |
|
910 "-jad=" + iItu.getTestDir() + "HelloWorld_unblock_uninstall.jad", |
|
911 }; |
|
912 result = Installer.mainWithResult(args); |
|
913 // Check result code. |
|
914 assertResult("Upgrading app whose uninstallation was blocked failed", |
|
915 result, Installer.ERR_NONE); |
|
916 // Check exception. |
|
917 assertTrue("installation returns exception", |
|
918 Installer.getExecuteException() == null); |
|
919 assertTrue("installed app uid not found after installation", Installer.iInstalledApps.length > 0); |
|
920 // Check that suite is installed. |
|
921 assertTrue("does not exist after installation", iItu.exists(suite)); |
|
922 // Check that IntegrityService root dir does not exist. |
|
923 assertNoIsDir(); |
|
924 // Check that uid is the same after upgrade. |
|
925 assertTrue("appUid differs after upgrade, old=" + appUid + |
|
926 ", new=" + Installer.iInstalledApps[0], |
|
927 appUid.equals(Installer.iInstalledApps[0])); |
|
928 |
|
929 // List application info. |
|
930 Log.logOut("InstallerEngineTest.testBlockUninstall: list -v"); |
|
931 result = Installer.mainWithResult(new String[] { "list", "-v" }); |
|
932 assertResult(result, Installer.ERR_NONE); |
|
933 |
|
934 Log.logOut("InstallerEngineTest.testBlockUninstall: Uninstall application whose uninstallation is no longer blocked."); |
|
935 result = Installer.mainWithResult(uninstallArgs); |
|
936 // Check result code. |
|
937 assertResult("Uninstalling app whose uninstallation is no longer blocked failed", |
|
938 result, Installer.ERR_NONE); |
|
939 // Check exception |
|
940 assertTrue("blocked uninstallation returns exception", |
|
941 Installer.getExecuteException() == null); |
|
942 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
943 // Check that suite is uninstalled. |
|
944 assertTrue("exists after unblocked uninstallation", !iItu.exists(suite)); |
|
945 // Check that IntegrityService root dir does not exist. |
|
946 assertNoIsDir(); |
|
947 |
|
948 // List application info. |
|
949 Log.logOut("InstallerEngineTest.testBlockUninstall: list -v"); |
|
950 result = Installer.mainWithResult(new String[] { "list", "-v" }); |
|
951 assertResult(result, Installer.ERR_NONE); |
|
952 |
|
953 } |
|
954 |
|
955 public void testOutputCommands() |
|
956 { |
|
957 Log.logOut("InstallerEngineTest.testOutputCommands begins"); |
|
958 // Some parameter combinations which cause an error to be returned. |
|
959 int result = Installer.mainWithResult(new String[] { }); |
|
960 assertResult(result, Installer.ERR_NOT_FOUND); |
|
961 result = Installer.mainWithResult(new String[] { "list", "-nosystemexit" }); |
|
962 assertResult(result, Installer.RET_NO_SYSTEM_EXIT); |
|
963 result = Installer.mainWithResult(new String[] { "list", "-storage=APPLICATION_PACKAGE_TABLE" }); |
|
964 assertResult(result, Installer.ERR_GENERAL); |
|
965 |
|
966 // Parameter combinations that can be executed successfully. |
|
967 callInstallerOk(new String[] { "unknowncommand" }); |
|
968 callInstallerOk(new String[] { "version" }); |
|
969 callInstallerOk(new String[] { "help" }); |
|
970 callInstallerOk(new String[] { "help", "unknowncommand" }); |
|
971 callInstallerOk(new String[] { "help", "help" }); |
|
972 callInstallerOk(new String[] { "help", "version" }); |
|
973 callInstallerOk(new String[] { "help", "install" }); |
|
974 callInstallerOk(new String[] { "help", "uninstall" }); |
|
975 callInstallerOk(new String[] { "help", "uninstallall" }); |
|
976 callInstallerOk(new String[] { "help", "list" }); |
|
977 callInstallerOk(new String[] { "help", "launch" }); |
|
978 callInstallerOk(new String[] { "help", "poll" }); |
|
979 callInstallerOk(new String[] { "help", "rollback" }); |
|
980 callInstallerOk(new String[] { "help", "test" }); |
|
981 callInstallerOk(new String[] { "list" }); |
|
982 callInstallerOk(new String[] { "list", "-v" }); |
|
983 callInstallerOk(new String[] { "list", "-storage" }); |
|
984 callInstallerOk(new String[] { "list", "-otastatus" }); |
|
985 callInstallerOk(new String[] { "list", "-systemproperties" }); |
|
986 callInstallerOk(new String[] { "launch", "-nouid" }); |
|
987 callInstallerOk(new String[] { "launch", "-uid=invaliduid" }); |
|
988 callInstallerOk(new String[] { "uninstallall" }); |
|
989 callInstallerOk(new String[] { "unregister" }); |
|
990 callInstallerOk(new String[] { "test", "-nomainclass" }); |
|
991 } |
|
992 |
|
993 public void testApplicationInfo() |
|
994 { |
|
995 Log.logOut("InstallerEngineTest.testApplicationInfo begins"); |
|
996 ApplicationInfo applicationInfo = ApplicationInfo.getInstance(); |
|
997 assertTrue("ApplicationInfo.getName returns incorrect value " + |
|
998 applicationInfo.getName(), |
|
999 "JavaInstaller".equals(applicationInfo.getName())); |
|
1000 assertTrue("ApplicationInfo.getSuiteName returns incorrect value " + |
|
1001 applicationInfo.getSuiteName(), |
|
1002 "JavaInstaller".equals(applicationInfo.getSuiteName())); |
|
1003 assertTrue("ApplicationInfo.getVendor returns incorrect value " + |
|
1004 applicationInfo.getVendor(), |
|
1005 "Nokia".equals(applicationInfo.getVendor())); |
|
1006 assertTrue("ApplicationInfo.getRuntimeType returns incorrect value " + |
|
1007 applicationInfo.getRuntimeType(), |
|
1008 "INSTALLER".equals(applicationInfo.getRuntimeType())); |
|
1009 assertTrue("ApplicationInfo.getProtectionDomain returns incorrect value " + |
|
1010 applicationInfo.getProtectionDomain(), |
|
1011 ApplicationInfo.MANUFACTURER_DOMAIN.equals |
|
1012 (applicationInfo.getProtectionDomain())); |
|
1013 assertTrue("ApplicationInfo.getUid returns incorrect value " + |
|
1014 applicationInfo.getUid(), |
|
1015 PlatformUid.createUid("0x2001843A").equals |
|
1016 (applicationInfo.getUid())); |
|
1017 assertTrue("ApplicationInfo.getSuiteUid returns incorrect value " + |
|
1018 applicationInfo.getSuiteUid(), |
|
1019 applicationInfo.getUid().equals |
|
1020 (applicationInfo.getSuiteUid())); |
|
1021 assertTrue("ApplicationInfo.getAttribute returns incorrect value " + |
|
1022 applicationInfo.getAttribute(null), |
|
1023 applicationInfo.getAttribute(null) == null); |
|
1024 |
|
1025 try |
|
1026 { |
|
1027 String mainClass = applicationInfo.getMainClass(); |
|
1028 assertTrue("ApplicationInfo.getMainClass did not throw exception", false); |
|
1029 } |
|
1030 catch (RuntimeException rte) |
|
1031 { |
|
1032 // expected exception |
|
1033 } |
|
1034 catch (Exception ex) |
|
1035 { |
|
1036 assertTrue("ApplicationInfo.getMainClass threw unexpected exception: " + ex, false); |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 public void testInstallOptions() |
|
1041 { |
|
1042 Log.logOut("InstallerEngineTest.testInstallOptions begins"); |
|
1043 // Install with all possible options. |
|
1044 String[] args = new String[] |
|
1045 { |
|
1046 "install", |
|
1047 "-silent", |
|
1048 "-forcecancel", |
|
1049 "-jad=" + iItu.getTestDir() + "HelloWorld.jad", |
|
1050 "-sourceurl=http://nohost/HelloWorld.jad", |
|
1051 "-charset=UTF-8", |
|
1052 "-iap=1", |
|
1053 "-drive=C", |
|
1054 "-upgrade=yes", |
|
1055 "-upgrade_data=no", |
|
1056 "-overwrite=yes", |
|
1057 "-untrusted=yes", |
|
1058 "-ocsp=yes", |
|
1059 "-ignore_ocsp_warnings=no", |
|
1060 "-download=no", |
|
1061 "-username=username", |
|
1062 "-password=password", |
|
1063 "-proxyhost=proxyhost", |
|
1064 "-proxyport=proxyport", |
|
1065 }; |
|
1066 int result = Installer.mainWithResult(args); |
|
1067 // Check result code. |
|
1068 assertResult(result, Installer.ERR_GENERAL); |
|
1069 // Check exception |
|
1070 assertTrue("failed installation returns incorrect exception " + |
|
1071 Installer.getExecuteException(), |
|
1072 iItu.isExceptionReason |
|
1073 (Installer.getExecuteException(), |
|
1074 InstallerErrorMessage.INST_UNEXPECTED_ERR, |
|
1075 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
1076 OtaStatusCode.INTERNAL_ERROR)); |
|
1077 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
1078 |
|
1079 // Install with both jad and jar options should fail. |
|
1080 args = new String[] |
|
1081 { |
|
1082 "install", |
|
1083 "-silent", |
|
1084 "-jad=" + iItu.getTestDir() + "HelloWorld.jad", |
|
1085 "-jar=" + iItu.getTestDir() + "HelloWorld.jar", |
|
1086 }; |
|
1087 result = Installer.mainWithResult(args); |
|
1088 // Check result code. |
|
1089 assertResult(result, Installer.ERR_GENERAL); |
|
1090 // Check exception |
|
1091 assertTrue("failed installation returns incorrect exception " + |
|
1092 Installer.getExecuteException(), |
|
1093 iItu.isExceptionReason |
|
1094 (Installer.getExecuteException(), |
|
1095 InstallerErrorMessage.INST_UNEXPECTED_ERR, |
|
1096 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
|
1097 OtaStatusCode.INTERNAL_ERROR)); |
|
1098 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
1099 } |
|
1100 |
|
1101 /** |
|
1102 * Tests subsequent application installations. First installs an application |
|
1103 * which requires authentication and then downloads a big application. |
|
1104 */ |
|
1105 public void testInstallAuthAndBig() |
|
1106 { |
|
1107 Log.logOut("InstallerEngineTest.testInstallAuthAndBig begins"); |
|
1108 // Do first installation with doInstallUninstall helper |
|
1109 SuiteInfo suite = new SuiteInfo("DS_Snow_http_auth", "DS_Effects"); |
|
1110 iDefaultOptions.addElement("-username=guest"); |
|
1111 iDefaultOptions.addElement("-password=guest"); |
|
1112 doInstallUninstall(suite, "http://195.134.231.83:7070/httpauth/DS_Snow_http_auth.jad", true, iDefaultOptions); |
|
1113 |
|
1114 // Then start installation which downloads a large file. |
|
1115 Log.log("InstallerEngineTest.testInstallAuthAndBig begin to install big app"); |
|
1116 String[] args = new String[] |
|
1117 { |
|
1118 "install", |
|
1119 "-silent", |
|
1120 "-jad=http://195.134.231.83:7070/omjserver/resources/omj/T00000900_JBenchmark2_8mb_gcf.jsp", |
|
1121 }; |
|
1122 int result = Installer.mainWithResult(args); |
|
1123 // Check result code. |
|
1124 assertResult(result, Installer.ERR_NONE); |
|
1125 // Check exception |
|
1126 assertTrue("installation returned exception " + |
|
1127 Installer.getExecuteException(), |
|
1128 Installer.getExecuteException() == null); |
|
1129 assertTrue("installed app uid should exist", Installer.iInstalledApps.length == 1); |
|
1130 } |
|
1131 |
|
1132 private int callInstallerOk(String[] aArgs) |
|
1133 { |
|
1134 int result = Installer.mainWithResult(aArgs); |
|
1135 // Check result code. |
|
1136 assertResult(result, Installer.ERR_NONE); |
|
1137 // Check exception |
|
1138 assertTrue("installation returned exception " + |
|
1139 Installer.getExecuteException(), |
|
1140 Installer.getExecuteException() == null); |
|
1141 assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0); |
|
1142 return result; |
|
1143 } |
|
1144 } |