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.rt.test.UnitTestSuiteCreator; |
22 import com.nokia.mj.impl.installer.utils.InstallerMain; |
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 UnitTestSuiteCreator |
33 public class SystemPropertyTests extends TestCase implements InstallerMain |
34 { |
34 { |
35 |
35 |
36 // Begin j2meunit test framework setup |
36 // Begin j2meunit test framework setup |
37 public TestSuite createTestSuite(String[] args) |
37 public void installerMain(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 { |
115 // Set a new value to same system property and check that it was correctly set. |
116 // Set a new value to same system property and check that it was correctly set. |
116 JvmInternal.setSystemProperty(testPropertyKey1, testPropertyVal2); |
117 JvmInternal.setSystemProperty(testPropertyKey1, testPropertyVal2); |
117 res = System.getProperty(testPropertyKey1); |
118 res = System.getProperty(testPropertyKey1); |
118 assertTrue("Fail3, got: "+ res, testPropertyVal2.equals(res)); |
119 assertTrue("Fail3, got: "+ res, testPropertyVal2.equals(res)); |
119 |
120 |
120 // Set a null value to same system property and check that an |
121 // Set a null value to same system property and check that an |
121 // exception is thrown and the value is not changed. |
122 // exception is thrown and the value is not changed. |
122 try |
123 try |
123 { |
124 { |
124 JvmInternal.setSystemProperty(testPropertyKey1, null); |
125 JvmInternal.setSystemProperty(testPropertyKey1, null); |
125 assertTrue("No exception1: "+ res, false); |
126 assertTrue("No exception1: "+ res, false); |
143 // Set a new value to same user property and check that it was correctly set. |
144 // Set a new value to same user property and check that it was correctly set. |
144 JvmInternal.setUserProperty(testPropertyKey2, testPropertyVal4); |
145 JvmInternal.setUserProperty(testPropertyKey2, testPropertyVal4); |
145 res = System.getProperty(testPropertyKey2); |
146 res = System.getProperty(testPropertyKey2); |
146 assertTrue("Fail7, got: "+ res, testPropertyVal4.equals(res)); |
147 assertTrue("Fail7, got: "+ res, testPropertyVal4.equals(res)); |
147 |
148 |
148 // Set a null value to same user property and check that an |
149 // Set a null value to same user property and check that an |
149 // exception is thrown and the value is not changed. |
150 // exception is thrown and the value is not changed. |
150 try |
151 try |
151 { |
152 { |
152 JvmInternal.setSystemProperty(testPropertyKey2, null); |
153 JvmInternal.setSystemProperty(testPropertyKey2, null); |
153 assertTrue("No exception2: "+ res, false); |
154 assertTrue("No exception2: "+ res, false); |
156 { |
157 { |
157 } |
158 } |
158 res = System.getProperty(testPropertyKey2); |
159 res = System.getProperty(testPropertyKey2); |
159 assertTrue("Fail8, got: "+ res, testPropertyVal4.equals(res)); |
160 assertTrue("Fail8, got: "+ res, testPropertyVal4.equals(res)); |
160 |
161 |
161 // Set the same system and user property and check that the user property |
162 // Set the same system and user property and check that the user property |
162 // doesn't override the system property. |
163 // doesn't override the system property. |
163 JvmInternal.setSystemProperty(testPropertyKey3, testPropertyVal5); |
164 JvmInternal.setSystemProperty(testPropertyKey3, testPropertyVal5); |
164 JvmInternal.setUserProperty(testPropertyKey3, testPropertyVal6); |
165 JvmInternal.setUserProperty(testPropertyKey3, testPropertyVal6); |
165 res = System.getProperty(testPropertyKey3); |
166 res = System.getProperty(testPropertyKey3); |
166 assertTrue("Fail9, got: "+ res, testPropertyVal5.equals(res)); |
167 assertTrue("Fail9, got: "+ res, testPropertyVal5.equals(res)); |