### Install JFRUnit JARs to Maven Repository Source: https://github.com/moditect/jfrunit/blob/main/README.md Execute this command to install the project's JAR files into your local Maven repository. Requires OpenJDK 16+ and Apache Maven. ```shell mvn install ``` -------------------------------- ### Spock Framework Test with JFR Events Source: https://github.com/moditect/jfrunit/blob/main/README.md An example of writing JfrUnit tests using the Spock Framework, showcasing its custom DSL for event assertions. ```groovy import org.moditect.jfrunit.JfrEvents import spock.lang.Specification import java.time.Duration class JfrSpec extends Specification { JfrEvents jfrEvents = new JfrEvents() @EnableEvent('jdk.GarbageCollection') @EnableEvent('jdk.ThreadSleep') def 'should Have GC And Sleep Events'() { when: System.gc() sleep(1000) then: jfrEvents['jdk.GarbageCollection'] jfrEvents['jdk.ThreadSleep'].withTime(Duration.ofMillis(1000)) } ``` -------------------------------- ### Java Test with JFR Events Source: https://github.com/moditect/jfrunit/blob/main/README.md Example of a Java test case using JfrUnit to assert specific JFR events like GarbageCollection and ThreadSleep. ```java import org.moditect.jfrunit.*; import static org.moditect.jfrunit.JfrEventsAssert.*; import static org.moditect.jfrunit.ExpectedEvent.*; import org.moditect.jfrunit.events.JfrEventTypes; @JfrEventTest public class JfrTest { public JfrEvents jfrEvents = new JfrEvents(); @Test @EnableEvent(GarbageCollection.EVENT_NAME) @EnableEvent(ThreadSleep.EVENT_NAME) public void shouldHaveGcAndSleepEvents() throws Exception { System.gc(); Thread.sleep(1000); jfrEvents.awaitEvents(); assertThat(jfrEvents).contains(JfrEventTypes.GARBAGE_COLLECTION); assertThat(jfrEvents).contains( JfrEventTypes.THREAD_SLEEP.withTime(Duration.ofMillis(1000))); } ``` -------------------------------- ### Build Moditect JFRUnit Source: https://github.com/moditect/jfrunit/blob/main/README.md Run this command to build the project. Requires OpenJDK 16+ and Apache Maven. ```shell mvn verify ``` -------------------------------- ### Enabling JFR Configuration Source: https://github.com/moditect/jfrunit/blob/main/README.md Shows how to use the @EnableConfiguration annotation to specify a JFR configuration file for event capturing. ```java @Test @EnableConfiguration("default") public void someTest() throws Exception { ... } ``` -------------------------------- ### Enabling JFR Events with Wildcards Source: https://github.com/moditect/jfrunit/blob/main/README.md Demonstrates using wildcard characters with the @EnableEvent annotation to capture multiple JFR event types. ```java @Test @EnableEvent("jdk.GC*") @EnableEvent("jdk.G1*") public void someTest() throws Exception { ... } ``` -------------------------------- ### Maven Dependency for JfrUnit Source: https://github.com/moditect/jfrunit/blob/main/README.md Add this dependency to your project's pom.xml to include JfrUnit for testing. ```xml org.moditect.jfrunit jfrunit-core 1.0.0.Alpha2 test ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.