Skip to content

Commit 253f6d2

Browse files
committed
Use Hamcrest matchers.
1 parent 7920d48 commit 253f6d2

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

src/test/java/com/github/dockerjava/api/model/BindTest.java

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import static com.github.dockerjava.api.model.AccessMode.ro;
44
import static com.github.dockerjava.api.model.AccessMode.rw;
5-
import static org.testng.Assert.assertEquals;
5+
import static org.hamcrest.MatcherAssert.assertThat;
6+
import static org.hamcrest.core.Is.is;
67

78
import org.testng.annotations.Test;
89

@@ -11,61 +12,61 @@ public class BindTest {
1112
@Test
1213
public void parseUsingDefaultAccessMode() {
1314
Bind bind = Bind.parse("/host:/container");
14-
assertEquals(bind.getPath(), "/host");
15-
assertEquals(bind.getVolume().getPath(), "/container");
16-
assertEquals(bind.getAccessMode(), AccessMode.DEFAULT);
17-
assertEquals(bind.getSecMode(), SELContext.none);
15+
assertThat(bind.getPath(), is("/host"));
16+
assertThat(bind.getVolume().getPath(), is("/container"));
17+
assertThat(bind.getAccessMode(), is(AccessMode.DEFAULT));
18+
assertThat(bind.getSecMode(), is(SELContext.none));
1819
}
1920

2021
@Test
2122
public void parseReadWrite() {
2223
Bind bind = Bind.parse("/host:/container:rw");
23-
assertEquals(bind.getPath(), "/host");
24-
assertEquals(bind.getVolume().getPath(), "/container");
25-
assertEquals(bind.getAccessMode(), rw);
26-
assertEquals(bind.getSecMode(), SELContext.none);
24+
assertThat(bind.getPath(), is("/host"));
25+
assertThat(bind.getVolume().getPath(), is("/container"));
26+
assertThat(bind.getAccessMode(), is(rw));
27+
assertThat(bind.getSecMode(), is(SELContext.none));
2728
}
2829

2930
@Test
3031
public void parseReadOnly() {
3132
Bind bind = Bind.parse("/host:/container:ro");
32-
assertEquals(bind.getPath(), "/host");
33-
assertEquals(bind.getVolume().getPath(), "/container");
34-
assertEquals(bind.getAccessMode(), ro);
35-
assertEquals(bind.getSecMode(), SELContext.none);
33+
assertThat(bind.getPath(), is("/host"));
34+
assertThat(bind.getVolume().getPath(), is("/container"));
35+
assertThat(bind.getAccessMode(), is(ro));
36+
assertThat(bind.getSecMode(), is(SELContext.none));
3637
}
3738

3839
@Test
3940
public void parseSELOnly() {
4041
Bind bind = Bind.parse("/host:/container:Z");
41-
assertEquals(bind.getPath(), "/host");
42-
assertEquals(bind.getVolume().getPath(), "/container");
43-
assertEquals(bind.getAccessMode(), AccessMode.DEFAULT);
44-
assertEquals(bind.getSecMode(), SELContext.single);
45-
42+
assertThat(bind.getPath(), is("/host"));
43+
assertThat(bind.getVolume().getPath(), is("/container"));
44+
assertThat(bind.getAccessMode(), is(AccessMode.DEFAULT));
45+
assertThat(bind.getSecMode(), is(SELContext.single));
46+
4647
bind = Bind.parse("/host:/container:z");
47-
assertEquals(bind.getPath(), "/host");
48-
assertEquals(bind.getVolume().getPath(), "/container");
49-
assertEquals(bind.getAccessMode(), AccessMode.DEFAULT);
50-
assertEquals(bind.getSecMode(), SELContext.shared);
48+
assertThat(bind.getPath(), is("/host"));
49+
assertThat(bind.getVolume().getPath(), is("/container"));
50+
assertThat(bind.getAccessMode(), is(AccessMode.DEFAULT));
51+
assertThat(bind.getSecMode(), is(SELContext.shared));
5152
}
5253

5354
@Test
5455
public void parseReadWriteSEL() {
5556
Bind bind = Bind.parse("/host:/container:rw,Z");
56-
assertEquals(bind.getPath(), "/host");
57-
assertEquals(bind.getVolume().getPath(), "/container");
58-
assertEquals(bind.getAccessMode(), rw);
59-
assertEquals(bind.getSecMode(), SELContext.single);
57+
assertThat(bind.getPath(), is("/host"));
58+
assertThat(bind.getVolume().getPath(), is("/container"));
59+
assertThat(bind.getAccessMode(), is(rw));
60+
assertThat(bind.getSecMode(), is(SELContext.single));
6061
}
6162

6263
@Test
6364
public void parseReadOnlySEL() {
6465
Bind bind = Bind.parse("/host:/container:ro,z");
65-
assertEquals(bind.getPath(), "/host");
66-
assertEquals(bind.getVolume().getPath(), "/container");
67-
assertEquals(bind.getAccessMode(), ro);
68-
assertEquals(bind.getSecMode(), SELContext.shared);
66+
assertThat(bind.getPath(), is("/host"));
67+
assertThat(bind.getVolume().getPath(), is("/container"));
68+
assertThat(bind.getAccessMode(), is(ro));
69+
assertThat(bind.getSecMode(), is(SELContext.shared));
6970
}
7071

7172
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Error parsing Bind.*")
@@ -85,32 +86,32 @@ public void parseNull() {
8586

8687
@Test
8788
public void toStringReadOnly() {
88-
assertEquals(Bind.parse("/host:/container:ro").toString(), "/host:/container:ro");
89+
assertThat(Bind.parse("/host:/container:ro").toString(), is("/host:/container:ro"));
8990
}
9091

9192
@Test
9293
public void toStringReadWrite() {
93-
assertEquals(Bind.parse("/host:/container:rw").toString(), "/host:/container:rw");
94+
assertThat(Bind.parse("/host:/container:rw").toString(), is("/host:/container:rw"));
9495
}
9596

9697
@Test
9798
public void toStringDefaultAccessMode() {
98-
assertEquals(Bind.parse("/host:/container").toString(), "/host:/container:rw");
99+
assertThat(Bind.parse("/host:/container").toString(), is("/host:/container:rw"));
99100
}
100101

101102
@Test
102103
public void toStringReadOnlySEL() {
103-
assertEquals(Bind.parse("/host:/container:ro,Z").toString(), "/host:/container:ro,Z");
104+
assertThat(Bind.parse("/host:/container:ro,Z").toString(), is("/host:/container:ro,Z"));
104105
}
105106

106107
@Test
107108
public void toStringReadWriteSEL() {
108-
assertEquals(Bind.parse("/host:/container:rw,z").toString(), "/host:/container:rw,z");
109+
assertThat(Bind.parse("/host:/container:rw,z").toString(), is("/host:/container:rw,z"));
109110
}
110111

111112
@Test
112113
public void toStringDefaultSEL() {
113-
assertEquals(Bind.parse("/host:/container:Z").toString(), "/host:/container:rw,Z");
114+
assertThat(Bind.parse("/host:/container:Z").toString(), is("/host:/container:rw,Z"));
114115
}
115116

116117
}

0 commit comments

Comments
 (0)