Search in sources :

Example 6 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class CacheTypesConfigTest method cacheConfigShouldBeAddedOnJoiningMember_whenExpiryPolicyFactoryNotResolvable.

// tests deferred resolution of expiry policy factory
@Test
public void cacheConfigShouldBeAddedOnJoiningMember_whenExpiryPolicyFactoryNotResolvable() throws InterruptedException {
    HazelcastInstance hz1 = factory.newHazelcastInstance(getConfig());
    CachingProvider cachingProvider = createServerCachingProvider(hz1);
    cachingProvider.getCacheManager().createCache(cacheName, createCacheConfig().setExpiryPolicyFactory(new PersonExpiryPolicyFactory()));
    HazelcastInstance hz2 = factory.newHazelcastInstance(getClassFilteringConfig());
    assertClusterSize(2, hz1, hz2);
    ICache<String, Person> cache = hz2.getCacheManager().getCache(cacheName);
    String key = generateKeyOwnedBy(hz2);
    expect.expectCause(new RootCauseMatcher(ClassNotFoundException.class, "classloading.domain.PersonExpiryPolicyFactory - " + "Package excluded explicitly"));
    cache.invoke(key, new PersonEntryProcessor());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) PersonExpiryPolicyFactory(classloading.domain.PersonExpiryPolicyFactory) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) Person(classloading.domain.Person) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) PersonEntryProcessor(classloading.domain.PersonEntryProcessor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class QueryAdvancedTest method testClassNotFoundErrorDelegatedToCallerOnQuery.

@Test
public void testClassNotFoundErrorDelegatedToCallerOnQuery() {
    Config config = getConfig();
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Integer, Integer> map = hazelcastInstance.getMap("map");
    map.put(1, 1);
    // A remote predicate can throw Error in case of Usercodeployment and missing sub classes
    // See the issue for actual problem https://github.com/hazelcast/hazelcast/issues/18052
    // We are throwing error to see if the error is delegated to the caller
    expected.expect(HazelcastException.class);
    expected.expectCause(new RootCauseMatcher(NoClassDefFoundError.class));
    map.values(new ErrorThrowingPredicate());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class BiCompletionStageTest method acceptEitherAsync_withExecutor.

@Test
public void acceptEitherAsync_withExecutor() {
    AtomicInteger executionCounter = new AtomicInteger();
    CompletableFuture<Void> eitherFuture = future1.acceptEitherAsync(future2, value -> {
        assertTrue(future1.isDone() || future2.isDone());
        executionCounter.getAndIncrement();
    }, countingExecutor);
    boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
    assertTrueEventually(() -> {
        assertTrue(eitherFuture.isDone());
    });
    if (exceptionalCompletion && eitherFuture.isCompletedExceptionally()) {
        expected.expect(CompletionException.class);
        expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
        eitherFuture.join();
    }
    // non-exceptional completion
    assertNull(eitherFuture.join());
    assertEquals(1, executionCounter.get());
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class BiCompletionStageTest method runAfterBoth.

@Test
public void runAfterBoth() {
    CompletableFuture<Void> combinedFuture = future1.runAfterBoth(future2, () -> {
        assertTrue(future1.isDone());
        assertTrue(future2.isDone());
    });
    boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
    assertTrueEventually(() -> assertTrue(combinedFuture.isDone()));
    if (exceptionalCompletion) {
        expected.expect(CompletionException.class);
        expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
        combinedFuture.join();
    }
    // non-exceptional completion
    assertNull(combinedFuture.join());
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with RootCauseMatcher

use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.

the class BiCompletionStageTest method runAfterEitherAsync_withExecutor.

@Test
public void runAfterEitherAsync_withExecutor() {
    AtomicInteger executionCounter = new AtomicInteger();
    CompletableFuture<Void> eitherFuture = future1.runAfterEitherAsync(future2, () -> {
        assertTrue(future1.isDone() || future2.isDone());
        executionCounter.getAndIncrement();
    }, countingExecutor);
    boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
    assertTrueEventually(() -> {
        assertTrue(eitherFuture.isDone());
    });
    if (exceptionalCompletion && eitherFuture.isCompletedExceptionally()) {
        expected.expect(CompletionException.class);
        expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
        eitherFuture.join();
    }
    // non-exceptional completion
    assertNull(eitherFuture.join());
    assertEquals(1, executionCounter.get());
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)122 QuickTest (com.hazelcast.test.annotation.QuickTest)118 Test (org.junit.Test)118 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)106 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)64 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)31 CompletableFutureTestUtil (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil)26 CancellationException (java.util.concurrent.CancellationException)25 CountDownLatch (java.util.concurrent.CountDownLatch)25 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)24 InternalCompletableFuture.newCompletedFuture (com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture)24 CountingExecutor (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.CountingExecutor)24 CompletableFutureTestUtil.ignore (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil.ignore)24 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)24 HazelcastTestSupport.assertInstanceOf (com.hazelcast.test.HazelcastTestSupport.assertInstanceOf)24 HazelcastTestSupport.assertOpenEventually (com.hazelcast.test.HazelcastTestSupport.assertOpenEventually)24 HazelcastTestSupport.assertTrueEventually (com.hazelcast.test.HazelcastTestSupport.assertTrueEventually)24 CompletableFuture (java.util.concurrent.CompletableFuture)24 CompletionException (java.util.concurrent.CompletionException)24 CompletionStage (java.util.concurrent.CompletionStage)24