use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class LauncherMemberMXBeanIntegrationTest method testQueryForMemberMXBeanWithProcessId.
@Test
public void testQueryForMemberMXBeanWithProcessId() throws Exception {
final Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
props.setProperty("name", getUniqueName());
new CacheFactory(props).create();
final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
final QueryExp constraint = Query.eq(Query.attr("ProcessId"), Query.value(ProcessUtils.identifyPid()));
waitForMemberMXBean(mbeanServer, pattern);
final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
assertFalse(mbeanNames.isEmpty());
assertEquals(1, mbeanNames.size());
final ObjectName objectName = mbeanNames.iterator().next();
final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
assertNotNull(mbean);
assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
assertEquals(getUniqueName(), mbean.getName());
assertEquals(getUniqueName(), mbean.getMember());
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class LauncherMemberMXBeanIntegrationTest method testQueryForMemberMXBean.
@Test
public void testQueryForMemberMXBean() throws Exception {
final Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
props.setProperty("name", getUniqueName());
new CacheFactory(props).create();
final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
waitForMemberMXBean(mbeanServer, pattern);
final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
assertFalse(mbeanNames.isEmpty());
assertEquals("mbeanNames=" + mbeanNames, 1, mbeanNames.size());
final ObjectName objectName = mbeanNames.iterator().next();
final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
assertNotNull(mbean);
assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
assertEquals(getUniqueName(), mbean.getName());
assertEquals(getUniqueName(), mbean.getMember());
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class LauncherMemberMXBeanIntegrationTest method testQueryForMemberMXBeanWithMemberName.
@Test
public void testQueryForMemberMXBeanWithMemberName() throws Exception {
final Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
props.setProperty("name", getUniqueName());
new CacheFactory(props).create();
final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
final QueryExp constraint = Query.eq(Query.attr("Name"), Query.value(getUniqueName()));
waitForMemberMXBean(mbeanServer, pattern);
final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
assertFalse(mbeanNames.isEmpty());
assertEquals(1, mbeanNames.size());
final ObjectName objectName = mbeanNames.iterator().next();
final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
assertNotNull(mbean);
assertEquals(getUniqueName(), mbean.getMember());
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class DistTXManagerImplJUnitTest method createCache.
@Override
protected void createCache() {
Properties props = new Properties();
props.put(MCAST_PORT, "0");
props.put(LOCATORS, "");
props.put(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
cache = new CacheFactory(props).create();
region = cache.createRegionFactory(RegionShortcut.REPLICATE).create("testRegion");
CacheTransactionManager txmgr = cache.getCacheTransactionManager();
assert (txmgr.isDistributed());
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class InlineKeyJUnitTest method createCache.
private GemFireCacheImpl createCache() {
Properties props = new Properties();
props.setProperty(LOCATORS, "");
props.setProperty(MCAST_PORT, "0");
GemFireCacheImpl result = (GemFireCacheImpl) new CacheFactory(props).create();
return result;
}
Aggregations