|
15 | 15 |
|
16 | 16 | import static org.junit.Assert.*;
|
17 | 17 |
|
| 18 | +import io.reactivex.schedulers.AbstractSchedulerTests; |
18 | 19 | import java.util.concurrent.*;
|
19 | 20 |
|
20 | 21 | import org.junit.Test;
|
21 | 22 |
|
22 | 23 | import io.reactivex.*;
|
23 | 24 | import io.reactivex.Scheduler.Worker;
|
24 | 25 | import io.reactivex.disposables.*;
|
25 |
| -import io.reactivex.internal.disposables.SequentialDisposable; |
26 | 26 | import io.reactivex.internal.functions.Functions;
|
27 | 27 | import io.reactivex.internal.schedulers.SingleScheduler.ScheduledWorker;
|
28 | 28 | import io.reactivex.schedulers.Schedulers;
|
29 | 29 |
|
30 |
| -public class SingleSchedulerTest { |
| 30 | +public class SingleSchedulerTest extends AbstractSchedulerTests { |
31 | 31 |
|
32 | 32 | @Test
|
33 | 33 | public void shutdownRejects() {
|
@@ -119,63 +119,8 @@ public void runnableDisposedAsyncTimed() throws Exception {
|
119 | 119 | }
|
120 | 120 | }
|
121 | 121 |
|
122 |
| - @Test(timeout = 10000) |
123 |
| - public void schedulePeriodicallyDirectZeroPeriod() throws Exception { |
124 |
| - Scheduler s = Schedulers.single(); |
125 |
| - |
126 |
| - for (int initial = 0; initial < 2; initial++) { |
127 |
| - final CountDownLatch cdl = new CountDownLatch(1); |
128 |
| - |
129 |
| - final SequentialDisposable sd = new SequentialDisposable(); |
130 |
| - |
131 |
| - try { |
132 |
| - sd.replace(s.schedulePeriodicallyDirect(new Runnable() { |
133 |
| - int count; |
134 |
| - @Override |
135 |
| - public void run() { |
136 |
| - if (++count == 10) { |
137 |
| - sd.dispose(); |
138 |
| - cdl.countDown(); |
139 |
| - } |
140 |
| - } |
141 |
| - }, initial, 0, TimeUnit.MILLISECONDS)); |
142 |
| - |
143 |
| - assertTrue("" + initial, cdl.await(5, TimeUnit.SECONDS)); |
144 |
| - } finally { |
145 |
| - sd.dispose(); |
146 |
| - } |
147 |
| - } |
| 122 | + @Override protected Scheduler getScheduler() { |
| 123 | + return Schedulers.single(); |
148 | 124 | }
|
149 | 125 |
|
150 |
| - @Test(timeout = 10000) |
151 |
| - public void schedulePeriodicallyZeroPeriod() throws Exception { |
152 |
| - Scheduler s = Schedulers.single(); |
153 |
| - |
154 |
| - for (int initial = 0; initial < 2; initial++) { |
155 |
| - |
156 |
| - final CountDownLatch cdl = new CountDownLatch(1); |
157 |
| - |
158 |
| - final SequentialDisposable sd = new SequentialDisposable(); |
159 |
| - |
160 |
| - Scheduler.Worker w = s.createWorker(); |
161 |
| - |
162 |
| - try { |
163 |
| - sd.replace(w.schedulePeriodically(new Runnable() { |
164 |
| - int count; |
165 |
| - @Override |
166 |
| - public void run() { |
167 |
| - if (++count == 10) { |
168 |
| - sd.dispose(); |
169 |
| - cdl.countDown(); |
170 |
| - } |
171 |
| - } |
172 |
| - }, initial, 0, TimeUnit.MILLISECONDS)); |
173 |
| - |
174 |
| - assertTrue("" + initial, cdl.await(5, TimeUnit.SECONDS)); |
175 |
| - } finally { |
176 |
| - sd.dispose(); |
177 |
| - w.dispose(); |
178 |
| - } |
179 |
| - } |
180 |
| - } |
181 | 126 | }
|
0 commit comments