Search in sources :

Example 1 with ContainerCloseBehaviour

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);
}
Also used : ContainerCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour) OptionsByType(com.oracle.bedrock.OptionsByType)

Example 2 with ContainerCloseBehaviour

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));
}
Also used : ContainerCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour) Application(com.oracle.bedrock.runtime.Application) Test(org.junit.Test)

Example 3 with ContainerCloseBehaviour

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));
}
Also used : ContainerCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour) Application(com.oracle.bedrock.runtime.Application) Test(org.junit.Test)

Example 4 with ContainerCloseBehaviour

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));
}
Also used : ContainerCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour) Test(org.junit.Test)

Aggregations

ContainerCloseBehaviour (com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour)4 Test (org.junit.Test)3 Application (com.oracle.bedrock.runtime.Application)2 OptionsByType (com.oracle.bedrock.OptionsByType)1