File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/test/scala/rx/lang/scala/observables Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -161,15 +161,23 @@ class BlockingObservableTest extends JUnitSuite {
161161 assertEquals(1 , r)
162162 }
163163
164- @ Test (expected = classOf [ NoSuchElementException ])
164+ @ Test
165165 def testToFutureWithEmpty () {
166166 val o = Observable .empty
167- Await .result(o.toBlocking.toFuture, 10 seconds)
167+ val future = o.toBlocking.toFuture // if this were to throw the original test would wrongly succeed
168+ Await .result(future.failed, 10 seconds) match {
169+ case t: NoSuchElementException => // this is what we expect
170+ case _ => fail(" expected the future to fail with a NoSuchElementException" )
171+ }
168172 }
169173
170- @ Test (expected = classOf [ IllegalArgumentException ])
174+ @ Test
171175 def testToFutureWithMultipleItems () {
172176 val o = Observable .just(1 , 2 )
173- Await .result(o.toBlocking.toFuture, 10 seconds)
177+ val future = o.toBlocking.toFuture // if this were to throw the original test would wrongly succeed
178+ Await .result(future.failed, 10 seconds) match {
179+ case t: IllegalArgumentException => // this is what we expect
180+ case _ => fail(" expected the future to fail with an IllegalArgumentException" )
181+ }
174182 }
175183}
You can’t perform that action at this time.
0 commit comments