equal
deleted
inserted
replaced
34 * @summary Tests that streaming doesn't work if |
34 * @summary Tests that streaming doesn't work if |
35 * FlightRecordingPermission("accessFlightRecorder") is missing |
35 * FlightRecordingPermission("accessFlightRecorder") is missing |
36 * @key jfr |
36 * @key jfr |
37 * @requires vm.hasJFR |
37 * @requires vm.hasJFR |
38 * @library /test/lib |
38 * @library /test/lib |
|
39 * |
39 * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=no-permission.policy |
40 * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=no-permission.policy |
40 * jdk.jfr.api.consumer.security.TestMissingPermission |
41 * jdk.jfr.api.consumer.security.TestMissingPermission |
41 */ |
42 */ |
42 public class TestMissingPermission { |
43 public class TestMissingPermission { |
43 |
44 |
47 } |
48 } |
48 |
49 |
49 private static void testRecordingStream() throws IOException { |
50 private static void testRecordingStream() throws IOException { |
50 try { |
51 try { |
51 try (EventStream es = EventStream.openRepository()) { |
52 try (EventStream es = EventStream.openRepository()) { |
52 fail(); |
53 throw new AssertionError("Should not be able to create EventStream without FlightRecorderPermission"); |
53 } |
54 } |
54 } catch (SecurityException se) { |
55 } catch (SecurityException se) { |
55 // OK, as expected |
56 // OK, as expected |
56 } |
57 } |
57 } |
58 } |
58 |
59 |
59 private static void testOpenRepository() throws IOException { |
60 private static void testOpenRepository() throws IOException { |
60 try { |
61 try { |
61 try (RecordingStream es = new RecordingStream()) { |
62 try (RecordingStream es = new RecordingStream()) { |
62 fail(); |
63 throw new AssertionError("Should not be able to create RecordingStream without FlightRecorderPermission"); |
63 } |
64 } |
64 } catch (SecurityException se) { |
65 } catch (SecurityException se) { |
65 // OK, as expected |
66 // OK, as expected |
66 } |
67 } |
67 } |
68 } |
68 |
|
69 private static void fail() { |
|
70 throw new AssertionError("Should not be able to create EventStream with FlightRecorderPermission"); |
|
71 } |
|
72 } |
69 } |