本文整理了Java中java.lang.RuntimeException.getCause()
方法的一些代码示例,展示了RuntimeException.getCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RuntimeException.getCause()
方法的具体详情如下:
包路径:java.lang.RuntimeException
类名称:RuntimeException
方法名:getCause
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
public SpelParseException getCause() {
return (SpelParseException) super.getCause();
}
代码示例来源:origin: spring-projects/spring-framework
@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);
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void interruptTestWaitStrategy() {
try {
Thread.currentThread().interrupt();
TestWaitStrategy.SLEEP_1000MS.run();
} catch (RuntimeException ex) {
assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test(timeout = 5000)
public void getTimeout() {
try {
Completable.never().blockingGet(100, TimeUnit.MILLISECONDS);
} catch (RuntimeException ex) {
if (!(ex.getCause() instanceof TimeoutException)) {
Assert.fail("Wrong exception cause: " + ex.getCause());
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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());
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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());
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
}
代码示例来源:origin: ReactiveX/RxJava
@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());
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@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);
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
内容来源于网络,如有侵权,请联系作者删除!