Skip to content

Commit 099f36a

Browse files
committed
minor test refactorings for type-related tests
1 parent c62d8c7 commit 099f36a

File tree

4 files changed

+43
-61
lines changed

4 files changed

+43
-61
lines changed

src/test/java/com/fasterxml/jackson/databind/type/JavaType76Test.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/test/java/com/fasterxml/jackson/databind/type/TestLocalType609.java renamed to src/test/java/com/fasterxml/jackson/databind/type/LocalTypeTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import com.fasterxml.jackson.databind.*;
44

5-
/**
6-
* Failing test related to [databind#609]
7-
*/
8-
public class TestLocalType609 extends BaseMapTest
5+
public class LocalTypeTest extends BaseMapTest
96
{
7+
// [databind#609]
108
static class EntityContainer {
119
RuleForm entity;
1210

@@ -22,6 +20,7 @@ public RuleForm() { }
2220
public RuleForm(int v) { value = v; }
2321
}
2422

23+
// [databind#609]
2524
public void testLocalPartialType609() throws Exception {
2625
ObjectMapper mapper = new ObjectMapper();
2726

src/test/java/com/fasterxml/jackson/databind/type/RecursiveType938Test.java renamed to src/test/java/com/fasterxml/jackson/databind/type/RecursiveTypeTest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
import com.fasterxml.jackson.databind.*;
66

7-
// for [databind#938]
8-
public class RecursiveType938Test extends BaseMapTest
7+
public class RecursiveTypeTest extends BaseMapTest
98
{
9+
// for [databind#1301]
10+
@SuppressWarnings("serial")
11+
static class HashTree<K, V> extends HashMap<K, HashTree<K, V>> { }
12+
13+
// for [databind#938]
1014
public static interface Ability<T> { }
1115

1216
public static final class ImmutablePair<L, R> implements Map.Entry<L, R>, Ability<ImmutablePair<L, R>> {
@@ -38,8 +42,27 @@ static <L, R> ImmutablePair<L, R> of(final L left, final R right) {
3842
}
3943
}
4044

45+
// for [databind#1301]
46+
public void testRecursiveType()
47+
{
48+
TypeFactory tf = TypeFactory.defaultInstance();
49+
JavaType type = tf.constructType(HashTree.class);
50+
assertNotNull(type);
51+
}
52+
53+
// for [databind#1301]
54+
@SuppressWarnings("serial")
55+
static class DataDefinition extends HashMap<String, DataDefinition> {
56+
public DataDefinition definition;
57+
public DataDefinition elements;
58+
public String regex;
59+
public boolean required;
60+
public String type;
61+
}
62+
4163
private final ObjectMapper MAPPER = new ObjectMapper();
4264

65+
// [databind#938]
4366
public void testRecursivePair() throws Exception
4467
{
4568
JavaType t = MAPPER.constructType(ImmutablePair.class);
@@ -55,4 +78,19 @@ public void testRecursivePair() throws Exception
5578

5679
// can not deserialize with current definition, however
5780
}
81+
82+
// for [databind#1301]
83+
public void testJavaTypeToString() throws Exception
84+
{
85+
TypeFactory tf = objectMapper().getTypeFactory();
86+
String desc = tf.constructType(DataDefinition.class).toString();
87+
assertNotNull(desc);
88+
// could try comparing exact message, but since it's informational try looser:
89+
if (!desc.contains("map type")) {
90+
fail("Description should contain 'map type', did not: "+desc);
91+
}
92+
if (!desc.contains("recursive type")) {
93+
fail("Description should contain 'recursive type', did not: "+desc);
94+
}
95+
}
5896
}

src/test/java/com/fasterxml/jackson/failing/JavaTypeDesc1301Test.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)