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"));
}
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"));
}
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));
}
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);
}
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");
}
Aggregations