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

import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.junit.ClassRule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

public class ExampleExposeContainerPortStaticTest {

    private static Logger log = LoggerFactory.getLogger(ExampleExposeContainerPortStaticTest.class);

    @ClassRule
    public static DockerRule testee = DockerRule.builder()//
            .imageName("nginx")//
            .publishAllPorts(false)//
            .expose("8080", "80")
            .build();

    @Test
    public void shouldExposeSpecifiedPort() throws InterruptedException, IOException {
        String nginxHome = "http://"+testee.getDockerHost()+":8080/";
        log.info("homepage: {}", nginxHome);
        assertTrue(AssertHtml.pageContainsString(nginxHome, "Welcome to nginx!"));
    }

}

@@ -642,19 +642,19 @@
 xpose(%228
-080
+123
 %22, %2280%22)
@@ -841,11 +841,11 @@
 +%22:8
-080
+123
 /%22;%0A

use port that does not interfere with default ports in CI environment