Skip to content

Commit 769853a

Browse files
committed
Add a (failing) test for #938
1 parent ead0c35 commit 769853a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.databind.*;
6+
7+
// for [databind#938]
8+
public class RecursiveType938Test extends BaseMapTest
9+
{
10+
public static interface Ability<T> { }
11+
12+
public static final class ImmutablePair<L, R> implements Map.Entry<L, R>, Ability<ImmutablePair<L, R>> {
13+
public final L key;
14+
public final R value;
15+
16+
public ImmutablePair(final L key, final R value) {
17+
this.key = key;
18+
this.value = value;
19+
}
20+
21+
@Override
22+
public L getKey() {
23+
return key;
24+
}
25+
26+
@Override
27+
public R getValue() {
28+
return value;
29+
}
30+
31+
@Override
32+
public R setValue(final R value) {
33+
throw new UnsupportedOperationException();
34+
}
35+
36+
static <L, R> ImmutablePair<L, R> of(final L left, final R right) {
37+
return new ImmutablePair<L, R>(left, right);
38+
}
39+
}
40+
41+
private final ObjectMapper MAPPER = new ObjectMapper();
42+
43+
public void testRecursivePair() throws Exception
44+
{
45+
JavaType t = MAPPER.constructType(ImmutablePair.class);
46+
47+
assertNotNull(t);
48+
assertEquals(ImmutablePair.class, t.getRawClass());
49+
50+
/*
51+
List<ImmutablePair<String, Double>> list = new ArrayList<ImmutablePair<String, Double>>();
52+
list.add(ImmutablePair.of("Hello World!", 123d));
53+
String json = MAPPER.writeValueAsString(list);
54+
assertNotNull(json);
55+
*/
56+
}
57+
}

0 commit comments

Comments
 (0)