Skip to content

Commit

Permalink
Add a failing test for #1604
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 11, 2017
1 parent 39f1adf commit d6f24a1
Showing 1 changed file with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.fasterxml.jackson.failing;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.databind.*;

// for [databind#1604]
public class NestedTypes1604Test extends BaseMapTest
{
public static class Data<T> {
private T data;

public Data(T data) {
this.data = data;
}

public T getData() {
return data;
}

public static <T> Data<List<T>> of(List<T> data) {
return new DataList<>(data);
}
}

public static class DataList<T> extends Data<List<T>> {
public DataList(List<T> data) {
super(data);
}
}

public static class Inner {
private int index;

public Inner(int index) {
this.index = index;
}

public int getIndex() {
return index;
}
}

public static class BadOuter {
private Data<List<Inner>> inner;

public BadOuter(Data<List<Inner>> inner) {
this.inner = inner;
}

public Data<List<Inner>> getInner() {
return inner;
}
}

public static class GoodOuter {
private DataList<Inner> inner;

public GoodOuter(DataList<Inner> inner) {
this.inner = inner;
}

public DataList<Inner> getInner() {
return inner;
}
}

public void testIssue1604() throws Exception
{
final ObjectMapper objectMapper = newObjectMapper();
List<Inner> inners = new ArrayList<>();
for (int i = 0; i < 2; i++) {
inners.add(new Inner(i));
}
BadOuter badOuter = new BadOuter(Data.of(inners));
GoodOuter goodOuter = new GoodOuter(new DataList<>(inners));
// String json = objectMapper.writeValueAsString(goodOuter);

// 11-Oct-2017, tatu: Fails with exception wrt type specialization
String json = objectMapper.writeValueAsString(badOuter);
assertNotNull(json);
}
}

0 comments on commit d6f24a1

Please sign in to comment.