void assertMessage(AssertionError ex) { String message = ex.toString(); if (!message.contains(("did not `registerOnSubscribe` within"))) { throw ex; } }
@Test public void resolveExceptionWithAssertionError() throws Exception { AssertionError error = new AssertionError("argh"); testException(error, error.toString()); }
@Test public void withTag() { try { for (int i = 1; i < 3; i++) { Observable.just(i) .test() .withTag("testing with item=" + i) .assertResult(1) ; } throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.toString().contains("testing with item=2")); } }
@Test public void timeoutIndicated2() throws InterruptedException { try { Flowable.never() .test() .awaitDone(1, TimeUnit.MILLISECONDS) .assertResult(1); throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.toString().contains("timeout!")); } }
@Test public void timeoutIndicated() throws InterruptedException { Thread.interrupted(); // clear flag TestSubscriber<Object> ts = Flowable.never() .test(); assertFalse(ts.await(1, TimeUnit.MILLISECONDS)); try { ts.assertResult(1); throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.toString().contains("timeout!")); } }
@Test public void resolveExceptionWithAssertionErrorAsRootCause() throws Exception { AssertionError cause = new AssertionError("argh"); FatalBeanException exception = new FatalBeanException("wrapped", cause); testException(exception, cause.toString()); }
@Test public void timeoutIndicated3() throws InterruptedException { TestSubscriber<Object> ts = Flowable.never() .test(); assertFalse(ts.awaitTerminalEvent(1, TimeUnit.MILLISECONDS)); try { ts.assertResult(1); throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.toString().contains("timeout!")); } }
@Test public void withTag() { try { for (int i = 1; i < 3; i++) { Flowable.just(i) .test() .withTag("testing with item=" + i) .assertResult(1) ; } throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.toString().contains("testing with item=2")); } }
@Test public void assertNoTimeout2() { try { Flowable.never() .test() .awaitCount(1, TestWaitStrategy.SLEEP_1MS, 50) .assertNoTimeout(); throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.getMessage().contains("Timeout?!")); } }
@Test public void assertTimeout2() { try { Flowable.empty() .test() .awaitCount(1, TestWaitStrategy.SLEEP_1MS, 50) .assertTimeout(); throw new RuntimeException("Should have thrown!"); } catch (AssertionError ex) { assertTrue(ex.toString(), ex.getMessage().contains("No timeout?!")); } }
@Test public void resolveExceptionWithAssertionError() throws Exception { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class); this.resolver.setApplicationContext(ctx); this.resolver.afterPropertiesSet(); AssertionError err = new AssertionError("argh"); HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle"); ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, new NestedServletException("Handler dispatch failed", err)); assertNotNull("Exception was not handled", mav); assertTrue(mav.isEmpty()); assertEquals(err.toString(), this.response.getContentAsString()); }
@Test public void resolveExceptionWithAssertionErrorAsRootCause() throws Exception { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class); this.resolver.setApplicationContext(ctx); this.resolver.afterPropertiesSet(); AssertionError err = new AssertionError("argh"); FatalBeanException ex = new FatalBeanException("wrapped", err); HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle"); ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex); assertNotNull("Exception was not handled", mav); assertTrue(mav.isEmpty()); assertEquals(err.toString(), this.response.getContentAsString()); }
@Override public boolean apply() { boolean res = true; IgniteCache<?, ?> cache = ig.cache(cacheName); try { assertEquals("CachePuts", 0L, cache.mxBean().getCachePuts()); assertEquals("CacheHits", 0L, cache.mxBean().getCacheHits()); assertEquals("CacheGets", 0L, cache.mxBean().getCacheGets()); assertEquals("CacheRemovals", 0L, cache.mxBean().getCacheRemovals()); assertEquals("CacheMisses", 0L, cache.mxBean().getCacheMisses()); assertEquals("AverageGetTime", 0f, cache.mxBean().getAveragePutTime()); assertEquals("AveragePutTime", 0f, cache.mxBean().getAverageGetTime()); assertEquals("AverageRemoveTime", 0f, cache.mxBean().getAverageRemoveTime()); } catch (AssertionError e) { log.warning(e.toString()); res = false; } return res; } }, WAIT_CONDITION_TIMEOUT));
public static void assertEquals(final long l, final long l1) { try { Assert.assertEquals(l, l1); } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } }
public static void fail(final java.lang.String string) { try { Assert.fail(string); } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } }
public static void assertEquals(final java.lang.String string, final java.lang.Object object, final java.lang.Object object1) { try { Assert.assertEquals(string, object, object1); } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } }
public static void assertEquals(final java.lang.String string, final short i, final short i1) { try { Assert.assertEquals(string, i, i1); } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } }
public static void assertEquals(final short i, final short i1) { try { Assert.assertEquals(i, i1); } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } }
public static void assertNotSame(final java.lang.Object object, final java.lang.Object object1) { try { Assert.assertNotSame(object, object1); } catch (AssertionError e) { ProxyAssertSupport.log.warn("AssertionFailure::" + e.toString(), e); throw e; } } }