本文整理了Java中java.lang.AssertionError.getMessage()
方法的一些代码示例,展示了AssertionError.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AssertionError.getMessage()
方法的具体详情如下:
包路径:java.lang.AssertionError
类名称:AssertionError
方法名:getMessage
暂无
代码示例来源:origin: square/okhttp
/**
* Returns true if {@code e} is due to a firmware bug fixed after Android 4.2.2.
* https://code.google.com/p/android/issues/detail?id=54072
*/
public static boolean isAndroidGetsocknameError(AssertionError e) {
return e.getCause() != null && e.getMessage() != null
&& e.getMessage().contains("getsockname failed");
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Execute the given Runnable, catch any {@link AssertionError}, decorate
* with {@code AssertionError} containing diagnostic information about the
* request and response, and then re-throw.
*/
public void assertWithDiagnostics(Runnable assertion) {
try {
assertion.run();
}
catch (AssertionError ex) {
throw new AssertionError(ex.getMessage() + "\n" + this, ex);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void assertValueSetMissing() {
Set<Integer> set = new HashSet<Integer>(Arrays.asList(0, 1, 2, 4, 5, 6, 7));
try {
Observable.range(1, 5)
.test()
.assertValueSet(set);
throw new RuntimeException("Should have failed");
} catch (AssertionError ex) {
assertTrue(ex.getMessage(), ex.getMessage().contains("Value not in the expected collection: " + 3));
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void assertValueSetMissing() {
Set<Integer> set = new HashSet<Integer>(Arrays.asList(0, 1, 2, 4, 5, 6, 7));
try {
Flowable.range(1, 5)
.test()
.assertValueSet(set);
throw new RuntimeException("Should have failed");
} catch (AssertionError ex) {
assertTrue(ex.getMessage(), ex.getMessage().contains("Value not in the expected collection: " + 3));
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headerContainsWithMissingHeader() throws Exception {
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.header("foo", containsString("baz")).match(this.request));
assertThat(error.getMessage(), containsString("but was null"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void queryParamContainsWithMissingValue() throws Exception {
this.request.setURI(new URI("http://foo.com/a?foo=bar&foo=baz"));
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.queryParam("foo", containsString("bx")).match(this.request));
assertThat(error.getMessage(), containsString("was \"bar\""));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headerMissing() throws Exception {
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.header("foo", "bar").match(this.request));
assertThat(error.getMessage(), containsString("was null"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headersWithMissingHeader() throws Exception {
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.header("foo", "bar").match(this.request));
assertThat(error.getMessage(), containsString("but was null"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void queryParamMissing() throws Exception {
this.request.setURI(new URI("http://foo.com/a"));
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.queryParam("foo", "bar").match(this.request));
assertThat(error.getMessage(), containsString("but was null"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void queryParamMissingValue() throws Exception {
this.request.setURI(new URI("http://foo.com/a?foo=bar&foo=baz"));
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.queryParam("foo", "bad").match(this.request));
assertThat(error.getMessage(), containsString("expected:<bad> but was:<bar>"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headerContainsWithMissingValue() throws Exception {
this.request.getHeaders().put("foo", Arrays.asList("bar", "baz"));
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.header("foo", containsString("bx")).match(this.request));
assertThat(error.getMessage(), containsString("was \"bar\""));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headerMissingValue() throws Exception {
this.request.getHeaders().put("foo", Arrays.asList("bar", "baz"));
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.header("foo", "bad").match(this.request));
assertThat(error.getMessage(), containsString("expected:<bad> but was:<bar>"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void methodNoMatch() throws Exception {
this.request.setMethod(HttpMethod.POST);
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.method(HttpMethod.GET).match(this.request));
assertThat(error.getMessage(), containsString("expected:<GET> but was:<POST>"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headersWithMissingValue() throws Exception {
this.request.getHeaders().put("foo", Collections.singletonList("bar"));
AssertionError error = assertThrows(AssertionError.class,
() -> MockRestRequestMatchers.header("foo", "bar", "baz").match(this.request));
assertThat(error.getMessage(), containsString("to have at least <2> values"));
}
代码示例来源: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 repositoryIsNotTxProxy() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(Config.class);
ctx.refresh();
try {
assertTxProxying(ctx);
fail("expected exception");
}
catch (AssertionError ex) {
assertThat(ex.getMessage(), equalTo("FooRepository is not a TX proxy"));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void unexpectedRequest() throws Exception {
try {
this.manager.validateRequest(createRequest(GET, "/foo"));
}
catch (AssertionError error) {
assertEquals("No further requests expected: HTTP GET /foo\n" +
"0 request(s) executed.\n", error.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void unexpectedRequest() throws Exception {
try {
this.manager.validateRequest(createRequest(GET, "/foo"));
}
catch (AssertionError error) {
assertEquals("No further requests expected: HTTP GET /foo\n" +
"0 request(s) executed.\n", error.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void contentTypeNoMatch() throws Exception {
this.mockServer.expect(content().contentType("application/json;charset=UTF-8")).andRespond(withSuccess());
try {
executeAndVerify("foo");
}
catch (AssertionError error) {
String message = error.getMessage();
assertTrue(message, message.startsWith("Content type expected:<application/json;charset=UTF-8>"));
}
}
内容来源于网络,如有侵权,请联系作者删除!