package pl.domzal.junit.docker.rule.examples;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;

import org.junit.Rule;
import org.junit.Test;

import pl.domzal.junit.docker.rule.DockerRule;

public class ExampleWaitForLogMessageTest {

    @Rule
    public DockerRule testee = DockerRule.builder()//
            .imageName("busybox")//
            .cmd("sh", "-c", "for i in 01 02 started 03 04 05; do (echo $i; sleep 1); done")//
            .waitForMessage("started")
            .build();

    @Test
    public void shouldReadMountFromJavaFile() throws Throwable {
        String log = testee.getLog();
        assertThat(log, not(containsString("05")));
        testee.waitFor("05", 10);
    }

}

@@ -560,28 +560,24 @@
 ould
-ReadMountFromJavaFil
+WaitForLogMessag
 e() 
@@ -661,12 +661,8 @@
 og, 
-not(
 cont
@@ -678,46 +678,192 @@
 g(%220
-5
+2
 %22))
-)
 ;%0A    
+%7D%0A%0A
     
-testee.waitFor
+@Test%0A    public void shouldStopWaitingWhenLogMessageFound() throws Throwable %7B%0A        String log = testee.getLog();%0A        assertThat(log, not(containsString
 (%2205%22
-, 10
+))
 );%0A 

split test cases of wait for message examples