Search in sources :

Example 11 with DiskStore

use of org.apache.geode.cache.DiskStore in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsRegionUsingDiskStoreWhenOverflowing.

@Test
public void testIsRegionUsingDiskStoreWhenOverflowing() {
    final String diskStoreName = "testDiskStore";
    final Region mockRegion = mockContext.mock(Region.class, "Region");
    final RegionAttributes mockRegionAttributes = mockContext.mock(RegionAttributes.class, "RegionAttributes");
    final EvictionAttributes mockEvictionAttributes = mockContext.mock(EvictionAttributes.class, "EvictionAttributes");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            exactly(4).of(mockRegion).getAttributes();
            will(returnValue(mockRegionAttributes));
            oneOf(mockRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.PARTITION));
            oneOf(mockRegionAttributes).getDiskStoreName();
            will(returnValue(diskStoreName));
            exactly(2).of(mockRegionAttributes).getEvictionAttributes();
            will(returnValue(mockEvictionAttributes));
            oneOf(mockEvictionAttributes).getAction();
            will(returnValue(EvictionAction.OVERFLOW_TO_DISK));
            oneOf(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertTrue(function.isUsingDiskStore(mockRegion, mockDiskStore));
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) EvictionAttributes(org.apache.geode.cache.EvictionAttributes) RegionAttributes(org.apache.geode.cache.RegionAttributes) Region(org.apache.geode.cache.Region) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 12 with DiskStore

use of org.apache.geode.cache.DiskStore in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testSetCacheServerDetails.

@Test
public void testSetCacheServerDetails() {
    final String diskStoreName = "testDiskStore";
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
    final CacheServer mockCacheServer1 = mockContext.mock(CacheServer.class, "CacheServer1");
    final CacheServer mockCacheServer2 = mockContext.mock(CacheServer.class, "CacheServer2");
    final CacheServer mockCacheServer3 = mockContext.mock(CacheServer.class, "CacheServer3");
    final ClientSubscriptionConfig mockCacheServer1ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer1ClientSubscriptionConfig");
    final ClientSubscriptionConfig mockCacheServer2ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer2ClientSubscriptionConfig");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getCacheServers();
            will(returnValue(Arrays.asList(mockCacheServer1, mockCacheServer2, mockCacheServer3)));
            exactly(2).of(mockCacheServer1).getClientSubscriptionConfig();
            will(returnValue(mockCacheServer1ClientSubscriptionConfig));
            oneOf(mockCacheServer1ClientSubscriptionConfig).getDiskStoreName();
            will(returnValue(diskStoreName));
            oneOf(mockCacheServer1).getBindAddress();
            will(returnValue("10.127.255.1"));
            oneOf(mockCacheServer1).getPort();
            will(returnValue(65536));
            oneOf(mockCacheServer1).getHostnameForClients();
            will(returnValue("gemini"));
            exactly(2).of(mockCacheServer2).getClientSubscriptionConfig();
            will(returnValue(mockCacheServer2ClientSubscriptionConfig));
            oneOf(mockCacheServer2ClientSubscriptionConfig).getDiskStoreName();
            will(returnValue("  "));
            oneOf(mockCacheServer3).getClientSubscriptionConfig();
            will(returnValue(null));
            exactly(3).of(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final Set<DiskStoreDetails.CacheServerDetails> expectedCacheServerDetails = CollectionUtils.asSet(createCacheServerDetails("10.127.255.1", 65536, "gemini"));
    final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    function.setCacheServerDetails(mockCache, mockDiskStore, diskStoreDetails);
    assertCacheServerDetails(expectedCacheServerDetails, diskStoreDetails);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) InternalCache(org.apache.geode.internal.cache.InternalCache) CacheServer(org.apache.geode.cache.server.CacheServer) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 13 with DiskStore

use of org.apache.geode.cache.DiskStore in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsCacheServerUsingDiskStoreWhenUsingDefaultDiskStore.

@Test
public void testIsCacheServerUsingDiskStoreWhenUsingDefaultDiskStore() {
    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
    final ClientSubscriptionConfig mockClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "ClientSubscriptionConfig");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            exactly(2).of(mockCacheServer).getClientSubscriptionConfig();
            will(returnValue(mockClientSubscriptionConfig));
            oneOf(mockClientSubscriptionConfig).getDiskStoreName();
            will(returnValue(""));
            oneOf(mockDiskStore).getName();
            will(returnValue(DiskStoreDetails.DEFAULT_DISK_STORE_NAME));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertTrue(function.isUsingDiskStore(mockCacheServer, mockDiskStore));
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 14 with DiskStore

use of org.apache.geode.cache.DiskStore in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsGatewaySenderUsingDiskStoreWhenUsingDefaultDiskStores.

@Test
public void testIsGatewaySenderUsingDiskStoreWhenUsingDefaultDiskStores() {
    final GatewaySender mockGatewaySender = mockContext.mock(GatewaySender.class, "GatewaySender");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockGatewaySender).getDiskStoreName();
            will(returnValue(" "));
            oneOf(mockDiskStore).getName();
            will(returnValue(DiskStoreDetails.DEFAULT_DISK_STORE_NAME));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertTrue(function.isUsingDiskStore(mockGatewaySender, mockDiskStore));
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 15 with DiskStore

use of org.apache.geode.cache.DiskStore in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsCacheServerUsingDiskStore.

@Test
public void testIsCacheServerUsingDiskStore() {
    final String diskStoreName = "testDiskStore";
    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
    final ClientSubscriptionConfig mockClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "ClientSubscriptionConfig");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            exactly(2).of(mockCacheServer).getClientSubscriptionConfig();
            will(returnValue(mockClientSubscriptionConfig));
            oneOf(mockClientSubscriptionConfig).getDiskStoreName();
            will(returnValue(diskStoreName));
            oneOf(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertTrue(function.isUsingDiskStore(mockCacheServer, mockDiskStore));
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DiskStore (org.apache.geode.cache.DiskStore)190 Test (org.junit.Test)120 AttributesFactory (org.apache.geode.cache.AttributesFactory)91 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)91 File (java.io.File)79 Region (org.apache.geode.cache.Region)71 Cache (org.apache.geode.cache.Cache)61 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)54 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)46 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)44 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)39 LocalRegion (org.apache.geode.internal.cache.LocalRegion)32 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)31 VM (org.apache.geode.test.dunit.VM)28 DiskRegion (org.apache.geode.internal.cache.DiskRegion)24 Host (org.apache.geode.test.dunit.Host)23 Expectations (org.jmock.Expectations)23 InternalCache (org.apache.geode.internal.cache.InternalCache)21 UnitTest (org.apache.geode.test.junit.categories.UnitTest)21 IOException (java.io.IOException)20