java.lang.AssertionError.toString()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中java.lang.AssertionError.toString()方法的一些代码示例,展示了AssertionError.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AssertionError.toString()方法的具体详情如下:
包路径:java.lang.AssertionError
类名称:AssertionError
方法名:toString

AssertionError.toString介绍

暂无

代码示例

代码示例来源:origin: reactive-streams/reactive-streams-jvm

void assertMessage(AssertionError ex) {
  String message = ex.toString();
  if (!message.contains(("did not `registerOnSubscribe` within"))) {
    throw ex;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void resolveExceptionWithAssertionError() throws Exception {
  AssertionError error = new AssertionError("argh");
  testException(error, error.toString());
}

代码示例来源:origin: ReactiveX/RxJava

@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"));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@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!"));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@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!"));
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void resolveExceptionWithAssertionErrorAsRootCause() throws Exception {
  AssertionError cause = new AssertionError("argh");
  FatalBeanException exception = new FatalBeanException("wrapped", cause);
  testException(exception, cause.toString());
}

代码示例来源:origin: ReactiveX/RxJava

@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!"));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@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"));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@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?!"));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@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?!"));
  }
}

代码示例来源:origin: spring-projects/spring-framework

@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());
}

代码示例来源:origin: spring-projects/spring-framework

@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());
}

代码示例来源:origin: apache/ignite

@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));

代码示例来源:origin: apache/activemq-artemis

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;
 }
}

代码示例来源:origin: apache/activemq-artemis

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;
 }
}

代码示例来源:origin: apache/activemq-artemis

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;
 }
}

代码示例来源:origin: apache/activemq-artemis

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;
 }
}

代码示例来源:origin: apache/activemq-artemis

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;
 }
}

代码示例来源:origin: apache/activemq-artemis

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;
   }
  }
}

代码示例来源:origin: akarnokd/RxJava3-preview

@Test
public void timeoutIndicated2() throws InterruptedException {
  try {
    Flowable.never()
    .test()
    .awaitDone(1, TimeUnit.MILLISECONDS)
    .assertResult(1);
    fail("Should have thrown!");
  } catch (AssertionError ex) {
    assertTrue(ex.toString(), ex.toString().contains("timeout!"));
  }
}

相关文章