javacommons/utils/tsrc/javasrc/com/nokia/mj/impl/rt/SystemPropertyTests.java
changeset 76 4ad59aaee882
parent 26 dc7c549001d5
child 83 26b2b12093af
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
    17 
    17 
    18 
    18 
    19 package com.nokia.mj.impl.rt;
    19 package com.nokia.mj.impl.rt;
    20 
    20 
    21 
    21 
    22 import com.nokia.mj.impl.installer.utils.InstallerMain;
    22 import com.nokia.mj.impl.rt.test.UnitTestSuiteCreator;
    23 import com.nokia.mj.impl.rt.support.JvmInternal;
    23 import com.nokia.mj.impl.rt.support.JvmInternal;
    24 
    24 
    25 import j2meunit.framework.Test;
    25 import j2meunit.framework.Test;
    26 import j2meunit.framework.TestCase;
    26 import j2meunit.framework.TestCase;
    27 import j2meunit.framework.TestMethod;
    27 import j2meunit.framework.TestMethod;
    28 import j2meunit.framework.TestSuite;
    28 import j2meunit.framework.TestSuite;
    29 
    29 
    30 /**
    30 /**
    31  * SystemProperty unit tests.
    31  * SystemProperty unit tests.
    32  */
    32  */
    33 public class SystemPropertyTests extends TestCase implements InstallerMain
    33 public class SystemPropertyTests extends TestCase implements UnitTestSuiteCreator
    34 {
    34 {
    35 
    35 
    36     // Begin j2meunit test framework setup
    36     // Begin j2meunit test framework setup
    37     public void installerMain(String[] args)
    37     public TestSuite createTestSuite(String[] args)
    38     {
    38     {
    39         TestSuite suite = new TestSuite(this.getClass().getName());
    39         TestSuite suite = new TestSuite(this.getClass().getName());
    40 
    40 
    41         suite.addTest(new SystemPropertyTests("setPropTests", new TestMethod()
    41         suite.addTest(new SystemPropertyTests("setPropTests", new TestMethod()
    42         {
    42         {
    60             {
    60             {
    61                 ((SystemPropertyTests)tc).dynamicPropTests();
    61                 ((SystemPropertyTests)tc).dynamicPropTests();
    62             }
    62             }
    63         }));
    63         }));
    64 
    64 
    65  
    65         return suite;
    66         com.nokia.mj.impl.utils.OmjTestRunner.run(suite);
       
    67 
    66 
    68     }
    67     }
    69 
    68 
    70     public SystemPropertyTests()
    69     public SystemPropertyTests()
    71     {
    70     {
   116             // Set a new value to same system property and check that it was correctly set.
   115             // Set a new value to same system property and check that it was correctly set.
   117             JvmInternal.setSystemProperty(testPropertyKey1, testPropertyVal2);
   116             JvmInternal.setSystemProperty(testPropertyKey1, testPropertyVal2);
   118             res = System.getProperty(testPropertyKey1);
   117             res = System.getProperty(testPropertyKey1);
   119             assertTrue("Fail3, got: "+ res, testPropertyVal2.equals(res));
   118             assertTrue("Fail3, got: "+ res, testPropertyVal2.equals(res));
   120 
   119 
   121             // Set a null value to same system property and check that an 
   120             // Set a null value to same system property and check that an
   122             // exception is thrown and the value is not changed.
   121             // exception is thrown and the value is not changed.
   123             try
   122             try
   124             {
   123             {
   125                 JvmInternal.setSystemProperty(testPropertyKey1, null);
   124                 JvmInternal.setSystemProperty(testPropertyKey1, null);
   126                 assertTrue("No exception1: "+ res, false);
   125                 assertTrue("No exception1: "+ res, false);
   144             // Set a new value to same user property and check that it was correctly set.
   143             // Set a new value to same user property and check that it was correctly set.
   145             JvmInternal.setUserProperty(testPropertyKey2, testPropertyVal4);
   144             JvmInternal.setUserProperty(testPropertyKey2, testPropertyVal4);
   146             res = System.getProperty(testPropertyKey2);
   145             res = System.getProperty(testPropertyKey2);
   147             assertTrue("Fail7, got: "+ res, testPropertyVal4.equals(res));
   146             assertTrue("Fail7, got: "+ res, testPropertyVal4.equals(res));
   148 
   147 
   149             // Set a null value to same user property and check that an 
   148             // Set a null value to same user property and check that an
   150             // exception is thrown and the value is not changed.
   149             // exception is thrown and the value is not changed.
   151             try
   150             try
   152             {
   151             {
   153                 JvmInternal.setSystemProperty(testPropertyKey2, null);
   152                 JvmInternal.setSystemProperty(testPropertyKey2, null);
   154                 assertTrue("No exception2: "+ res, false);
   153                 assertTrue("No exception2: "+ res, false);
   157             {
   156             {
   158             }
   157             }
   159             res = System.getProperty(testPropertyKey2);
   158             res = System.getProperty(testPropertyKey2);
   160             assertTrue("Fail8, got: "+ res, testPropertyVal4.equals(res));
   159             assertTrue("Fail8, got: "+ res, testPropertyVal4.equals(res));
   161 
   160 
   162             // Set the same system and user property and check that the user property 
   161             // Set the same system and user property and check that the user property
   163             // doesn't override the system property.
   162             // doesn't override the system property.
   164             JvmInternal.setSystemProperty(testPropertyKey3, testPropertyVal5);
   163             JvmInternal.setSystemProperty(testPropertyKey3, testPropertyVal5);
   165             JvmInternal.setUserProperty(testPropertyKey3, testPropertyVal6);
   164             JvmInternal.setUserProperty(testPropertyKey3, testPropertyVal6);
   166             res = System.getProperty(testPropertyKey3);
   165             res = System.getProperty(testPropertyKey3);
   167             assertTrue("Fail9, got: "+ res, testPropertyVal5.equals(res));
   166             assertTrue("Fail9, got: "+ res, testPropertyVal5.equals(res));