use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.
the class DockerPathUtilTest method resolveAbsolutelyWithRelativeParentPath.
@Test
public void resolveAbsolutelyWithRelativeParentPath() throws Exception {
// ../relative/path
String toResolve = join(SEP, DOT + DOT, RELATIVE_PATH);
// '/base/directory' and '../relative/path' to '/base/relative/path'
assertEquals(new File(new File(ABS_BASE_DIR).getParent(), RELATIVE_PATH), DockerPathUtil.resolveAbsolutely(toResolve, ABS_BASE_DIR));
}
use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.
the class DockerPathUtilTest method resolveAbsolutelyWithTrailingSlashWithRelativePath.
@Test
public void resolveAbsolutelyWithTrailingSlashWithRelativePath() {
// relative/path
String toResolve = RELATIVE_PATH;
// /base/directory/
String absBaseDir = ABS_BASE_DIR + SEP;
// '/base/directory/' and 'relative/path' to '/base/directory/relative/path'
assertEquals(new File(absBaseDir + toResolve), DockerPathUtil.resolveAbsolutely(toResolve, absBaseDir));
}
use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.
the class VolumeBindingUtilTest method testResolveUserHomeVolumePath.
/**
* Resolving arbitrary user home paths, e.g. represented as {@code ~user}, is not supported.
*/
@Test(expected = IllegalArgumentException.class)
public void testResolveUserHomeVolumePath() {
String volumeString = format(BIND_STRING_FMT, USER_HOME, CONTAINER_PATH);
// '~user:/path/to/container/dir' to '/home/user:/path/to/container/dir'
String relativizedVolumeString = resolveRelativeVolumeBinding(new File("ignored"), volumeString);
}
use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.
the class VolumeBindingUtilTest method testResolveUserVolumePath.
/**
* Insures that a host volume binding string that contains a path relative to the user's home directory resolves to
* the user's home directory and not the supplied base directory.
*/
@Test
public void testResolveUserVolumePath() {
String volumeString = format(BIND_STRING_FMT, USER_PATH, CONTAINER_PATH);
// '~/rel:/path/to/container/dir' to '/user/home/rel:/path/to/container/dir'
String relativizedVolumeString = resolveRelativeVolumeBinding(new File("ignored"), volumeString);
String expectedBindingString = format(BIND_STRING_FMT, new File(System.getProperty("user.home"), PathTestUtil.stripLeadingTilde(USER_PATH)), CONTAINER_PATH);
assertEquals(expectedBindingString, relativizedVolumeString);
}
use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.
the class VolumeBindingUtilTest method testResolveParentRelativeVolumePath.
/**
* Insures that a relative path referencing the parent directory are properly resolved against a base directory.
*/
@Test
public void testResolveParentRelativeVolumePath() {
// '../rel'
String relativePath = DOT + RELATIVE_PATH;
String volumeString = format(BIND_STRING_FMT, relativePath, CONTAINER_PATH);
// '../rel:/path/to/container/dir to '/absolute/rel:/path/to/container/dir'
String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
String expectedBindingString = format(BIND_STRING_FMT, new File(ABS_BASEDIR.getParent(), stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH);
assertEquals(expectedBindingString, relativizedVolumeString);
}
Aggregations