Search in sources :

Example 21 with Platform

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

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

Example 22 with Platform

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

the class JavaVirtualMachineTest method shouldReturnLocalPlatformAddress.

@Test
public void shouldReturnLocalPlatformAddress() throws Exception {
    Platform platform = JavaVirtualMachine.get();
    assertThat(platform.getAddress(), is(LocalPlatform.get().getAddress()));
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) Test(org.junit.Test)

Example 23 with Platform

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

the class SimpleJUnitTestRunTest method shouldAddListenersFromOptions.

@Test
public void shouldAddListenersFromOptions() throws Exception {
    Platform platform = mock(Platform.class);
    JavaApplicationProcess process = mock(JavaApplicationProcess.class);
    SimpleJUnitTestListener listener1 = new SimpleJUnitTestListener();
    SimpleJUnitTestListener listener2 = new SimpleJUnitTestListener();
    OptionsByType optionsByType = OptionsByType.of(listener1.asOption(), listener2.asOption());
    try (SimpleJUnitTestRun application = new SimpleJUnitTestRun(platform, process, optionsByType)) {
        assertThat(application.getRunListeners(), containsInAnyOrder(listener1, listener2));
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) JavaApplicationProcess(com.oracle.bedrock.runtime.java.JavaApplicationProcess) SimpleJUnitTestRun(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 24 with Platform

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

the class SimpleJUnitTestRunTest method shouldStartTests.

@Test
public void shouldStartTests() throws Exception {
    Platform platform = mock(Platform.class);
    JavaApplicationProcess process = mock(JavaApplicationProcess.class);
    OptionsByType optionsByType = OptionsByType.empty();
    try (SimpleJUnitTestRun application = new SimpleJUnitTestRun(platform, process, optionsByType)) {
        TestClasses testClasses = TestClasses.empty();
        OptionsByType testOptions = OptionsByType.of(testClasses);
        SimpleJUnitTestRun spyApp = spy(application);
        doReturn(null).when(spyApp).submit(any(RemoteCallable.class), anyVararg());
        spyApp.startTests(testOptions);
        ArgumentCaptor<RemoteCallable> captorCallable = ArgumentCaptor.forClass(RemoteCallable.class);
        verify(spyApp).submit(captorCallable.capture(), anyVararg());
        RemoteCallable callable = captorCallable.getValue();
        assertThat(callable, is(instanceOf(JUnitTestRunner.StartTests.class)));
        JUnitTestRunner.StartTests startTests = (JUnitTestRunner.StartTests) callable;
        assertThat(startTests.getOptions(), is(arrayContainingInAnyOrder(testClasses)));
    }
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) Platform(com.oracle.bedrock.runtime.Platform) RemoteCallable(com.oracle.bedrock.runtime.concurrent.RemoteCallable) JavaApplicationProcess(com.oracle.bedrock.runtime.java.JavaApplicationProcess) SimpleJUnitTestRun(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun) OptionsByType(com.oracle.bedrock.OptionsByType) JUnitTestRunner(com.oracle.bedrock.testsupport.junit.JUnitTestRunner) Test(org.junit.Test)

Example 25 with Platform

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

the class AbstractCoherenceClusterBuilderTest method shouldPerformRollingRestartOfCluster.

/**
 * Ensure we perform a rolling restart of a {@link CoherenceCluster}
 */
@Test
public void shouldPerformRollingRestartOfCluster() {
    final int CLUSTER_SIZE = 4;
    AvailablePortIterator availablePorts = LocalPlatform.get().getAvailablePorts();
    ClusterPort clusterPort = ClusterPort.of(new Capture<>(availablePorts));
    String clusterName = "Rolling" + getClass().getSimpleName();
    Platform platform = getPlatform();
    CoherenceClusterBuilder builder = new CoherenceClusterBuilder();
    builder.include(CLUSTER_SIZE, CoherenceClusterMember.class, DisplayName.of("DCS"), clusterPort, ClusterName.of(clusterName), LocalHost.only(), Console.system());
    try (CoherenceCluster cluster = builder.build(getPlatform())) {
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        StabilityPredicate<CoherenceCluster> predicate = StabilityPredicate.of(CoherenceCluster.Predicates.autoStartServicesSafe());
        cluster.filter(member -> member.isServiceRunning("ProxyService")).relaunch();
        cluster.unordered().limit(2).relaunch(predicate);
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        cluster.unordered().limit(2).relaunch(predicate);
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        cluster.unordered().limit(2).relaunch(predicate);
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        // introduce a new system property for the relaunched members
        cluster.relaunch(predicate, SystemProperty.of("cloned", "yes"));
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        // ensure all the members have the new system property
        for (CoherenceClusterMember member : cluster) {
            assertThat(member.getSystemProperty("cloned"), is("yes"));
        }
    }
}
Also used : WellKnownAddress(com.oracle.bedrock.runtime.coherence.options.WellKnownAddress) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Decoration(com.oracle.bedrock.options.Decoration) ClusterName(com.oracle.bedrock.runtime.coherence.options.ClusterName) MachineName(com.oracle.bedrock.runtime.coherence.options.MachineName) StabilityPredicate(com.oracle.bedrock.runtime.options.StabilityPredicate) ClusterPort(com.oracle.bedrock.runtime.coherence.options.ClusterPort) CacheConfig(com.oracle.bedrock.runtime.coherence.options.CacheConfig) Capture(com.oracle.bedrock.util.Capture) HashSet(java.util.HashSet) LocalHost(com.oracle.bedrock.runtime.coherence.options.LocalHost) Console(com.oracle.bedrock.runtime.options.Console) AvailablePortIterator(com.oracle.bedrock.runtime.network.AvailablePortIterator) OptionsByType(com.oracle.bedrock.OptionsByType) NamedCache(com.tangosol.net.NamedCache) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Trilean(com.oracle.bedrock.util.Trilean) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) LocalStorage(com.oracle.bedrock.runtime.coherence.options.LocalStorage) Test(org.junit.Test) SystemProperty(com.oracle.bedrock.runtime.java.options.SystemProperty) DeferredHelper.invoking(com.oracle.bedrock.deferred.DeferredHelper.invoking) Eventually.assertThat(com.oracle.bedrock.testsupport.deferred.Eventually.assertThat) Platform(com.oracle.bedrock.runtime.Platform) ApplicationListener(com.oracle.bedrock.runtime.ApplicationListener) DisplayName(com.oracle.bedrock.runtime.options.DisplayName) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Assert(org.junit.Assert) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) AvailablePortIterator(com.oracle.bedrock.runtime.network.AvailablePortIterator) ClusterPort(com.oracle.bedrock.runtime.coherence.options.ClusterPort) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) 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