< prev index next >

test/jdk/jdk/jfr/api/recording/event/TestThreshold.java

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


  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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.api.recording.event;
  27 
  28 import java.time.Duration;
  29 import java.util.List;
  30 
  31 import jdk.jfr.Event;
  32 import jdk.jfr.Recording;
  33 import jdk.jfr.consumer.RecordedEvent;
  34 import jdk.test.lib.Asserts;
  35 import jdk.test.lib.jfr.Events;
  36 
  37 /*
  38  * @test
  39  * @summary Test event threshold.
  40  * @key jfr

  41  * @library /test/lib
  42  * @run main/othervm jdk.jfr.api.recording.event.TestThreshold
  43  */
  44 public class TestThreshold {
  45 
  46     public static void main(String[] args) throws Throwable {
  47         Recording r = new Recording();
  48 
  49         r.start();
  50         r.enable(MyEvent.class).withThreshold(Duration.ofMillis(500));
  51         createEvent(0, 100);
  52         createEvent(1, 600);
  53         createEvent(2, 100);
  54         r.stop();
  55 
  56         List<RecordedEvent> events = Events.fromRecording(r);
  57         Asserts.assertTrue(1 <= events.size(), "Should get at most 1 event");
  58         r.close();
  59     }
  60 




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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.api.recording.event;
  27 
  28 import java.time.Duration;
  29 import java.util.List;
  30 
  31 import jdk.jfr.Event;
  32 import jdk.jfr.Recording;
  33 import jdk.jfr.consumer.RecordedEvent;
  34 import jdk.test.lib.Asserts;
  35 import jdk.test.lib.jfr.Events;
  36 
  37 /**
  38  * @test
  39  * @summary Test event threshold.
  40  * @key jfr
  41  * @requires vm.hasJFR
  42  * @library /test/lib
  43  * @run main/othervm jdk.jfr.api.recording.event.TestThreshold
  44  */
  45 public class TestThreshold {
  46 
  47     public static void main(String[] args) throws Throwable {
  48         Recording r = new Recording();
  49 
  50         r.start();
  51         r.enable(MyEvent.class).withThreshold(Duration.ofMillis(500));
  52         createEvent(0, 100);
  53         createEvent(1, 600);
  54         createEvent(2, 100);
  55         r.stop();
  56 
  57         List<RecordedEvent> events = Events.fromRecording(r);
  58         Asserts.assertTrue(1 <= events.size(), "Should get at most 1 event");
  59         r.close();
  60     }
  61 


< prev index next >