本文整理匯總了Java中java.util.concurrent.CompletableFuture.failedFuture方法的典型用法代碼示例。如果您正苦於以下問題:Java CompletableFuture.failedFuture方法的具體用法?Java CompletableFuture.failedFuture怎麽用?Java CompletableFuture.failedFuture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.CompletableFuture
的用法示例。
在下文中一共展示了CompletableFuture.failedFuture方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: error
import java.util.concurrent.CompletableFuture; //導入方法依賴的package包/類
@Test
public void error() {
CompletableFuture<Integer> cf = CompletableFuture.failedFuture(new IOException());
Folyam.fromCompletionStage(cf)
.test()
.assertFailure(IOException.class);
}
示例2: error
import java.util.concurrent.CompletableFuture; //導入方法依賴的package包/類
@Test
public void error() {
CompletableFuture<Integer> cf = CompletableFuture.failedFuture(new IOException());
Esetleg.fromCompletionStage(cf)
.test()
.assertFailure(IOException.class);
}
示例3: testFailedFuture_null
import java.util.concurrent.CompletableFuture; //導入方法依賴的package包/類
/**
* failedFuture(null) throws NPE
*/
public void testFailedFuture_null() {
try {
CompletableFuture<Integer> f = CompletableFuture.failedFuture(null);
shouldThrow();
} catch (NullPointerException success) {}
}
示例4: completedWithIOException
import java.util.concurrent.CompletableFuture; //導入方法依賴的package包/類
static <T> CompletableFuture<T> completedWithIOException(String message) {
return CompletableFuture.failedFuture(new IOException(message));
}
示例5: testFailedFuture
import java.util.concurrent.CompletableFuture; //導入方法依賴的package包/類
/**
* failedFuture returns a CompletableFuture completed
* exceptionally with the given Exception
*/
public void testFailedFuture() {
CFException ex = new CFException();
CompletableFuture<Integer> f = CompletableFuture.failedFuture(ex);
checkCompletedExceptionally(f, ex);
}