Search in sources :

Example 16 with DiskStore

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

the class DescribeDiskStoreFunctionJUnitTest method testSetPdxSerializationDetails.

@Test
public void testSetPdxSerializationDetails() {
    final String diskStoreName = "testDiskStore";
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getPdxPersistent();
            will(returnValue(true));
            oneOf(mockCache).getPdxDiskStore();
            will(returnValue(diskStoreName));
            oneOf(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
    function.setPdxSerializationDetails(mockCache, mockDiskStore, diskStoreDetails);
    assertTrue(diskStoreDetails.isPdxSerializationMetaDataStored());
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) InternalCache(org.apache.geode.internal.cache.InternalCache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 17 with DiskStore

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

the class DescribeDiskStoreFunctionJUnitTest method testIsGatewaySenderUsingDiskStoreWhenDiskStoresMismatch.

@Test
public void testIsGatewaySenderUsingDiskStoreWhenDiskStoresMismatch() {
    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("mockDiskStore"));
            oneOf(mockDiskStore).getName();
            will(returnValue("testDiskStore"));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertFalse(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 18 with DiskStore

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

the class DescribeDiskStoreFunctionJUnitTest method testSetAsyncEventQueueDetails.

@Test
public void testSetAsyncEventQueueDetails() {
    final String diskStoreName = "testDiskStore";
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
    final AsyncEventQueue mockQueue1 = mockContext.mock(AsyncEventQueue.class, "AsyncEvenQueue1");
    final AsyncEventQueue mockQueue2 = mockContext.mock(AsyncEventQueue.class, "AsyncEvenQueue2");
    final AsyncEventQueue mockQueue3 = mockContext.mock(AsyncEventQueue.class, "AsyncEvenQueue3");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getAsyncEventQueues();
            will(returnValue(CollectionUtils.asSet(mockQueue1, mockQueue2, mockQueue3)));
            oneOf(mockQueue1).isPersistent();
            will(returnValue(true));
            oneOf(mockQueue1).getDiskStoreName();
            will(returnValue(diskStoreName));
            oneOf(mockQueue1).getId();
            will(returnValue("q1"));
            oneOf(mockQueue2).isPersistent();
            will(returnValue(true));
            oneOf(mockQueue2).getDiskStoreName();
            will(returnValue(null));
            oneOf(mockQueue3).isPersistent();
            will(returnValue(false));
            atLeast(1).of(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final Set<DiskStoreDetails.AsyncEventQueueDetails> expectedAsyncEventQueueDetails = CollectionUtils.asSet(createAsyncEventQueueDetails("q1"));
    final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
    function.setAsyncEventQueueDetails(mockCache, mockDiskStore, diskStoreDetails);
    assertAsyncEventQueueDetails(expectedAsyncEventQueueDetails, diskStoreDetails);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) InternalCache(org.apache.geode.internal.cache.InternalCache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 19 with DiskStore

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

the class DescribeDiskStoreFunctionJUnitTest method testIsAsyncEventQueueUsingDiskStoreWhenDiskStoresMismatch.

@Test
public void testIsAsyncEventQueueUsingDiskStoreWhenDiskStoresMismatch() {
    final AsyncEventQueue mockQueue = mockContext.mock(AsyncEventQueue.class, "AsyncEventQueue");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockQueue).getDiskStoreName();
            will(returnValue("mockDiskStore"));
            oneOf(mockQueue).isPersistent();
            will(returnValue(true));
            oneOf(mockDiskStore).getName();
            will(returnValue(DiskStoreDetails.DEFAULT_DISK_STORE_NAME));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertFalse(function.isUsingDiskStore(mockQueue, mockDiskStore));
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 20 with DiskStore

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

the class DescribeDiskStoreFunctionJUnitTest method testIsRegionUsingDiskStoreWhenDiskStoresMismatch.

@Test
public void testIsRegionUsingDiskStoreWhenDiskStoresMismatch() {
    final Region mockRegion = mockContext.mock(Region.class, "Region");
    final RegionAttributes mockRegionAttributes = mockContext.mock(RegionAttributes.class, "RegionAttributes");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            atLeast(1).of(mockRegion).getAttributes();
            will(returnValue(mockRegionAttributes));
            oneOf(mockRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.PERSISTENT_PARTITION));
            oneOf(mockRegionAttributes).getDiskStoreName();
            will(returnValue("mockDiskStore"));
            oneOf(mockDiskStore).getName();
            will(returnValue("testDiskStore"));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertFalse(function.isUsingDiskStore(mockRegion, mockDiskStore));
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) RegionAttributes(org.apache.geode.cache.RegionAttributes) Region(org.apache.geode.cache.Region) 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