Skip to content

Commit f7ede19

Browse files
committed
Add failing ("tofix") test for #599
1 parent a2384dd commit f7ede19

File tree

1 file changed

+44
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)