Search in sources :

Example 21 with Application

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

Example 22 with Application

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

Example 23 with 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}}"));
}
Also used : Inspect(com.oracle.bedrock.runtime.docker.commands.Inspect) Platform(com.oracle.bedrock.runtime.Platform) MetaClass(com.oracle.bedrock.runtime.MetaClass) Application(com.oracle.bedrock.runtime.Application) Test(org.junit.Test)

Example 24 with Application

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

Example 25 with Application

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"));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Arguments(com.oracle.bedrock.runtime.options.Arguments) Remove(com.oracle.bedrock.runtime.docker.commands.Remove) MetaClass(com.oracle.bedrock.runtime.MetaClass) Application(com.oracle.bedrock.runtime.Application) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Aggregations

Application (com.oracle.bedrock.runtime.Application)57 Test (org.junit.Test)23 CapturingApplicationConsole (com.oracle.bedrock.runtime.console.CapturingApplicationConsole)22 Platform (com.oracle.bedrock.runtime.Platform)16 Arguments (com.oracle.bedrock.runtime.options.Arguments)13 OptionsByType (com.oracle.bedrock.OptionsByType)12 File (java.io.File)12 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)11 Timeout (com.oracle.bedrock.options.Timeout)9 MetaClass (com.oracle.bedrock.runtime.MetaClass)9 List (java.util.List)7 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)6 Remove (com.oracle.bedrock.runtime.docker.commands.Remove)5 RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)5 InetAddress (java.net.InetAddress)5 SleepingApplication (applications.SleepingApplication)4 ContainerCloseBehaviour (com.oracle.bedrock.runtime.docker.options.ContainerCloseBehaviour)4 TimeUnit (java.util.concurrent.TimeUnit)4 Collectors (java.util.stream.Collectors)4 EventingApplication (classloader.applications.EventingApplication)3