Search in sources :

Example 71 with RootCauseMatcher

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

the class LoggingScheduledExecutorTest method throwsExecutionException_withCallable.

@Test
public void throwsExecutionException_withCallable() throws Exception {
    executor = new LoggingScheduledExecutor(logger, 1, factory);
    Future<Integer> future = executor.submit(new FailedCallable());
    expectedException.expect(new RootCauseMatcher(RuntimeException.class));
    future.get();
    assertNull(logger.getThrowable());
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 72 with RootCauseMatcher

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

the class DistributedObjectTest method testDistributedObjectDestroyed_whenDestroyDuringInitialization.

@Test
public void testDistributedObjectDestroyed_whenDestroyDuringInitialization() throws InterruptedException, ExecutionException {
    final CountDownLatch initializationStarted = new CountDownLatch(1);
    final CountDownLatch objectDestroyed = new CountDownLatch(1);
    Config config = new Config();
    ConfigAccessor.getServicesConfig(config).addServiceConfig(new ServiceConfig().setEnabled(true).setName(TestInitializingObjectService.NAME).setImplementation(new TestInitializingObjectService(() -> {
        initializationStarted.countDown();
        try {
            objectDestroyed.await();
        } catch (InterruptedException e) {
            ignore(e);
        }
    })));
    String serviceName = TestInitializingObjectService.NAME;
    String objectName = "test-object";
    HazelcastInstance instance = createHazelcastInstance(config);
    Future f = spawn(() -> {
        // must fail with DistributedObjectDestroyedException
        instance.getDistributedObject(serviceName, objectName);
    });
    initializationStarted.await();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
    UUID source = nodeEngine.getLocalMember().getUuid();
    nodeEngine.getProxyService().destroyDistributedObject(serviceName, objectName, source);
    objectDestroyed.countDown();
    expectedException.expect(ExecutionException.class);
    expectedException.expectCause(new RootCauseMatcher(DistributedObjectDestroyedException.class));
    f.get();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) Future(java.util.concurrent.Future) CountDownLatch(java.util.concurrent.CountDownLatch) UUID(java.util.UUID) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 73 with RootCauseMatcher

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

the class YamlConfigImportVariableReplacementTest method testImportNodeScalarVsMappingThrows.

@Test
public void testImportNodeScalarVsMappingThrows() 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: {}";
    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 74 with RootCauseMatcher

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

the class YamlConfigImportVariableReplacementTest method testImportNodeScalarVsSequenceThrows.

@Test
public void testImportNodeScalarVsSequenceThrows() 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:\n" + "    - seqName: {}";
    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 75 with RootCauseMatcher

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

the class YamlOnlyConfigBuilderTest method testNullInMapThrows.

@Test
public void testNullInMapThrows() {
    String yaml = "" + "hazelcast:\n" + "  map:\n" + "    test:\n" + "    query-caches: {}\n";
    expected.expect(new RootCauseMatcher(InvalidConfigurationException.class, "hazelcast/map/test"));
    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)

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