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