Book Image

Learning Reactive Programming with Java 8

By : Nickolay Tzvetinov
Book Image

Learning Reactive Programming with Java 8

By: Nickolay Tzvetinov

Overview of this book

Table of Contents (15 chapters)
Learning Reactive Programming with Java 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Testing asynchronous Observable instances with the help of the TestScheduler class


There is one last type of predefined scheduler that we didn't mention in Chapter 6, Using Concurrency and Parallelism with Schedulers. This is the TestScheduler scheduler, a scheduler designed to be used in unit tests. All the actions scheduled on it are wrapped in objects containing the time they should be executed at, and won't be executed before the triggerActions() method of the Scheduler instance is called. This method executes all of the actions that are not executed and are scheduled to be executed at or before the Scheduler instance's present time. This time is virtual. This means that it is set by us and we can advance to any moment in the future using the special methods of this scheduler.

In order to demonstrate it, we'll want to develop another method for creating a new type of observable. The implementation of the method itself won't be discussed in this chapter, but you can find it in the source...