formatting corrections on test-container tests
This commit is contained in:
parent
4931f31d91
commit
8fd641b074
|
@ -13,17 +13,22 @@ import org.junit.Test;
|
|||
import org.testcontainers.containers.DockerComposeContainer;
|
||||
|
||||
public class DockerComposeContainerTests {
|
||||
@ClassRule
|
||||
public static DockerComposeContainer compose = new DockerComposeContainer(new File("src/test/resources/test-compose.yml"))
|
||||
.withExposedService("simpleWebServer_1", 80);
|
||||
|
||||
@ClassRule
|
||||
public static DockerComposeContainer compose =
|
||||
new DockerComposeContainer(
|
||||
new File("src/test/resources/test-compose.yml"))
|
||||
.withExposedService("simpleWebServer_1", 80);
|
||||
|
||||
@Test
|
||||
public void when() throws Exception {
|
||||
String address ="http://" + compose.getServiceHost("simpleWebServer_1", 80)+ ":"+ compose.getServicePort("simpleWebServer_1", 80);
|
||||
public void givenSimpleWebServerContainer_whenGetReuqest_thenReturnsResponse()
|
||||
throws Exception {
|
||||
String address = "http://" + compose.getServiceHost("simpleWebServer_1", 80)
|
||||
+ ":" + compose.getServicePort("simpleWebServer_1", 80);
|
||||
String response = simpleGetRequest(address);
|
||||
|
||||
assertEquals(response, "Hello World!");
|
||||
}
|
||||
|
||||
|
||||
private String simpleGetRequest(String address) throws Exception {
|
||||
URL url = new URL(address);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
|
|
|
@ -15,15 +15,20 @@ import org.testcontainers.containers.GenericContainer;
|
|||
@Testable
|
||||
public class GenericContainerTests {
|
||||
@ClassRule
|
||||
public static GenericContainer simpleWebServer = new GenericContainer("alpine:3.2")
|
||||
public static GenericContainer simpleWebServer =
|
||||
new GenericContainer("alpine:3.2")
|
||||
.withExposedPorts(80)
|
||||
.withCommand("/bin/sh", "-c", "while true; do echo "
|
||||
+ "\"HTTP/1.1 200 OK\n\nHello World!\" | nc -l -p 80; done");
|
||||
.withCommand("/bin/sh", "-c", "while true; do echo "
|
||||
+ "\"HTTP/1.1 200 OK\n\nHello World!\" | nc -l -p 80; done");
|
||||
|
||||
@Test
|
||||
public void givenSimpleWebServerContainer_whenGetReuqest_thenReturnsResponse() throws Exception {
|
||||
String address = "http://" + simpleWebServer.getContainerIpAddress() + ":" + simpleWebServer.getMappedPort(80);
|
||||
public void givenSimpleWebServerContainer_whenGetReuqest_thenReturnsResponse()
|
||||
throws Exception {
|
||||
String address = "http://"
|
||||
+ simpleWebServer.getContainerIpAddress()
|
||||
+ ":" + simpleWebServer.getMappedPort(80);
|
||||
String response = simpleGetRequest(address);
|
||||
|
||||
assertEquals(response, "Hello World!");
|
||||
}
|
||||
|
||||
|
@ -32,7 +37,8 @@ public class GenericContainerTests {
|
|||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
|
|
@ -14,7 +14,9 @@ import org.testcontainers.containers.GenericContainer;
|
|||
|
||||
public class WebDriverContainerTests {
|
||||
@Rule
|
||||
public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer().withDesiredCapabilities(DesiredCapabilities.chrome());
|
||||
public BrowserWebDriverContainer chrome
|
||||
= new BrowserWebDriverContainer()
|
||||
.withDesiredCapabilities(DesiredCapabilities.chrome());
|
||||
|
||||
@Test
|
||||
public void whenNavigatedToPage_thenHeadingIsInThePage() {
|
||||
|
|
Loading…
Reference in New Issue