forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortBindingTest.java
More file actions
66 lines (50 loc) · 1.84 KB
/
Copy pathPortBindingTest.java
File metadata and controls
66 lines (50 loc) · 1.84 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.github.dockerjava.api.model;
import com.github.dockerjava.api.model.Ports.Binding;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
public class PortBindingTest {
private static final ExposedPort TCP_8080 = ExposedPort.tcp(8080);
@Rule
public ExpectedException expectedEx = ExpectedException.none();
@Test
public void fullDefinition() {
assertEquals(PortBinding.parse("127.0.0.1:80:8080/tcp"),
new PortBinding(Binding.bindIpAndPort("127.0.0.1", 80), TCP_8080));
}
@Test
public void noProtocol() {
assertEquals(PortBinding.parse("127.0.0.1:80:8080"), new PortBinding(Binding.bindIpAndPort("127.0.0.1", 80), TCP_8080));
}
@Test
public void noHostIp() {
assertEquals(PortBinding.parse("80:8080/tcp"), new PortBinding(Binding.bindPort(80), TCP_8080));
}
@Test
public void portsOnly() {
assertEquals(PortBinding.parse("80:8080"), new PortBinding(Binding.bindPort(80), TCP_8080));
}
@Test
public void exposedPortOnly() {
assertEquals(PortBinding.parse("8080"), new PortBinding(Binding.empty(), TCP_8080));
}
@Test
public void dynamicHostPort() {
assertEquals(PortBinding.parse("127.0.0.1::8080"), new PortBinding(Binding.bindIp("127.0.0.1"), TCP_8080));
}
@Test
@Ignore
public void parseInvalidInput() {
expectedEx.expect(IllegalArgumentException.class);
expectedEx.expectMessage("Error parsing PortBinding 'nonsense'");
PortBinding.parse("nonsense");
}
@Test
public void parseNull() {
expectedEx.expect(IllegalArgumentException.class);
expectedEx.expectMessage("Error parsing PortBinding 'null'");
PortBinding.parse(null);
}
}