Search in sources :

Example 46 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class OperationRunnerImplTest method runOperation_whenRunThrowsException.

@Test
public void runOperation_whenRunThrowsException() {
    Operation op = new Operation() {

        @Override
        public void run() throws Exception {
            throw new ExpectedRuntimeException();
        }
    };
    op.setOperationResponseHandler(responseHandler);
    op.setPartitionId(operationRunner.getPartitionId());
    operationRunner.run(op);
    verify(responseHandler).sendResponse(same(op), any(ExpectedRuntimeException.class));
}
Also used : ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) Operation(com.hazelcast.spi.impl.operationservice.Operation) BlockingOperation(com.hazelcast.spi.impl.operationservice.BlockingOperation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 47 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class PacketDispatcherTest method whenProblemHandlingPacket_thenSwallowed.

// when one of the handlers throws an exception, the exception is logged but not rethrown
@Test
public void whenProblemHandlingPacket_thenSwallowed() {
    Packet packet = new Packet().setPacketType(Packet.Type.OPERATION);
    Mockito.doThrow(new ExpectedRuntimeException()).when(operationExecutor).accept(packet);
    dispatcher.accept(packet);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 48 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.

the class OperationServiceImpl_invokeOnPartitionTest method whenExceptionThrownInOperationRun.

@Test
public void whenExceptionThrownInOperationRun() {
    DummyOperation operation = new DummyOperation(new ExceptionThrowingCallable());
    InternalCompletableFuture<String> invocation = operationService.invokeOnPartition(null, operation, getPartitionId(remote));
    try {
        invocation.joinInternal();
        fail();
    } catch (ExpectedRuntimeException expected) {
    }
}
Also used : ExceptionThrowingCallable(com.hazelcast.test.ExceptionThrowingCallable) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 49 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast-jet by hazelcast.

the class JobTest method when_jobIsFailed_then_jobStatusIsCompletedEventually.

@Test
public void when_jobIsFailed_then_jobStatusIsCompletedEventually() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS((DistributedSupplier<Processor>) () -> new MockP().setCompleteError(new ExpectedRuntimeException()), NODE_COUNT)));
    // When
    Job job = instance1.newJob(dag);
    // Then
    try {
        job.getFuture().get();
        fail();
    } catch (ExecutionException expected) {
        assertEquals(FAILED, job.getStatus());
    }
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 50 with ExpectedRuntimeException

use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast-jet by hazelcast.

the class JobTest method when_jobIsFailed_then_trackedJobCanQueryJobResult.

@Test
public void when_jobIsFailed_then_trackedJobCanQueryJobResult() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS((DistributedSupplier<Processor>) () -> new MockP().setCompleteError(new ExpectedRuntimeException()), NODE_COUNT)));
    // When
    instance1.newJob(dag);
    Collection<Job> trackedJobs = instance2.getJobs();
    assertEquals(1, trackedJobs.size());
    Job trackedJob = trackedJobs.iterator().next();
    // Then
    try {
        trackedJob.getFuture().get();
        fail();
    } catch (ExecutionException expected) {
        assertEquals(FAILED, trackedJob.getStatus());
    }
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) MockP(com.hazelcast.jet.core.TestProcessors.MockP) Job(com.hazelcast.jet.Job) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)50 Test (org.junit.Test)44 QuickTest (com.hazelcast.test.annotation.QuickTest)36 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)27 RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)16 Config (com.hazelcast.config.Config)11 ExecutionException (java.util.concurrent.ExecutionException)7 Executor (java.util.concurrent.Executor)6 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)5 CompletionException (java.util.concurrent.CompletionException)5 TestNodeContext (com.hazelcast.instance.TestNodeContext)4 SlowTest (com.hazelcast.test.annotation.SlowTest)4 Category (org.junit.experimental.categories.Category)4 RunWith (org.junit.runner.RunWith)4 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)3 Job (com.hazelcast.jet.Job)3 MockP (com.hazelcast.jet.core.TestProcessors.MockP)3 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)3 InternalCompletableFuture.newCompletedFuture (com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture)3 CompletableFutureTestUtil (com.hazelcast.spi.impl.operationservice.impl.CompletableFutureTestUtil)3