33import static com .github .dockerjava .api .model .AccessMode .ro ;
44import static com .github .dockerjava .api .model .AccessMode .rw ;
55import static org .hamcrest .MatcherAssert .assertThat ;
6+ import static org .hamcrest .Matchers .nullValue ;
67import static org .hamcrest .core .Is .is ;
78
89import org .testng .annotations .Test ;
@@ -16,6 +17,8 @@ public void parseUsingDefaultAccessMode() {
1617 assertThat (bind .getVolume ().getPath (), is ("/container" ));
1718 assertThat (bind .getAccessMode (), is (AccessMode .DEFAULT ));
1819 assertThat (bind .getSecMode (), is (SELContext .none ));
20+ assertThat (bind .getNoCopy (), nullValue ());
21+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
1922 }
2023
2124 @ Test
@@ -25,6 +28,52 @@ public void parseReadWrite() {
2528 assertThat (bind .getVolume ().getPath (), is ("/container" ));
2629 assertThat (bind .getAccessMode (), is (rw ));
2730 assertThat (bind .getSecMode (), is (SELContext .none ));
31+ assertThat (bind .getNoCopy (), nullValue ());
32+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
33+ }
34+
35+ @ Test
36+ public void parseReadWriteNoCopy () {
37+ Bind bind = Bind .parse ("/host:/container:rw,nocopy" );
38+ assertThat (bind .getPath (), is ("/host" ));
39+ assertThat (bind .getVolume ().getPath (), is ("/container" ));
40+ assertThat (bind .getAccessMode (), is (rw ));
41+ assertThat (bind .getSecMode (), is (SELContext .none ));
42+ assertThat (bind .getNoCopy (), is (true ));
43+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
44+ }
45+
46+ @ Test
47+ public void parseReadWriteShared () {
48+ Bind bind = Bind .parse ("/host:/container:rw,shared" );
49+ assertThat (bind .getPath (), is ("/host" ));
50+ assertThat (bind .getVolume ().getPath (), is ("/container" ));
51+ assertThat (bind .getAccessMode (), is (rw ));
52+ assertThat (bind .getSecMode (), is (SELContext .none ));
53+ assertThat (bind .getNoCopy (), nullValue ());
54+ assertThat (bind .getPropagationMode (), is (PropagationMode .SHARED ));
55+ }
56+
57+ @ Test
58+ public void parseReadWriteSlave () {
59+ Bind bind = Bind .parse ("/host:/container:rw,slave" );
60+ assertThat (bind .getPath (), is ("/host" ));
61+ assertThat (bind .getVolume ().getPath (), is ("/container" ));
62+ assertThat (bind .getAccessMode (), is (rw ));
63+ assertThat (bind .getSecMode (), is (SELContext .none ));
64+ assertThat (bind .getNoCopy (), nullValue ());
65+ assertThat (bind .getPropagationMode (), is (PropagationMode .SLAVE ));
66+ }
67+
68+ @ Test
69+ public void parseReadWritePrivate () {
70+ Bind bind = Bind .parse ("/host:/container:rw,private" );
71+ assertThat (bind .getPath (), is ("/host" ));
72+ assertThat (bind .getVolume ().getPath (), is ("/container" ));
73+ assertThat (bind .getAccessMode (), is (rw ));
74+ assertThat (bind .getSecMode (), is (SELContext .none ));
75+ assertThat (bind .getNoCopy (), nullValue ());
76+ assertThat (bind .getPropagationMode (), is (PropagationMode .PRIVATE ));
2877 }
2978
3079 @ Test
@@ -34,6 +83,8 @@ public void parseReadOnly() {
3483 assertThat (bind .getVolume ().getPath (), is ("/container" ));
3584 assertThat (bind .getAccessMode (), is (ro ));
3685 assertThat (bind .getSecMode (), is (SELContext .none ));
86+ assertThat (bind .getNoCopy (), nullValue ());
87+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
3788 }
3889
3990 @ Test
@@ -43,12 +94,16 @@ public void parseSELOnly() {
4394 assertThat (bind .getVolume ().getPath (), is ("/container" ));
4495 assertThat (bind .getAccessMode (), is (AccessMode .DEFAULT ));
4596 assertThat (bind .getSecMode (), is (SELContext .single ));
97+ assertThat (bind .getNoCopy (), nullValue ());
98+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
4699
47100 bind = Bind .parse ("/host:/container:z" );
48101 assertThat (bind .getPath (), is ("/host" ));
49102 assertThat (bind .getVolume ().getPath (), is ("/container" ));
50103 assertThat (bind .getAccessMode (), is (AccessMode .DEFAULT ));
51104 assertThat (bind .getSecMode (), is (SELContext .shared ));
105+ assertThat (bind .getNoCopy (), nullValue ());
106+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
52107 }
53108
54109 @ Test
@@ -58,6 +113,8 @@ public void parseReadWriteSEL() {
58113 assertThat (bind .getVolume ().getPath (), is ("/container" ));
59114 assertThat (bind .getAccessMode (), is (rw ));
60115 assertThat (bind .getSecMode (), is (SELContext .single ));
116+ assertThat (bind .getNoCopy (), nullValue ());
117+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
61118 }
62119
63120 @ Test
@@ -67,6 +124,8 @@ public void parseReadOnlySEL() {
67124 assertThat (bind .getVolume ().getPath (), is ("/container" ));
68125 assertThat (bind .getAccessMode (), is (ro ));
69126 assertThat (bind .getSecMode (), is (SELContext .shared ));
127+ assertThat (bind .getNoCopy (), nullValue ());
128+ assertThat (bind .getPropagationMode (), is (PropagationMode .DEFAULT_MODE ));
70129 }
71130
72131 @ Test (expectedExceptions = IllegalArgumentException .class , expectedExceptionsMessageRegExp = "Error parsing Bind.*" )
@@ -94,6 +153,26 @@ public void toStringReadWrite() {
94153 assertThat (Bind .parse ("/host:/container:rw" ).toString (), is ("/host:/container:rw" ));
95154 }
96155
156+ @ Test
157+ public void toStringReadWriteNoCopy () {
158+ assertThat (Bind .parse ("/host:/container:rw,nocopy" ).toString (), is ("/host:/container:rw,nocopy" ));
159+ }
160+
161+ @ Test
162+ public void toStringReadWriteShared () {
163+ assertThat (Bind .parse ("/host:/container:rw,shared" ).toString (), is ("/host:/container:rw,shared" ));
164+ }
165+
166+ @ Test
167+ public void toStringReadWriteSlave () {
168+ assertThat (Bind .parse ("/host:/container:rw,slave" ).toString (), is ("/host:/container:rw,slave" ));
169+ }
170+
171+ @ Test
172+ public void toStringReadWritePrivate () {
173+ assertThat (Bind .parse ("/host:/container:rw,private" ).toString (), is ("/host:/container:rw,private" ));
174+ }
175+
97176 @ Test
98177 public void toStringDefaultAccessMode () {
99178 assertThat (Bind .parse ("/host:/container" ).toString (), is ("/host:/container:rw" ));
0 commit comments