Skip to content

Commit 779411e

Browse files
committed
add a failing test to help with AtomicRef default-typing issues
1 parent 01a80c1 commit 779411e

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/test/java/com/fasterxml/jackson/databind/jsontype/PolymorphicViaRefTypeTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.fasterxml.jackson.annotation.JsonSubTypes;
66
import com.fasterxml.jackson.annotation.JsonTypeInfo;
7+
78
import com.fasterxml.jackson.databind.*;
89

910
public class PolymorphicViaRefTypeTest extends BaseMapTest
@@ -35,7 +36,7 @@ static class TypeInfoAtomic {
3536

3637
private final ObjectMapper MAPPER = objectMapper();
3738

38-
public void testOptionalWithAtomic() throws Exception
39+
public void testPolymorphicAtomicRefProperty() throws Exception
3940
{
4041
TypeInfoAtomic data = new TypeInfoAtomic();
4142
data.value = new AtomicReference<BaseForAtomic>(new ImplForAtomic(42));
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.util.concurrent.atomic.AtomicReference;
4+
5+
import com.fasterxml.jackson.databind.*;
6+
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
7+
8+
public class PolymorphicViaRefTypeTest extends BaseMapTest
9+
{
10+
static class AtomicStringWrapper {
11+
public AtomicReference<StringWrapper> wrapper;
12+
13+
protected AtomicStringWrapper() { }
14+
public AtomicStringWrapper(String str) {
15+
wrapper = new AtomicReference<StringWrapper>(new StringWrapper(str));
16+
}
17+
}
18+
19+
/*
20+
/**********************************************************************
21+
/* Test methods
22+
/**********************************************************************
23+
*/
24+
25+
public void testAtomicRefViaDefaultTyping() throws Exception
26+
{
27+
ObjectMapper mapper = new ObjectMapper();
28+
mapper.enableDefaultTyping(DefaultTyping.NON_FINAL);
29+
AtomicStringWrapper data = new AtomicStringWrapper("foo");
30+
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
31+
AtomicStringWrapper result = mapper.readValue(json, AtomicStringWrapper.class);
32+
assertNotNull(result);
33+
}
34+
}

0 commit comments

Comments
 (0)