Search in sources :

Example 11 with Platform

use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.

the class RemoteJavaApplicationLauncherTest method shouldSendEventsToApplication.

@Test
public void shouldSendEventsToApplication() throws Exception {
    Platform platform = getRemotePlatform();
    EventListener listener = new EventListener(1);
    RemoteEvent event = new EventingApplication.Event(19);
    try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(EventingApplication.class), IPv4Preferred.yes())) {
        application.addListener(listener, StreamName.of("Back"));
        EventingApplication.listen(application, "Out", "Back");
        application.raise(event, StreamName.of("Out"));
        Assert.assertThat(listener.await(1, TimeUnit.MINUTES), is(true));
        Assert.assertThat(listener.getEvents().size(), is(1));
        Assert.assertThat(listener.getEvents().get(0), is(event));
        application.close();
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) RemoteEvent(com.oracle.bedrock.runtime.concurrent.RemoteEvent) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) RemoteEvent(com.oracle.bedrock.runtime.concurrent.RemoteEvent) RemoteEventListener(com.oracle.bedrock.runtime.concurrent.RemoteEventListener) EventingApplication(com.oracle.bedrock.runtime.remote.java.applications.EventingApplication) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 12 with Platform

use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.

the class FileShareDeployerTest method shouldDeployArtifactWithDestination.

@Test
public void shouldDeployArtifactWithDestination() throws Exception {
    Platform platform = mock(Platform.class);
    Option option = mock(Option.class);
    OptionsByType platformOptions = OptionsByType.empty();
    File localShareFolder = temporaryFolder.newFolder();
    File remoteShareFolder = temporaryFolder.newFolder();
    File workingFolder = temporaryFolder.newFolder();
    String content = "File 1";
    File sourceFile = createSourceFile(content);
    File destinationFolder = temporaryFolder.newFolder();
    File destinationFile = new File(destinationFolder, "foo.txt");
    when(platform.getOptions()).thenReturn(platformOptions);
    DeploymentArtifact artifact = new DeploymentArtifact(sourceFile, destinationFile);
    FileShareDeployerStub deployer = new FileShareDeployerStub(localShareFolder.getAbsolutePath(), remoteShareFolder.getAbsolutePath());
    deployer.deploy(Collections.singletonList(artifact), workingFolder.getCanonicalPath(), platform, option);
    assertThat(destinationFile.exists(), is(true));
    try (BufferedReader reader = new BufferedReader(new FileReader(destinationFile))) {
        String line = reader.readLine();
        assertThat(line, is(content));
    }
    assertThat(deployer.platform, is(sameInstance(platform)));
    assertThat(deployer.optionsByType.asArray(), hasItemInArray(sameInstance(option)));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) BufferedReader(java.io.BufferedReader) Option(com.oracle.bedrock.Option) FileReader(java.io.FileReader) Matchers.anyString(org.mockito.Matchers.anyString) OptionsByType(com.oracle.bedrock.OptionsByType) File(java.io.File) DeploymentArtifact(com.oracle.bedrock.runtime.remote.DeploymentArtifact) Test(org.junit.Test)

Example 13 with Platform

use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.

the class FileShareDeployerTest method shouldDeployArtifactWhenFinalDestinationIsRemoteShare.

@Test
public void shouldDeployArtifactWhenFinalDestinationIsRemoteShare() throws Exception {
    Platform platform = mock(Platform.class);
    Option option = mock(Option.class);
    OptionsByType platformOptions = OptionsByType.empty();
    File localShareFolder = temporaryFolder.newFolder();
    File remoteShareFolder = temporaryFolder.newFolder();
    File workingFolder = temporaryFolder.newFolder();
    String content = "File 3";
    File sourceFile = createSourceFile(content);
    File destinationFile = new File(remoteShareFolder, sourceFile.getName());
    when(platform.getOptions()).thenReturn(platformOptions);
    DeploymentArtifact artifact = new DeploymentArtifact(sourceFile, destinationFile);
    FileShareDeployer deployer = new FileShareDeployerStub(localShareFolder.getAbsolutePath(), remoteShareFolder.getAbsolutePath());
    FileShareDeployer spy = spy(deployer);
    spy.deploy(Collections.singletonList(artifact), workingFolder.getCanonicalPath(), platform, option);
    verify(spy, never()).performRemoteCopy(anyString(), anyString(), any(Platform.class), any(OptionsByType.class));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Option(com.oracle.bedrock.Option) Matchers.anyString(org.mockito.Matchers.anyString) OptionsByType(com.oracle.bedrock.OptionsByType) File(java.io.File) DeploymentArtifact(com.oracle.bedrock.runtime.remote.DeploymentArtifact) Test(org.junit.Test)

Example 14 with Platform

use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.

the class HelmCommandTest method shouldAddArgumentValues.

@Test
public void shouldAddArgumentValues() throws Exception {
    Platform platform = mock(Platform.class);
    OptionsByType options = OptionsByType.empty();
    HelmCommand command = newInstance();
    CLI copy = command.withArguments("arg-1", "arg-2");
    assertThat(copy, is(notNullValue()));
    assertThat(copy, is(instanceOf(command.getClass())));
    assertThat(copy.getCommands(), is(command.getCommands()));
    assertThat(copy.getFlags(), is(command.getFlags()));
    assertThat(copy.getEnvironment(), is(command.getEnvironment()));
    Arguments args = copy.getArguments();
    assertThat(args, is(notNullValue()));
    List<String> list = args.resolve(platform, options);
    assertThat(list, is(notNullValue()));
    assertThat(list, contains("arg-1", "arg-2"));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Arguments(com.oracle.bedrock.runtime.options.Arguments) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 15 with Platform

use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.

the class HelmCommandTest method shouldAddArgument.

@Test
public void shouldAddArgument() throws Exception {
    Platform platform = mock(Platform.class);
    OptionsByType options = OptionsByType.empty();
    HelmCommand command = newInstance();
    CLI copy = command.withArguments(Argument.of("arg-1"), Argument.of("arg-2"));
    assertThat(copy, is(notNullValue()));
    assertThat(copy, is(instanceOf(command.getClass())));
    assertThat(copy.getCommands(), is(command.getCommands()));
    assertThat(copy.getFlags(), is(command.getFlags()));
    assertThat(copy.getEnvironment(), is(command.getEnvironment()));
    Arguments args = copy.getArguments();
    assertThat(args, is(notNullValue()));
    List<String> list = args.resolve(platform, options);
    assertThat(list, is(notNullValue()));
    assertThat(list, contains("arg-1", "arg-2"));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) Arguments(com.oracle.bedrock.runtime.options.Arguments) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Aggregations

Platform (com.oracle.bedrock.runtime.Platform)86 Test (org.junit.Test)69 OptionsByType (com.oracle.bedrock.OptionsByType)55 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)49 MetaClass (com.oracle.bedrock.runtime.MetaClass)23 Arguments (com.oracle.bedrock.runtime.options.Arguments)18 Application (com.oracle.bedrock.runtime.Application)16 File (java.io.File)15 RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)14 AbstractTest (com.oracle.bedrock.testsupport.junit.AbstractTest)12 DeploymentArtifact (com.oracle.bedrock.runtime.remote.DeploymentArtifact)11 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)10 AbstractRemoteTest (com.oracle.bedrock.runtime.remote.AbstractRemoteTest)10 ArrayList (java.util.ArrayList)8 Option (com.oracle.bedrock.Option)7 GetClusterSize (com.oracle.bedrock.runtime.coherence.callables.GetClusterSize)7 GetLocalMemberId (com.oracle.bedrock.runtime.coherence.callables.GetLocalMemberId)7 Properties (java.util.Properties)7 Matchers.anyString (org.mockito.Matchers.anyString)7 EnvironmentVariables (com.oracle.bedrock.runtime.options.EnvironmentVariables)6