< prev index next >

test/jdk/jdk/jfr/event/io/TestFileReadOnly.java

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


  23  * questions.
  24  */
  25 
  26 package jdk.jfr.event.io;
  27 
  28 import static jdk.test.lib.Asserts.fail;
  29 
  30 import java.io.File;
  31 import java.io.IOException;
  32 import java.io.RandomAccessFile;
  33 import java.nio.ByteBuffer;
  34 import java.nio.channels.FileChannel;
  35 import java.time.Duration;
  36 import java.util.ArrayList;
  37 import java.util.List;
  38 
  39 import jdk.jfr.Recording;
  40 import jdk.jfr.consumer.RecordedEvent;
  41 import jdk.test.lib.jfr.Events;
  42 
  43 /*
  44  * @test
  45  * @key jfr

  46  * @library /test/lib /test/jdk
  47  * @run main/othervm jdk.jfr.event.io.TestFileReadOnly
  48  */
  49 public class TestFileReadOnly {
  50 
  51     public static void main(String[] args) throws Throwable {
  52         File tmp = File.createTempFile("TestFileReadOnly", ".tmp", new File("."));
  53         tmp.deleteOnExit();
  54         Recording recording = new Recording();
  55         List<IOEvent> expectedEvents = new ArrayList<>();
  56 
  57         recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0));
  58         recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0));
  59         recording.start();
  60 
  61         final byte[] buf = { 1, 2, 3 };
  62 
  63         // Create the file.
  64         try (RandomAccessFile f = new RandomAccessFile(tmp, "rw")) {
  65             f.write(buf);




  23  * questions.
  24  */
  25 
  26 package jdk.jfr.event.io;
  27 
  28 import static jdk.test.lib.Asserts.fail;
  29 
  30 import java.io.File;
  31 import java.io.IOException;
  32 import java.io.RandomAccessFile;
  33 import java.nio.ByteBuffer;
  34 import java.nio.channels.FileChannel;
  35 import java.time.Duration;
  36 import java.util.ArrayList;
  37 import java.util.List;
  38 
  39 import jdk.jfr.Recording;
  40 import jdk.jfr.consumer.RecordedEvent;
  41 import jdk.test.lib.jfr.Events;
  42 
  43 /**
  44  * @test
  45  * @key jfr
  46  * @requires vm.hasJFR
  47  * @library /test/lib /test/jdk
  48  * @run main/othervm jdk.jfr.event.io.TestFileReadOnly
  49  */
  50 public class TestFileReadOnly {
  51 
  52     public static void main(String[] args) throws Throwable {
  53         File tmp = File.createTempFile("TestFileReadOnly", ".tmp", new File("."));
  54         tmp.deleteOnExit();
  55         Recording recording = new Recording();
  56         List<IOEvent> expectedEvents = new ArrayList<>();
  57 
  58         recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0));
  59         recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0));
  60         recording.start();
  61 
  62         final byte[] buf = { 1, 2, 3 };
  63 
  64         // Create the file.
  65         try (RandomAccessFile f = new RandomAccessFile(tmp, "rw")) {
  66             f.write(buf);


< prev index next >