Java Code Examples for java.util.logging.Logger#setResourceBundle()
The following examples show how to use
java.util.logging.Logger#setResourceBundle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSetResourceBundle.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 2
Source File: TestSetResourceBundle.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 3
Source File: TestSetResourceBundle.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 4
Source File: TestSetResourceBundle.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 5
Source File: TestSetResourceBundle.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 6
Source File: TestSetResourceBundle.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 7
Source File: TestSetResourceBundle.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 8
Source File: TestSetResourceBundle.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 9
Source File: TestSetResourceBundle.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 10
Source File: TestSetResourceBundle.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test the LoggingPermission("control") is required. * @param loggerName The logger to use. */ public static void testPermission(String loggerName) { if (System.getSecurityManager() != null) { throw new Error("Security manager is already set"); } Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); System.setSecurityManager(new SecurityManager()); final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); try { foobar.setResourceBundle(bundle); throw new RuntimeException("Permission not checked!"); } catch (AccessControlException x) { if (x.getPermission() instanceof LoggingPermission) { if ("control".equals(x.getPermission().getName())) { System.out.println("Got expected exception: " + x); return; } } throw new RuntimeException("Unexpected exception: "+x, x); } }
Example 11
Source File: TestAnonymousLogger.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 12
Source File: TestAnonymousLogger.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 13
Source File: TestAnonymousLogger.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 14
Source File: TestAnonymousLogger.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 15
Source File: TestAnonymousLogger.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 16
Source File: TestAnonymousLogger.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 17
Source File: TestAnonymousLogger.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 18
Source File: TestAnonymousLogger.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 19
Source File: TestAnonymousLogger.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 20
Source File: TestAnonymousLogger.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }