author | dfuchs |
Sun, 22 Dec 2013 11:20:07 +0100 | |
changeset 22086 | 866b0a7d0127 |
parent 21663 | f364900c7cc5 |
child 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
1 |
/* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
4 |
* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
8 |
* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
13 |
* accompanied this code). |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
14 |
* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
18 |
* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
21 |
* questions. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
22 |
*/ |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
23 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
24 |
import java.security.CodeSource; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
25 |
import java.security.Permission; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
26 |
import java.security.PermissionCollection; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
27 |
import java.security.Permissions; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
28 |
import java.security.Policy; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
29 |
import java.security.ProtectionDomain; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
30 |
import java.util.EnumSet; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
31 |
import java.util.HashMap; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
32 |
import java.util.Map; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
33 |
import java.util.logging.LogManager; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
34 |
import java.util.logging.Logger; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
35 |
import java.util.logging.LoggingPermission; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
36 |
import sun.misc.JavaAWTAccess; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
37 |
import sun.misc.SharedSecrets; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
38 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
39 |
/* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
40 |
* @test |
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
41 |
* @bug 8017174 8010727 8019945 |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
42 |
* @summary NPE when using Logger.getAnonymousLogger or |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
43 |
* LogManager.getLogManager().getLogger |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
44 |
* |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
45 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext LoadingApplet |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
46 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext LoadingApplet |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
47 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext LoadingMain |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
48 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext LoadingMain |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
49 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext One |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
50 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext One |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
51 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext Two |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
52 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext Two |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
53 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext Three |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
54 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext Three |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
55 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext Four |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
56 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext Four |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
57 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext Five |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
58 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext Five |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
59 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext Six |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
60 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext Six |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
61 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext Seven |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
62 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext Seven |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
63 |
* @run main/othervm -Dtest.security=off TestAppletLoggerContext |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
64 |
* @run main/othervm -Dtest.security=on TestAppletLoggerContext |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
65 |
*/ |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
66 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
67 |
// NOTE: We run in other VM in order to 1. switch security manager and 2. cause |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
68 |
// LogManager class to be loaded anew. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
69 |
public class TestAppletLoggerContext { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
70 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
71 |
// Avoids the hassle of dealing with files and system props... |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
72 |
static class SimplePolicy extends Policy { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
73 |
private final Permissions perms; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
74 |
public SimplePolicy(Permission... permissions) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
75 |
perms = new Permissions(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
76 |
for (Permission permission : permissions) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
77 |
perms.add(permission); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
78 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
79 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
80 |
@Override |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
81 |
public PermissionCollection getPermissions(CodeSource cs) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
82 |
return perms; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
83 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
84 |
@Override |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
85 |
public PermissionCollection getPermissions(ProtectionDomain pd) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
86 |
return perms; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
87 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
88 |
@Override |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
89 |
public boolean implies(ProtectionDomain pd, Permission p) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
90 |
return perms.implies(p); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
91 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
92 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
93 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
94 |
// The bridge class initializes the logging system. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
95 |
// It stubs the applet context in order to simulate context changes. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
96 |
// |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
97 |
public static class Bridge { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
98 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
99 |
private static class JavaAWTAccessStub implements JavaAWTAccess { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
100 |
boolean active = true; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
101 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
102 |
private static class TestExc { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
103 |
private final Map<Object, Object> map = new HashMap<>(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
104 |
void put(Object key, Object v) { map.put(key, v); } |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
105 |
Object get(Object key) { return map.get(key); } |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
106 |
void remove(Object o) { map.remove(o); } |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
107 |
public static TestExc exc(Object o) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
108 |
return TestExc.class.cast(o); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
109 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
110 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
111 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
112 |
TestExc exc; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
113 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
114 |
@Override |
19809
dc0480c1b36c
8019853: Break logging and AWT circular dependency
dfuchs
parents:
18593
diff
changeset
|
115 |
public Object getAppletContext() { return active ? exc : null; } |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
116 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
117 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
118 |
final static JavaAWTAccessStub javaAwtAccess = new JavaAWTAccessStub(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
119 |
public static void init() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
120 |
SharedSecrets.setJavaAWTAccess(javaAwtAccess); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
121 |
if (System.getProperty("test.security", "on").equals("on")) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
122 |
Policy p = new SimplePolicy(new LoggingPermission("control", null), |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
123 |
new RuntimePermission("setContextClassLoader"), |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
124 |
new RuntimePermission("shutdownHooks")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
125 |
Policy.setPolicy(p); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
126 |
System.setSecurityManager(new SecurityManager()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
127 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
128 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
129 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
130 |
public static void changeContext() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
131 |
System.out.println("... Switching to a new applet context ..."); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
132 |
javaAwtAccess.active = true; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
133 |
javaAwtAccess.exc = new JavaAWTAccessStub.TestExc(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
134 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
135 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
136 |
public static void desactivate() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
137 |
System.out.println("... Running with no applet context ..."); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
138 |
javaAwtAccess.exc = null; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
139 |
javaAwtAccess.active = false; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
140 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
141 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
142 |
public static class CustomAnonymousLogger extends Logger { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
143 |
public CustomAnonymousLogger() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
144 |
this(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
145 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
146 |
public CustomAnonymousLogger(String name) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
147 |
super(null, null); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
148 |
System.out.println( " LogManager: " +LogManager.getLogManager()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
149 |
System.out.println( " getLogger: " +LogManager.getLogManager().getLogger(name)); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
150 |
setParent(LogManager.getLogManager().getLogger(name)); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
151 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
152 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
153 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
154 |
public static class CustomLogger extends Logger { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
155 |
CustomLogger(String name) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
156 |
super(name, null); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
157 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
158 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
159 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
160 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
161 |
public static enum TestCase { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
162 |
LoadingApplet, LoadingMain, One, Two, Three, Four, Five, Six, Seven; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
163 |
public void test() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
164 |
switch(this) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
165 |
// When run - each of these two tests must be |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
166 |
// run before any other tests and before each other. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
167 |
case LoadingApplet: testLoadingApplet(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
168 |
case LoadingMain: testLoadingMain(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
169 |
case One: testOne(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
170 |
case Two: testTwo(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
171 |
case Three: testThree(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
172 |
case Four: testFour(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
173 |
case Five: testFive(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
174 |
case Six: testSix(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
175 |
case Seven: testSeven(); break; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
176 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
177 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
178 |
public String describe() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
179 |
switch(this) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
180 |
case LoadingApplet: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
181 |
return "Test that when the LogManager class is" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
182 |
+ " loaded in an applet thread first," |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
183 |
+ "\n all LoggerContexts are correctly initialized"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
184 |
case LoadingMain: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
185 |
return "Test that when the LogManager class is" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
186 |
+ " loaded in the main thread first," |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
187 |
+ "\n all LoggerContexts are correctly initialized"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
188 |
case One: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
189 |
return "Test that Logger.getAnonymousLogger()" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
190 |
+ " and new CustomAnonymousLogger() don't throw NPE"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
191 |
case Two: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
192 |
return "Test that Logger.getLogger(\"\")" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
193 |
+ " does not return null nor throws NPE"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
194 |
case Three: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
195 |
return "Test that LogManager.getLogManager().getLogger(\"\")" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
196 |
+ " does not return null nor throws NPE"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
197 |
case Four: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
198 |
return "Test that Logger.getLogger(Logger.GLOBAL_LOGGER_NAME)" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
199 |
+ " does not return null,\n and that" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
200 |
+ " new CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME)" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
201 |
+ " does not throw NPE"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
202 |
case Five: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
203 |
return "Test that LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME)" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
204 |
+ "\n does not return null nor throws NPE"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
205 |
case Six: |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
206 |
return "Test that manager.getLogger(Logger.GLOBAL_LOGGER_NAME)" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
207 |
+ " returns null\n when manager is not the default" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
208 |
+ " LogManager instance.\n" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
209 |
+ "Test adding a new logger named \"global\" in that" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
210 |
+ " non default instance."; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
211 |
case Seven: return "Test that manager.getLogger(\"\")" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
212 |
+ " returns null\n when manager is not the default" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
213 |
+ " LogManager instance.\n" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
214 |
+ "Test adding a new logger named \"\" in that" |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
215 |
+ " non default instance."; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
216 |
default: return "Undefined"; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
217 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
218 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
219 |
}; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
220 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
221 |
/** |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
222 |
* @param args the command line arguments |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
223 |
*/ |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
224 |
public static void main(String[] args) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
225 |
Bridge.init(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
226 |
EnumSet<TestCase> tests = EnumSet.noneOf(TestCase.class); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
227 |
for (String arg : args) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
228 |
tests.add(TestCase.valueOf(arg)); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
229 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
230 |
if (args.length == 0) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
231 |
tests = EnumSet.complementOf(EnumSet.of(TestCase.LoadingMain)); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
232 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
233 |
final EnumSet<TestCase> loadingTests = |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
234 |
EnumSet.of(TestCase.LoadingApplet, TestCase.LoadingMain); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
235 |
int testrun = 0; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
236 |
for (TestCase test : tests) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
237 |
if (loadingTests.contains(test)) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
238 |
if (testrun > 0) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
239 |
throw new UnsupportedOperationException("Test case " |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
240 |
+ test + " must be executed first!"); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
241 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
242 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
243 |
System.out.println("Testing "+ test+": "); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
244 |
System.out.println(test.describe()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
245 |
try { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
246 |
test.test(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
247 |
} catch (Exception x) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
248 |
throw new Error(String.valueOf(test) |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
249 |
+ (System.getSecurityManager() == null ? " without " : " with ") |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
250 |
+ "security failed: "+x+"\n "+"FAILED: "+test.describe()+"\n", x); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
251 |
} finally { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
252 |
testrun++; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
253 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
254 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
255 |
System.out.println("PASSED: "+ test); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
256 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
257 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
258 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
259 |
public static void testLoadingApplet() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
260 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
261 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
262 |
Logger bar = new Bridge.CustomLogger("com.foo.Bar"); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
263 |
LogManager.getLogManager().addLogger(bar); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
264 |
assertNotNull(bar.getParent()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
265 |
testParent(bar); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
266 |
testParent(LogManager.getLogManager().getLogger("global")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
267 |
testParent(LogManager.getLogManager().getLogger(bar.getName())); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
268 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
269 |
Bridge.desactivate(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
270 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
271 |
Logger foo = new Bridge.CustomLogger("com.foo.Foo"); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
272 |
boolean b = LogManager.getLogManager().addLogger(foo); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
273 |
assertEquals(Boolean.TRUE, Boolean.valueOf(b)); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
274 |
assertNotNull(foo.getParent()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
275 |
testParent(foo); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
276 |
testParent(LogManager.getLogManager().getLogger("global")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
277 |
testParent(LogManager.getLogManager().getLogger(foo.getName())); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
278 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
279 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
280 |
public static void testLoadingMain() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
281 |
Bridge.desactivate(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
282 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
283 |
Logger bar = new Bridge.CustomLogger("com.foo.Bar"); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
284 |
LogManager.getLogManager().addLogger(bar); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
285 |
assertNotNull(bar.getParent()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
286 |
testParent(bar); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
287 |
testParent(LogManager.getLogManager().getLogger("global")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
288 |
testParent(LogManager.getLogManager().getLogger(bar.getName())); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
289 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
290 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
291 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
292 |
Logger foo = new Bridge.CustomLogger("com.foo.Foo"); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
293 |
boolean b = LogManager.getLogManager().addLogger(foo); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
294 |
assertEquals(Boolean.TRUE, Boolean.valueOf(b)); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
295 |
assertNotNull(foo.getParent()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
296 |
testParent(foo); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
297 |
testParent(LogManager.getLogManager().getLogger("global")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
298 |
testParent(LogManager.getLogManager().getLogger(foo.getName())); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
299 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
300 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
301 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
302 |
public static void testOne() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
303 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
304 |
Logger logger1 = Logger.getAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
305 |
Logger logger1b = Logger.getAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
306 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
307 |
Logger logger2 = Logger.getAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
308 |
Logger logger2b = Logger.getAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
309 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
310 |
Logger logger3 = new Bridge.CustomAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
311 |
Logger logger3b = new Bridge.CustomAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
312 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
313 |
Logger logger4 = new Bridge.CustomAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
314 |
Logger logger4b = new Bridge.CustomAnonymousLogger(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
315 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
316 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
317 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
318 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
319 |
public static void testTwo() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
320 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
321 |
Logger logger1 = Logger.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
322 |
Logger logger1b = Logger.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
323 |
assertNotNull(logger1); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
324 |
assertNotNull(logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
325 |
assertEquals(logger1, logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
326 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
327 |
Logger logger2 = Logger.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
328 |
Logger logger2b = Logger.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
329 |
assertNotNull(logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
330 |
assertNotNull(logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
331 |
assertEquals(logger2, logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
332 |
assertEquals(logger1, logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
333 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
334 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
335 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
336 |
public static void testThree() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
337 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
338 |
Logger logger1 = LogManager.getLogManager().getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
339 |
Logger logger1b = LogManager.getLogManager().getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
340 |
assertNotNull(logger1); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
341 |
assertNotNull(logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
342 |
assertEquals(logger1, logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
343 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
344 |
Logger logger2 = LogManager.getLogManager().getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
345 |
Logger logger2b = LogManager.getLogManager().getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
346 |
assertNotNull(logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
347 |
assertNotNull(logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
348 |
assertEquals(logger2, logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
349 |
assertEquals(logger1, logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
350 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
351 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
352 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
353 |
public static void testFour() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
354 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
355 |
Logger logger1 = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
356 |
Logger logger1b = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
357 |
assertNotNull(logger1); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
358 |
assertNotNull(logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
359 |
assertEquals(logger1, logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
360 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
361 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
362 |
Logger logger2 = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
363 |
Logger logger2b = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
364 |
assertNotNull(logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
365 |
assertNotNull(logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
366 |
assertEquals(logger2, logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
367 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
368 |
assertEquals(logger1, logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
369 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
370 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
371 |
Logger logger3 = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
372 |
Logger logger3b = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
373 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
374 |
Logger logger4 = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
375 |
Logger logger4b = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
376 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
377 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
378 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
379 |
public static void testFive() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
380 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
381 |
Logger logger1 = LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
382 |
Logger logger1b = LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
383 |
assertNotNull(logger1); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
384 |
assertNotNull(logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
385 |
assertEquals(logger1, logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
386 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
387 |
Bridge.changeContext(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
388 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
389 |
Logger logger2 = LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
390 |
Logger logger2b = LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
391 |
assertNotNull(logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
392 |
assertNotNull(logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
393 |
assertEquals(logger2, logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
394 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
395 |
assertEquals(logger1, logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
396 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
397 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
398 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
399 |
/** |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
400 |
* This test is designed to test the behavior of additional LogManager instances. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
401 |
* It must be noted that if the security manager is off, then calling |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
402 |
* Bridge.changeContext() has actually no effect - which explains why we have |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
403 |
* some differences between the cases security manager on & security manager |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
404 |
* off. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
405 |
**/ |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
406 |
public static void testSix() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
407 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
408 |
Bridge.desactivate(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
409 |
LogManager manager = new LogManager() {}; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
410 |
Logger logger1 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
411 |
Logger logger1b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
412 |
assertNull(logger1); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
413 |
assertNull(logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
414 |
Logger global = new Bridge.CustomLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
415 |
manager.addLogger(global); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
416 |
Logger logger2 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
417 |
Logger logger2b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
418 |
assertNotNull(logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
419 |
assertNotNull(logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
420 |
assertEquals(logger2, global); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
421 |
assertEquals(logger2b, global); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
422 |
assertNull(manager.getLogger("")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
423 |
assertNull(manager.getLogger("")); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
424 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
425 |
for (int j = 0; j<3; j++) { |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
426 |
Bridge.changeContext(); |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
427 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
428 |
// this is not a supported configuration: |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
429 |
// We are in an applet context with several log managers. |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
430 |
// We however need to check our assumptions... |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
431 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
432 |
// Applet context => root logger and global logger should also be null. |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
433 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
434 |
Logger expected = (System.getSecurityManager() == null ? global : null); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
435 |
Logger logger3 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
436 |
Logger logger3b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
437 |
assertEquals(expected, logger3); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
438 |
assertEquals(expected, logger3b); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
439 |
Logger global2 = new Bridge.CustomLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
440 |
manager.addLogger(global2); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
441 |
Logger logger4 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
442 |
Logger logger4b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
443 |
assertNotNull(logger4); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
444 |
assertNotNull(logger4b); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
445 |
expected = (System.getSecurityManager() == null ? global : global2);; |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
446 |
assertEquals(logger4, expected); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
447 |
assertEquals(logger4b, expected); |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
448 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
449 |
Logger logger5 = manager.getLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
450 |
Logger logger5b = manager.getLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
451 |
Logger expectedRoot = null; |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
452 |
assertEquals(logger5, expectedRoot); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
453 |
assertEquals(logger5b, expectedRoot); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
454 |
} |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
455 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
456 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
457 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
458 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
459 |
/** |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
460 |
* This test is designed to test the behavior of additional LogManager instances. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
461 |
* It must be noted that if the security manager is off, then calling |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
462 |
* Bridge.changeContext() has actually no effect - which explains why we have |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
463 |
* some differences between the cases security manager on & security manager |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
464 |
* off. |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
465 |
**/ |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
466 |
public static void testSeven() { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
467 |
for (int i=0; i<3 ; i++) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
468 |
Bridge.desactivate(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
469 |
LogManager manager = new LogManager() {}; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
470 |
Logger logger1 = manager.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
471 |
Logger logger1b = manager.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
472 |
assertNull(logger1); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
473 |
assertNull(logger1b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
474 |
Logger global = new Bridge.CustomLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
475 |
manager.addLogger(global); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
476 |
Logger logger2 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
477 |
Logger logger2b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
478 |
assertNotNull(logger2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
479 |
assertNotNull(logger2b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
480 |
assertEquals(logger2, global); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
481 |
assertEquals(logger2b, global); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
482 |
Logger logger3 = manager.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
483 |
Logger logger3b = manager.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
484 |
assertNull(logger3); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
485 |
assertNull(logger3b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
486 |
Logger root = new Bridge.CustomLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
487 |
manager.addLogger(root); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
488 |
Logger logger4 = manager.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
489 |
Logger logger4b = manager.getLogger(""); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
490 |
assertNotNull(logger4); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
491 |
assertNotNull(logger4b); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
492 |
assertEquals(logger4, root); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
493 |
assertEquals(logger4b, root); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
494 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
495 |
for (int j = 0 ; j < 3 ; j++) { |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
496 |
Bridge.changeContext(); |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
497 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
498 |
// this is not a supported configuration: |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
499 |
// We are in an applet context with several log managers. |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
500 |
// We however need to check our assumptions... |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
501 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
502 |
// Applet context => root logger and global logger should also be null. |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
503 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
504 |
Logger logger5 = manager.getLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
505 |
Logger logger5b = manager.getLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
506 |
Logger expectedRoot = (System.getSecurityManager() == null ? root : null); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
507 |
assertEquals(logger5, expectedRoot); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
508 |
assertEquals(logger5b, expectedRoot); |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
509 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
510 |
if (System.getSecurityManager() != null) { |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
511 |
assertNull(manager.getLogger(Logger.GLOBAL_LOGGER_NAME)); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
512 |
} else { |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
513 |
assertEquals(global, manager.getLogger(Logger.GLOBAL_LOGGER_NAME)); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
514 |
} |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
515 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
516 |
Logger global2 = new Bridge.CustomLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
517 |
manager.addLogger(global2); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
518 |
Logger logger6 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
519 |
Logger logger6b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
520 |
Logger expectedGlobal = (System.getSecurityManager() == null ? global : global2); |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
521 |
|
19825
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
522 |
assertNotNull(logger6); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
523 |
assertNotNull(logger6b); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
524 |
assertEquals(logger6, expectedGlobal); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
525 |
assertEquals(logger6b, expectedGlobal); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
526 |
if (System.getSecurityManager() != null) { |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
527 |
assertNull(manager.getLogger("")); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
528 |
} else { |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
529 |
assertEquals(root, manager.getLogger("")); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
530 |
} |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
531 |
|
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
532 |
Logger root2 = new Bridge.CustomLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
533 |
manager.addLogger(root2); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
534 |
expectedRoot = (System.getSecurityManager() == null ? root : root2); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
535 |
Logger logger7 = manager.getLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
536 |
Logger logger7b = manager.getLogger(""); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
537 |
assertNotNull(logger7); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
538 |
assertNotNull(logger7b); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
539 |
assertEquals(logger7, expectedRoot); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
540 |
assertEquals(logger7b, expectedRoot); |
a7e79bc2e437
8023168: Cleanup LogManager class initialization and LogManager/LoggerContext relationship
dfuchs
parents:
19809
diff
changeset
|
541 |
} |
18593
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
542 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
543 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
544 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
545 |
public static void testParent(Logger logger) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
546 |
Logger l = logger; |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
547 |
while (l.getParent() != null) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
548 |
l = l.getParent(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
549 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
550 |
assertEquals("", l.getName()); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
551 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
552 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
553 |
public static class TestError extends RuntimeException { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
554 |
public TestError(String msg) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
555 |
super(msg); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
556 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
557 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
558 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
559 |
public static void assertNotNull(Object obj) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
560 |
if (obj == null) throw new NullPointerException(); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
561 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
562 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
563 |
public static void assertNull(Object obj) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
564 |
if (obj != null) throw new TestError("Null expected, got "+obj); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
565 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
566 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
567 |
public static void assertEquals(Object o1, Object o2) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
568 |
if (o1 != o2) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
569 |
throw new TestError(o1 + " != " + o2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
570 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
571 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
572 |
|
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
573 |
public static void assertNotEquals(Object o1, Object o2) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
574 |
if (o1 == o2) { |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
575 |
throw new TestError(o1 + " == " + o2); |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
576 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
577 |
} |
40715ebb6681
8017174: NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger
dfuchs
parents:
diff
changeset
|
578 |
} |