use of io.fabric8.maven.docker.access.VolumeCreateConfig 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.access.VolumeCreateConfig 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 = JsonFactory.newJsonObject(vcc.toJson());
assertEquals("test", vccJson.get("Driver").getAsString());
}
}));
result = "testVolume";
}
};
String volume = new VolumeService(docker).createVolume(config);
assertEquals(volume, "testVolume");
}
use of io.fabric8.maven.docker.access.VolumeCreateConfig 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.access.VolumeCreateConfig in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClient method createVolume.
@Override
public String createVolume(VolumeCreateConfig containerConfig) throws DockerAccessException {
String createJson = containerConfig.toJson();
log.debug("Volume create config: %s", createJson);
try {
String url = urlBuilder.createVolume();
log.verbose(Logger.LogVerboseCategory.API, API_LOG_FORMAT_POST_WITH_REQUEST, url, createJson);
String response = delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
JsonObject json = JsonFactory.newJsonObject(response);
logWarnings(json);
return json.get("Name").getAsString();
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to create volume for [%s]", containerConfig.getName());
}
}
Aggregations