use of io.fabric8.maven.docker.util.Task in project fabric8 by jboss-fuse.
the class WaitForProvisionTaskTest method testProvisioningTimeout.
@Test
public void testProvisioningTimeout() throws Exception {
Container container = createMock(Container.class);
expect(container.getId()).andReturn("container").anyTimes();
expect(container.isAlive()).andReturn(true).anyTimes();
expect(container.isManaged()).andReturn(true).anyTimes();
expect(container.getProvisionStatus()).andReturn("").anyTimes();
expect(container.getSshUrl()).andReturn("container:8181").anyTimes();
expect(container.getProvisionException()).andReturn(null).anyTimes();
replay(container);
WaitForProvisionTask task = new WaitForProvisionTask(container, "success", 4000L);
assertFalse(task.call());
verify(container);
}
use of io.fabric8.maven.docker.util.Task in project fabric8-maven-plugin by fabric8io.
the class DockerImageWatcher method watch.
@Override
public void watch(List<ImageConfiguration> configs, final Set<HasMetadata> resources, PlatformMode mode) {
BuildService.BuildContext buildContext = getContext().getBuildContext();
WatchService.WatchContext watchContext = getContext().getWatchContext();
// add a image customizer
watchContext = new WatchService.WatchContext.Builder(watchContext).imageCustomizer(new Task<ImageConfiguration>() {
@Override
public void execute(ImageConfiguration imageConfiguration) throws DockerAccessException, MojoExecutionException, MojoFailureException {
buildImage(imageConfiguration);
}
}).containerRestarter(new Task<WatchService.ImageWatcher>() {
@Override
public void execute(WatchService.ImageWatcher imageWatcher) throws DockerAccessException, MojoExecutionException, MojoFailureException {
restartContainer(imageWatcher, resources);
}
}).build();
ServiceHub hub = getContext().getServiceHub();
try {
hub.getWatchService().watch(watchContext, buildContext, configs);
} catch (Exception ex) {
throw new RuntimeException("Error while watching", ex);
}
}
Aggregations