Skip to content

Commit 7b6af88

Browse files
committed
Add failing tests wrt #245
1 parent dd5c9d9 commit 7b6af88

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,7 @@ public void annotateNextValue(String annotation) {
286286
_writer.addTypeAnnotation(annotation);
287287
}
288288

289-
/* Ion Exentions
290-
*
291-
*/
289+
// // // Ion Extensions
292290

293291
public void writeDate(Calendar value) throws JsonGenerationException, IOException {
294292
_verifyValueWrite("write date value");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fasterxml.jackson.dataformat.ion.failing;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
7+
import com.fasterxml.jackson.dataformat.ion.IonFactory;
8+
import com.fasterxml.jackson.dataformat.ion.IonObjectMapper;
9+
10+
// For [dataformats-binary#245]: no pretty-printing for textual format
11+
public class PrettyPrintWriteTest
12+
{
13+
@JsonPropertyOrder({ "x", "y" })
14+
static class Point {
15+
public int x = 1;
16+
public int y = 2;
17+
}
18+
19+
@Test
20+
public void testBasicPrettyPrintTextual() throws Exception
21+
{
22+
IonObjectMapper mapper = IonObjectMapper.builder(IonFactory.forTextualWriters()).build();
23+
Assert.assertEquals("{\n x:1,\n y:2\n}",
24+
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(new Point()));
25+
}
26+
27+
// and with binary format, should simply be no-op
28+
@Test
29+
public void testIgnorePrettyPrintForBinary() throws Exception
30+
{
31+
IonObjectMapper mapper = IonObjectMapper.builder(IonFactory.forBinaryWriters()).build();
32+
byte[] encoded = mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(new Point());
33+
Assert.assertNotNull(encoded);
34+
}
35+
}

0 commit comments

Comments
 (0)