1 /* |
|
2 * Copyright (c) 2009 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 package com.nokia.mj.impl.rt.test; |
|
18 |
|
19 /* |
|
20 -jcl:cdc11:nokiaextcdc -Dcom.nokia.jvm.port=j9.JvmPortCdc -Dcom.nokia.rt.port=midptest -Dcom.ibm.j9.ext.dirs=c:\java\jsr\classes\ -Dno_anonymous com.nokia.mj.impl.rt.midptest.MidpTest |
|
21 -jcl:cldc11:nokiaextcldc -Dcom.nokia.jvm.port=j9.JvmPortCldc -Dcom.nokia.rt.port=midptest -Dcom.ibm.j9.ext.dirs=c:\java\jsr\classes\ -Dno_anonymous com.nokia.mj.impl.rt.midptest.MidpTest |
|
22 |
|
23 java -Djava.ext.dirs=z:\epoc32\winscw\c\java\jsr\classes -Dcom.nokia.jvm.port=sun.JvmPortJ2se -Dcom.nokia.rt.port=midptest com.nokia.mj.impl.rt.midptest.MidpTest |
|
24 java -Djava.ext.dirs=${JAVA_BIN_ROOT}/jsr/classes -Dcom.nokia.jvm.port=sun.JvmPortJ2se -Dcom.nokia.rt.port=midptest com.nokia.mj.impl.rt.midptest.MidpTest |
|
25 |
|
26 |
|
27 |
|
28 AccessControllerImpl: |
|
29 |
|
30 private void init() |
|
31 { |
|
32 this.MSID = MSID; |
|
33 // grantedPermissions = null; // Read it from the storage |
|
34 grantedPermissions = new PolicyBasedPermission[1]; // Read it from the storage |
|
35 PolicyBasedPermissionImpl pi = new PolicyBasedPermissionImpl("com.nokia.mj.impl.rt.test.TestPermission","",null, 0); |
|
36 grantedPermissions[0] = pi; |
|
37 securityPromptHandler = new SecurityPromptHandler(); |
|
38 } |
|
39 |
|
40 */ |
|
41 |
|
42 import com.nokia.mj.impl.rt.support.*; |
|
43 import java.security.AccessControlException; |
|
44 |
|
45 public final class TestMain |
|
46 { |
|
47 static boolean useAnonymousApproach = true; |
|
48 |
|
49 public TestMain() |
|
50 { |
|
51 System.out.println("***TestMain()***\n"); |
|
52 System.out.println("java.version: " + System.getProperty("java.version")); |
|
53 System.out.println("java.fullversion: " + System.getProperty("java.fullversion")+"\n"); |
|
54 |
|
55 System.out.println("Test starts "); |
|
56 |
|
57 try |
|
58 { |
|
59 try |
|
60 { |
|
61 JvmInternal.enableRuntimeExit(); |
|
62 } |
|
63 catch (Throwable th) |
|
64 { |
|
65 } |
|
66 // Jvm.loadSystemLibrary(""); |
|
67 |
|
68 TestPermission p = new TestPermission("Test"); |
|
69 try |
|
70 { |
|
71 ApplicationUtils.getInstance().checkPermission(p); |
|
72 System.out.println("TestPermission1 ACCEPTED."); |
|
73 } |
|
74 catch (AccessControlException a) |
|
75 { |
|
76 System.out.println("TestPermission1 DENIED."); |
|
77 } |
|
78 catch (Throwable th) |
|
79 { |
|
80 System.out.println("TestPermission1 FAILED: " + th); |
|
81 th.printStackTrace(); |
|
82 } |
|
83 |
|
84 try |
|
85 { |
|
86 ApplicationUtils.getInstance().checkPermission(p, |
|
87 new PromptTextProvider() |
|
88 { |
|
89 public String[] getText() |
|
90 { |
|
91 String[] sa = new String[1]; |
|
92 sa[0] = "The Text"; |
|
93 return sa; |
|
94 } |
|
95 public String getText(int index) |
|
96 { |
|
97 if (index == 0) |
|
98 { |
|
99 return "The Text"; |
|
100 } |
|
101 return null; |
|
102 } |
|
103 } |
|
104 ); |
|
105 System.out.println("TestPermission3 ACCEPTED."); |
|
106 } |
|
107 catch (AccessControlException a) |
|
108 { |
|
109 System.out.println("TestPermission3 DENIED."); |
|
110 } |
|
111 catch (Throwable th) |
|
112 { |
|
113 System.out.println("TestPermission3 FAILED: " + th); |
|
114 th.printStackTrace(); |
|
115 } |
|
116 |
|
117 |
|
118 ApplicationInfo appInfo = ApplicationInfo.getInstance(); |
|
119 |
|
120 System.out.println("getRuntimeType: " + appInfo.getRuntimeType()); |
|
121 System.out.println("getProtectionDomain: " + appInfo.getProtectionDomain()); |
|
122 System.out.println("getUid: " + appInfo.getUid()); |
|
123 System.out.println("getSuiteUid: " + appInfo.getSuiteUid()); |
|
124 System.out.println("getSuiteName: " + appInfo.getSuiteName()); |
|
125 System.out.println("getName: " + appInfo.getName()); |
|
126 System.out.println("getVendor: " + appInfo.getVendor()); |
|
127 System.out.println("getVersion: " + appInfo.getVersion()); |
|
128 System.out.println("getRootPath: " + appInfo.getRootPath()); |
|
129 System.out.println("getMainClass: " + appInfo.getMainClass()); |
|
130 System.out.println("getAttribute: " + appInfo.getAttribute("MIDlet-1")); |
|
131 |
|
132 System.out.println("no_anonymous: " + System.getProperty("no_anonymous")); |
|
133 System.out.println("test.version: " + System.getProperty("test.version")); |
|
134 System.out.println("test2.version: " + System.getProperty("test2.version")); |
|
135 System.out.println("test3: " + System.getProperty("test3")); |
|
136 System.out.println("test.dynamic: " + System.getProperty("test.dynamic")); |
|
137 System.out.println("test.dynamic: " + System.getProperty("test.dynamic")); |
|
138 System.out.println("test.dynamic2: " + System.getProperty("test.dynamic2")); |
|
139 System.out.println("test.dynamic2: " + System.getProperty("test.dynamic2")); |
|
140 try |
|
141 { |
|
142 System.setProperty("testColon", ":colon"); |
|
143 java.util.Properties pr = System.getProperties(); |
|
144 System.out.println("CDC test.version: " + pr.getProperty("test.version")); |
|
145 System.out.println("CDC test.dynamic: " + pr.getProperty("test.dynamic")); |
|
146 System.out.println("CDC test.dynamic2: " + pr.getProperty("test.dynamic2")); |
|
147 System.out.println("CDC testColon: " + pr.getProperty("testColon")); |
|
148 // |
|
149 // pr.list(System.out); |
|
150 // pr.list(new java.io.PrintWriter(System.out)); |
|
151 } |
|
152 catch (Throwable th) |
|
153 { |
|
154 System.out.println("Skipping CLDC "+th); |
|
155 //th.printStackTrace(); |
|
156 } |
|
157 |
|
158 if (System.getProperty("no_anonymous") != null) |
|
159 { |
|
160 useAnonymousApproach = false; |
|
161 } |
|
162 System.out.println("Using anonymous = " + useAnonymousApproach); |
|
163 for (int k = 0; k< 1; k++) |
|
164 { |
|
165 new Test1(); |
|
166 new Test2(); |
|
167 new Test3(); |
|
168 new Test4(); |
|
169 new Test5(); |
|
170 new Test6(); |
|
171 } |
|
172 System.gc(); |
|
173 System.gc(); |
|
174 JvmInternal.runFinalization(); |
|
175 useAnonymousApproach = false; |
|
176 FinalizerStatistics.printStatus(); |
|
177 |
|
178 ApplicationUtils appUtils = ApplicationUtils.getInstance(); |
|
179 //Get the name of the application. |
|
180 appUtils.addShutdownListener(new ShutdownListener() |
|
181 { |
|
182 public void shuttingDown() |
|
183 { |
|
184 System.out.println("shuttingDown1"); |
|
185 } |
|
186 |
|
187 }); |
|
188 |
|
189 appUtils.addShutdownListener(new ShutdownListener() |
|
190 { |
|
191 public void shuttingDown() |
|
192 { |
|
193 System.out.println("shuttingDown2"); |
|
194 } |
|
195 |
|
196 }); |
|
197 |
|
198 appUtils.addShutdownListener(new ShutdownListener() |
|
199 { |
|
200 public void shuttingDown() |
|
201 { |
|
202 System.out.println("shuttingDown3"); |
|
203 } |
|
204 |
|
205 }); |
|
206 |
|
207 appUtils.addShutdownListener(new ShutdownListener() |
|
208 { |
|
209 public void shuttingDown() |
|
210 { |
|
211 System.out.println("shuttingDown4"); |
|
212 } |
|
213 |
|
214 }); |
|
215 |
|
216 appUtils.notifyExitCmd(); |
|
217 |
|
218 |
|
219 |
|
220 } |
|
221 |
|
222 catch (Throwable th) |
|
223 { |
|
224 System.err.println("Error in tests: "+th); |
|
225 th.printStackTrace(); |
|
226 } |
|
227 System.out.println("Test ends "); |
|
228 } |
|
229 |
|
230 } |
|
231 |
|