use of com.oracle.bedrock.runtime.Application 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.Application in project oracle-bedrock by coherence-community.
the class DockerContainerTest method shouldAddAsFeature.
@Test
public void shouldAddAsFeature() throws Exception {
Platform platform = mock(Platform.class);
Application application = mock(Application.class);
DockerContainer container = new DockerContainer("foo", OptionsByType.empty());
when(application.getPlatform()).thenReturn(platform);
container.onAddingTo(application);
assertThat(container.getApplication(), is(sameInstance(application)));
}
use of com.oracle.bedrock.runtime.Application in project oracle-bedrock by coherence-community.
the class DockerContainerTest method shouldRunInspectWithFilter.
@Test
public void shouldRunInspectWithFilter() throws Exception {
Docker docker = Docker.auto();
Platform platform = mock(Platform.class);
Application application = mock(Application.class, "App");
Application inspectApp = mock(Application.class, "Inspect");
Inspect inspect = mock(Inspect.class);
DockerContainer container = new DockerContainer("foo", OptionsByType.of(docker));
DockerContainer containerSpy = spy(container);
when(application.getPlatform()).thenReturn(platform);
when(platform.launch(any(MetaClass.class))).thenReturn(inspectApp);
when(inspect.format(anyString())).thenReturn(inspect);
doReturn(inspect).when(containerSpy).createInspectCommand();
containerSpy.onAddingTo(application);
containerSpy.inspect("{{filter}}");
verify(inspect).run(same(platform), same(docker));
verify(inspect).format(eq("{{filter}}"));
}
use of com.oracle.bedrock.runtime.Application 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.Application in project oracle-bedrock by coherence-community.
the class DockerImageTest method shouldRemoveImage.
@Test
public void shouldRemoveImage() throws Exception {
Docker docker = Docker.auto();
Platform platform = mock(Platform.class);
Application application = mock(Application.class, "App");
Application removeApp = mock(Application.class, "Inspect");
DockerImage image = new DockerImage(Arrays.asList("foo"), OptionsByType.of(docker));
when(application.getPlatform()).thenReturn(platform);
when(platform.launch(any(MetaClass.class), anyVararg())).thenReturn(removeApp);
image.onAddingTo(application);
image.remove();
ArgumentCaptor<MetaClass> captor = ArgumentCaptor.forClass(MetaClass.class);
verify(platform).launch(captor.capture(), anyVararg());
Remove.RemoveImage remove = (Remove.RemoveImage) captor.getValue();
assertThat(remove, is(notNullValue()));
OptionsByType optionsByType = OptionsByType.empty();
remove.onLaunch(platform, optionsByType);
Arguments arguments = optionsByType.get(Arguments.class);
List<String> values = arguments.resolve(mock(Platform.class), OptionsByType.empty());
assertThat(values, contains("rmi", "foo"));
}
Aggregations