javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/InstallerEngineTest.java
branchRCL_3
changeset 60 6c158198356e
parent 19 04becd199f91
child 83 26b2b12093af
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    50 
    50 
    51     public void installerMain(String[] aArgs)
    51     public void installerMain(String[] aArgs)
    52     {
    52     {
    53         TestSuite suite = new TestSuite(this.getClass().getName());
    53         TestSuite suite = new TestSuite(this.getClass().getName());
    54 
    54 
       
    55         String runIndex = System.getProperty("com.nokia.mj.impl.installer.test.param1");
       
    56 
    55         if (Platform.isLinux())
    57         if (Platform.isLinux())
    56         {
    58         {
    57             // In S60 this would be interactive test, so disable it there.
    59             // In S60 this would be interactive test, so disable it there.
    58             suite.addTest(new InstallerEngineTest("testTrustedJadNonSilentOk", new TestMethod()
    60             suite.addTest(new InstallerEngineTest("testTrustedJadNonSilentOk", new TestMethod()
    59             {
    61             {
    62                     ((InstallerEngineTest)tc).testTrustedJadNonSilentOk();
    64                     ((InstallerEngineTest)tc).testTrustedJadNonSilentOk();
    63                 }
    65                 }
    64             }));
    66             }));
    65         }
    67         }
    66 
    68 
       
    69         if (runIndex == null || runIndex.equalsIgnoreCase("run1"))
       
    70         {
       
    71         // Run 1
    67         suite.addTest(new InstallerEngineTest("testMidletMessageOk", new TestMethod()
    72         suite.addTest(new InstallerEngineTest("testMidletMessageOk", new TestMethod()
    68         {
    73         {
    69             public void run(TestCase tc)
    74             public void run(TestCase tc)
    70             {
    75             {
    71                 ((InstallerEngineTest)tc).testMidletMessageOk();
    76                 ((InstallerEngineTest)tc).testMidletMessageOk();
   101             public void run(TestCase tc)
   106             public void run(TestCase tc)
   102             {
   107             {
   103                 ((InstallerEngineTest)tc).test3AppsOk();
   108                 ((InstallerEngineTest)tc).test3AppsOk();
   104             }
   109             }
   105         }));
   110         }));
   106 
   111         }
       
   112 
       
   113         if (runIndex == null || runIndex.equalsIgnoreCase("run2"))
       
   114         {
       
   115         // Run 2
   107         suite.addTest(new InstallerEngineTest("testDownloadJadOk", new TestMethod()
   116         suite.addTest(new InstallerEngineTest("testDownloadJadOk", new TestMethod()
   108         {
   117         {
   109             public void run(TestCase tc)
   118             public void run(TestCase tc)
   110             {
   119             {
   111                 ((InstallerEngineTest)tc).testDownloadJadOk();
   120                 ((InstallerEngineTest)tc).testDownloadJadOk();
   213             public void run(TestCase tc)
   222             public void run(TestCase tc)
   214             {
   223             {
   215                 ((InstallerEngineTest)tc).testNoJavaBinRoot();
   224                 ((InstallerEngineTest)tc).testNoJavaBinRoot();
   216             }
   225             }
   217         }));
   226         }));
   218 
   227         }
       
   228 
       
   229         if (runIndex == null || runIndex.equalsIgnoreCase("run3"))
       
   230         {
       
   231         // Run 3
   219         suite.addTest(new InstallerEngineTest("testBlockUninstall", new TestMethod()
   232         suite.addTest(new InstallerEngineTest("testBlockUninstall", new TestMethod()
   220         {
   233         {
   221             public void run(TestCase tc)
   234             public void run(TestCase tc)
   222             {
   235             {
   223                 ((InstallerEngineTest)tc).testBlockUninstall();
   236                 ((InstallerEngineTest)tc).testBlockUninstall();
   237             public void run(TestCase tc)
   250             public void run(TestCase tc)
   238             {
   251             {
   239                 ((InstallerEngineTest)tc).testApplicationInfo();
   252                 ((InstallerEngineTest)tc).testApplicationInfo();
   240             }
   253             }
   241         }));
   254         }));
   242 
   255         }
       
   256 
       
   257         if (runIndex == null || runIndex.equalsIgnoreCase("run4"))
       
   258         {
       
   259         // Run 4
   243         suite.addTest(new InstallerEngineTest("testInstallOptions", new TestMethod()
   260         suite.addTest(new InstallerEngineTest("testInstallOptions", new TestMethod()
   244         {
   261         {
   245             public void run(TestCase tc)
   262             public void run(TestCase tc)
   246             {
   263             {
   247                 ((InstallerEngineTest)tc).testInstallOptions();
   264                 ((InstallerEngineTest)tc).testInstallOptions();
   253             public void run(TestCase tc)
   270             public void run(TestCase tc)
   254             {
   271             {
   255                 ((InstallerEngineTest)tc).testInstallAuthAndBig();
   272                 ((InstallerEngineTest)tc).testInstallAuthAndBig();
   256             }
   273             }
   257         }));
   274         }));
       
   275         }
   258 
   276 
   259         com.nokia.mj.impl.utils.OmjTestRunner.run(suite);
   277         com.nokia.mj.impl.utils.OmjTestRunner.run(suite);
   260     }
   278     }
   261 
   279 
   262     public InstallerEngineTest()
   280     public InstallerEngineTest()
   305 
   323 
   306     public void assertNoIsDir()
   324     public void assertNoIsDir()
   307     {
   325     {
   308         assertTrue("IntegrityService root dir exists",
   326         assertTrue("IntegrityService root dir exists",
   309                    !FileUtils.exists(FileUtils.getIntegrityServiceRoot()));
   327                    !FileUtils.exists(FileUtils.getIntegrityServiceRoot()));
       
   328     }
       
   329 
       
   330     /**
       
   331      */
       
   332     public String getTestServer()
       
   333     {
       
   334         String server = System.getProperty("com.nokia.mj.impl.installer.test.server");
       
   335         assertNotNull("-server=<address>:<port> argument required.", server);
       
   336         return server;
   310     }
   337     }
   311 
   338 
   312     /**
   339     /**
   313      * Makes installation, update and uninstallation for given application.
   340      * Makes installation, update and uninstallation for given application.
   314      * Does the following steps:
   341      * Does the following steps:
   408         assertTrue("does not exist after installation: " + aFilename, iItu.exists(aSuite));
   435         assertTrue("does not exist after installation: " + aFilename, iItu.exists(aSuite));
   409         // Check that IntegrityService root dir does not exist.
   436         // Check that IntegrityService root dir does not exist.
   410         assertNoIsDir();
   437         assertNoIsDir();
   411 
   438 
   412         // List.
   439         // List.
   413         Log.logOut("InstallerEngineTest.doInstallUninstall: list -v");
   440         //Log.logOut("InstallerEngineTest.doInstallUninstall: list -v");
   414         result = Installer.mainWithResult(new String[] { "list", "-v" });
   441         //result = Installer.mainWithResult(new String[] { "list", "-v" });
   415         assertResult(result, Installer.ERR_NONE);
   442         //assertResult(result, Installer.ERR_NONE);
   416         Log.logOut("InstallerEngineTest.doInstallUninstall: list -otastatus");
   443         //Log.logOut("InstallerEngineTest.doInstallUninstall: list -otastatus");
   417         result = Installer.mainWithResult(new String[] { "list", "-otastatus" });
   444         //result = Installer.mainWithResult(new String[] { "list", "-otastatus" });
   418         assertResult(result, Installer.ERR_NONE);
   445         //assertResult(result, Installer.ERR_NONE);
   419 
   446 
   420         // Update with cancellation.
   447         // Update with cancellation.
   421         Log.logOut("InstallerEngineTest.doInstallUninstall: update with cancellation " + aFilename);
   448         Log.logOut("InstallerEngineTest.doInstallUninstall: update with cancellation " + aFilename);
   422         result = Installer.mainWithResult(cancelArgs);
   449         result = Installer.mainWithResult(cancelArgs);
   423         // Check result code.
   450         // Check result code.
   568     }
   595     }
   569 
   596 
   570     public void testDownloadJadOk()
   597     public void testDownloadJadOk()
   571     {
   598     {
   572         Log.logOut("InstallerEngineTest.testDownloadJadOk begins");
   599         Log.logOut("InstallerEngineTest.testDownloadJadOk begins");
   573         SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP");
   600         SuiteInfo suite = new SuiteInfo("HelloWorld", "Nokia");
   574         doInstallUninstall(suite, "http://195.134.231.83:7070/omjserver/resources/omj/T00000900_JBenchmark2_gcf.jsp", true, iDefaultOptions);
   601         doInstallUninstall(suite, "http://" + getTestServer() + "/installertest/HelloWorld_ota.jad", true, iDefaultOptions);
   575     }
   602     }
   576 
   603 
   577     public void testDownloadJarOk()
   604     public void testDownloadJarOk()
   578     {
   605     {
   579         Log.logOut("InstallerEngineTest.testDownloadJarOk begins");
   606         Log.logOut("InstallerEngineTest.testDownloadJarOk begins");
   580         SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP");
   607         SuiteInfo suite = new SuiteInfo("HelloWorld", "Nokia");
   581         doInstallUninstall(suite, "http://195.134.231.83:7070/omjserver/resources/omj/JBenchmark2.jar", false, iDefaultOptions);
   608         doInstallUninstall(suite, "http://" + getTestServer() + "/installertest/HelloWorld.jar", false, iDefaultOptions);
   582     }
   609     }
   583 
   610 
   584     public void testDownloadJadHttpRedirectOk()
   611     public void testDownloadJadHttpRedirectOk()
   585     {
   612     {
   586         Log.logOut("InstallerEngineTest.testDownloadJadHttpRedirectOk begins");
   613         Log.logOut("InstallerEngineTest.testDownloadJadHttpRedirectOk begins");
   587         SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP");
   614         SuiteInfo suite = new SuiteInfo("HelloWorld_redirect", "Nokia");
   588         doInstallUninstall(suite, "http://195.134.231.83:7070/RedirectServlet/redirect?name=JBenchmark2.jad&count=5", true, iDefaultOptions);
   615         doInstallUninstall(suite, "http://" + getTestServer() + "/installertest/redirect?name=HelloWorld_redirect.jad&count=5", true, iDefaultOptions);
   589     }
   616     }
   590 
   617 
   591     public void testDownloadJarHttpRedirectOk()
   618     public void testDownloadJarHttpRedirectOk()
   592     {
   619     {
   593         Log.logOut("InstallerEngineTest.testDownloadJarHttpRedirectOk begins");
   620         Log.logOut("InstallerEngineTest.testDownloadJarHttpRedirectOk begins");
   594         SuiteInfo suite = new SuiteInfo("JBenchmark2", "Kishonti LP");
   621         SuiteInfo suite = new SuiteInfo("HelloWorld_redirect", "Nokia");
   595         doInstallUninstall(suite, "http://195.134.231.83:7070/RedirectServlet/redirect?name=JBenchmark2.jar", false, iDefaultOptions);
   622         doInstallUninstall(suite, "http://" + getTestServer() + "/installertest/redirect?name=HelloWorld_redirect.jar", false, iDefaultOptions);
   596     }
   623     }
   597 
   624 
   598     public void testDownloadJadHttpAuthOk()
   625     public void testDownloadJadHttpAuthOk()
   599     {
   626     {
   600         Log.logOut("InstallerEngineTest.testDownloadJadHttpAuthOk begins");
   627         Log.logOut("InstallerEngineTest.testDownloadJadHttpAuthOk begins");
   601         SuiteInfo suite = new SuiteInfo("DS_Snow_http_auth", "DS_Effects");
   628         SuiteInfo suite = new SuiteInfo("HelloWorld_http_auth", "Nokia");
   602         iDefaultOptions.addElement("-username=guest");
   629         iDefaultOptions.addElement("-username=guest");
   603         iDefaultOptions.addElement("-password=guest");
   630         iDefaultOptions.addElement("-password=guest");
   604         doInstallUninstall(suite, "http://195.134.231.83:7070/httpauth/DS_Snow_http_auth.jad", true, iDefaultOptions);
   631         doInstallUninstall(suite, "http://" + getTestServer() + "/installertest/httpauth/HelloWorld_http_auth.jad", true, iDefaultOptions);
   605     }
   632     }
   606 
   633 
   607     public void testDownloadJadHttpAuthNok()
   634     public void testDownloadJadHttpAuthNok()
   608     {
   635     {
   609         Log.logOut("InstallerEngineTest.testDownloadJadHttpAuthNok begins");
   636         Log.logOut("InstallerEngineTest.testDownloadJadHttpAuthNok begins");
   610         String[] args = new String[]
   637         String[] args = new String[]
   611         {
   638         {
   612             "install",
   639             "install",
   613             "-silent",
   640             "-silent",
   614             "-jad=http://195.134.231.83:7070/httpauth/DS_Snow_http_auth.jad",
   641             "-jad=http://" + getTestServer() + "/installertest/httpauth/HelloWorld_http_auth.jad",
   615         };
   642         };
   616         int result = Installer.mainWithResult(args);
   643         int result = Installer.mainWithResult(args);
   617         // Check result code.
   644         // Check result code.
   618         assertResult(result, Installer.ERR_CANCEL);
   645         assertResult(result, Installer.ERR_CANCEL);
   619         // Check exception
   646         // Check exception
   620         assertTrue("failed installation returns incorrect exception " +
   647         assertTrue("failed installation returns incorrect exception " +
   621                    Installer.getExecuteException(),
   648                    Installer.getExecuteException(),
   622                    iItu.isExceptionReason
   649                    iItu.isExceptionReason
   623                    (Installer.getExecuteException(),
   650                    (Installer.getExecuteException(),
   624                     InstallerErrorMessage.INST_CANCEL,
   651                     InstallerErrorMessage.INST_CANCEL,
   625                     InstallerDetailedErrorMessage.NO_MSG,
   652                     InstallerDetailedErrorMessage.INST_CANCEL,
   626                     OtaStatusCode.USER_CANCELLED));
   653                     OtaStatusCode.USER_CANCELLED));
   627         assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0);
   654         assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0);
   628     }
   655     }
   629 
   656 
   630     public void testDownloadJadHttpRedirectCountExceeded()
   657     public void testDownloadJadHttpRedirectCountExceeded()
   632         Log.logOut("InstallerEngineTest.testDownloadJadHttpRedirectCountExceeded begins");
   659         Log.logOut("InstallerEngineTest.testDownloadJadHttpRedirectCountExceeded begins");
   633         String[] args = new String[]
   660         String[] args = new String[]
   634         {
   661         {
   635             "install",
   662             "install",
   636             "-silent",
   663             "-silent",
   637             "-jad=http://195.134.231.83:7070/RedirectServlet/redirect?name=JBenchmark2.jad&count=6",
   664             "-jad=http://" + getTestServer() + "/installertest/redirect?name=HelloWorld_redirect.jad&count=6",
   638         };
   665         };
   639         int result = Installer.mainWithResult(args);
   666         int result = Installer.mainWithResult(args);
   640         // Check result code.
   667         // Check result code.
   641         assertResult(result, Installer.ERR_GENERAL);
   668         assertResult(result, Installer.ERR_GENERAL);
   642         // Check exception
   669         // Check exception
   675         // Start installation which downloads a large file.
   702         // Start installation which downloads a large file.
   676         String[] args = new String[]
   703         String[] args = new String[]
   677         {
   704         {
   678             "install",
   705             "install",
   679             "-silent",
   706             "-silent",
   680             "-jad=http://195.134.231.83:7070/omjserver/resources/omj/T00000900_JBenchmark2_8mb_gcf.jsp",
   707             "-jad=http://" + getTestServer() + "/installertest/HelloWorld_8mb.jad",
   681         };
   708         };
   682         Log.log("InstallerEngineTest.testDownloadJadCancel: installation starts");
   709         Log.log("InstallerEngineTest.testDownloadJadCancel: installation starts");
   683         int result = Installer.mainWithResult(args);
   710         int result = Installer.mainWithResult(args);
   684         Log.log("InstallerEngineTest.testDownloadJadCancel: installation returned");
   711         Log.log("InstallerEngineTest.testDownloadJadCancel: installation returned");
   685         // Check result code.
   712         // Check result code.
   688         assertTrue("failed installation returns incorrect exception " +
   715         assertTrue("failed installation returns incorrect exception " +
   689                    Installer.getExecuteException(),
   716                    Installer.getExecuteException(),
   690                    iItu.isExceptionReason
   717                    iItu.isExceptionReason
   691                    (Installer.getExecuteException(),
   718                    (Installer.getExecuteException(),
   692                     InstallerErrorMessage.INST_CANCEL,
   719                     InstallerErrorMessage.INST_CANCEL,
   693                     InstallerDetailedErrorMessage.NO_MSG,
   720                     InstallerDetailedErrorMessage.INST_CANCEL,
   694                     OtaStatusCode.USER_CANCELLED));
   721                     OtaStatusCode.USER_CANCELLED));
   695         assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0);
   722         assertTrue("installed app uid should not exist", Installer.iInstalledApps.length == 0);
   696         Log.log("InstallerEngineTest.testDownloadJadCancel: end");
   723         Log.log("InstallerEngineTest.testDownloadJadCancel: end");
   697     }
   724     }
   698 
   725 
   983         callInstallerOk(new String[] { "list", "-storage" });
  1010         callInstallerOk(new String[] { "list", "-storage" });
   984         callInstallerOk(new String[] { "list", "-otastatus" });
  1011         callInstallerOk(new String[] { "list", "-otastatus" });
   985         callInstallerOk(new String[] { "list", "-systemproperties" });
  1012         callInstallerOk(new String[] { "list", "-systemproperties" });
   986         callInstallerOk(new String[] { "launch", "-nouid" });
  1013         callInstallerOk(new String[] { "launch", "-nouid" });
   987         callInstallerOk(new String[] { "launch", "-uid=invaliduid" });
  1014         callInstallerOk(new String[] { "launch", "-uid=invaliduid" });
   988         callInstallerOk(new String[] { "uninstallall" });
  1015         callInstallerOk(new String[] { "uninstallall", "-silent" });
   989         callInstallerOk(new String[] { "unregister" });
  1016         callInstallerOk(new String[] { "unregister" });
   990         callInstallerOk(new String[] { "test", "-nomainclass" });
  1017         callInstallerOk(new String[] { "test", "-nomainclass" });
   991     }
  1018     }
   992 
  1019 
   993     public void testApplicationInfo()
  1020     public void testApplicationInfo()
  1104      */
  1131      */
  1105     public void testInstallAuthAndBig()
  1132     public void testInstallAuthAndBig()
  1106     {
  1133     {
  1107         Log.logOut("InstallerEngineTest.testInstallAuthAndBig begins");
  1134         Log.logOut("InstallerEngineTest.testInstallAuthAndBig begins");
  1108         // Do first installation with doInstallUninstall helper
  1135         // Do first installation with doInstallUninstall helper
  1109         SuiteInfo suite = new SuiteInfo("DS_Snow_http_auth", "DS_Effects");
  1136         SuiteInfo suite = new SuiteInfo("HelloWorld_http_auth", "Nokia");
  1110         iDefaultOptions.addElement("-username=guest");
  1137         iDefaultOptions.addElement("-username=guest");
  1111         iDefaultOptions.addElement("-password=guest");
  1138         iDefaultOptions.addElement("-password=guest");
  1112         doInstallUninstall(suite, "http://195.134.231.83:7070/httpauth/DS_Snow_http_auth.jad", true, iDefaultOptions);
  1139         doInstallUninstall(suite, "http://" + getTestServer() + "/installertest/httpauth/HelloWorld_http_auth.jad", true, iDefaultOptions);
  1113 
  1140 
  1114         // Then start installation which downloads a large file.
  1141         // Then start installation which downloads a large file.
  1115         Log.log("InstallerEngineTest.testInstallAuthAndBig begin to install big app");
  1142         Log.log("InstallerEngineTest.testInstallAuthAndBig begin to install big app");
  1116         String[] args = new String[]
  1143         String[] args = new String[]
  1117         {
  1144         {
  1118             "install",
  1145             "install",
  1119             "-silent",
  1146             "-silent",
  1120             "-jad=http://195.134.231.83:7070/omjserver/resources/omj/T00000900_JBenchmark2_8mb_gcf.jsp",
  1147             "-jad=http://" + getTestServer() + "/installertest/HelloWorld_8mb.jad",
  1121         };
  1148         };
  1122         int result = Installer.mainWithResult(args);
  1149         int result = Installer.mainWithResult(args);
  1123         // Check result code.
  1150         // Check result code.
  1124         assertResult(result, Installer.ERR_NONE);
  1151         assertResult(result, Installer.ERR_NONE);
  1125         // Check exception
  1152         // Check exception