Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 12, 2024
2 parents bc231c8 + 294d3df commit 2ad2bd0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,39 +79,47 @@ public void testWithoutSerializers() throws Exception
/**
* Deserialization will fail, however.
*/
public void testWithoutDeserializers() throws Exception
public void testWithoutDeserializersFail() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
try {
mapper.readValue("[1,2,3]",
new TypeReference<ImmutableList<Integer>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, ImmutableList.class);
}

try {
mapper.readValue("[1,2,3]", new TypeReference<ImmutableSet<Integer>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, ImmutableSet.class);
}

try {
mapper.readValue("[1,2,3]", new TypeReference<ImmutableSortedSet<Integer>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, ImmutableSortedSet.class);
}

try {
mapper.readValue("{\"a\":true,\"b\":false}", new TypeReference<ImmutableMap<Integer,Boolean>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, ImmutableMap.class);
}
}

private void _verifyImmutableException(InvalidDefinitionException e, Class<?> type) {
// Exception changed a bit in 2.18.2, need to match
//verifyException(e, "cannot find a deserializer");
verifyException(e, "Cannot construct instance of ");
verifyException(e, "No creators");
verifyException(e, type.getName());
}

/*
/**********************************************************************
/* Basic tests for actual registered module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public void testWithoutDeserializers() throws Exception
new TypeReference<Multiset<String>>() { });
fail("Should have failed");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
// Exception changed a bit in 2.18.2, need to match
//verifyException(e, "cannot find a deserializer");
verifyException(e, "Cannot construct instance of ");
verifyException(e, "No creators");
verifyException(e, Multiset.class.getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,32 @@ public void withoutDeserializers() throws Exception
new TypeReference<PSequence<Integer>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, PSequence.class);
}

try {
mapper.readValue("[1,2,3]", new TypeReference<PSet<Integer>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, PSet.class);
}

try {
mapper.readValue("{\"a\":true,\"b\":false}", new TypeReference<PMap<Integer,Boolean>>() { });
fail("Expected failure for missing deserializer");
} catch (InvalidDefinitionException e) {
verifyException(e, "cannot find a deserializer");
_verifyImmutableException(e, PMap.class);
}
}

private void _verifyImmutableException(InvalidDefinitionException e, Class<?> type) {
// Exception changed a bit in 2.18.2, need to match
//verifyException(e, "cannot find a deserializer");
verifyException(e, "Cannot construct instance of ");
verifyException(e, "No creators");
verifyException(e, type.getName());
}

/*
/**********************************************************************
/* Unit tests for actual registered module
Expand Down

0 comments on commit 2ad2bd0

Please sign in to comment.