Skip to content

Instantly share code, notes, and snippets.

@brianm
Created October 20, 2011 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianm/1302037 to your computer and use it in GitHub Desktop.
Save brianm/1302037 to your computer and use it in GitHub Desktop.
@Test
public void testBetterErrorMessage() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
try {
mapper.writeValueAsString(new Thing());
fail("should have raised an exception against a private class");
}
catch (Exception e) {
assertThat(e.getMessage(), containsString("private"));
}
}
private static class Thing
{
@JsonAnyGetter
public Map getProperties()
{
HashMap map = new HashMap();
map.put("a", "A");
return map;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment