Search in sources :

Example 56 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class UnregisterInterestDUnitTest method createClientCache.

public static void createClientCache(Host host, Integer port) throws Exception {
    DistributedSystem ds = new UnregisterInterestDUnitTest().getSystem();
    ds.disconnect();
    Properties props = new Properties();
    props.setProperty(LOCATORS, "");
    props.setProperty(MCAST_PORT, "0");
    ClientCacheFactory ccf = new ClientCacheFactory(props);
    ccf.setPoolSubscriptionEnabled(true);
    ccf.addPoolServer(host.getHostName(), port);
    cache = ccf.create();
    ClientRegionFactory crf = ((GemFireCacheImpl) cache).createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
    crf.create(regionname);
}
Also used : GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 57 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class RegisterInterestBeforeRegionCreationDUnitTest method createCache.

private void createCache(Properties props) throws Exception {
    DistributedSystem ds = getSystem(props);
    assertNotNull(ds);
    ds.disconnect();
    ds = getSystem(props);
    cache = CacheFactory.create(ds);
    assertNotNull(cache);
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 58 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class ReliableMessagingDUnitTest method createCache.

private Cache createCache(Properties props) throws Exception {
    DistributedSystem ds = getSystem(props);
    ds.disconnect();
    ds = getSystem(props);
    Cache result = null;
    result = CacheFactory.create(ds);
    if (result == null) {
        throw new Exception("CacheFactory.create() returned null ");
    }
    return result;
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Cache(org.apache.geode.cache.Cache)

Example 59 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class GfshCommandJUnitTest method testGetMemberWithMatchingMemberId.

@Test
public void testGetMemberWithMatchingMemberId() {
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
    final DistributedMember mockMemberOne = createMockMember("1", "One");
    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getMembers();
            will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
            oneOf(mockCache).getDistributedSystem();
            will(returnValue(mockDistributedSystem));
            oneOf(mockDistributedSystem).getDistributedMember();
            will(returnValue(mockMemberSelf));
        }
    });
    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
    assertSame(mockMemberTwo, commands.getMember(mockCache, "2"));
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 60 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class GfshCommandJUnitTest method testGetMemberWithMatchingMemberNameCaseInsensitive.

@Test
public void testGetMemberWithMatchingMemberNameCaseInsensitive() {
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
    final DistributedMember mockMemberOne = createMockMember("1", "One");
    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getMembers();
            will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
            oneOf(mockCache).getDistributedSystem();
            will(returnValue(mockDistributedSystem));
            oneOf(mockDistributedSystem).getDistributedMember();
            will(returnValue(mockMemberSelf));
        }
    });
    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
    assertSame(mockMemberSelf, commands.getMember(mockCache, "self"));
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DistributedSystem (org.apache.geode.distributed.DistributedSystem)250 Properties (java.util.Properties)102 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)65 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)61 Test (org.junit.Test)59 Cache (org.apache.geode.cache.Cache)55 AttributesFactory (org.apache.geode.cache.AttributesFactory)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)30 Region (org.apache.geode.cache.Region)24 IOException (java.io.IOException)20 CacheServer (org.apache.geode.cache.server.CacheServer)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 InternalCache (org.apache.geode.internal.cache.InternalCache)16 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 ArrayList (java.util.ArrayList)15 LogWriter (org.apache.geode.LogWriter)15 DistributedMember (org.apache.geode.distributed.DistributedMember)15 LocalRegion (org.apache.geode.internal.cache.LocalRegion)15 RegionAttributes (org.apache.geode.cache.RegionAttributes)14 Pool (org.apache.geode.cache.client.Pool)14