< prev index next >

test/jdk/jdk/jfr/jmx/security/TestNotificationListenerPermission.java

Print this page
rev 51054 : imported patch 9000013-aixDisableJFR-requires.patch


  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.jmx.security;
  27 
  28 import java.lang.management.ManagementFactory;
  29 import java.util.concurrent.CountDownLatch;
  30 
  31 import javax.management.Notification;
  32 import javax.management.NotificationListener;
  33 import javax.management.ObjectName;
  34 
  35 import jdk.management.jfr.FlightRecorderMXBean;
  36 import jdk.test.lib.Asserts;
  37 
  38 import jdk.jfr.jmx.JmxHelper;
  39 
  40 /*
  41  * @test
  42  * @key jfr
  43  * @summary Test with minimal needed permissions. All functions should work.

  44  * @library /test/lib /test/jdk
  45  * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=listener.policy jdk.jfr.jmx.security.TestNotificationListenerPermission
  46  */
  47 public class TestNotificationListenerPermission {
  48     private static boolean gotSecurityException;
  49 
  50     static class TestListener implements NotificationListener {
  51         private final CountDownLatch latch = new CountDownLatch(1);
  52 
  53         @Override
  54         public void handleNotification(Notification arg0, Object arg1) {
  55             try {
  56                 System.getProperty("user.name");
  57             } catch (SecurityException se) {
  58                 se.printStackTrace();
  59                 gotSecurityException = true;
  60             }
  61             latch.countDown();
  62         }
  63 




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.jmx.security;
  27 
  28 import java.lang.management.ManagementFactory;
  29 import java.util.concurrent.CountDownLatch;
  30 
  31 import javax.management.Notification;
  32 import javax.management.NotificationListener;
  33 import javax.management.ObjectName;
  34 
  35 import jdk.management.jfr.FlightRecorderMXBean;
  36 import jdk.test.lib.Asserts;
  37 
  38 import jdk.jfr.jmx.JmxHelper;
  39 
  40 /**
  41  * @test
  42  * @key jfr
  43  * @summary Test with minimal needed permissions. All functions should work.
  44  * @requires vm.hasJFR
  45  * @library /test/lib /test/jdk
  46  * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=listener.policy jdk.jfr.jmx.security.TestNotificationListenerPermission
  47  */
  48 public class TestNotificationListenerPermission {
  49     private static boolean gotSecurityException;
  50 
  51     static class TestListener implements NotificationListener {
  52         private final CountDownLatch latch = new CountDownLatch(1);
  53 
  54         @Override
  55         public void handleNotification(Notification arg0, Object arg1) {
  56             try {
  57                 System.getProperty("user.name");
  58             } catch (SecurityException se) {
  59                 se.printStackTrace();
  60                 gotSecurityException = true;
  61             }
  62             latch.countDown();
  63         }
  64 


< prev index next >