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