Search in sources :

Example 16 with CacheFactory

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());
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 17 with CacheFactory

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());
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 18 with CacheFactory

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());
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 19 with CacheFactory

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());
}
Also used : ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager)

Example 20 with CacheFactory

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;
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory)

Aggregations

CacheFactory (org.apache.geode.cache.CacheFactory)125 Properties (java.util.Properties)51 Test (org.junit.Test)51 Cache (org.apache.geode.cache.Cache)44 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)38 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)28 Region (org.apache.geode.cache.Region)21 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)18 CacheServer (org.apache.geode.cache.server.CacheServer)17 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)17 File (java.io.File)15 Before (org.junit.Before)14 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)13 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)12 ClientCache (org.apache.geode.cache.client.ClientCache)11 Host (org.apache.geode.test.dunit.Host)11 IOException (java.io.IOException)10 AttributesFactory (org.apache.geode.cache.AttributesFactory)10 PdxType (org.apache.geode.pdx.internal.PdxType)9 MyPdxSerializer (com.examples.snapshot.MyPdxSerializer)8