1919import nl .altindag .crip .CertificateRipper ;
2020import nl .altindag .crip .request .Request ;
2121import org .awaitility .Awaitility ;
22- import org .junit .jupiter .api .Disabled ;
2322import org .junit .jupiter .api .Test ;
2423
2524import java .io .IOException ;
2928
3029import static org .assertj .core .api .Assertions .assertThat ;
3130
32- @ Disabled
3331class FtpClientRunnableIT {
3432
3533 private static final Pattern CAPTURED_CERTIFICATES = Pattern .compile ("\\ * [1-9]+: ftps://localhost:2231" );
3634
3735 @ Test
38- void shouldPrintCertificates () throws IOException {
36+ void shouldPrintCertificates () throws IOException , InterruptedException {
3937 URL dockerComposeFile = FtpClientRunnableIT .class .getClassLoader ().getResource ("docker-compose/ftp/docker-compose.yaml" );
4038 assertThat (dockerComposeFile ).isNotNull ();
4139
@@ -44,28 +42,31 @@ void shouldPrintCertificates() throws IOException {
4442 "docker" ,
4543 "compose" ,
4644 "--file=" + dockerComposeFile .getPath (),
47- "up"
45+ "up" ,
46+ "-d"
4847 ).start ();
4948
50- Request request = CertificateRipper .print ("ftps://localhost:2231" ).build ();
49+ try {
50+ Request request = CertificateRipper .print ("ftps://localhost:2231" ).build ();
5151
52- Awaitility .await ()
53- .atMost (2 , TimeUnit .MINUTES )
54- .pollInterval (1 , TimeUnit .SECONDS )
55- .untilAsserted (() -> {
56- request .run ();
57- String standardOutput = String .join (System .lineSeparator (), consoleCaptor .getStandardOutput ());
58- assertThat (CAPTURED_CERTIFICATES .matcher (standardOutput ).find ()).isTrue ();
59- });
52+ Awaitility .await ()
53+ .atMost (2 , TimeUnit .MINUTES )
54+ .pollInterval (1 , TimeUnit .SECONDS )
55+ .untilAsserted (() -> {
56+ request .run ();
57+ String standardOutput = String .join (System .lineSeparator (), consoleCaptor .getStandardOutput ());
58+ assertThat (CAPTURED_CERTIFICATES .matcher (standardOutput ).find ()).isTrue ();
59+ });
60+ } finally {
61+ new ProcessBuilder (
62+ "docker" ,
63+ "compose" ,
64+ "--file=" + dockerComposeFile .getPath (),
65+ "down"
66+ ).start ().waitFor ();
6067
61- new ProcessBuilder (
62- "docker" ,
63- "compose" ,
64- "--file=" + dockerComposeFile .getPath (),
65- "down"
66- ).start ();
67-
68- consoleCaptor .close ();
68+ consoleCaptor .close ();
69+ }
6970 }
7071
7172}
0 commit comments