Search in sources :

Example 81 with Path

use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.

the class DockerPathUtilTest method resolveAbsolutelyWithRelativePath.

@Test
public void resolveAbsolutelyWithRelativePath() {
    // relative/path
    String toResolve = RELATIVE_PATH;
    // /base/directory
    String absBaseDir = ABS_BASE_DIR;
    // '/base/directory' and 'relative/path' to '/base/directory/relative/path'
    assertEquals(new File(absBaseDir + SEP + toResolve), DockerPathUtil.resolveAbsolutely(toResolve, absBaseDir));
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 82 with Path

use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.

the class DockerPathUtilTest method resolveAbsolutelyWithExtraSlashes.

@Test
public void resolveAbsolutelyWithExtraSlashes() throws Exception {
    // relative/path//
    String toResolve = RELATIVE_PATH + SEP + SEP;
    // '/base/directory' and 'relative/path//' to '/base/directory/relative/path'
    assertEquals(new File(ABS_BASE_DIR + SEP + RELATIVE_PATH), DockerPathUtil.resolveAbsolutely(toResolve, ABS_BASE_DIR));
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 83 with Path

use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveParentRelativeVolumePathWithNoParent.

/**
 * Insures that a relative path referencing the parent directory are properly resolved against a base directory.
 */
@Test
@Ignore("TODO: fix this test, and DockerPathUtil as well")
public void testResolveParentRelativeVolumePathWithNoParent() {
    // '../../rel'
    String relativePath = join(SEP, DOT + DOT, DOT + DOT, "rel");
    String volumeString = format(BIND_STRING_FMT, relativePath, CONTAINER_PATH);
    File baseDir = PathTestUtil.getFirstDirectory(ABS_BASEDIR);
    // '../../rel:/path/to/container/dir to '/absolute/rel:/path/to/container/dir'
    String relativizedVolumeString = resolveRelativeVolumeBinding(baseDir, volumeString);
    String expectedBindingString = format(BIND_STRING_FMT, new File(baseDir.getParent(), stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH);
    assertEquals(expectedBindingString, relativizedVolumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 84 with Path

use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveRelativeVolumePathContainingSlashes.

/**
 * The volume binding string: {@code src/test/docker:/path/to/container/mountpoint} is resolved, because {@code src/
 * test/docker} is considered a <em>relative path</em>.
 */
@Test
public void testResolveRelativeVolumePathContainingSlashes() throws Exception {
    String relativePath = "src" + SEP + "test" + SEP + "docker";
    String volumeString = format(BIND_STRING_FMT, relativePath, CONTAINER_PATH);
    // 'src/test/docker:/path/to/container/dir' to '/absolute/basedir/src/test/docker:/path/to/container/dir'
    String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
    String expectedBindingString = format(BIND_STRING_FMT, new File(ABS_BASEDIR, relativePath), CONTAINER_PATH);
    assertEquals(expectedBindingString, relativizedVolumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 85 with Path

use of io.fabric8.annotations.Path in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveVolumeBindingsWithRunVolumeConfiguration.

/**
 * Insures that relative paths in the host portion of a volume binding string are properly resolved against a base
 * directory when present in a {@link RunVolumeConfiguration}.
 */
@Test
public void testResolveVolumeBindingsWithRunVolumeConfiguration() {
    RunVolumeConfiguration.Builder builder = new RunVolumeConfiguration.Builder();
    builder.bind(singletonList(format(BIND_STRING_FMT, RELATIVE_PATH, CONTAINER_PATH)));
    RunVolumeConfiguration volumeConfiguration = builder.build();
    // './rel:/path/to/container/dir' to '/absolute/basedir/rel:/path/to/container/dir'
    resolveRelativeVolumeBindings(ABS_BASEDIR, volumeConfiguration);
    String expectedBindingString = format(BIND_STRING_FMT, join("", ABS_BASEDIR.getAbsolutePath(), stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH);
    assertEquals(expectedBindingString, volumeConfiguration.getBind().get(0));
}
Also used : RunVolumeConfiguration(io.fabric8.maven.docker.config.RunVolumeConfiguration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)45 File (java.io.File)41 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)18 PathTestUtil.createTmpFile (io.fabric8.maven.docker.util.PathTestUtil.createTmpFile)17 HashMap (java.util.HashMap)12 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)11 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)11 Path (java.nio.file.Path)11 FabricService (io.fabric8.api.FabricService)10 RuntimeProperties (io.fabric8.api.RuntimeProperties)9 Properties (java.util.Properties)9 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)8 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)8 InputStream (java.io.InputStream)8 Path (javax.ws.rs.Path)8 HttpProxyRule (io.fabric8.gateway.model.HttpProxyRule)7 NodeState (io.fabric8.groups.NodeState)7 URISyntaxException (java.net.URISyntaxException)7 List (java.util.List)6