Search in sources :

Example 16 with Platform

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

the class HelmCommandTest method shouldAddArguments.

@Test
public void shouldAddArguments() throws Exception {
    Platform platform = mock(Platform.class);
    OptionsByType options = OptionsByType.empty();
    HelmCommand command = newInstance();
    CLI copy = command.withArguments(Arguments.of(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)

Example 17 with Platform

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

the class HelmCommandTest method shouldAddFlags.

@Test
public void shouldAddFlags() throws Exception {
    Platform platform = mock(Platform.class);
    OptionsByType options = OptionsByType.empty();
    HelmCommand command = newInstance();
    CLI copy = command.withFlags(Arguments.of(Argument.of("arg-1"), Argument.of("arg-2")));
    assertThat(copy, is(notNullValue()));
    assertThat(copy, is(instanceOf(command.getClass())));
    assertThat(copy.getArguments(), is(command.getArguments()));
    assertThat(copy.getCommands(), is(command.getCommands()));
    assertThat(copy.getEnvironment(), is(command.getEnvironment()));
    Arguments flags = copy.getFlags();
    assertThat(flags, is(notNullValue()));
    List<String> list = flags.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 18 with Platform

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

the class CommonCommandTests method shouldSetEnvironmentVariableFromString.

@Test
public void shouldSetEnvironmentVariableFromString() throws Exception {
    Platform platform = mock(Platform.class);
    OptionsByType options = OptionsByType.empty();
    C command = newInstance();
    CLI copy = command.withEnvironment("foo-var");
    assertThat(copy, is(notNullValue()));
    assertThat(copy, is(instanceOf(command.getClass())));
    assertThat(copy.getCommands(), is(command.getCommands()));
    assertThat(copy.getArguments(), is(command.getArguments()));
    assertThat(copy.getFlags(), is(command.getFlags()));
    copy.onLaunching(platform, options);
    EnvironmentVariables variables = options.get(EnvironmentVariables.class);
    assertThat(variables, is(notNullValue()));
    Properties properties = variables.realize(platform);
    assertThat(properties, is(notNullValue()));
    assertThat(properties.containsKey("foo-var"), is(true));
}
Also used : EnvironmentVariables(com.oracle.bedrock.runtime.options.EnvironmentVariables) Platform(com.oracle.bedrock.runtime.Platform) Properties(java.util.Properties) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 19 with Platform

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

the class PowerShellHttpDeployerTest 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();
    PowerShellHttpDeployer deploymentMethod = new PowerShellHttpDeployer();
    DeployedArtifacts deployedArtifacts = new DeployedArtifacts();
    deploymentMethod.deployAllArtifacts(null, destination, platform, address, optionsByType, deployedArtifacts);
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) InetSocketAddress(java.net.InetSocketAddress) DeployedArtifacts(com.oracle.bedrock.runtime.remote.DeployedArtifacts) OptionsByType(com.oracle.bedrock.OptionsByType) AbstractWindowsTest(com.oracle.bedrock.runtime.remote.winrm.AbstractWindowsTest) Test(org.junit.Test)

Example 20 with Platform

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

the class AbstractWindowsTest method hasWinRM.

/**
 * Determine whether WinRM is running on the local platform.
 *
 * @return true if WinRM is running, otherwise false.
 */
public static boolean hasWinRM() {
    if (!isWindows()) {
        return false;
    }
    int exitCode = -1;
    Platform platform = LocalPlatform.get();
    CapturingApplicationConsole console = new CapturingApplicationConsole();
    try (Application application = platform.launch(Application.class, Executable.named("cmd.exe"), Argument.of("/C"), Argument.of("winrm"), Argument.of("enumerate"), Argument.of("winrm/config/listener"), DisplayName.of("WinRMCheck"), Console.of(console))) {
        try {
            exitCode = application.waitFor();
        } catch (AssertionError assertionError) {
        // ignored
        }
    }
    Queue<String> lines = console.getCapturedOutputLines();
    return exitCode == 0 && lines.size() > 0 && lines.poll().startsWith("Listener");
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) Platform(com.oracle.bedrock.runtime.Platform) CapturingApplicationConsole(com.oracle.bedrock.runtime.console.CapturingApplicationConsole) Application(com.oracle.bedrock.runtime.Application)

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