Search in sources :

Example 26 with Platform

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

the class AbstractCoherenceCacheServerTest method shouldStartJMXConnection.

/**
 * Ensure we can start and connect to the Coherence using the {@link JmxFeature}.
 *
 * @throws Exception
 */
@Test
public void shouldStartJMXConnection() throws Exception {
    AvailablePortIterator availablePorts = LocalPlatform.get().getAvailablePorts();
    Platform platform = getPlatform();
    try (CoherenceCacheServer server = platform.launch(CoherenceCacheServer.class, ClusterPort.from(availablePorts), LocalHost.only(), RoleName.of("test-role"), SiteName.of("test-site"), JmxFeature.enabled(), JMXManagementMode.LOCAL_ONLY)) {
        assertThat(invoking(server).getClusterSize(), is(1));
        assertThat(server.getRoleName(), is("test-role"));
        assertThat(server.getSiteName(), is("test-site"));
        JmxFeature jmxFeature = server.get(JmxFeature.class);
        assertThat(jmxFeature, is(notNullValue()));
        // use JMX to determine the cluster size
        int size = jmxFeature.getMBeanAttribute(new ObjectName("Coherence:type=Cluster"), "ClusterSize", Integer.class);
        assertThat(size, is(1));
    }
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) AvailablePortIterator(com.oracle.bedrock.runtime.network.AvailablePortIterator) JmxFeature(com.oracle.bedrock.runtime.java.features.JmxFeature) ObjectName(javax.management.ObjectName) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.Test)

Example 27 with Platform

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

the class AbstractCoherenceCacheServerTest method shouldStartSingletonCluster.

/**
 * Ensure that we can start and stop a single Coherence Cluster Member.
 */
@Test
public void shouldStartSingletonCluster() {
    Platform platform = getPlatform();
    try (CoherenceCacheServer server = platform.launch(CoherenceCacheServer.class, ClusterPort.automatic(), LocalHost.only(), Diagnostics.enabled(), Console.system())) {
        Eventually.assertThat(server, new GetLocalMemberId(), is(1));
        Eventually.assertThat(server, new GetClusterSize(), is(1));
        Eventually.assertThat(server, new GetServiceStatus("DistributedCache"), is(ServiceStatus.ENDANGERED));
    }
}
Also used : GetLocalMemberId(com.oracle.bedrock.runtime.coherence.callables.GetLocalMemberId) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) GetClusterSize(com.oracle.bedrock.runtime.coherence.callables.GetClusterSize) GetServiceStatus(com.oracle.bedrock.runtime.coherence.callables.GetServiceStatus) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.Test)

Example 28 with Platform

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

the class CoherenceSessionIT method shouldGetSystemSession.

@Test
public void shouldGetSystemSession() {
    Platform platform = getPlatform();
    try (CoherenceCacheServer server = platform.launch(CoherenceCacheServer.class, ClusterPort.automatic(), LocalHost.only(), Console.system())) {
        Eventually.assertThat(server, new GetLocalMemberId(), is(1));
        Eventually.assertThat(server, new GetClusterSize(), is(1));
        Session session = server.getSession(Coherence.SYSTEM_SESSION);
        assertThat(session, is(notNullValue()));
        assertThat(session.isActive(), is(true));
        assertThat(session.getScopeName(), is(Coherence.SYSTEM_SESSION));
    }
}
Also used : GetLocalMemberId(com.oracle.bedrock.runtime.coherence.callables.GetLocalMemberId) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) GetClusterSize(com.oracle.bedrock.runtime.coherence.callables.GetClusterSize) Session(com.tangosol.net.Session) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 29 with Platform

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

the class CoherenceSessionIT method shouldGetDefaultSession.

@Test
public void shouldGetDefaultSession() {
    Platform platform = getPlatform();
    try (CoherenceCacheServer server = platform.launch(CoherenceCacheServer.class, ClusterPort.automatic(), LocalHost.only(), Console.system())) {
        Eventually.assertThat(server, new GetLocalMemberId(), is(1));
        Eventually.assertThat(server, new GetClusterSize(), is(1));
        Session session = server.getSession();
        assertThat(session, is(notNullValue()));
        assertThat(session.isActive(), is(true));
        assertThat(session.getScopeName(), is(Coherence.DEFAULT_SCOPE));
    }
}
Also used : GetLocalMemberId(com.oracle.bedrock.runtime.coherence.callables.GetLocalMemberId) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) GetClusterSize(com.oracle.bedrock.runtime.coherence.callables.GetClusterSize) Session(com.tangosol.net.Session) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 30 with Platform

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

the class CoherenceSessionIT method shouldGetCacheFromDefaultSession.

@Test
public void shouldGetCacheFromDefaultSession() {
    Platform platform = getPlatform();
    try (CoherenceCacheServer server = platform.launch(CoherenceCacheServer.class, ClusterPort.automatic(), LocalHost.only(), Console.system())) {
        Eventually.assertThat(server, new GetLocalMemberId(), is(1));
        Eventually.assertThat(server, new GetClusterSize(), is(1));
        Session session = server.getSession();
        assertThat(session, is(notNullValue()));
        NamedCache<String, String> sessionCache = session.getCache("test");
        NamedCache<String, String> cache = server.getCache("test");
        assertThat(sessionCache, is(notNullValue()));
        assertThat(cache, is(notNullValue()));
        sessionCache.put("key-1", "value-1");
        assertThat(cache.get("key-1"), is("value-1"));
    }
}
Also used : GetLocalMemberId(com.oracle.bedrock.runtime.coherence.callables.GetLocalMemberId) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) GetClusterSize(com.oracle.bedrock.runtime.coherence.callables.GetClusterSize) Session(com.tangosol.net.Session) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.jupiter.api.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