Skip to content

Commit 1fc5272

Browse files
committed
Fix #2049 test failure (broken test)
1 parent 144a07f commit 1fc5272

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/test/java/tools/jackson/databind/tofix/NodeContext2049Test.java renamed to src/test/java/tools/jackson/databind/node/NodeContext2049Test.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tools.jackson.databind.tofix;
1+
package tools.jackson.databind.node;
22

33
import java.util.ArrayList;
44
import java.util.Iterator;
@@ -13,14 +13,15 @@
1313
import tools.jackson.databind.deser.std.DelegatingDeserializer;
1414
import tools.jackson.databind.json.JsonMapper;
1515
import tools.jackson.databind.testutil.DatabindTestUtil;
16-
import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;
1716
import tools.jackson.databind.type.CollectionLikeType;
1817

1918

2019
import static org.junit.jupiter.api.Assertions.assertSame;
2120

22-
// 30-Mar-2024, tatu: For some reason fails for 3.0 after conversion
23-
// to JUnit5. Should fix.
21+
/**
22+
* Test for ensuring that parent references are correctly set during
23+
* deserialization when using custom deserializers with token stream context.
24+
*/
2425
public class NodeContext2049Test extends DatabindTestUtil
2526
{
2627
public interface HasParent {
@@ -131,7 +132,9 @@ public ValueDeserializer<?> createContextual(DeserializationContext ctxt, BeanPr
131132
CollectionLikeType collectionType = ctxt.getTypeFactory().constructCollectionLikeType(propertyType.getRawClass(),
132133
contentType);
133134
ValueInstantiator instantiator = new ListValueInstantiator();
134-
retValue = new CollectionDeserializer(collectionType, objectDeserializer, null, instantiator);
135+
CollectionDeserializer collDeser = new CollectionDeserializer(collectionType, objectDeserializer, null, instantiator);
136+
// Need to make the CollectionDeserializer contextual
137+
retValue = collDeser.createContextual(ctxt, property);
135138
} else {
136139
retValue = objectDeserializer;
137140
}
@@ -140,21 +143,17 @@ public ValueDeserializer<?> createContextual(DeserializationContext ctxt, BeanPr
140143

141144
@Override
142145
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException {
143-
// TODO Auto-generated method stub
144-
return null;
146+
throw new UnsupportedOperationException();
145147
}
146-
147-
}
148+
}
148149

149150
/*
150151
/**********************************************************************
151152
/* Test methods
152153
/**********************************************************************
153154
*/
154155

155-
private ObjectMapper objectMapper;
156-
{
157-
objectMapper = JsonMapper.builder()
156+
private ObjectMapper objectMapper = JsonMapper.builder()
158157
.addModule(new tools.jackson.databind.JacksonModule() {
159158
@Override
160159
public String getModuleName() {
@@ -170,7 +169,6 @@ public void setupModule(SetupContext context) {
170169
}
171170
})
172171
.build();
173-
}
174172

175173
final static String JSON = "{\n" +
176174
" \"children\": [\n" +
@@ -186,7 +184,6 @@ public void setupModule(SetupContext context) {
186184
" }\n" +
187185
"}";
188186

189-
@JacksonTestFailureExpected
190187
@Test
191188
public void testReadNoBuffering() throws Exception {
192189
Parent obj = objectMapper.readerFor(Parent.class).readValue(JSON);
@@ -196,7 +193,6 @@ public void testReadNoBuffering() throws Exception {
196193
}
197194
}
198195

199-
@JacksonTestFailureExpected
200196
@Test
201197
public void testReadFromTree() throws Exception {
202198
JsonNode tree = objectMapper.readTree(JSON);

0 commit comments

Comments
 (0)