Search in sources :

Example 1 with RootCauseMatcher

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

the class YamlOnlyConfigBuilderTest method testExplicitNullScalarThrows.

@Test
public void testExplicitNullScalarThrows() {
    String yaml = "" + "hazelcast:\n" + "  instance-name: !!null";
    expected.expect(new RootCauseMatcher(InvalidConfigurationException.class, "hazelcast/instance-name"));
    buildConfig(yaml);
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with RootCauseMatcher

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

the class YamlOnlyConfigBuilderTest method testNullInSequenceThrows.

@Test
public void testNullInSequenceThrows() {
    String yaml = "" + "hazelcast:\n" + "  listeners:\n" + "    - com.package.SomeListener\n" + "    -\n";
    expected.expect(new RootCauseMatcher(InvalidConfigurationException.class, "hazelcast/listeners"));
    buildConfig(yaml);
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with RootCauseMatcher

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

the class YamlConfigImportVariableReplacementTest method testImportRedefinesSameConfigScalarThrows.

@Test
public void testImportRedefinesSameConfigScalarThrows() throws Exception {
    String importedYaml = "" + "hazelcast:\n" + "  cluster-name: name1";
    String path = helper.givenConfigFileInWorkDir("foo.bar", importedYaml).getAbsolutePath();
    String yaml = "" + "hazelcast:\n" + "  import:\n" + "    - ${config.location}\n" + "  cluster-name: name2";
    rule.expect(new RootCauseMatcher(InvalidConfigurationException.class, "hazelcast/cluster-name"));
    buildConfig(yaml, "config.location", path);
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with RootCauseMatcher

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

the class YamlConfigImportVariableReplacementTest method testImportNodeSequenceVsMappingThrows.

@Test
public void testImportNodeSequenceVsMappingThrows() throws Exception {
    String importedYaml = "" + "hazelcast:\n" + "  cluster-name:\n" + "    - seqname";
    String path = helper.givenConfigFileInWorkDir("foo.bar", importedYaml).getAbsolutePath();
    String yaml = "" + "hazelcast:\n" + "  import:\n" + "    - ${config.location}\n" + "  cluster-name: {}";
    rule.expect(new RootCauseMatcher(InvalidConfigurationException.class, "hazelcast/cluster-name"));
    buildConfig(yaml, "config.location", path);
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with RootCauseMatcher

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

the class CacheTypesConfigTest method cacheConfigShouldBeAddedOnJoiningMember_whenCacheLoaderFactoryNotResolvableWithClassLoaderSet.

// tests deferred resolution of factories, with context class loader set correctly
@Test
public void cacheConfigShouldBeAddedOnJoiningMember_whenCacheLoaderFactoryNotResolvableWithClassLoaderSet() throws InterruptedException {
    HazelcastInstance hz1 = factory.newHazelcastInstance(getConfig());
    CachingProvider cachingProvider = createServerCachingProvider(hz1);
    CacheManager cacheManager1 = cachingProvider.getCacheManager(null, null, propertiesByInstanceItself(hz1));
    CacheConfig<String, Person> cacheConfig = createCacheConfig();
    cacheConfig.setCacheLoaderFactory(new PersonCacheLoaderFactory());
    cacheManager1.createCache(cacheName, cacheConfig);
    // joining member cannot resolve PersonCacheLoaderFactory class
    HazelcastInstance hz2 = factory.newHazelcastInstance(getClassFilteringConfig());
    assertClusterSize(2, hz1, hz2);
    ICache<String, Person> cache = hz2.getCacheManager().getCache(cacheName);
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(hz2.getConfig().getClassLoader());
        CacheProxy<String, Person> cacheProxy = (CacheProxy<String, Person>) cache;
        CacheService cacheService = (CacheService) cacheProxy.getService();
        expect.expectCause(new RootCauseMatcher(ClassNotFoundException.class, "classloading.domain.PersonCacheLoaderFactory - " + "Package excluded explicitly"));
        cacheService.getCacheConfig(cache.getPrefixedName()).getCacheLoaderFactory();
        String key = generateKeyOwnedBy(hz2);
        cache.invoke(key, new PersonEntryProcessor());
    } finally {
        Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) HazelcastInstance(com.hazelcast.core.HazelcastInstance) PersonCacheLoaderFactory(classloading.domain.PersonCacheLoaderFactory) CacheProxy(com.hazelcast.cache.impl.CacheProxy) CacheManager(javax.cache.CacheManager) FilteringClassLoader(com.hazelcast.internal.util.FilteringClassLoader) Person(classloading.domain.Person) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) CacheService(com.hazelcast.cache.impl.CacheService) PersonEntryProcessor(classloading.domain.PersonEntryProcessor) 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