forked from testcontainers/testcontainers-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InternalCommandPortListeningCheckTest.java
37 lines (27 loc) · 1.51 KB
/
InternalCommandPortListeningCheckTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.testcontainers.containers.wait.internal;
import com.google.common.collect.ImmutableSet;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import static org.rnorth.visibleassertions.VisibleAssertions.assertFalse;
import static org.rnorth.visibleassertions.VisibleAssertions.assertTrue;
public class InternalCommandPortListeningCheckTest {
// Linking a custom configuration into the container so that nginx is listening on port 8080. This is necessary to prove
// that the command formatting uses the correct casing for hexadecimal numbers (i.e. 1F90 and not 1f90).
@Rule
public GenericContainer nginx = new GenericContainer<>("nginx:1.9.4")
.withClasspathResourceMapping("nginx_on_8080.conf", "/etc/nginx/conf.d/default.conf", BindMode.READ_ONLY);
@Test
public void singleListening() {
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(nginx, ImmutableSet.of(8080));
final Boolean result = check.call();
assertTrue("InternalCommandPortListeningCheck identifies a single listening port", result);
}
@Test
public void nonListening() {
final InternalCommandPortListeningCheck check = new InternalCommandPortListeningCheck(nginx, ImmutableSet.of(8080, 1234));
final Boolean result = check.call();
assertFalse("InternalCommandPortListeningCheck detects a non-listening port among many", result);
}
}