use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class IonWriterTestCase method testWriteSymbolTokenWithGoodSid.
@Test
public void testWriteSymbolTokenWithGoodSid() throws Exception {
iw = makeWriter();
iw.writeSymbolToken(newSymbolToken((String) null, NAME_SID));
IonDatagram dg = reload();
IonSymbol s = (IonSymbol) dg.get(0);
checkSymbol(SystemSymbols.NAME, NAME_SID, s);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class IonWriterTestCase method testWriteLobNull.
@Test
public void testWriteLobNull() throws Exception {
iw = makeWriter();
iw.writeBlob(null);
iw.writeBlob(null, 10, 12);
iw.writeClob(null);
iw.writeClob(null, 23, 1);
IonDatagram dg = reload();
for (int i = 0; i < 4; i++) {
IonLob lob = (IonLob) dg.get(i);
assertTrue("dg[" + i + "] not null", lob.isNullValue());
}
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class TextWriterTest method testNewLineTypesWithPrettyPrinting.
@Test
public void testNewLineTypesWithPrettyPrinting() {
for (IonTextWriterBuilder.NewLineType nlt : IonTextWriterBuilder.NewLineType.values()) {
String expected = String.format("%s\"Foo\"%<sBar%<s(%<s 1%<s 2%<s 3%<s)%<s[%<s 4,%<s 5,%<s 6%<s]", nlt.getCharSequence());
IonTextWriterBuilder writerBuilder = IonTextWriterBuilder.standard().withInitialIvmHandling(SUPPRESS).withWriteTopLevelValuesOnNewLines(false).withPrettyPrinting().withNewLineType(nlt);
IonDatagram dg = system().newDatagram();
dg.add().newString("Foo");
dg.add().newSymbol("Bar");
dg.add().newSexp(new int[] { 1, 2, 3 });
dg.add().newList(new int[] { 4, 5, 6 });
StringBuilder sb = new StringBuilder();
IonWriter writer = writerBuilder.build(sb);
dg.writeTo(writer);
assertEquals(expected, sb.toString());
}
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class TextWriterTest method testJsonLongStrings.
@Test
public void testJsonLongStrings() throws Exception {
options = IonTextWriterBuilder.json();
options.setLongStringThreshold(5);
IonDatagram dg = system().newDatagram();
dg.add().newString("hello");
dg.add().newString("hello!");
dg.add().newString("goodbye");
dg.add().newString("what's\nup\ndoc");
expectRendering("\"hello\" '''hello!''' \"goodbye\" '''what\\'s\nup\ndoc'''", dg);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class TextWriterTest method testWritingFloatPositiveInfinityToJson.
@Test
public void testWritingFloatPositiveInfinityToJson() throws Exception {
options = IonTextWriterBuilder.json();
options.setInitialIvmHandling(SUPPRESS);
IonDatagram dg = system().newDatagram();
dg.add().newFloat(Double.POSITIVE_INFINITY);
iw = makeWriter();
dg.writeTo(iw);
String actual = outputString();
assertEquals("null", actual);
}
Aggregations