• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TestSubject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中rx.subjects.TestSubject的典型用法代码示例。如果您正苦于以下问题:Java TestSubject类的具体用法?Java TestSubject怎么用?Java TestSubject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestSubject类属于rx.subjects包,在下文中一共展示了TestSubject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: multipleLeftTerminalRightOtherThread

import rx.subjects.TestSubject; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void multipleLeftTerminalRightOtherThread() {
    TestScheduler otherScheduler = Schedulers.test();
    TestSubject<EventB> eventBSubject = TestSubject.create(otherScheduler);
    Observable<Either<EventA, EventB>> either = RxEither.from(eventASubject, eventBSubject);
    either.subscribe(subscriber);

    eventASubject.onNext(eventA);
    eventBSubject.onNext(eventB);
    eventBSubject.onCompleted();
    eventASubject.onNext(eventA);

    testScheduler.triggerActions();
    subscriber.assertNotCompleted();
    otherScheduler.triggerActions();

    subscriber.assertNoErrors();
    subscriber.assertCompleted();
    subscriber.assertUnsubscribed();
    subscriber.assertValues(Either.<EventA, EventB>left(eventA),
                            Either.<EventA, EventB>left(eventA),
                            Either.<EventA, EventB>right(eventB));
}
 
开发者ID:eleventigers,项目名称:rxeither,代码行数:25,代码来源:RxEitherTest.java


示例2: onErrorCallsCallback

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void onErrorCallsCallback() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    Loader.Callbacks<Result<String>> callbacks = mock(Loader.Callbacks.class);
    Exception error = new Exception();
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.setCallbacks(callbacks);
    loader.start();
    subject.onError(error);

    scheduler.triggerActions();

    verify(callbacks).onLoaderStart();
    verify(callbacks).onLoaderResult(Result.<String>error(error));
    verify(callbacks).onLoaderComplete();
}
 
开发者ID:evant,项目名称:retain-state,代码行数:17,代码来源:RxLoaderTest.java


示例3: testLoaderStartRemoveFragment

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartRemoveFragment() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            getActivity().removeFragment();
        }
    });
    Thread.sleep(500); // Need to wait for onDestroy() to be called.
    subject.onNext("test");
    subject.onCompleted();
    testScheduler.triggerActions();
    getInstrumentation().waitForIdleSync();

    assertThat(getActivity().<String>getNext()).isNull();
    assertThat(getActivity().isCompleted()).isFalse().as("onCompleted() is not called if the activity is destroyed");
}
 
开发者ID:evant,项目名称:rxloader,代码行数:21,代码来源:BaseRxLoaderActivityWithFragmentTest.java


示例4: testLoaderStartDetachFragment

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartDetachFragment() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            getActivity().detachFragment();
        }
    });
    Thread.sleep(500); // Need to wait for onDestroy() to be called.
    subject.onNext("test");
    subject.onCompleted();
    testScheduler.triggerActions();
    getInstrumentation().waitForIdleSync();

    assertThat(getActivity().<String>getNext()).isNull();
    assertThat(getActivity().isCompleted()).isFalse().as("onCompleted() is not called if the fragment is detached");
}
 
开发者ID:evant,项目名称:rxloader,代码行数:21,代码来源:BaseRxLoaderActivityWithFragmentTest.java


示例5: testLoaderStartRotation

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartRotation() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            getActivity().recreate();
        }
    });
    createLoader(getActivity(), subject);
    getActivity().waitForStarted();

    assertThat(getActivity().isStarted()).isTrue().as("onStarted() called again after a configuration change");
}
 
开发者ID:evant,项目名称:rxloader,代码行数:17,代码来源:BaseRxLoaderActivityTest.java


示例6: testLoaderStartRotationNext

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartRotationNext() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    subject.onNext("test");
    subject.onCompleted();
    testScheduler.triggerActions();
    getActivity().waitForNext();
    getActivity().waitForCompleted();
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            getActivity().recreate();
        }
    });
    createLoader(getActivity(), subject);
    getActivity().waitForNext();
    getActivity().waitForCompleted();

    assertThat(getActivity().<String>getNext()).isEqualTo("test").as("result is delivered again after a configuration change");
    assertThat(getActivity().isCompleted()).isTrue().as("onCompleted() is called again after a configuration change");
}
 
开发者ID:evant,项目名称:rxloader,代码行数:24,代码来源:BaseRxLoaderActivityTest.java


示例7: testLoaderStartRotationError

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartRotationError() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    subject.onError(new Exception("test"));
    testScheduler.triggerActions();
    getActivity().waitForError();
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            getActivity().recreate();
        }
    });
    createLoader(getActivity(), subject);
    getActivity().waitForError();

    assertThat(getActivity().<String>getError()).hasMessage("test").as("onError() is called again after a configuration change");
}
 
开发者ID:evant,项目名称:rxloader,代码行数:20,代码来源:BaseRxLoaderActivityTest.java


示例8: testLoaderStartNextAfterDestroyed

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartNextAfterDestroyed() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            getActivity().finish();
        }
    });
    Thread.sleep(500); // Need to wait for onDestroy() to be called.
    subject.onNext("test");
    subject.onCompleted();
    testScheduler.triggerActions();
    getInstrumentation().waitForIdleSync();

    assertThat(getActivity().<String>getNext()).isNull();
    assertThat(getActivity().isCompleted()).isFalse().as("onCompleted() is not called if the activity is destroyed");

    // Needed to recreate the activity since the test runner expects it to exist. 
    getActivity();
}
 
开发者ID:evant,项目名称:rxloader,代码行数:24,代码来源:BaseRxLoaderActivityTest.java


示例9: testLoaderStartNextRotationClear

import rx.subjects.TestSubject; //导入依赖的package包/类
@SmallTest
public void testLoaderStartNextRotationClear() throws InterruptedException {
    TestSubject<String> subject = TestSubject.create(testScheduler);
    RxLoader<String> loader = createLoader(getActivity(), subject).start();
    getActivity().waitForStarted();
    subject.onNext("test");
    subject.onCompleted();
    testScheduler.triggerActions();
    getActivity().waitForNext();
    getActivity().waitForCompleted();
    loader.clear();
    T newActivity = recreateActivity();
    createLoader(newActivity, subject);
    getInstrumentation().waitForIdleSync();
    Thread.sleep(500); // Give loader a chance to deliver the result.

    assertThat(newActivity.<String>getNext()).isNull();
    assertThat(newActivity.isCompleted()).isFalse().as("onCompleted() is not called if the result was cleared");
}
 
开发者ID:evant,项目名称:rxloader,代码行数:20,代码来源:BaseRxLoaderActivityTest.java


示例10: setUp

import rx.subjects.TestSubject; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    testScheduler = new TestScheduler();
    statusSubject = TestSubject.create(testScheduler);
    jobSubject = TestSubject.create(testScheduler);

    when(uploadInteractor.getAll()).thenReturn(Observable.empty());

    uploadManager =
            new UploadManager(uploadInteractor, uploadErrorAdapter, jobSubject, statusSubject,
                    false);
}
 
开发者ID:jsaund,项目名称:RxUploader,代码行数:13,代码来源:UploadManagerTest.java


示例11: testDanglingUpload

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void testDanglingUpload() {
    final String jobId1 = "job-id-1";
    final String jobId2 = "job-id-2";

    final Job job1 = Job.builder()
            .setId(jobId1)
            .setFilepath("filepath")
            .setMetadata(Collections.emptyMap())
            .setStatus(createQueued(jobId1))
            .setMimeType("text/plain")
            .build();

    final Job job2 = Job.builder()
            .setId(jobId2)
            .setFilepath("filepath")
            .setMetadata(Collections.emptyMap())
            .setStatus(createSending(jobId2, 0))
            .setMimeType("text/plain")
            .build();

    when(uploadInteractor.getAll())
            .thenReturn(Observable.from(Arrays.asList(job1, job2)));

    final TestScheduler testScheduler = new TestScheduler();
    final TestSubject<Status> statusSubject = TestSubject.create(testScheduler);
    final TestSubject<Job> jobSubject = TestSubject.create(testScheduler);

    new UploadManager(uploadInteractor, uploadErrorAdapter, jobSubject, statusSubject, false);

    verify(uploadInteractor, times(1)).update(any(Status.class));

    final Status expectedStatus = Status.createFailed(job2.id(), ErrorType.TERMINATED);
    verify(uploadInteractor).update(expectedStatus);
}
 
开发者ID:jsaund,项目名称:RxUploader,代码行数:36,代码来源:UploadManagerTest.java


示例12: setUpServer

import rx.subjects.TestSubject; //导入依赖的package包/类
@Before
public void setUpServer() {
    tradeEventStreamClient = mock(EventStreamClient.class);
    scheduler = Schedulers.test();
    vwapServer = new VwapServer(42, tradeEventStreamClient, scheduler);
    tradeSourceSubject = TestSubject.create(scheduler);
    when(tradeEventStreamClient.readServerSideEvents()).thenReturn(tradeSourceSubject);
}
 
开发者ID:RxHandsOn,项目名称:MarketData,代码行数:9,代码来源:VwapServerTest.java


示例13: newlyCreatedIsNotSubscribed

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void newlyCreatedIsNotSubscribed() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    RxLoader<String> loader = new RxLoader<>(subject);

    assertFalse(subject.hasObservers());
}
 
开发者ID:evant,项目名称:loadie,代码行数:8,代码来源:RxLoaderTest.java


示例14: startedSubscribes

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void startedSubscribes() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.start();

    assertTrue(subject.hasObservers());
}
 
开发者ID:evant,项目名称:loadie,代码行数:9,代码来源:RxLoaderTest.java


示例15: canceledUnsubscribes

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void canceledUnsubscribes() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.start();
    loader.cancel();

    assertFalse(subject.hasObservers());
}
 
开发者ID:evant,项目名称:loadie,代码行数:10,代码来源:RxLoaderTest.java


示例16: onNextCallsCallbacks

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void onNextCallsCallbacks() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    Loader.Callbacks<String> callbacks = mock(Loader.Callbacks.class);
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.setCallbacks(callbacks);
    loader.start();
    subject.onNext("test");

    scheduler.triggerActions();

    verify(callbacks).onLoaderStart();
    verify(callbacks).onLoaderResult("test");
}
 
开发者ID:evant,项目名称:loadie,代码行数:15,代码来源:RxLoaderTest.java


示例17: onErrorCallsCallback

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void onErrorCallsCallback() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    Loader.Callbacks<String> callbacks = mock(Loader.Callbacks.class);
    Exception error = new Exception();
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.setCallbacks(callbacks);
    loader.start();
    subject.onError(error);

    scheduler.triggerActions();

    verify(callbacks).onLoaderStart();
    verify(callbacks).onLoaderError(error);
}
 
开发者ID:evant,项目名称:loadie,代码行数:16,代码来源:RxLoaderTest.java


示例18: onCompleteCallsCallback

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void onCompleteCallsCallback() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    Loader.Callbacks<String> callbacks = mock(Loader.Callbacks.class);
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.setCallbacks(callbacks);
    loader.start();
    subject.onCompleted();

    scheduler.triggerActions();

    verify(callbacks).onLoaderStart();
    verify(callbacks).onLoaderSuccess();
}
 
开发者ID:evant,项目名称:loadie,代码行数:15,代码来源:RxLoaderTest.java


示例19: onNextCallsCallbacks

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void onNextCallsCallbacks() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    Loader.Callbacks<Result<String>> callbacks = mock(Loader.Callbacks.class);
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.setCallbacks(callbacks);
    loader.start();
    subject.onNext("test");
    
    scheduler.triggerActions();

    verify(callbacks).onLoaderStart();
    verify(callbacks).onLoaderResult(Result.success("test"));
}
 
开发者ID:evant,项目名称:retain-state,代码行数:15,代码来源:RxLoaderTest.java


示例20: onCompleteCallsCallback

import rx.subjects.TestSubject; //导入依赖的package包/类
@Test
public void onCompleteCallsCallback() {
    TestSubject<String> subject = TestSubject.create(scheduler);
    Loader.Callbacks<Result<String>> callbacks = mock(Loader.Callbacks.class);
    RxLoader<String> loader = new RxLoader<>(subject);
    loader.setCallbacks(callbacks);
    loader.start();
    subject.onCompleted();

    scheduler.triggerActions();

    verify(callbacks).onLoaderStart();
    verify(callbacks).onLoaderComplete();
}
 
开发者ID:evant,项目名称:retain-state,代码行数:15,代码来源:RxLoaderTest.java



注:本文中的rx.subjects.TestSubject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UserLevel类代码示例发布时间:2022-05-22
下一篇:
Java Duration类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap