fixed tests to take care of stackTrace element appearing sometimes
This commit is contained in:
parent
0c3b9670f0
commit
7d96ce8d6d
@ -24,7 +24,7 @@ public final class ThrowableFunctionalTest extends TestCase {
|
|||||||
public void testExceptionWithCause() {
|
public void testExceptionWithCause() {
|
||||||
Exception e = new Exception("top level", new IOException("io error"));
|
Exception e = new Exception("top level", new IOException("io error"));
|
||||||
String json = gson.toJson(e);
|
String json = gson.toJson(e);
|
||||||
assertEquals("{\"detailMessage\":\"top level\",\"cause\":{\"detailMessage\":\"io error\"}}", json);
|
assertTrue(json.contains("{\"detailMessage\":\"top level\",\"cause\":{\"detailMessage\":\"io error\""));
|
||||||
|
|
||||||
e = gson.fromJson("{'detailMessage':'top level','cause':{'detailMessage':'io error'}}", Exception.class);
|
e = gson.fromJson("{'detailMessage':'top level','cause':{'detailMessage':'io error'}}", Exception.class);
|
||||||
assertEquals("top level", e.getMessage());
|
assertEquals("top level", e.getMessage());
|
||||||
@ -35,7 +35,7 @@ public final class ThrowableFunctionalTest extends TestCase {
|
|||||||
public void testSerializedNameOnExceptionFields() {
|
public void testSerializedNameOnExceptionFields() {
|
||||||
MyException e = new MyException();
|
MyException e = new MyException();
|
||||||
String json = gson.toJson(e);
|
String json = gson.toJson(e);
|
||||||
assertEquals("{\"my_custom_name\":\"myCustomMessageValue\"}", json);
|
assertTrue(json.contains("{\"my_custom_name\":\"myCustomMessageValue\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testErrorWithoutCause() {
|
public void testErrorWithoutCause() {
|
||||||
|
Loading…
Reference in New Issue
Block a user