Search in sources :

Example 1 with InternalCacheEvent

use of org.apache.geode.internal.cache.InternalCacheEvent in project geode by apache.

the class DestroyMessageTest method shouldBeMockable.

@Test
public void shouldBeMockable() throws Exception {
    DestroyMessage mockDestroyMessageX = mock(DestroyMessage.class);
    InternalCacheEvent mockInternalCacheEvent = mock(InternalCacheEvent.class);
    DistributedRegion mockDistributedRegion = mock(DistributedRegion.class);
    when(mockDestroyMessageX.createEvent(eq(mockDistributedRegion))).thenReturn(mockInternalCacheEvent);
    assertThat(mockDestroyMessageX.createEvent(mockDistributedRegion)).isSameAs(mockInternalCacheEvent);
}
Also used : DestroyMessage(org.apache.geode.internal.cache.wan.serial.BatchDestroyOperation.DestroyMessage) InternalCacheEvent(org.apache.geode.internal.cache.InternalCacheEvent) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 2 with InternalCacheEvent

use of org.apache.geode.internal.cache.InternalCacheEvent in project geode by apache.

the class EventIDVerificationInP2PDUnitTest method createServerCache.

public static void createServerCache(Integer type) throws Exception {
    new EventIDVerificationInP2PDUnitTest().createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    if (type.intValue() == DISTRIBUTED_ACK)
        factory.setScope(Scope.DISTRIBUTED_ACK);
    if (type.intValue() == GLOBAL)
        factory.setScope(Scope.GLOBAL);
    else
        factory.setScope(Scope.DISTRIBUTED_NO_ACK);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    factory.addCacheListener(new CacheListenerAdapter() {

        public void afterCreate(EntryEvent event) {
            eventId = ((InternalCacheEvent) event).getEventId();
            if (receiver) {
                synchronized (EventIDVerificationInP2PDUnitTest.class) {
                    gotCallback = true;
                    EventIDVerificationInP2PDUnitTest.class.notify();
                }
            }
        }

        public void afterUpdate(EntryEvent event) {
            eventId = ((InternalCacheEvent) event).getEventId();
            if (receiver) {
                synchronized (EventIDVerificationInP2PDUnitTest.class) {
                    gotCallback = true;
                    EventIDVerificationInP2PDUnitTest.class.notify();
                }
            }
        }

        public void afterDestroy(EntryEvent event) {
            eventId = ((InternalCacheEvent) event).getEventId();
            if (receiver) {
                synchronized (EventIDVerificationInP2PDUnitTest.class) {
                    gotCallback = true;
                    EventIDVerificationInP2PDUnitTest.class.notify();
                }
            }
        }

        public void afterRegionDestroy(RegionEvent event) {
            eventId = ((InternalCacheEvent) event).getEventId();
            if (receiver) {
                synchronized (EventIDVerificationInP2PDUnitTest.class) {
                    gotCallback = true;
                    EventIDVerificationInP2PDUnitTest.class.notify();
                }
            }
        }

        public void afterRegionInvalidate(RegionEvent event) {
            eventId = ((InternalCacheEvent) event).getEventId();
            if (receiver) {
                synchronized (EventIDVerificationInP2PDUnitTest.class) {
                    gotCallback = true;
                    EventIDVerificationInP2PDUnitTest.class.notify();
                }
            }
        }
    });
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheListenerAdapter(org.apache.geode.cache.util.CacheListenerAdapter) RegionAttributes(org.apache.geode.cache.RegionAttributes) EntryEvent(org.apache.geode.cache.EntryEvent) InternalCacheEvent(org.apache.geode.internal.cache.InternalCacheEvent) Properties(java.util.Properties) RegionEvent(org.apache.geode.cache.RegionEvent)

Aggregations

InternalCacheEvent (org.apache.geode.internal.cache.InternalCacheEvent)2 Properties (java.util.Properties)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 EntryEvent (org.apache.geode.cache.EntryEvent)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 RegionEvent (org.apache.geode.cache.RegionEvent)1 CacheListenerAdapter (org.apache.geode.cache.util.CacheListenerAdapter)1 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)1 DestroyMessage (org.apache.geode.internal.cache.wan.serial.BatchDestroyOperation.DestroyMessage)1 UnitTest (org.apache.geode.test.junit.categories.UnitTest)1 Test (org.junit.Test)1