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