File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
rxjava-core/src/test/java/rx Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ package rx ;
2
+
3
+ import java .util .ArrayList ;
4
+ import java .util .List ;
5
+ import java .util .concurrent .TimeUnit ;
6
+
7
+ import org .junit .Ignore ;
8
+ import org .junit .Test ;
9
+
10
+ import rx .util .functions .Action0 ;
11
+ import rx .util .functions .Action1 ;
12
+
13
+ @ Ignore // since this doesn't do any automatic testing
14
+ public class IntervalDemo {
15
+
16
+ @ Test public void demoInterval () throws Exception {
17
+ testLongObservable (Observable .interval (500 , TimeUnit .MILLISECONDS ).take (4 ), "demoInterval" );
18
+ }
19
+
20
+ public void testLongObservable (Observable <Long > o , final String testname ) throws Exception {
21
+ final List <Long > l = new ArrayList <Long >();
22
+ Action1 <Long > onNext = new Action1 <Long >() {
23
+ public void call (Long i ) {
24
+ l .add (i );
25
+ System .out .println (testname + " got " + i );
26
+ }
27
+ };
28
+ Action1 <Throwable > onError = new Action1 <Throwable >() {
29
+ public void call (Throwable t ) { t .printStackTrace (); }
30
+ };
31
+ Action0 onComplete = new Action0 () {
32
+ public void call () {
33
+ System .out .println (testname + " complete" );
34
+ }
35
+ };
36
+ o .subscribe (onNext , onError , onComplete );
37
+
38
+ // need to wait, otherwise JUnit kills the thread of interval()
39
+ Thread .sleep (2500 );
40
+ }
41
+
42
+ }
You can’t perform that action at this time.
0 commit comments