@Test
public void testBuildDockerUri() throws Exception {
URI uri = UriUtilsExtended.buildDockerUri("http", "a.b.c", 1234, null);
assertNotNull(uri);
assertEquals("http", uri.getScheme());
assertEquals("a.b.c", uri.getHost());
assertEquals(1234, uri.getPort());
assertEquals("/v1.24", uri.getPath());
uri = UriUtilsExtended.buildDockerUri(null, "a.b.c", -1, "/path");
assertNotNull(uri);
assertEquals("https", uri.getScheme());
assertEquals("a.b.c", uri.getHost());
assertEquals(443, uri.getPort());
assertEquals("/path/v1.24", uri.getPath());
try {
UriUtilsExtended.buildDockerUri("ftp", "a.b.c", 21, "/path");
fail("ftp protocol should not be supported!");
} catch (LocalizableValidationException e) {
assertEquals("Unsupported scheme, must be http or https: ftp", e.getMessage());
}
try {
UriUtilsExtended.buildDockerUri(null, "ftp://a.b.c", -1, "/path");
fail("ftp protocol should not be supported!");
} catch (LocalizableValidationException e) {
assertEquals("Unsupported scheme, must be http or https: ftp", e.getMessage());
}
}