Skip to content

Commit ff3a9d6

Browse files
committed
Merge branch '2.19'
2 parents 272c2b1 + dbe9be2 commit ff3a9d6

File tree

4 files changed

+83
-23
lines changed

4 files changed

+83
-23
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: ./mvnw -B -q -ff -ntp test
6161
- name: Publish code coverage
6262
if: ${{ matrix.release_build && github.event_name != 'pull_request' }}
63-
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
63+
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
6464
with:
6565
token: ${{ secrets.CODECOV_TOKEN }}
6666
file: ./target/site/jacoco/jacoco.xml

src/test/java/tools/jackson/dataformat/xml/deser/XsiNilBasicTest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public static class DoubleWrapper2 {
3030
public DoubleWrapper2() { }
3131
}
3232

33-
private final XmlMapper MAPPER = newMapper();
33+
// 30-Jan-2025, tatu: To tease out [dataformat-xml#714] let's do this:
34+
private final XmlMapper MAPPER = mapperBuilder()
35+
.enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
36+
.build();
3437

3538
// 30-Jan-2025, tatu: Due to [databind#3406] fail on trailing tokens,
3639
// a likely bug surfaced around Root level `null`s. But for now let's
@@ -103,6 +106,7 @@ public void testWithDoubleAsMixed() throws Exception
103106
}
104107

105108
// [dataformat-xml#714]: trailing bogus `JsonToken.END_OBJECT`
109+
/*
106110
@Test
107111
public void testRootPojoAsNull() throws Exception
108112
{
@@ -111,6 +115,7 @@ public void testRootPojoAsNull() throws Exception
111115
Point.class);
112116
assertNull(bean);
113117
}
118+
*/
114119

115120
@Test
116121
public void testRootPojoAsNonNull() throws Exception
@@ -149,8 +154,8 @@ public void testDisableXsiNilLeafProcessing() throws Exception
149154
.readValue(DOC).toString());
150155
}
151156

152-
// [dataformat-xml#468]: Allow disabling xsi:nil special handling
153157
// [dataformat-xml#714]: trailing bogus `JsonToken.END_OBJECT`
158+
/*
154159
@Test
155160
public void testDisableXsiNilRootProcessing() throws Exception
156161
{
@@ -166,4 +171,5 @@ public void testDisableXsiNilRootProcessing() throws Exception
166171
assertEquals(a2q("{'nil':'true'}"),
167172
noXsiNilReader.readValue(DOC).toString());
168173
}
174+
*/
169175
}

src/test/java/tools/jackson/dataformat/xml/deser/builder/BuilderSimpleTest.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class BuilderSimpleTest extends XmlTestUtil
2222
// // Simple 2-property value class, builder with standard naming
2323

2424
@JsonDeserialize(builder=SimpleBuilderXY.class)
25-
static class ValueClassXY
25+
public static class ValueClassXY
2626
{
2727
final int _x, _y;
2828

@@ -32,7 +32,7 @@ protected ValueClassXY(int x, int y) {
3232
}
3333
}
3434

35-
static class SimpleBuilderXY
35+
public static class SimpleBuilderXY
3636
{
3737
public int x, y;
3838

@@ -54,7 +54,7 @@ public ValueClassXY build() {
5454
// // 3-property value, with more varied builder
5555

5656
@JsonDeserialize(builder=BuildABC.class)
57-
static class ValueClassABC
57+
public static class ValueClassABC
5858
{
5959
final int a, b, c;
6060

@@ -66,7 +66,7 @@ protected ValueClassABC(int a, int b, int c) {
6666
}
6767

6868
@JsonIgnoreProperties({ "d" })
69-
static class BuildABC
69+
public static class BuildABC
7070
{
7171
public int a; // to be used as is
7272
private int b, c;
@@ -91,16 +91,16 @@ public ValueClassABC build() {
9191
// // Then Builder that is itself immutable
9292

9393
@JsonDeserialize(builder=BuildImmutable.class)
94-
static class ValueImmutable
94+
public static class ValueImmutable
9595
{
9696
final int value;
9797
protected ValueImmutable(int v) { value = v; }
9898
}
9999

100-
static class BuildImmutable {
100+
public static class BuildImmutable {
101101
private final int value;
102-
103-
private BuildImmutable() { this(0); }
102+
103+
public BuildImmutable() { this(0); }
104104
private BuildImmutable(int v) {
105105
value = v;
106106
}
@@ -114,14 +114,14 @@ public ValueImmutable build() {
114114
// And then with custom naming:
115115

116116
@JsonDeserialize(builder=BuildFoo.class)
117-
static class ValueFoo
117+
public static class ValueFoo
118118
{
119119
final int value;
120-
protected ValueFoo(int v) { value = v; }
120+
public ValueFoo(int v) { value = v; }
121121
}
122122

123123
@JsonPOJOBuilder(withPrefix="foo", buildMethodName="construct")
124-
static class BuildFoo {
124+
public static class BuildFoo {
125125
private int value;
126126

127127
public BuildFoo fooValue(int v) {
@@ -137,20 +137,20 @@ public ValueFoo construct() {
137137
// for [databind#761]
138138

139139
@JsonDeserialize(builder=ValueInterfaceBuilder.class)
140-
interface ValueInterface {
140+
public interface ValueInterface {
141141
int getX();
142142
}
143143

144144
@JsonDeserialize(builder=ValueInterface2Builder.class)
145-
interface ValueInterface2 {
145+
public interface ValueInterface2 {
146146
int getX();
147147
}
148148

149-
static class ValueInterfaceImpl implements ValueInterface
149+
public static class ValueInterfaceImpl implements ValueInterface
150150
{
151151
final int _x;
152152

153-
protected ValueInterfaceImpl(int x) {
153+
public ValueInterfaceImpl(int x) {
154154
_x = x+1;
155155
}
156156

@@ -160,11 +160,11 @@ public int getX() {
160160
}
161161
}
162162

163-
static class ValueInterface2Impl implements ValueInterface2
163+
public static class ValueInterface2Impl implements ValueInterface2
164164
{
165165
final int _x;
166166

167-
protected ValueInterface2Impl(int x) {
167+
public ValueInterface2Impl(int x) {
168168
_x = x+1;
169169
}
170170

@@ -174,7 +174,7 @@ public int getX() {
174174
}
175175
}
176176

177-
static class ValueInterfaceBuilder
177+
public static class ValueInterfaceBuilder
178178
{
179179
public int x;
180180

@@ -188,7 +188,7 @@ public ValueInterface build() {
188188
}
189189
}
190190

191-
static class ValueInterface2Builder
191+
public static class ValueInterface2Builder
192192
{
193193
public int x;
194194

@@ -206,7 +206,7 @@ public ValueInterface2Impl build() {
206206
// [databind#777]
207207
@JsonDeserialize(builder = SelfBuilder777.class)
208208
@JsonPOJOBuilder(buildMethodName = "", withPrefix = "with")
209-
static class SelfBuilder777 {
209+
public static class SelfBuilder777 {
210210
public int x;
211211

212212
public SelfBuilder777 withX(int value) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package tools.jackson.dataformat.xml.tofix;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import tools.jackson.databind.*;
6+
7+
import tools.jackson.dataformat.xml.XmlMapper;
8+
import tools.jackson.dataformat.xml.XmlReadFeature;
9+
import tools.jackson.dataformat.xml.XmlTestUtil;
10+
import tools.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
11+
12+
import static org.junit.jupiter.api.Assertions.*;
13+
14+
public class XsiNilBasic714Test extends XmlTestUtil
15+
{
16+
private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
17+
18+
// 30-Jan-2025, tatu: To tease out [dataformat-xml#714] let's do this:
19+
private final XmlMapper MAPPER = mapperBuilder()
20+
.enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
21+
.build();
22+
23+
// [dataformat-xml#714]: trailing END_OBJECT
24+
@JacksonTestFailureExpected
25+
@Test
26+
public void testRootPojoAsNull() throws Exception
27+
{
28+
Point bean = MAPPER.readValue(
29+
"<Point "+XSI_NS_DECL+" xsi:nil='true' />",
30+
Point.class);
31+
assertNull(bean);
32+
}
33+
34+
// [dataformat-xml#468]: Allow disabling xsi:nil special handling
35+
36+
// [dataformat-xml#714]: trailing END_OBJECT
37+
@JacksonTestFailureExpected
38+
@Test
39+
public void testDisableXsiNilRootProcessing() throws Exception
40+
{
41+
final ObjectReader r = MAPPER.readerFor(JsonNode.class);
42+
final String DOC = "<Point "+XSI_NS_DECL+" xsi:nil='true'></Point>";
43+
44+
// with default processing:
45+
assertEquals("null", r.readValue(DOC).toString());
46+
47+
// 07-Jul-2021, tatu: Alas! 2.x sets format feature flags too late to
48+
// affect root element (3.0 works correctly). So cannot test
49+
50+
ObjectReader noXsiNilReader = r.without(XmlReadFeature.PROCESS_XSI_NIL);
51+
assertEquals(a2q("{'nil':'true'}"),
52+
noXsiNilReader.readValue(DOC).toString());
53+
}
54+
}

0 commit comments

Comments
 (0)