Search in sources :

Example 16 with AsyncEvent

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

the class LuceneEventListenerJUnitTest method shouldThrowAndCaptureIOException.

@Test
public void shouldThrowAndCaptureIOException() throws BucketNotFoundException {
    RepositoryManager manager = Mockito.mock(RepositoryManager.class);
    Mockito.when(manager.getRepository(any(), any(), any())).thenThrow(IOException.class);
    AtomicReference<Throwable> lastException = new AtomicReference<>();
    LuceneEventListener.setExceptionObserver(lastException::set);
    LuceneEventListener listener = new LuceneEventListener(manager);
    AsyncEvent event = Mockito.mock(AsyncEvent.class);
    try {
        listener.processEvents(Arrays.asList(new AsyncEvent[] { event }));
        fail("should have thrown an exception");
    } catch (InternalGemFireError expected) {
        assertEquals(expected, lastException.get());
    }
}
Also used : RepositoryManager(org.apache.geode.cache.lucene.internal.repository.RepositoryManager) AtomicReference(java.util.concurrent.atomic.AtomicReference) AsyncEvent(org.apache.geode.cache.asyncqueue.AsyncEvent) InternalGemFireError(org.apache.geode.InternalGemFireError) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

AsyncEvent (org.apache.geode.cache.asyncqueue.AsyncEvent)16 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)4 IOException (java.io.IOException)3 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)3 RepositoryManager (org.apache.geode.cache.lucene.internal.repository.RepositoryManager)3 UnitTest (org.apache.geode.test.junit.categories.UnitTest)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 InternalGemFireError (org.apache.geode.InternalGemFireError)2 AttributesFactory (org.apache.geode.cache.AttributesFactory)2 Cache (org.apache.geode.cache.Cache)2 Region (org.apache.geode.cache.Region)2 IndexRepository (org.apache.geode.cache.lucene.internal.repository.IndexRepository)2 BucketNotFoundException (org.apache.geode.internal.cache.BucketNotFoundException)2 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)2 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)2