Search in sources :

Example 1 with MyGatewayEventFilter

use of org.apache.geode.internal.cache.wan.MyGatewayEventFilter in project geode by apache.

the class AsyncEventQueueValidationsJUnitTest method testAsyncEventQueueConfiguredFromXmlUsesFilter.

@Test
@Parameters(method = "getCacheXmlFileBaseNames")
public void testAsyncEventQueueConfiguredFromXmlUsesFilter(String cacheXmlFileBaseName) {
    // Create cache with xml
    String cacheXmlFileName = TestUtil.getResourcePath(getClass(), getClass().getSimpleName() + "." + cacheXmlFileBaseName + ".cache.xml");
    cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create();
    // Get region and do puts
    Region region = cache.getRegion(cacheXmlFileBaseName);
    int numPuts = 10;
    for (int i = 0; i < numPuts; i++) {
        region.put(i, i);
    }
    // Get AsyncEventQueue and GatewayEventFilter
    AsyncEventQueue aeq = cache.getAsyncEventQueue(cacheXmlFileBaseName);
    List<GatewayEventFilter> filters = aeq.getGatewayEventFilters();
    assertTrue(filters.size() == 1);
    MyGatewayEventFilter filter = (MyGatewayEventFilter) filters.get(0);
    // Validate filter callbacks were invoked
    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> filter.getBeforeEnqueueInvocations() == numPuts);
    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> filter.getBeforeTransmitInvocations() == numPuts);
    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> filter.getAfterAcknowledgementInvocations() == numPuts);
}
Also used : AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) Region(org.apache.geode.cache.Region) CacheFactory(org.apache.geode.cache.CacheFactory) MyGatewayEventFilter(org.apache.geode.internal.cache.wan.MyGatewayEventFilter) MyGatewayEventFilter(org.apache.geode.internal.cache.wan.MyGatewayEventFilter) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Parameters(junitparams.Parameters) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Parameters (junitparams.Parameters)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 Region (org.apache.geode.cache.Region)1 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)1 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)1 MyGatewayEventFilter (org.apache.geode.internal.cache.wan.MyGatewayEventFilter)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1