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());
}
}
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());
}
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class HazelcastInstanceFactoryTest method test_NewInstance_failed_beforeNodeStart.
@Test(expected = ExpectedRuntimeException.class)
public void test_NewInstance_failed_beforeNodeStart() throws Exception {
NodeContext context = new TestNodeContext() {
@Override
public NodeExtension createNodeExtension(Node node) {
NodeExtension nodeExtension = super.createNodeExtension(node);
doThrow(new ExpectedRuntimeException()).when(nodeExtension).beforeStart();
return nodeExtension;
}
};
Config config = new Config();
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class HazelcastInstanceFactoryTest method test_NewInstance_failed_afterNodeStart.
@Test(expected = ExpectedRuntimeException.class)
public void test_NewInstance_failed_afterNodeStart() throws Exception {
NodeContext context = new TestNodeContext() {
@Override
public NodeExtension createNodeExtension(Node node) {
NodeExtension nodeExtension = super.createNodeExtension(node);
doThrow(new ExpectedRuntimeException()).when(nodeExtension).afterStart();
return nodeExtension;
}
};
Config config = new Config();
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
hazelcastInstance = HazelcastInstanceFactory.newHazelcastInstance(config, randomString(), context);
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class JobTest method when_jobFailed_then_trackedJobCanQueryResult.
@Test
public void when_jobFailed_then_trackedJobCanQueryResult() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS((SupplierEx<Processor>) () -> new MockP().setCompleteError(new ExpectedRuntimeException()), NODE_COUNT)));
// When
Job submittedJob = instance().getJet().newJob(dag);
Collection<Job> trackedJobs = instances()[1].getJet().getJobs();
Job trackedJob = trackedJobs.stream().filter(j -> j.getId() == submittedJob.getId()).findFirst().orElse(null);
assertNotNull(trackedJob);
// Then
try {
trackedJob.getFuture().get();
fail();
} catch (ExecutionException expected) {
assertEquals(FAILED, trackedJob.getStatus());
}
}
Aggregations