@Override public SpelParseException getCause() { return (SpelParseException) super.getCause(); }
@Override @Nullable public DataAccessException translateExceptionIfPossible(RuntimeException ex) { if (ex instanceof HibernateException) { return convertHibernateAccessException((HibernateException) ex); } if (ex instanceof PersistenceException && ex.getCause() instanceof HibernateException) { return convertHibernateAccessException((HibernateException) ex.getCause()); } return EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex); }
@Test public void interrupted() { Iterator<Object> it = Observable.never().blockingLatest().iterator(); Thread.currentThread().interrupt(); try { it.hasNext(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } Thread.interrupted(); }
@Test public void interrupted() { Iterator<Object> it = Flowable.never().blockingLatest().iterator(); Thread.currentThread().interrupt(); try { it.hasNext(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } Thread.interrupted(); }
@Test public void interruptTestWaitStrategy() { try { Thread.currentThread().interrupt(); TestWaitStrategy.SLEEP_1000MS.run(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interrupt() { Iterator<Object> it = Observable.never().blockingNext().iterator(); try { Thread.currentThread().interrupt(); it.next(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interrupt() { Iterator<Object> it = Flowable.never().blockingNext().iterator(); try { Thread.currentThread().interrupt(); it.next(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interruptWait() { BlockingObservableIterator<Integer> it = new BlockingObservableIterator<Integer>(128); try { Thread.currentThread().interrupt(); it.hasNext(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void awaitDoneTimed() { TestObserver<Integer> to = new TestObserver<Integer>(); Thread.currentThread().interrupt(); try { to.awaitDone(5, TimeUnit.SECONDS); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void awaitDoneTimed() { TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); Thread.currentThread().interrupt(); try { ts.awaitDone(5, TimeUnit.SECONDS); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interruptWait() { BlockingFlowableIterator<Integer> it = new BlockingFlowableIterator<Integer>(128); try { Thread.currentThread().interrupt(); it.hasNext(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void awaitInterrupted() { Thread.currentThread().interrupt(); try { PublishProcessor.create().ignoreElements().blockingAwait(); fail("Should have thrown RuntimeException"); } catch (RuntimeException ex) { if (!(ex.getCause() instanceof InterruptedException)) { fail("Wrong cause: " + ex.getCause()); } } }
@Test public void awaitTimeoutInterrupted() { Thread.currentThread().interrupt(); try { PublishProcessor.create().ignoreElements().blockingAwait(1, TimeUnit.SECONDS); fail("Should have thrown RuntimeException"); } catch (RuntimeException ex) { if (!(ex.getCause() instanceof InterruptedException)) { fail("Wrong cause: " + ex.getCause()); } } }
@Test(timeout = 5000) public void blockingFirstTimeout() { BlockingFirstSubscriber<Integer> bf = new BlockingFirstSubscriber<Integer>(); Thread.currentThread().interrupt(); try { bf.blockingGet(); fail("Should have thrown!"); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void blockingGetDefaultInterrupt() { final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<Integer>(); Thread.currentThread().interrupt(); try { bmo.blockingGet(0); fail("Should have thrown"); } catch (RuntimeException ex) { assertTrue(ex.getCause() instanceof InterruptedException); } finally { Thread.interrupted(); } }
@Test public void blockingGetErrorTimeoutInterrupt() { final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<Integer>(); Thread.currentThread().interrupt(); try { bmo.blockingGetError(1, TimeUnit.MINUTES); fail("Should have thrown"); } catch (RuntimeException ex) { assertTrue(ex.getCause() instanceof InterruptedException); } finally { Thread.interrupted(); } }
@Test public void blockingGetErrorTimedOut() { final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<Integer>(); try { assertNull(bmo.blockingGetError(1, TimeUnit.NANOSECONDS)); fail("Should have thrown"); } catch (RuntimeException expected) { assertEquals(TimeoutException.class, expected.getCause().getClass()); assertEquals(timeoutMessage(1, TimeUnit.NANOSECONDS), expected.getCause().getMessage()); } } }
@Test public void customInterceptorAppliesWithCheckedException() { try { cs.cacheWithCheckedException("id", true); fail("Should have failed"); } catch (RuntimeException e) { assertNotNull("missing original exception", e.getCause()); assertEquals(IOException.class, e.getCause().getClass()); } catch (Exception e) { fail("Wrong exception type " + e); } }
@Test(timeout = 5000) public void blockingFirstTimeout2() { BlockingFirstSubscriber<Integer> bf = new BlockingFirstSubscriber<Integer>(); bf.onSubscribe(new BooleanSubscription()); Thread.currentThread().interrupt(); try { bf.blockingGet(); fail("Should have thrown!"); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }