Only run a test if the docker server is running
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.file.Paths;
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
+import static java.net.HttpURLConnection.HTTP_OK;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assumptions.assumeThat;
import static org.openqa.selenium.remote.http.Contents.utf8String;
import static org.openqa.selenium.remote.http.HttpMethod.GET;
@@ -80,8 +83,10 @@ public void shouldComplainBitterlyIfNoSupportedVersionOfDockerProtocolIsFound()
@Test
public void foo() throws URISyntaxException {
+ assumeThat(Paths.get("/var/run/docker.sock")).exists();
+
HttpClient client = HttpClient.Factory.create("reactor").createClient(ClientConfig.defaultConfig().baseUri(new URI("unix:///var/run/docker.sock")));
HttpResponse res = client.execute(new HttpRequest(GET, "/version"));
- System.out.println(res.getStatus());
+ assertThat(res.getStatus()).isEqualTo(HTTP_OK);
}
}
