Skip to content

Commit c23c372

Browse files
committed
Minor cleanup post #4016
1 parent a4a3eae commit c23c372

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/test/java/com/fasterxml/jackson/databind/ser/CyclicTypeSerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public class CyclicTypeSerTest
1818
extends BaseMapTest
1919
{
20-
public static class Bean
20+
static class Bean
2121
{
2222
Bean _next;
2323
final String _name;
Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
package com.fasterxml.jackson.databind.ser.dos;
22

3-
import com.fasterxml.jackson.core.StreamWriteConstraints;
4-
import com.fasterxml.jackson.databind.BaseMapTest;
5-
import com.fasterxml.jackson.databind.JsonMappingException;
6-
import com.fasterxml.jackson.databind.ObjectMapper;
7-
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
8-
import com.fasterxml.jackson.databind.ser.CyclicTypeSerTest;
9-
103
import java.util.ArrayList;
114
import java.util.List;
125

6+
import com.fasterxml.jackson.core.StreamWriteConstraints;
7+
8+
import com.fasterxml.jackson.databind.*;
9+
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
10+
1311
/**
1412
* Simple unit tests to verify that we fail gracefully if you attempt to serialize
1513
* data that is cyclic (eg a list that contains itself).
1614
*/
1715
public class CyclicDataSerTest
1816
extends BaseMapTest
1917
{
18+
static class CyclicBean
19+
{
20+
CyclicBean _next;
21+
final String _name;
22+
23+
public CyclicBean(CyclicBean next, String name) {
24+
_next = next;
25+
_name = name;
26+
}
27+
28+
public CyclicBean getNext() { return _next; }
29+
public String getName() { return _name; }
30+
31+
public void assignNext(CyclicBean n) { _next = n; }
32+
}
33+
2034
private final ObjectMapper MAPPER = newJsonMapper();
2135

2236
public void testLinkedAndCyclic() throws Exception {
23-
CyclicTypeSerTest.Bean bean = new CyclicTypeSerTest.Bean(null, "last");
37+
CyclicBean bean = new CyclicBean(null, "last");
2438
bean.assignNext(bean);
2539
try {
2640
writeAndMap(MAPPER, bean);
@@ -36,12 +50,12 @@ public void testListWithSelfReference() throws Exception {
3650
list.add(list);
3751
try {
3852
writeAndMap(MAPPER, list);
39-
fail("expected JsonMappingException");
40-
} catch (JsonMappingException jmex) {
53+
fail("expected DatabindException");
54+
} catch (DatabindException e) {
4155
String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed",
4256
StreamWriteConstraints.DEFAULT_MAX_DEPTH + 1);
43-
assertTrue("JsonMappingException message is as expected?",
44-
jmex.getMessage().startsWith(exceptionPrefix));
57+
assertTrue("DatabindException message is as expected?",
58+
e.getMessage().startsWith(exceptionPrefix));
4559
}
4660
}
4761
}

0 commit comments

Comments
 (0)