Skip to content

Commit 8f78c6f

Browse files
committed
Split/fork test class for #3906: still failing for 3.0 for now
1 parent 8676bf9 commit 8f78c6f

File tree

2 files changed

+65
-24
lines changed

2 files changed

+65
-24
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package tools.jackson.databind.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
4+
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
5+
import com.fasterxml.jackson.annotation.JsonCreator;
6+
import com.fasterxml.jackson.annotation.PropertyAccessor;
7+
8+
import tools.jackson.databind.BaseMapTest;
9+
import tools.jackson.databind.ObjectMapper;
10+
11+
/**
12+
* Test case that covers both failing-by-regression tests and passing tests.
13+
* <p>For more details, refer to
14+
* <a href="https://github.com/FasterXML/jackson-databind/issues/3906">
15+
* [databind#3906]: Regression: 2.15.0 breaks deserialization for records when mapper.setVisibility(ALL, NONE);</a>
16+
*<p>
17+
* NOTE: fixed for 2.x in 2.16; 2 failing cases still for 3.0.
18+
*/
19+
public class RecordDeserialization3906Test extends BaseMapTest
20+
{
21+
record Record3906(String string, int integer) {
22+
}
23+
24+
@JsonAutoDetect(creatorVisibility = Visibility.NON_PRIVATE)
25+
record Record3906Annotated(String string, int integer) {
26+
}
27+
28+
record Record3906Creator(String string, int integer) {
29+
@JsonCreator
30+
Record3906Creator {
31+
}
32+
}
33+
34+
/*
35+
/**********************************************************
36+
/* Failing tests that pass in 2.14, fixed in 2.16 but not 3.x
37+
/**********************************************************
38+
*/
39+
40+
// minimal config for reproduction
41+
public void testEmptyJsonToRecordMiminal() throws Exception {
42+
ObjectMapper mapper = jsonMapperBuilder()
43+
.changeDefaultVisibility(vc ->
44+
vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE))
45+
.build();
46+
47+
Record3906 recordDeser = mapper.readValue("{}", Record3906.class);
48+
49+
assertEquals(new Record3906(null, 0), recordDeser);
50+
}
51+
52+
// actual config used reproduction
53+
public void testEmptyJsonToRecordActualImpl() throws Exception {
54+
ObjectMapper mapper = jsonMapperBuilder()
55+
.changeDefaultVisibility(vc ->
56+
vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE)
57+
.withVisibility(PropertyAccessor.FIELD, Visibility.ANY))
58+
.build();
59+
Record3906 recordDeser = mapper.readValue("{}", Record3906.class);
60+
61+
assertEquals(new Record3906(null, 0), recordDeser);
62+
}
63+
}

src/test-jdk14/java/tools/jackson/databind/records/RecordDeserialization3906Test.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,11 @@ private record PrivateRecord3906(String string, int integer) {
4040

4141
/*
4242
/**********************************************************
43-
/* Failing tests that pass in 2.14 (regression)
43+
/* Failing tests that pass in 2.x
4444
/**********************************************************
4545
*/
4646

47-
// minimal config for reproduction
48-
public void testEmptyJsonToRecordMiminal() throws Exception {
49-
ObjectMapper mapper = jsonMapperBuilder()
50-
.changeDefaultVisibility(vc ->
51-
vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE))
52-
.build();
53-
54-
Record3906 recordDeser = mapper.readValue("{}", Record3906.class);
55-
56-
assertEquals(new Record3906(null, 0), recordDeser);
57-
}
58-
59-
// actual config used reproduction
60-
public void testEmptyJsonToRecordActualImpl() throws Exception {
61-
ObjectMapper mapper = jsonMapperBuilder()
62-
.changeDefaultVisibility(vc ->
63-
vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE)
64-
.withVisibility(PropertyAccessor.FIELD, Visibility.ANY))
65-
.build();
66-
Record3906 recordDeser = mapper.readValue("{}", Record3906.class);
67-
68-
assertEquals(new Record3906(null, 0), recordDeser);
69-
}
47+
// Forked to test class under "failing/" for 3.0
7048

7149
/*
7250
/**********************************************************

0 commit comments

Comments
 (0)