< prev index next >

test/jdk/jdk/jfr/api/recording/destination/TestDestInvalid.java

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


  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.api.recording.destination;
  27 
  28 import java.io.IOException;
  29 import java.nio.file.Files;
  30 import java.nio.file.Path;
  31 import java.nio.file.Paths;
  32 import java.util.List;
  33 
  34 import jdk.jfr.Recording;
  35 import jdk.jfr.consumer.RecordedEvent;
  36 import jdk.jfr.consumer.RecordingFile;
  37 import jdk.test.lib.Asserts;
  38 import jdk.test.lib.jfr.CommonHelper;
  39 import jdk.test.lib.jfr.EventNames;
  40 import jdk.test.lib.jfr.VoidFunction;
  41 
  42 /*
  43  * @test
  44  * @summary Test setDestination to invalid paths
  45  * @key jfr

  46  * @library /test/lib
  47  * @run main/othervm jdk.jfr.api.recording.destination.TestDestInvalid
  48  */
  49 public class TestDestInvalid {
  50 
  51     public static void main(String[] args) throws Throwable {
  52         Recording r = new Recording();
  53         r.enable(EventNames.OSInformation);
  54         r.setToDisk(true);
  55 
  56         Asserts.assertNull(r.getDestination(), "dest not null by default");
  57 
  58         // Set destination to empty path (same as curr dir, not a file)
  59         verifyException(()->{r.setDestination(Paths.get(""));}, "No exception for setDestination(\"\")", IOException.class);
  60         System.out.println("1 destination: " + r.getDestination());
  61         Asserts.assertNull(r.getDestination(), "default dest not null after failed setDest");
  62 
  63         // Set dest to a valid path. This should be kept when a new setDest fails.
  64         Path dest = Paths.get(".", "my.jfr");
  65         r.setDestination(dest);




  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.api.recording.destination;
  27 
  28 import java.io.IOException;
  29 import java.nio.file.Files;
  30 import java.nio.file.Path;
  31 import java.nio.file.Paths;
  32 import java.util.List;
  33 
  34 import jdk.jfr.Recording;
  35 import jdk.jfr.consumer.RecordedEvent;
  36 import jdk.jfr.consumer.RecordingFile;
  37 import jdk.test.lib.Asserts;
  38 import jdk.test.lib.jfr.CommonHelper;
  39 import jdk.test.lib.jfr.EventNames;
  40 import jdk.test.lib.jfr.VoidFunction;
  41 
  42 /**
  43  * @test
  44  * @summary Test setDestination to invalid paths
  45  * @key jfr
  46  * @requires vm.hasJFR
  47  * @library /test/lib
  48  * @run main/othervm jdk.jfr.api.recording.destination.TestDestInvalid
  49  */
  50 public class TestDestInvalid {
  51 
  52     public static void main(String[] args) throws Throwable {
  53         Recording r = new Recording();
  54         r.enable(EventNames.OSInformation);
  55         r.setToDisk(true);
  56 
  57         Asserts.assertNull(r.getDestination(), "dest not null by default");
  58 
  59         // Set destination to empty path (same as curr dir, not a file)
  60         verifyException(()->{r.setDestination(Paths.get(""));}, "No exception for setDestination(\"\")", IOException.class);
  61         System.out.println("1 destination: " + r.getDestination());
  62         Asserts.assertNull(r.getDestination(), "default dest not null after failed setDest");
  63 
  64         // Set dest to a valid path. This should be kept when a new setDest fails.
  65         Path dest = Paths.get(".", "my.jfr");
  66         r.setDestination(dest);


< prev index next >