javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/ApplicationRegistratorTest.java
branchRCL_3
changeset 19 04becd199f91
child 23 98ccebc37403
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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.applicationregistrator;
       
    20 
       
    21 import com.nokia.mj.impl.installer.utils.InstallerException;
       
    22 import com.nokia.mj.impl.installer.utils.InstallerMain;
       
    23 import com.nokia.mj.impl.installer.utils.PlatformUid;
       
    24 import com.nokia.mj.impl.utils.Uid;
       
    25 
       
    26 import j2meunit.framework.Test;
       
    27 import j2meunit.framework.TestCase;
       
    28 import j2meunit.framework.TestMethod;
       
    29 import j2meunit.framework.TestSuite;
       
    30 
       
    31 /**
       
    32  * ApplicationRegistrator unit tests.
       
    33  *
       
    34  * @author Nokia Corporation
       
    35  * @version $Rev: 9041 $
       
    36  */
       
    37 public class ApplicationRegistratorTest extends TestCase implements InstallerMain
       
    38 {
       
    39 
       
    40     private static final String DEFAULT_SVG_ICON_PATH_NAME = "c:\\private\\102033E6\\installer\\jiutdata\\utils\\javahelper.mif";
       
    41 
       
    42     // Begin j2meunit test framework setup
       
    43 
       
    44     public void installerMain(String[] args)
       
    45     {
       
    46         TestSuite suite = new TestSuite(this.getClass().getName());
       
    47 
       
    48         suite.addTest(new ApplicationRegistratorTest("testStartAndCloseSession", new TestMethod()
       
    49         {
       
    50             public void run(TestCase tc)
       
    51             {
       
    52                 ((ApplicationRegistratorTest)tc).testStartAndCloseSession();
       
    53             }
       
    54         }));
       
    55 
       
    56         suite.addTest(new ApplicationRegistratorTest("testStartAndCommitSession", new TestMethod()
       
    57         {
       
    58             public void run(TestCase tc)
       
    59             {
       
    60                 ((ApplicationRegistratorTest)tc).testStartAndCommitSession();
       
    61             }
       
    62         }));
       
    63 
       
    64         suite.addTest(new ApplicationRegistratorTest("testUidInUse", new TestMethod()
       
    65         {
       
    66             public void run(TestCase tc)
       
    67             {
       
    68                 ((ApplicationRegistratorTest)tc).testUidInUse();
       
    69             }
       
    70         }));
       
    71 
       
    72         suite.addTest(new ApplicationRegistratorTest("testGetGroupName", new TestMethod()
       
    73         {
       
    74             public void run(TestCase tc)
       
    75             {
       
    76                 ((ApplicationRegistratorTest)tc).testGetGroupName();
       
    77             }
       
    78         }));
       
    79 
       
    80         suite.addTest(new ApplicationRegistratorTest("testRegisterApplication", new TestMethod()
       
    81         {
       
    82             public void run(TestCase tc)
       
    83             {
       
    84                 ((ApplicationRegistratorTest)tc).testRegisterApplication();
       
    85             }
       
    86         }));
       
    87 
       
    88         suite.addTest(new ApplicationRegistratorTest("testRegisterApplicationSucceeded", new TestMethod()
       
    89         {
       
    90             public void run(TestCase tc)
       
    91             {
       
    92                 ((ApplicationRegistratorTest)tc).testRegisterApplicationSucceeded();
       
    93             }
       
    94         }));
       
    95 
       
    96         suite.addTest(new ApplicationRegistratorTest("testUnregisterApplication", new TestMethod()
       
    97         {
       
    98             public void run(TestCase tc)
       
    99             {
       
   100                 ((ApplicationRegistratorTest)tc).testUnregisterApplication();
       
   101             }
       
   102         }));
       
   103 
       
   104         suite.addTest(new ApplicationRegistratorTest("testRollbackRegistration", new TestMethod()
       
   105         {
       
   106             public void run(TestCase tc)
       
   107             {
       
   108                 ((ApplicationRegistratorTest)tc).testRollbackRegistration();
       
   109             }
       
   110         }));
       
   111 
       
   112         suite.addTest(new ApplicationRegistratorTest("testRollbackSucceeded", new TestMethod()
       
   113         {
       
   114             public void run(TestCase tc)
       
   115             {
       
   116                 ((ApplicationRegistratorTest)tc).testRollbackSucceeded();
       
   117             }
       
   118         }));
       
   119 
       
   120         suite.addTest(new ApplicationRegistratorTest("testRegAppWithoutIcon", new TestMethod()
       
   121         {
       
   122             public void run(TestCase tc)
       
   123             {
       
   124                 ((ApplicationRegistratorTest)tc).testRegAppWithoutIcon();
       
   125             }
       
   126         }));
       
   127 
       
   128         suite.addTest(new ApplicationRegistratorTest("testRegAppWithoutIconSucceeded", new TestMethod()
       
   129         {
       
   130             public void run(TestCase tc)
       
   131             {
       
   132                 ((ApplicationRegistratorTest)tc).testRegAppWithoutIconSucceeded();
       
   133             }
       
   134         }));
       
   135 
       
   136         suite.addTest(new ApplicationRegistratorTest("testUnregAppWithoutIcon", new TestMethod()
       
   137         {
       
   138             public void run(TestCase tc)
       
   139             {
       
   140                 ((ApplicationRegistratorTest)tc).testUnregAppWithoutIcon();
       
   141             }
       
   142         }));
       
   143 
       
   144         suite.addTest(new ApplicationRegistratorTest("testRegAppWithSuiteIcon", new TestMethod()
       
   145         {
       
   146             public void run(TestCase tc)
       
   147             {
       
   148                 ((ApplicationRegistratorTest)tc).testRegAppWithSuiteIcon();
       
   149             }
       
   150         }));
       
   151 
       
   152         suite.addTest(new ApplicationRegistratorTest("testRegAppWithSuiteIconSucceeded", new TestMethod()
       
   153         {
       
   154             public void run(TestCase tc)
       
   155             {
       
   156                 ((ApplicationRegistratorTest)tc).testRegAppWithSuiteIconSucceeded();
       
   157             }
       
   158         }));
       
   159 
       
   160         suite.addTest(new ApplicationRegistratorTest("testUnregAppWithSuiteIcon", new TestMethod()
       
   161         {
       
   162             public void run(TestCase tc)
       
   163             {
       
   164                 ((ApplicationRegistratorTest)tc).testUnregAppWithSuiteIcon();
       
   165             }
       
   166         }));
       
   167 
       
   168         com.nokia.mj.impl.utils.OmjTestRunner.run(suite);
       
   169     }
       
   170 
       
   171     public ApplicationRegistratorTest()
       
   172     {
       
   173     }
       
   174 
       
   175     public ApplicationRegistratorTest(String aTestName, TestMethod aTestMethod)
       
   176     {
       
   177         super(aTestName, aTestMethod);
       
   178     }
       
   179 
       
   180     public void assertFalse(String aMsg, boolean aCondition)
       
   181     {
       
   182         assertTrue(aMsg, !aCondition);
       
   183     }
       
   184 
       
   185     // End j2meunit test framework setup
       
   186 
       
   187     protected void setUp()
       
   188     {
       
   189     }
       
   190 
       
   191     protected void tearDown()
       
   192     {
       
   193     }
       
   194 
       
   195     public void testStartAndCloseSession()
       
   196     {
       
   197         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   198 
       
   199         try
       
   200         {
       
   201             appReg.startSession();
       
   202             // close the session immediately
       
   203             appReg.closeSession();
       
   204             // make sure that closeSession can be called even if the
       
   205             // session has already been closed
       
   206             appReg.closeSession();
       
   207         }
       
   208         catch (InstallerException ie)
       
   209         {
       
   210             ie.printStackTrace();
       
   211             assertTrue("Unexpected exception: " + ie, false);
       
   212             appReg.closeSession();
       
   213         }
       
   214     }
       
   215 
       
   216     public void testStartAndCommitSession()
       
   217     {
       
   218         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   219 
       
   220         try
       
   221         {
       
   222             appReg.startSession();
       
   223             // commit the session immediately
       
   224             appReg.commitSession(true);
       
   225 
       
   226         }
       
   227         catch (InstallerException ie)
       
   228         {
       
   229             ie.printStackTrace();
       
   230             assertTrue("Unexpected exception: " + ie, false);
       
   231             appReg.closeSession();
       
   232         }
       
   233     }
       
   234 
       
   235     public void testUidInUse()
       
   236     {
       
   237         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   238 
       
   239         try
       
   240         {
       
   241             // this Uid should be valid in S60
       
   242             Uid uid = Uid.createUid("[A0032000]");
       
   243             boolean inUse = false;
       
   244 
       
   245             // session must be started first
       
   246             try
       
   247             {
       
   248                 inUse = appReg.uidInUse(uid);
       
   249                 assertTrue("Calling UidInUse should not succeed without session!", false);
       
   250             }
       
   251             catch (InstallerException ie)
       
   252             {
       
   253                 // this exception is espected
       
   254             }
       
   255 
       
   256             appReg.startSession();
       
   257             assertFalse("Uid should not be in use", appReg.uidInUse(uid));
       
   258             appReg.closeSession();
       
   259         }
       
   260         catch (InstallerException ie)
       
   261         {
       
   262             ie.printStackTrace();
       
   263             assertTrue("Unexpected exception: " + ie, false);
       
   264             appReg.closeSession();
       
   265         }
       
   266     }
       
   267 
       
   268 
       
   269     public void testGetGroupName()
       
   270     {
       
   271         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   272 
       
   273         try
       
   274         {
       
   275             // this Uid should be valid but non existing in S60
       
   276             Uid uid = Uid.createUid("[E0032000]");
       
   277             String groupName = "";
       
   278 
       
   279             // session must be started first
       
   280             try
       
   281             {
       
   282                 groupName = appReg.getGroupName(uid);
       
   283                 assertTrue("Calling getGroupName should not succeed without session!", false);
       
   284             }
       
   285             catch (InstallerException ie)
       
   286             {
       
   287                 // this exception is espected
       
   288             }
       
   289 
       
   290             appReg.startSession();
       
   291             // there is no application with this uid, so this throws exception
       
   292             try
       
   293             {
       
   294                 groupName = appReg.getGroupName(uid);
       
   295             }
       
   296             catch (InstallerException ie)
       
   297             {
       
   298                 // ignore this expected exception
       
   299             }
       
   300             appReg.closeSession();
       
   301         }
       
   302         catch (InstallerException ie)
       
   303         {
       
   304             ie.printStackTrace();
       
   305             assertTrue("Unexpected exception: " + ie, false);
       
   306             appReg.closeSession();
       
   307         }
       
   308     }
       
   309 
       
   310     public void testRegisterApplication()
       
   311     {
       
   312         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   313 
       
   314         try
       
   315         {
       
   316             Uid uid = Uid.createUid("[20032000]");
       
   317             AppRegInfo appRegInfo = new AppRegInfo(
       
   318                 // Uid aUid,
       
   319                 uid,
       
   320                 // String aGroupName,
       
   321                 //"Games",
       
   322                 "VeryVeryLongGroupNameThatMustBeShortened",
       
   323                 // String aMIDletName,
       
   324                 "GameMIDlet",
       
   325                 // String aTargetDrive,
       
   326                 "C:",
       
   327                 // String aIconFileName contains alread the name of the converted icon,
       
   328                 "c:\\private\\102033E6\\installer\\jiutdata\\icon1.mbm",
       
   329                 // String aJarFileName,
       
   330                 "c:\\private\\102033E6\\installer\\jiutdata\\utils\\einstein_EN_FR_IT_DE_ES_N97_v2942.jar",
       
   331                 // boolean aHidden,
       
   332                 false,
       
   333                 // boolean aBackground
       
   334                 false);
       
   335 
       
   336             // session must be started first
       
   337             try
       
   338             {
       
   339                 appReg.registerApplication(appRegInfo);
       
   340                 assertTrue("Calling registerApplication should not succeed without session!", false);
       
   341             }
       
   342             catch (InstallerException ie)
       
   343             {
       
   344                 // this exception is espected
       
   345             }
       
   346 
       
   347             appReg.startSession();
       
   348 
       
   349             // convert icon before registering
       
   350             StringBuffer iconSuffix = new StringBuffer();
       
   351             boolean convOk = appReg.convertIcon("icon.png", "c:\\private\\102033E6\\installer\\jiutdata\\icon1.mbm",
       
   352                                                 "c:\\private\\102033E6\\installer\\jiutdata\\utils\\einstein_EN_FR_IT_DE_ES_N97_v2942.jar", iconSuffix);
       
   353             assertTrue("Icon conversion failed.", convOk);
       
   354             assertTrue("Suffix of the converted icon is incorrect.", iconSuffix.toString().equals(".mbm"));
       
   355 
       
   356             appReg.registerApplication(appRegInfo);
       
   357             appReg.commitSession(true);
       
   358         }
       
   359         catch (InstallerException ie)
       
   360         {
       
   361             ie.printStackTrace();
       
   362             assertTrue("Unexpected exception: " + ie, false);
       
   363             appReg.commitSession(true);
       
   364         }
       
   365     }
       
   366 
       
   367     public void testRegisterApplicationSucceeded()
       
   368     {
       
   369         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   370 
       
   371         try
       
   372         {
       
   373             // application with this Uid was registered in testRegisterApplication
       
   374             Uid uid = Uid.createUid("[20032000]");
       
   375             String groupName = "";
       
   376             boolean uidInUse = false;
       
   377 
       
   378             appReg.startSession();
       
   379             groupName = appReg.getGroupName(uid);
       
   380             assertTrue(
       
   381                 "The group name was not VeryVeryLongGrou, it was " + groupName,
       
   382                 "VeryVeryLongGrou".equals(groupName));
       
   383 
       
   384             uidInUse = appReg.uidInUse(uid);
       
   385             assertTrue("uidInUse returned false value", true == uidInUse);
       
   386 
       
   387             appReg.closeSession();
       
   388         }
       
   389         catch (InstallerException ie)
       
   390         {
       
   391             ie.printStackTrace();
       
   392             assertTrue("Unexpected exception: " + ie, false);
       
   393             appReg.closeSession();
       
   394         }
       
   395     }
       
   396 
       
   397     public void testUnregisterApplication()
       
   398     {
       
   399         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   400 
       
   401         try
       
   402         {
       
   403             // application with this Uid was registered in testRegisterApplication
       
   404             Uid uid = Uid.createUid("[20032000]");
       
   405 
       
   406             AppRegInfo appRegInfo = new AppRegInfo(
       
   407                 // Uid aUid,
       
   408                 uid,
       
   409                 // String aGroupName,
       
   410                 "",
       
   411                 // String aMIDletName,
       
   412                 "",
       
   413                 // String aTargetDrive,
       
   414                 "",
       
   415                 // String aIconFileName, dummy
       
   416                 "",
       
   417                 // String aJarFileName, dummy
       
   418                 "",
       
   419                 // boolean aHidden,
       
   420                 false,
       
   421                 // boolean aBackground
       
   422                 false);
       
   423 
       
   424             appReg.startSession();
       
   425             appReg.unregisterApplication(appRegInfo);
       
   426             appReg.commitSession(true);
       
   427         }
       
   428         catch (InstallerException ie)
       
   429         {
       
   430             ie.printStackTrace();
       
   431             assertTrue("Unexpected exception: " + ie, false);
       
   432             appReg.closeSession();
       
   433         }
       
   434     }
       
   435 
       
   436 
       
   437     public void testRollbackRegistration()
       
   438     {
       
   439         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   440 
       
   441         try
       
   442         {
       
   443             Uid uid = Uid.createUid("[20032001]");
       
   444             AppRegInfo appRegInfo = new AppRegInfo(
       
   445                 // Uid aUid,
       
   446                 uid,
       
   447                 // String aGroupName,
       
   448                 "Games",
       
   449                 // String aMIDletName,
       
   450                 "GameMIDlet1",
       
   451                 // String aTargetDrive,
       
   452                 "C:",
       
   453                 // String aIconFileName,  must be accessible and have \\ characters
       
   454                 DEFAULT_SVG_ICON_PATH_NAME,
       
   455                 // String aJarFileName,
       
   456                 "c:\\private\\102033E6\\installer\\jiutdata\\utils\\einstein_EN_FR_IT_DE_ES_N97_v2942.jar",
       
   457                 // boolean aHidden,
       
   458                 false,
       
   459                 // boolean aBackground
       
   460                 false);
       
   461 
       
   462             appReg.startSession();
       
   463             appReg.registerApplication(appRegInfo);
       
   464             appReg.rollbackSession();
       
   465         }
       
   466         catch (InstallerException ie)
       
   467         {
       
   468             ie.printStackTrace();
       
   469             assertTrue("Unexpected exception: " + ie, false);
       
   470             appReg.closeSession();
       
   471         }
       
   472     }
       
   473 
       
   474     public void testRollbackSucceeded()
       
   475     {
       
   476         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   477 
       
   478         try
       
   479         {
       
   480             // application with this Uid was registered in testRollbackRegistration
       
   481             Uid uid = Uid.createUid("[20032001]");
       
   482             String groupName = "";
       
   483             boolean uidInUse = false;
       
   484 
       
   485             appReg.startSession();
       
   486 
       
   487             try
       
   488             {
       
   489                 uidInUse = appReg.uidInUse(uid);
       
   490                 assertTrue("uidInUse returned true although registration was rolled back", false == uidInUse);
       
   491             }
       
   492             catch (Exception e)
       
   493             {
       
   494                 e.printStackTrace();
       
   495                 assertTrue("Unexpected exception: " + e, false);
       
   496             }
       
   497 
       
   498             try
       
   499             {
       
   500                 groupName = appReg.getGroupName(uid);
       
   501                 // If the application cannot be found, returns ""
       
   502                 assertTrue("getGroupName succeeded even though application registration was rolled back.",
       
   503                            "".equals(groupName));
       
   504             }
       
   505             catch (InstallerException e2)
       
   506             {
       
   507                 e2.printStackTrace();
       
   508                 assertTrue("Unexpected exception: " + e2, false);
       
   509             }
       
   510 
       
   511             appReg.closeSession();
       
   512         }
       
   513         catch (Exception ie)
       
   514         {
       
   515             ie.printStackTrace();
       
   516             assertTrue("Unexpected exception: " + ie, false);
       
   517             appReg.closeSession();
       
   518         }
       
   519     }
       
   520 
       
   521 
       
   522     public void testRegAppWithoutIcon()
       
   523     {
       
   524         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   525 
       
   526         try
       
   527         {
       
   528             Uid uid = Uid.createUid("[A0032005]");
       
   529             AppRegInfo appRegInfo = new AppRegInfo(
       
   530                 // Uid aUid,
       
   531                 uid,
       
   532                 // String aGroupName,
       
   533                 "",
       
   534                 // String aMIDletName,
       
   535                 "NoIconMidlet",
       
   536                 // String aTargetDrive,
       
   537                 "C:",
       
   538                 // String aIconFileName,
       
   539                 DEFAULT_SVG_ICON_PATH_NAME,
       
   540                 // String aJarFileName,
       
   541                 "c:\\private\\102033E6\\installer\\jiutdata\\utils\\einstein_EN_FR_IT_DE_ES_N97_v2942.jar",
       
   542                 // boolean aHidden,
       
   543                 false,
       
   544                 // boolean aBackground
       
   545                 false);
       
   546 
       
   547             // session must be started first
       
   548             try
       
   549             {
       
   550                 appReg.registerApplication(appRegInfo);
       
   551                 assertTrue("Calling registerApplication should not succeed without session!", false);
       
   552             }
       
   553             catch (InstallerException ie)
       
   554             {
       
   555                 // this exception is espected
       
   556             }
       
   557 
       
   558             appReg.startSession();
       
   559             appReg.registerApplication(appRegInfo);
       
   560             appReg.commitSession(true);
       
   561         }
       
   562         catch (InstallerException ie)
       
   563         {
       
   564             ie.printStackTrace();
       
   565             assertTrue("Unexpected exception: " + ie, false);
       
   566             appReg.commitSession(true);
       
   567         }
       
   568     }
       
   569 
       
   570     public void testRegAppWithoutIconSucceeded()
       
   571     {
       
   572         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   573 
       
   574         try
       
   575         {
       
   576             // application with this Uid was registered in testRegAppWithoutIcon
       
   577             Uid uid = Uid.createUid("[A0032005]");
       
   578             String groupName = "";
       
   579             boolean uidInUse = false;
       
   580 
       
   581             appReg.startSession();
       
   582             groupName = appReg.getGroupName(uid);
       
   583             assertTrue(
       
   584                 "The group name was not empty, it was " + groupName,
       
   585                 "".equals(groupName));
       
   586 
       
   587             uidInUse = appReg.uidInUse(uid);
       
   588             assertTrue("uidInUse returned false value", true == uidInUse);
       
   589 
       
   590             appReg.closeSession();
       
   591         }
       
   592         catch (InstallerException ie)
       
   593         {
       
   594             ie.printStackTrace();
       
   595             assertTrue("Unexpected exception: " + ie, false);
       
   596             appReg.closeSession();
       
   597         }
       
   598     }
       
   599 
       
   600     public void testUnregAppWithoutIcon()
       
   601     {
       
   602         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   603 
       
   604         try
       
   605         {
       
   606             // application with this Uid was registered in testRegAppWithoutIcon
       
   607             Uid uid = Uid.createUid("[A0032005]");
       
   608 
       
   609             AppRegInfo appRegInfo = new AppRegInfo(
       
   610                 // Uid aUid,
       
   611                 uid,
       
   612                 // String aGroupName,
       
   613                 "",
       
   614                 // String aMIDletName,
       
   615                 "NoIconMidlet",
       
   616                 // String aTargetDrive,
       
   617                 "C:",
       
   618                 // String aIconFileName,
       
   619                 "",
       
   620                 // String aJarFileName,
       
   621                 "",
       
   622                 // boolean aHidden,
       
   623                 false,
       
   624                 // boolean aBackground
       
   625                 false);
       
   626 
       
   627             appReg.startSession();
       
   628             appReg.unregisterApplication(appRegInfo);
       
   629             appReg.commitSession(true);
       
   630         }
       
   631         catch (InstallerException ie)
       
   632         {
       
   633             ie.printStackTrace();
       
   634             assertTrue("Unexpected exception: " + ie, false);
       
   635             appReg.closeSession();
       
   636         }
       
   637     }
       
   638 
       
   639 
       
   640     public void testRegAppWithSuiteIcon()
       
   641     {
       
   642         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   643 
       
   644         try
       
   645         {
       
   646             Uid uid = Uid.createUid("[A0032FF5]");
       
   647             AppRegInfo appRegInfo = new AppRegInfo(
       
   648                 // Uid aUid,
       
   649                 uid,
       
   650                 // String aGroupName,
       
   651                 "Suite",
       
   652                 // String aMIDletName,
       
   653                 "SuiteIconMidlet",
       
   654                 // String aTargetDrive,
       
   655                 "C:",
       
   656                 // String aIconFileName,
       
   657                 "c:\\private\\102033E6\\installer\\jiutdata\\icon2.mif",
       
   658                 // String aJarFileName,
       
   659                 "c:\\private\\102033E6\\installer\\jiutdata\\utils\\MIDPTestMisc.jar",
       
   660                 // boolean aHidden,
       
   661                 false,
       
   662                 // boolean aBackground
       
   663                 false);
       
   664 
       
   665             // session must be started first
       
   666             try
       
   667             {
       
   668                 appReg.registerApplication(appRegInfo);
       
   669                 assertTrue("Calling registerApplication should not succeed without session!", false);
       
   670             }
       
   671             catch (InstallerException ie)
       
   672             {
       
   673                 // this exception is espected
       
   674             }
       
   675 
       
   676             appReg.startSession();
       
   677 
       
   678             // convert svg icon before registering
       
   679             StringBuffer iconSuffix = new StringBuffer();
       
   680             boolean convOk = appReg.convertIcon("gear.svg", "c:\\private\\102033E6\\installer\\jiutdata\\icon2.mif",
       
   681                                                 "c:\\private\\102033E6\\installer\\jiutdata\\utils\\MIDPTestMisc.jar", iconSuffix);
       
   682             assertTrue("Icon conversion failed.", convOk);
       
   683             assertTrue("Suffix of the converted icon is incorrect.", iconSuffix.toString().equals(".mif"));
       
   684 
       
   685             appReg.registerApplication(appRegInfo);
       
   686             appReg.commitSession(true);
       
   687         }
       
   688         catch (InstallerException ie)
       
   689         {
       
   690             ie.printStackTrace();
       
   691             assertTrue("Unexpected exception: " + ie, false);
       
   692             appReg.commitSession(true);
       
   693         }
       
   694     }
       
   695 
       
   696     public void testRegAppWithSuiteIconSucceeded()
       
   697     {
       
   698         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   699 
       
   700         try
       
   701         {
       
   702             // application with this Uid was registered in testRegAppWithSuiteIcon
       
   703             Uid uid = Uid.createUid("[A0032FF5]");
       
   704             String groupName = "";
       
   705             boolean uidInUse = false;
       
   706 
       
   707             appReg.startSession();
       
   708             groupName = appReg.getGroupName(uid);
       
   709             assertTrue(
       
   710                 "The group name was not Suite, it was " + groupName,
       
   711                 "Suite".equals(groupName));
       
   712 
       
   713             uidInUse = appReg.uidInUse(uid);
       
   714             assertTrue("uidInUse returned false value", true == uidInUse);
       
   715 
       
   716             appReg.closeSession();
       
   717         }
       
   718         catch (InstallerException ie)
       
   719         {
       
   720             ie.printStackTrace();
       
   721             assertTrue("Unexpected exception: " + ie, false);
       
   722             appReg.closeSession();
       
   723         }
       
   724     }
       
   725 
       
   726 
       
   727     public void testUnregAppWithSuiteIcon()
       
   728     {
       
   729         ApplicationRegistrator appReg = new ApplicationRegistrator();
       
   730 
       
   731         try
       
   732         {
       
   733             // application with this Uid was registered in testRegAppWithSuiteIcon
       
   734             Uid uid = Uid.createUid("[A0032FF5]");
       
   735 
       
   736             AppRegInfo appRegInfo = new AppRegInfo(
       
   737                 // Uid aUid,
       
   738                 uid,
       
   739                 // String aGroupName,
       
   740                 "",
       
   741                 // String aMIDletName,
       
   742                 "",
       
   743                 // String aTargetDrive,
       
   744                 "",
       
   745                 // String aIconFileName,
       
   746                 "",
       
   747                 // String aJarFileName,
       
   748                 "",
       
   749                 // boolean aHidden,
       
   750                 false,
       
   751                 // boolean aBackground
       
   752                 false);
       
   753 
       
   754             appReg.startSession();
       
   755             appReg.unregisterApplication(appRegInfo);
       
   756             appReg.commitSession(true);
       
   757         }
       
   758         catch (InstallerException ie)
       
   759         {
       
   760             ie.printStackTrace();
       
   761             assertTrue("Unexpected exception: " + ie, false);
       
   762             appReg.closeSession();
       
   763         }
       
   764     }
       
   765 
       
   766 }