Search in sources :

Example 51 with RootCauseMatcher

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

the class PromoteLiteMemberTest method normalMember_promotion_shouldFail_onNonMaster.

@Test
public void normalMember_promotion_shouldFail_onNonMaster() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    factory.newHazelcastInstance(new Config());
    HazelcastInstance hz2 = factory.newHazelcastInstance(new Config());
    HazelcastInstance hz3 = factory.newHazelcastInstance(new Config());
    PromoteLiteMemberOp op = new PromoteLiteMemberOp();
    op.setCallerUuid(getMember(hz2).getUuid());
    InternalCompletableFuture<MembersView> future = getOperationService(hz2).invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, getAddress(hz3));
    exception.expect(CompletionException.class);
    exception.expect(new RootCauseMatcher(IllegalStateException.class));
    future.join();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 52 with RootCauseMatcher

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

the class LoggingScheduledExecutorTest method throwsExecutionException_withCallable_withFutureGetTimeout.

@Test
public void throwsExecutionException_withCallable_withFutureGetTimeout() throws Exception {
    executor = new LoggingScheduledExecutor(logger, 1, factory);
    Future<Integer> future = executor.submit(new FailedCallable());
    expectedException.expect(new RootCauseMatcher(RuntimeException.class));
    future.get(10, SECONDS);
    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 53 with RootCauseMatcher

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

the class YamlClientConfigImportVariableReplacementTest method testImportRedefinesSameConfigScalarThrows.

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

Example 54 with RootCauseMatcher

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

the class YamlClientConfigImportVariableReplacementTest method testImportNodeScalarVsSequenceThrows.

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

Example 55 with RootCauseMatcher

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

the class YamlClientConfigImportVariableReplacementTest method testImportNodeScalarVsMappingThrows.

@Test
public void testImportNodeScalarVsMappingThrows() throws Exception {
    String importedYaml = "" + "hazelcast-client:\n" + "  cluster-name: name1";
    String configPath = helper.givenConfigFileInWorkDir("foo.bar", importedYaml).getAbsolutePath();
    String yaml = "" + "hazelcast-client:\n" + "  import:\n" + "    - ${config.location}\n" + "  cluster-name: {}";
    rule.expect(new RootCauseMatcher(InvalidConfigurationException.class, "hazelcast-client/cluster-name"));
    buildConfig(yaml, "config.location", configPath);
}
Also used : RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException) 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