File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
src/test/java/de/rieckpil/blog/jfrunit Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 4242 <jgiven-maven-plugin .version>2.0.1</jgiven-maven-plugin .version>
4343 <junit-jupiter .version>5.11.4</junit-jupiter .version>
4444 <spring-cloud-aws .version>3.3.0</spring-cloud-aws .version>
45+ <jfrunit .version>1.0.0.Alpha2</jfrunit .version>
4546 </properties >
4647
4748 <dependencyManagement >
289290 <version >${gatling.version} </version >
290291 <scope >test</scope >
291292 </dependency >
293+ <dependency >
294+ <groupId >org.moditect.jfrunit</groupId >
295+ <artifactId >jfrunit-core</artifactId >
296+ <version >${jfrunit.version} </version >
297+ <scope >test</scope >
298+ </dependency >
292299
293300 <!-- Behavior Driven Development using JGiven -->
294301 <dependency >
Original file line number Diff line number Diff line change 1+ package de .rieckpil .blog .jfrunit ;
2+
3+ public class BusinessService {
4+
5+ void performTask () {
6+
7+ System .out .println ("Performing task ..." );
8+
9+ try {
10+ Thread .sleep (1000L );
11+ System .gc ();
12+ }
13+ catch (InterruptedException e ) {
14+ throw new RuntimeException (e );
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ package de .rieckpil .blog .jfrunit ;
2+
3+ import java .time .Duration ;
4+
5+ import org .junit .jupiter .api .Test ;
6+ import org .moditect .jfrunit .EnableEvent ;
7+ import org .moditect .jfrunit .JfrEventTest ;
8+ import org .moditect .jfrunit .JfrEvents ;
9+ import org .moditect .jfrunit .events .GarbageCollection ;
10+ import org .moditect .jfrunit .events .JfrEventTypes ;
11+ import org .moditect .jfrunit .events .ThreadSleep ;
12+
13+ import static org .moditect .jfrunit .JfrEventsAssert .assertThat ;
14+
15+ @ JfrEventTest
16+ public class PerformanceTest {
17+
18+ public JfrEvents jfrEvents = new JfrEvents ();
19+
20+ @ Test
21+ @ EnableEvent (GarbageCollection .EVENT_NAME )
22+ @ EnableEvent (ThreadSleep .EVENT_NAME )
23+ void shouldExecuteWithinTimeLimit () {
24+
25+ new BusinessService ().performTask ();
26+
27+ assertThat (jfrEvents )
28+ .contains (JfrEventTypes .GARBAGE_COLLECTION );
29+
30+ assertThat (jfrEvents ).contains (
31+ JfrEventTypes .THREAD_SLEEP .withTime (Duration .ofMillis (1000 )));
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments