static void sleep(int millis) { try { Thread.sleep(millis); } catch (InterruptedException ex) { throw new RuntimeException(ex); } } }
@Override public void run() { try (Socket socket = new Socket(InetAddress.getLocalHost(), serverPort)) { OutputStream outputStream = socket.getOutputStream(); PrintWriter writer = new PrintWriter(outputStream); sendLogRequests(writer, socket.getInputStream()); } catch (IOException e) { LOGGER.error("error sending requests", e); throw new RuntimeException(e); } }
@Override public SingleSource<Integer> apply(final Integer integer) throws Exception { throw new RuntimeException("something went terribly wrong!"); } })
@Override public Throwable call() { return new RuntimeException(); } });
@Override public R apply(T t1) { throw new RuntimeException("Forced failure"); } };
@Override public void run() { throw new RuntimeException("failed on second one too"); } }));
@Override public void accept(Long n) { throw new RuntimeException(); } };
@Override public void onNext(Long args) { throw new RuntimeException("forced failure"); } };
@Override public void onNext(Long args) { throw new RuntimeException("forced failure"); } };
@Override public Map<Integer, Collection<String>> call() { throw new RuntimeException("Forced failure"); } };
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
public void waitToFinish() { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
protected void captureMaxThreads() { int concurrentThreads = threadsRunning.get(); int maxThreads = maxConcurrentThreads.get(); if (concurrentThreads > maxThreads) { maxConcurrentThreads.compareAndSet(maxThreads, concurrentThreads); if (concurrentThreads > 1) { new RuntimeException("should not be greater than 1").printStackTrace(); } } }
@Override public Observable<?> apply(Observable<? extends Throwable> t1) { return Observable.error(new RuntimeException()); } }).subscribe(observer);
@Test public void badException() { Throwable e = new BadException(); assertSame(e, new CompositeException(e).getCause().getCause()); assertSame(e, new CompositeException(new RuntimeException(e)).getCause().getCause().getCause()); }
@Test public void ambIterableOrder() { Completable error = Completable.error(new RuntimeException()); Completable.amb(Arrays.asList(Completable.complete(), error)).test().assertComplete(); }
@Test public void assertNotSubscribed() { TestObserver<Integer> to = new TestObserver<Integer>(); to.assertNotSubscribed(); to.errors().add(new TestException()); try { to.assertNotSubscribed(); throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { // expected } }
@Test public void assertValueSetOnlyThrowsWhenCompleted() { TestObserver<Integer> to = TestObserver.create(); to.onSubscribe(Disposables.empty()); to.onComplete(); try { to.assertValueSetOnly(Collections.<Integer>emptySet()); throw new RuntimeException(); } catch (AssertionError ex) { // expected } }
@Test public void singleOrErrorError() { Observable.error(new RuntimeException("error")) .singleOrError() .test() .assertNoValues() .assertErrorMessage("error") .assertError(RuntimeException.class); }
@Test public void ambWithOrder() { Flowable<Integer> error = Flowable.error(new RuntimeException()); Flowable.just(1).ambWith(error).test().assertValue(1).assertComplete(); }