2424import static java .nio .file .Files .createDirectories ;
2525import static java .nio .file .Files .write ;
2626import static java .util .Arrays .asList ;
27+ import static java .util .Objects .requireNonNull ;
2728import static org .hamcrest .MatcherAssert .assertThat ;
28- import static org .hamcrest .Matchers .allOf ;
29- import static org .hamcrest .Matchers .containsString ;
30- import static org .hamcrest .Matchers .is ;
31- import static org .hamcrest .Matchers .not ;
29+ import static org .hamcrest .Matchers .*;
3230import static org .junit .jupiter .api .Assertions .assertThrows ;
3331import static org .junit .jupiter .api .Assertions .fail ;
3432
5654import org .junit .jupiter .api .AfterEach ;
5755import org .junit .jupiter .api .BeforeEach ;
5856import org .junit .jupiter .api .Test ;
57+ import org .junit .jupiter .api .io .TempDir ;
5958
6059public class StandaloneAcceptanceTest {
6160 private static final String FILES = "__files" ;
@@ -291,7 +290,7 @@ public void respondsWithPreExistingRecordingInProxyMode() throws Exception {
291290 }
292291
293292 @ Test
294- public void recordsProxiedRequestsWhenSpecifiedOnCommandLine () throws Exception {
293+ public void recordsProxiedRequestsWhenSpecifiedOnCommandLineViaLegacyRecorder () throws Exception {
295294 WireMock otherServerClient = startOtherServerAndClient ();
296295 startRunner ("--record-mappings" );
297296 givenThat (
@@ -310,7 +309,7 @@ public void recordsProxiedRequestsWhenSpecifiedOnCommandLine() throws Exception
310309 }
311310
312311 @ Test
313- public void recordsRequestHeadersWhenSpecifiedOnCommandLine () throws Exception {
312+ public void recordsRequestHeadersWhenSpecifiedOnCommandLineViaLegacyRecorder () throws Exception {
314313 WireMock otherServerClient = startOtherServerAndClient ();
315314 startRunner ("--record-mappings" , "--match-headers" , "Accept" );
316315 givenThat (
@@ -328,7 +327,7 @@ public void recordsRequestHeadersWhenSpecifiedOnCommandLine() throws Exception {
328327 }
329328
330329 @ Test
331- public void recordsGzippedResponseBodiesDecompressed () throws Exception {
330+ public void recordsGzippedResponseBodiesDecompressedViaLegacyRecorder () {
332331 WireMock otherServerClient = startOtherServerAndClient ();
333332 startRunner ("--record-mappings" );
334333 givenThat (
@@ -344,6 +343,24 @@ public void recordsGzippedResponseBodiesDecompressed() throws Exception {
344343 assertThat (filesDirectory , containsAFileContaining ("gzipped body" ));
345344 }
346345
346+ @ Test
347+ void recordsGzippedResponseBodiesDecompressedViaNewRecorder (@ TempDir Path tempFileRoot ) {
348+ WireMock target = startOtherServerAndClient ();
349+
350+ startRunner ("--root-dir" , tempFileRoot .toString ());
351+
352+ target .register (get ("/record-this" ).willReturn (ok ("Recorded" )));
353+
354+ startRecording (otherServer .baseUrl ());
355+ testClient .get ("/record-this" );
356+ stopRecording ();
357+
358+ assertThat (Arrays .stream (requireNonNull (tempFileRoot .resolve ("mappings" ).toFile ().list ()))
359+ .filter (name -> name .contains ("record-this" ))
360+ .findFirst ()
361+ .get (), endsWith (".json" ));
362+ }
363+
347364 @ Test
348365 public void matchesVeryLongHeader () {
349366 startRunner ("--jetty-header-buffer-size" , "32678" );
@@ -624,7 +641,7 @@ public void describeTo(Description desc) {
624641
625642 @ Override
626643 public boolean matchesSafely (File dir ) {
627- return Arrays .stream (Objects . requireNonNull (dir .list ())).noneMatch (contains (namePart ));
644+ return Arrays .stream (requireNonNull (dir .list ())).noneMatch (contains (namePart ));
628645 }
629646 };
630647 }
@@ -640,7 +657,7 @@ public void describeTo(Description desc) {
640657 @ Override
641658 public boolean matchesSafely (File dir ) {
642659 return (int )
643- Arrays .stream (Objects . requireNonNull (dir .list ())).filter (contains (namePart )).count ()
660+ Arrays .stream (requireNonNull (dir .list ())).filter (contains (namePart )).count ()
644661 == 1 ;
645662 }
646663 };
0 commit comments