@Test public void testInterruptTerminalEventAwaitTimed() { TestSubscriber<Integer> ts = TestSubscriber.create(); final Thread t0 = Thread.currentThread(); Worker w = Schedulers.computation().createWorker(); try { w.schedule( new Action0() { @Override public void call() { t0.interrupt(); } }, 200, TimeUnit.MILLISECONDS); try { ts.awaitTerminalEvent(5, TimeUnit.SECONDS); fail("Did not interrupt wait!"); } catch (RuntimeException ex) { if (!(ex.getCause() instanceof InterruptedException)) { fail("The cause is not InterruptedException! " + ex.getCause()); } } } finally { w.unsubscribe(); } }
// @Ignore @Test public void validateNegativeMaxLengthTest() { ValidationTestApp validationTestApp = new ValidationTestApp( new File(testMeta.getDir()), -1L, new SingleHDFSByteExactlyOnceWriter()); boolean error = false; try { LocalMode.runApp(validationTestApp, 1); } catch (RuntimeException e) { if (e.getCause() instanceof ConstraintViolationException) { error = true; } } Assert.assertEquals("Max length validation not thrown with -1 max length", true, error); }
@Test public void receiveShouldFailWithUnmappedName() { // Given Mapping sendMapping = new MappingBuilder(OPERATION_FIELD_NAME).mapOperation("mappedCall", "OP").build(); MappedApi service = service(sendMapping); service.mappedCall("a", 0L); Mapping receiveMapping = partialMapping(); // When String message = null; try { MapMessageDecoder.of(MappedApi.class, serviceMock, receiveMapping) .onMessage(captureMessage()); fail("RuntimeException expected"); } catch (RuntimeException e) { message = e.getCause().getMessage(); } // Then assertEquals("no mapping for field: s2", message); }