use of io.fabric8.maven.docker.config.VolumeConfiguration in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testCreateVolumeConfig.
@Test
public void testCreateVolumeConfig() throws Exception {
final VolumeConfiguration config = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
// Use a 'delegate' to verify the argument given directly. No need
// for an 'intermediate' return method in the service just to check this.
docker.createVolume(with(new Delegate<VolumeCreateConfig>() {
void check(VolumeCreateConfig vcc) {
assertThat(vcc.getName(), is("testVolume"));
JSONObject vccJson = (JSONObject) JSONParser.parseJSON(vcc.toJson());
assertEquals(vccJson.get("Driver"), "test");
}
}));
result = "testVolume";
}
};
String volume = new VolumeService(docker).createVolume(config);
assertEquals(volume, "testVolume");
}
use of io.fabric8.maven.docker.config.VolumeConfiguration in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testRemoveVolume.
@Test
public void testRemoveVolume() throws Exception {
VolumeConfiguration vc = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
docker.createVolume((VolumeCreateConfig) any);
result = "testVolume";
docker.removeVolume("testVolume");
}
};
VolumeService volumeService = new VolumeService(docker);
String name = volumeService.createVolume(vc);
volumeService.removeVolume(name);
}
use of io.fabric8.maven.docker.config.VolumeConfiguration in project docker-maven-plugin by fabric8io.
the class VolumeServiceTest method testCreateVolume.
@Test
public void testCreateVolume() throws Exception {
VolumeConfiguration vc = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
new Expectations() {
{
docker.createVolume((VolumeCreateConfig) any);
result = "testVolume";
}
};
assertThat(vc.getName(), is("testVolume"));
String name = new VolumeService(docker).createVolume(vc);
assertThat(name, is("testVolume"));
}
use of io.fabric8.maven.docker.config.VolumeConfiguration in project docker-maven-plugin by fabric8io.
the class VolumeRemoveMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub serviceHub) throws DockerAccessException, MojoExecutionException {
VolumeService volService = serviceHub.getVolumeService();
for (VolumeConfiguration volume : getVolumes()) {
log.info("Removing volume %s", volume.getName());
volService.removeVolume(volume.getName());
}
}
use of io.fabric8.maven.docker.config.VolumeConfiguration 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));
}
Aggregations