Skip to content

Commit c745da5

Browse files
committed
minor test refactor
1 parent b5c05cc commit c745da5

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

src/main/java/com/fasterxml/jackson/databind/util/ClassUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ public static Ctor[] getConstructors(Class<?> cls) {
979979
* @since 2.7
980980
*/
981981
public static Class<?> getDeclaringClass(Class<?> cls) {
982-
// Caching does not seem worthwhile, as per profiling
983982
return isObjectOrPrimitive(cls) ? null : cls.getDeclaringClass();
984983
}
985984

src/test/java/com/fasterxml/jackson/databind/struct/TestBackRefsWithPolymorphic.java

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,6 @@
1212
// Unit test for [JACKSON-890]
1313
public class TestBackRefsWithPolymorphic extends BaseMapTest
1414
{
15-
private final String CLASS_NAME = getClass().getName();
16-
17-
// NOTE: order is arbitrary, test is fragile... has to work for now
18-
private final String JSON =
19-
"{\"@class\":\""+CLASS_NAME+"$PropertySheetImpl\",\"id\":0,\"properties\":{\"p1name\":{\"@class\":"
20-
+"\"" +CLASS_NAME+ "$StringPropertyImpl\",\"id\":0,\"name\":\"p1name\",\"value\":\"p1value\"},"
21-
+"\"p2name\":{\"@class\":\""+CLASS_NAME+"$StringPropertyImpl\",\"id\":0,"
22-
+"\"name\":\"p2name\",\"value\":\"p2value\"}}}";
23-
24-
private final ObjectMapper MAPPER = new ObjectMapper();
25-
26-
public void testDeserialize() throws IOException
27-
{
28-
PropertySheet input = MAPPER.readValue(JSON, PropertySheet.class);
29-
assertEquals(JSON, MAPPER.writeValueAsString(input));
30-
}
31-
32-
public void testSerialize() throws IOException
33-
{
34-
PropertySheet sheet = new PropertySheetImpl();
35-
36-
sheet.addProperty(new StringPropertyImpl("p1name", "p1value"));
37-
sheet.addProperty(new StringPropertyImpl("p2name", "p2value"));
38-
String actual = MAPPER.writeValueAsString(sheet);
39-
assertEquals(JSON, actual);
40-
}
41-
4215
@JsonPropertyOrder(alphabetic=true)
4316
interface Entity
4417
{
@@ -217,4 +190,36 @@ public StringPropertyImpl(String name, String value) {
217190
}
218191

219192
static class YetAnotherClass extends StringPropertyImpl { }
193+
194+
/*
195+
/**********************************************************
196+
/* Test methods
197+
/**********************************************************
198+
*/
199+
200+
private final String CLASS_NAME = getClass().getName();
201+
// NOTE: order is arbitrary, test is fragile... has to work for now
202+
private final String JSON =
203+
"{\"@class\":\""+CLASS_NAME+"$PropertySheetImpl\",\"id\":0,\"properties\":{\"p1name\":{\"@class\":"
204+
+"\"" +CLASS_NAME+ "$StringPropertyImpl\",\"id\":0,\"name\":\"p1name\",\"value\":\"p1value\"},"
205+
+"\"p2name\":{\"@class\":\""+CLASS_NAME+"$StringPropertyImpl\",\"id\":0,"
206+
+"\"name\":\"p2name\",\"value\":\"p2value\"}}}";
207+
208+
private final ObjectMapper MAPPER = new ObjectMapper();
209+
210+
public void testDeserialize() throws IOException
211+
{
212+
PropertySheet input = MAPPER.readValue(JSON, PropertySheet.class);
213+
assertEquals(JSON, MAPPER.writeValueAsString(input));
214+
}
215+
216+
public void testSerialize() throws IOException
217+
{
218+
PropertySheet sheet = new PropertySheetImpl();
219+
220+
sheet.addProperty(new StringPropertyImpl("p1name", "p1value"));
221+
sheet.addProperty(new StringPropertyImpl("p2name", "p2value"));
222+
String actual = MAPPER.writeValueAsString(sheet);
223+
assertEquals(JSON, actual);
224+
}
220225
}

0 commit comments

Comments
 (0)