fixed tests to take care of stackTrace element appearing sometimes

This commit is contained in:
Inderjeet Singh 2014-12-10 22:43:44 +00:00
parent 0c3b9670f0
commit 7d96ce8d6d

View File

@ -24,7 +24,7 @@ public final class ThrowableFunctionalTest extends TestCase {
public void testExceptionWithCause() {
Exception e = new Exception("top level", new IOException("io error"));
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);
assertEquals("top level", e.getMessage());
@ -35,7 +35,7 @@ public final class ThrowableFunctionalTest extends TestCase {
public void testSerializedNameOnExceptionFields() {
MyException e = new MyException();
String json = gson.toJson(e);
assertEquals("{\"my_custom_name\":\"myCustomMessageValue\"}", json);
assertTrue(json.contains("{\"my_custom_name\":\"myCustomMessageValue\""));
}
public void testErrorWithoutCause() {