File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
main/java/com/github/dockerjava/api/model
test/java/com/github/dockerjava/api/model Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public boolean isReadOnly() {
3838 *
3939 * @param serialized the specification, e.g. <code>/host:/container:ro</code>
4040 * @return a {@link Bind} matching the specification
41+ * @throws IllegalArgumentException if the specification cannot be parsed
4142 */
4243 public static Bind parse (String serialized ) {
4344 try {
@@ -52,16 +53,14 @@ public static Bind parse(String serialized) {
5253 else if ("ro" .equals (parts [2 ].toLowerCase ()))
5354 return new Bind (parts [0 ], Volume .parse (parts [1 ]), true );
5455 else
55- throw new RuntimeException ("Error parsing Bind '"
56- + serialized + "'" );
56+ throw new IllegalArgumentException ();
5757 }
5858 default : {
59- throw new RuntimeException ("Error parsing Bind '" + serialized
60- + "'" );
59+ throw new IllegalArgumentException ();
6160 }
6261 }
6362 } catch (Exception e ) {
64- throw new RuntimeException ("Error parsing Bind '" + serialized
63+ throw new IllegalArgumentException ("Error parsing Bind '" + serialized
6564 + "'" );
6665 }
6766 }
Original file line number Diff line number Diff line change @@ -30,9 +30,22 @@ public void parseReadOnly() {
3030 assertEquals (bind .isReadOnly (), true );
3131 }
3232
33- @ Test (expectedExceptions = RuntimeException .class )
33+ @ Test (expectedExceptions = IllegalArgumentException .class ,
34+ expectedExceptionsMessageRegExp = "Error parsing Bind.*" )
3435 public void parseInvalidAccessMode () {
3536 Bind .parse ("/host:/container:xx" );
3637 }
37-
38+
39+ @ Test (expectedExceptions = IllegalArgumentException .class ,
40+ expectedExceptionsMessageRegExp = "Error parsing Bind 'nonsense'" )
41+ public void parseInvalidInput () {
42+ Bind .parse ("nonsense" );
43+ }
44+
45+ @ Test (expectedExceptions = IllegalArgumentException .class ,
46+ expectedExceptionsMessageRegExp = "Error parsing Bind 'null'" )
47+ public void parseNull () {
48+ Bind .parse (null );
49+ }
50+
3851}
You can’t perform that action at this time.
0 commit comments