Search in sources :

Example 6 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsAsyncEventQueueUsingDiskStore.

@Test
public void testIsAsyncEventQueueUsingDiskStore() {
    final String diskStoreName = "testDiskStore";
    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(diskStoreName));
            oneOf(mockQueue).isPersistent();
            will(returnValue(true));
            oneOf(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertTrue(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 7 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testIsAsyncEventQueueUsingDiskStoreWhenQueueIsNotPersistent.

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

        {
            oneOf(mockQueue).isPersistent();
            will(returnValue(false));
        }
    });
    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 8 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testGetAsyncEventQueueDiskStoreName.

@Test
public void testGetAsyncEventQueueDiskStoreName() {
    final String expectedDiskStoreName = "testDiskStore";
    final AsyncEventQueue mockQueue = mockContext.mock(AsyncEventQueue.class, "AsyncEventQueue");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockQueue).getDiskStoreName();
            will(returnValue(expectedDiskStoreName));
        }
    });
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
    assertEquals(expectedDiskStoreName, function.getDiskStoreName(mockQueue));
}
Also used : Expectations(org.jmock.Expectations) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 9 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue 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 10 with AsyncEventQueue

use of org.apache.geode.cache.asyncqueue.AsyncEventQueue 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)

Aggregations

AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)62 Test (org.junit.Test)20 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)19 AsyncEventQueueFactory (org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory)13 AsyncEventQueueImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl)13 Cache (org.apache.geode.cache.Cache)10 GatewaySender (org.apache.geode.cache.wan.GatewaySender)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 UnitTest (org.apache.geode.test.junit.categories.UnitTest)8 Expectations (org.jmock.Expectations)8 DiskStore (org.apache.geode.cache.DiskStore)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)6 Region (org.apache.geode.cache.Region)5 AsyncEventQueueStats (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueStats)5 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)5 File (java.io.File)4 Properties (java.util.Properties)4