Search in sources :

Example 1 with ImageCloseBehaviour

use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.

the class DockerImage 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;
    }
    ImageCloseBehaviour behaviour = closingOptions.get(ImageCloseBehaviour.class);
    behaviour.accept(this);
}
Also used : ImageCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour) OptionsByType(com.oracle.bedrock.OptionsByType)

Example 2 with ImageCloseBehaviour

use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.

the class DockerImageTest method shouldCloseWithNullApplication.

@Test
public void shouldCloseWithNullApplication() throws Exception {
    DockerImage image = new DockerImage(Arrays.asList("foo", "bar"), OptionsByType.empty());
    ImageCloseBehaviour behaviour = mock(ImageCloseBehaviour.class);
    image.onClosed(null, OptionsByType.of(behaviour));
    verify(behaviour).accept(same(image));
}
Also used : ImageCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour) Test(org.junit.Test)

Example 3 with ImageCloseBehaviour

use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.

the class DockerImageTest method shouldCloseWithApplicationAndUseApplicationCloseBehaviour.

@Test
public void shouldCloseWithApplicationAndUseApplicationCloseBehaviour() throws Exception {
    Application application = mock(Application.class);
    DockerImage image = new DockerImage(Arrays.asList("foo", "bar"), OptionsByType.empty());
    ImageCloseBehaviour behaviourApp = mock(ImageCloseBehaviour.class);
    when(application.getOptions()).thenReturn(OptionsByType.of(behaviourApp));
    image.onClosed(application, OptionsByType.empty());
    verify(behaviourApp).accept(same(image));
}
Also used : ImageCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour) Application(com.oracle.bedrock.runtime.Application) Test(org.junit.Test)

Example 4 with ImageCloseBehaviour

use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.

the class DockerImageTest method shouldCloseWithApplicationAndUseOverridingBehaviour.

@Test
public void shouldCloseWithApplicationAndUseOverridingBehaviour() throws Exception {
    Application application = mock(Application.class);
    DockerImage image = new DockerImage(Arrays.asList("foo", "bar"), OptionsByType.empty());
    ImageCloseBehaviour behaviourApp = mock(ImageCloseBehaviour.class, "1");
    ImageCloseBehaviour behaviourOverride = mock(ImageCloseBehaviour.class, "2");
    when(application.getOptions()).thenReturn(OptionsByType.of(behaviourApp));
    image.onClosed(application, OptionsByType.of(behaviourOverride));
    verify(behaviourApp, never()).accept(same(image));
    verify(behaviourOverride).accept(same(image));
}
Also used : ImageCloseBehaviour(com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour) Application(com.oracle.bedrock.runtime.Application) Test(org.junit.Test)

Aggregations

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