use of com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerContainer method onClosed.
@Override
public void onClosed(Application application, OptionsByType optionsByType) {
OptionsByType closingOptions;
if (application != null) {
closingOptions = OptionsByType.of(application.getOptions());
closingOptions.addAll(optionsByType);
} else {
closingOptions = optionsByType;
}
ContainerCloseBehaviour behaviour = closingOptions.get(ContainerCloseBehaviour.class);
behaviour.accept(this);
}
use of com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerContainerTest method shouldCloseWithApplicationAndUseApplicationCloseBehaviour.
@Test
public void shouldCloseWithApplicationAndUseApplicationCloseBehaviour() throws Exception {
Application application = mock(Application.class);
DockerContainer container = new DockerContainer("foo", OptionsByType.empty());
ContainerCloseBehaviour behaviourApp = mock(ContainerCloseBehaviour.class);
when(application.getOptions()).thenReturn(OptionsByType.of(behaviourApp));
container.onClosed(application, OptionsByType.empty());
verify(behaviourApp).accept(same(container));
}
use of com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerContainerTest method shouldCloseWithApplicationAndUseOverridingBehaviour.
@Test
public void shouldCloseWithApplicationAndUseOverridingBehaviour() throws Exception {
Application application = mock(Application.class);
DockerContainer container = new DockerContainer("foo", OptionsByType.empty());
ContainerCloseBehaviour behaviourApp = mock(ContainerCloseBehaviour.class, "1");
ContainerCloseBehaviour behaviourOverride = mock(ContainerCloseBehaviour.class, "2");
when(application.getOptions()).thenReturn(OptionsByType.of(behaviourApp));
container.onClosed(application, OptionsByType.of(behaviourOverride));
verify(behaviourApp, never()).accept(same(container));
verify(behaviourOverride).accept(same(container));
}
use of com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerContainerTest method shouldCloseWithNullApplication.
@Test
public void shouldCloseWithNullApplication() throws Exception {
DockerContainer container = new DockerContainer("foo", OptionsByType.empty());
ContainerCloseBehaviour behaviour = mock(ContainerCloseBehaviour.class);
container.onClosed(null, OptionsByType.of(behaviour));
verify(behaviour).accept(same(container));
}
Aggregations