當前位置: 首頁>>代碼示例>>Java>>正文


Java TestObserver.assertErrorMessage方法代碼示例

本文整理匯總了Java中io.reactivex.observers.TestObserver.assertErrorMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java TestObserver.assertErrorMessage方法的具體用法?Java TestObserver.assertErrorMessage怎麽用?Java TestObserver.assertErrorMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.observers.TestObserver的用法示例。


在下文中一共展示了TestObserver.assertErrorMessage方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCheckWidgetCalledFromNonMainThread

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testCheckWidgetCalledFromNonMainThread() throws InterruptedException, TimeoutException {
	TestObserver<?> testObserver = getEmptySubscribedTestObserver();

	AtomicBoolean atomic = new AtomicBoolean(false);

	Thread thread = new Thread(() -> {
		boolean checkWidget = Preconditions.checkWidget(testObserver, shell);

		assertThat(checkWidget, is(false));

		testObserver.assertError(IllegalStateException.class);
		testObserver.assertErrorMessage(
				"Expected to be called on the main thread but was " + Thread.currentThread().getName());
		atomic.set(true);
	});
	thread.start();

	await().untilTrue(atomic);
}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:21,代碼來源:PreconditionsTest.java

示例2: test_error

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void test_error() {
	Observable<String> observable = Observable.error(new Exception("We got an Exception"));
	TestObserver<String> testObserver = new TestObserver<>();

	observable.subscribe(testObserver);

	testObserver.assertError(Exception.class);
	testObserver.assertNotComplete();
	testObserver.assertErrorMessage("We got an Exception");
	testObserver.assertFailure(exception -> {
		return exception instanceof Exception;
	});

	testObserver.assertFailureAndMessage(Exception.class, "We got an Exception");
}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:17,代碼來源:Modern_Testing.java

示例3: testCheckWidgetWithDisposedWidget

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testCheckWidgetWithDisposedWidget() {
	TestObserver<?> testObserver = getEmptySubscribedTestObserver();

	shell.dispose();
	boolean checkWidget = Preconditions.checkWidget(testObserver, shell);

	assertThat(checkWidget, is(false));

	testObserver.assertError(IllegalStateException.class);
	testObserver.assertErrorMessage("The given widget is diposed");
}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:13,代碼來源:PreconditionsTest.java

示例4: testCheckWidgetWithNullWidget

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testCheckWidgetWithNullWidget() {
	TestObserver<?> testObserver = getEmptySubscribedTestObserver();

	boolean checkWidget = Preconditions.checkWidget(testObserver, null);

	assertThat(checkWidget, is(false));

	testObserver.assertError(NullPointerException.class);
	testObserver.assertErrorMessage("The given widget was null");
}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:12,代碼來源:PreconditionsTest.java


注:本文中的io.reactivex.observers.TestObserver.assertErrorMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。