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