Search in sources :

Example 1 with Platform

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

the class CurlHttpDeployerTest method shouldDeployEmptyArtifacts.

@Test
public void shouldDeployEmptyArtifacts() throws Exception {
    Map<String, DeploymentArtifact> artifacts = new HashMap<>();
    String destination = "/foo";
    Platform platform = mock(Platform.class);
    InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
    OptionsByType optionsByType = OptionsByType.empty();
    CurlHttpDeployer deploymentMethod = new CurlHttpDeployer();
    DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
    deploymentMethod.deployAllArtifacts(artifacts, destination, platform, address, optionsByType, deployedArtifacts);
    verifyNoMoreInteractions(platform);
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) Platform(com.oracle.bedrock.runtime.Platform) HashMap(java.util.HashMap) InetSocketAddress(java.net.InetSocketAddress) DeployedArtifacts(com.oracle.bedrock.runtime.remote.DeployedArtifacts) DeploymentArtifact(com.oracle.bedrock.runtime.remote.DeploymentArtifact) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 2 with Platform

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

the class CurlHttpDeployerTest method shouldDeployNullArtifacts.

@Test
public void shouldDeployNullArtifacts() throws Exception {
    String destination = "/foo";
    Platform platform = mock(Platform.class);
    InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
    OptionsByType optionsByType = OptionsByType.empty();
    CurlHttpDeployer deploymentMethod = new CurlHttpDeployer();
    DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
    deploymentMethod.deployAllArtifacts(null, destination, platform, address, optionsByType, deployedArtifacts);
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) Platform(com.oracle.bedrock.runtime.Platform) InetSocketAddress(java.net.InetSocketAddress) DeployedArtifacts(com.oracle.bedrock.runtime.remote.DeployedArtifacts) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 3 with Platform

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

the class WGetHttpDeployerTest method shouldDeployNullArtifacts.

@Test
public void shouldDeployNullArtifacts() throws Exception {
    String destination = "/foo";
    Platform platform = mock(Platform.class);
    InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 1234);
    OptionsByType optionsByType = OptionsByType.empty();
    WGetHttpDeployer deploymentMethod = new WGetHttpDeployer();
    DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
    deploymentMethod.deployAllArtifacts(null, destination, platform, address, optionsByType, deployedArtifacts);
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) Platform(com.oracle.bedrock.runtime.Platform) InetSocketAddress(java.net.InetSocketAddress) DeployedArtifacts(com.oracle.bedrock.runtime.remote.DeployedArtifacts) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 4 with Platform

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

the class RemoteJavaApplicationLauncherTest method shouldInheritRuntimeProperties.

/**
 * Ensure that {@link JavaApplication}s correctly inherits arguments based on system properties
 * starting with bedrock.runtime.inherit.xxx=
 */
@Test
public void shouldInheritRuntimeProperties() throws Exception {
    // set a system property for this process
    System.getProperties().setProperty("bedrock.runtime.inherit.property", "-Dmessage=hello");
    // build and start the SleepingApplication
    Platform platform = getRemotePlatform();
    try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), IPv4Preferred.yes())) {
        // ask the application for the current system property value
        String message = application.getSystemProperty("message");
        // ensure that the application has the system property
        Assert.assertThat(message, is("hello"));
    } finally {
        // remove the system property to clean up
        System.getProperties().remove("bedrock.runtime.inherit.property");
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 5 with Platform

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

the class RemoteJavaApplicationLauncherTest method shouldSetWorkingDirectory.

@Test
public void shouldSetWorkingDirectory() throws Exception {
    String appName = "sleeping";
    File folder = temporaryFolder.newFolder();
    String appNameSanitized = PlatformSeparators.autoDetect().asSanitizedFileName(appName);
    File expectedDirectory = new File(folder, appNameSanitized);
    // build and start the SleepingApplication
    Platform platform = getRemotePlatform();
    try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), DisplayName.of(appName), WorkingDirectory.subDirectoryOf(folder))) {
        String dir = application.invoke(new GetWorkingDirectory());
        Assert.assertThat(dir, is(expectedDirectory.getCanonicalPath()));
        WorkingDirectory workingDir = application.getOptions().get(WorkingDirectory.class);
        Assert.assertThat(workingDir, is(notNullValue()));
        Assert.assertThat(workingDir.getValue(), is((Object) expectedDirectory));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) WorkingDirectory(com.oracle.bedrock.runtime.options.WorkingDirectory) Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) 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