use of io.fabric8.maven.docker.model.PortBindingException in project docker-maven-plugin by fabric8io.
the class RunServiceTest method failAfterRetryingIfInsufficientPortBindingInformation.
@Test(expected = PortBindingException.class)
public void failAfterRetryingIfInsufficientPortBindingInformation(@Mocked Container container, @Mocked ImageConfiguration imageConfiguration, @Mocked PortMapping portMapping) throws DockerAccessException {
new Expectations() {
{
docker.createContainer(withAny(new ContainerCreateConfig("img")), anyString);
result = "containerId";
portMapping.needsPropertiesUpdate();
result = true;
queryService.getMandatoryContainer("containerId");
result = container;
times = 20;
container.isRunning();
result = true;
container.getPortBindings();
result = new PortBindingException("5432/tcp", new Gson().fromJson("{\"5432/tcp\": []}", JsonObject.class));
}
};
runService.createAndStartContainer(imageConfiguration, portMapping, new GavLabel("Im:A:Test"), properties, getBaseDirectory(), "blah", new Date());
}
use of io.fabric8.maven.docker.model.PortBindingException in project docker-maven-plugin by fabric8io.
the class RunServiceTest method retryIfInsufficientPortBindingInformation.
@Test
public void retryIfInsufficientPortBindingInformation(@Mocked Container container, @Mocked ImageConfiguration imageConfiguration, @Mocked PortMapping portMapping) throws DockerAccessException {
new Expectations() {
{
docker.createContainer(withAny(new ContainerCreateConfig("img")), anyString);
result = "containerId";
portMapping.needsPropertiesUpdate();
result = true;
queryService.getMandatoryContainer("containerId");
result = container;
times = 2;
container.isRunning();
result = true;
container.getPortBindings();
result = new PortBindingException("5432/tcp", new Gson().fromJson("{\"5432/tcp\": []}", JsonObject.class));
returns(ImmutableMap.of("5432/tcp", new Container.PortBinding(56741, "0.0.0.0")), ImmutableMap.of("5432/tcp", new Container.PortBinding(56741, "0.0.0.0")));
}
};
String containerId = runService.createAndStartContainer(imageConfiguration, portMapping, new GavLabel("Im:A:Test"), properties, getBaseDirectory(), "blah", new Date());
new Verifications() {
{
assertEquals("containerId", containerId);
}
};
}
Aggregations