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