File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
src/test/java/rx/subscriptions Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ package rx .subscriptions ;
2+
3+ import javafx .beans .binding .Binding ;
4+ import javafx .embed .swing .JFXPanel ;
5+ import org .junit .Test ;
6+ import rx .Observable ;
7+ import rx .schedulers .JavaFxScheduler ;
8+ import rx .subscribers .JavaFxSubscriber ;
9+
10+ import java .util .concurrent .TimeUnit ;
11+ import java .util .concurrent .*;
12+
13+ import static org .junit .Assert .assertTrue ;
14+
15+ public final class BindingTest {
16+
17+ public BindingTest () {
18+ new JFXPanel ();
19+ }
20+ @ Test
21+ public void testCompositeBinding () {
22+ CompositeBinding bindings = new CompositeBinding ();
23+
24+ Observable <Long > source = Observable .interval (1 ,TimeUnit .SECONDS );
25+ CountDownLatch unsbuscribeWait = new CountDownLatch (2 );
26+
27+ Binding <Long > binding1 = JavaFxSubscriber .toBinding (source .doOnUnsubscribe (unsbuscribeWait ::countDown ).observeOn (JavaFxScheduler .getInstance ()));
28+ bindings .add (binding1 );
29+
30+ Binding <Long > binding2 = JavaFxSubscriber .toBinding (source .doOnUnsubscribe (unsbuscribeWait ::countDown ).reduce (0L ,(x ,y ) -> x + y ).observeOn (JavaFxScheduler .getInstance ()));
31+ bindings .add (binding2 );
32+
33+ try {
34+ Thread .sleep (3000 );
35+ } catch (InterruptedException e ) {
36+ e .printStackTrace ();
37+ }
38+ assertTrue (bindings .hasSubscriptions ());
39+
40+ bindings .dispose ();
41+
42+ try {
43+ unsbuscribeWait .await (10 ,TimeUnit .SECONDS );
44+ } catch (InterruptedException e ) {
45+ e .printStackTrace ();
46+ }
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments