Skip to content

Commit 4d552a7

Browse files
committed
Merge branch '2.x' into 3.x
2 parents f966e7b + 7f45555 commit 4d552a7

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

cbor/src/test/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
opens tools.jackson.dataformat.cbor.seq;
2525
opens tools.jackson.dataformat.cbor.testutil;
2626
opens tools.jackson.dataformat.cbor.testutil.failure;
27+
opens tools.jackson.dataformat.cbor.tofix;
2728
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package tools.jackson.dataformat.cbor.tofix;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
5+
import tools.jackson.databind.ObjectMapper;
6+
7+
import tools.jackson.dataformat.cbor.CBORGenerator;
8+
import tools.jackson.dataformat.cbor.CBORTestBase;
9+
import tools.jackson.dataformat.cbor.CBORWriteFeature;
10+
import tools.jackson.dataformat.cbor.testutil.failure.JacksonTestFailureExpected;
11+
12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
14+
import org.junit.jupiter.api.Test;
15+
16+
public class StringRef599Test extends CBORTestBase
17+
{
18+
static class AB599 {
19+
public String a;
20+
public String b;
21+
}
22+
23+
@JsonIgnoreProperties(ignoreUnknown = true)
24+
static class B599 {
25+
public String b;
26+
}
27+
28+
private final ObjectMapper MAPPER = cborMapper(cborFactoryBuilder()
29+
.enable(CBORWriteFeature.STRINGREF)
30+
.build());
31+
32+
// [dataformats-binary#599]
33+
@JacksonTestFailureExpected
34+
@Test
35+
public void testStringRef() throws Exception
36+
{
37+
AB599 ab = new AB599();
38+
ab.a = "foo";
39+
// important: has to be same String value to use StringRef
40+
ab.b = ab.a;
41+
byte[] cbor = MAPPER.writeValueAsBytes(ab);
42+
B599 b = MAPPER.readValue(cbor, B599.class);
43+
assertEquals(ab.b, b.b);
44+
}
45+
}

0 commit comments

Comments
 (0)