|
15 | 15 | // |
16 | 16 | package org.msgpack.jackson.dataformat; |
17 | 17 |
|
| 18 | +import com.fasterxml.jackson.databind.ObjectMapper; |
18 | 19 | import org.junit.Test; |
19 | 20 |
|
20 | 21 | import java.io.IOException; |
| 22 | +import java.nio.charset.Charset; |
21 | 23 | import java.util.Arrays; |
22 | 24 |
|
| 25 | +import static org.hamcrest.CoreMatchers.not; |
| 26 | +import static org.hamcrest.CoreMatchers.containsString; |
| 27 | + |
23 | 28 | import static org.junit.Assert.assertEquals; |
| 29 | +import static org.junit.Assert.assertThat; |
24 | 30 | import static org.junit.Assert.assertTrue; |
25 | 31 |
|
26 | 32 | public class MessagePackDataformatForPojoTest |
@@ -99,4 +105,18 @@ public void testChangingPropertyNames() |
99 | 105 | ChangingPropertyNamesPojo value = objectMapper.readValue(bytes, ChangingPropertyNamesPojo.class); |
100 | 106 | assertEquals("komamitsu", value.getTheName()); |
101 | 107 | } |
| 108 | + |
| 109 | + @Test |
| 110 | + public void testSerializationWithoutSchema() |
| 111 | + throws IOException |
| 112 | + { |
| 113 | + ObjectMapper objectMapper = new ObjectMapper(factory); // to not affect shared objectMapper state |
| 114 | + UsingCustomConstructorPojo orig = new UsingCustomConstructorPojo("komamitsu", 55); |
| 115 | + objectMapper.setAnnotationIntrospector(new JsonArrayFormat()); |
| 116 | + byte[] bytes = objectMapper.writeValueAsBytes(orig); |
| 117 | + String scheme = new String(bytes, Charset.forName("UTF-8")); |
| 118 | + assertThat(scheme, not(containsString("name"))); |
| 119 | + UsingCustomConstructorPojo value = objectMapper.readValue(bytes, UsingCustomConstructorPojo.class); |
| 120 | + assertEquals("komamitsu", value.name); |
| 121 | + } |
102 | 122 | } |
0 commit comments