use of com.amazon.ion.IonValue in project ion-java by amzn.
the class OutputStreamWriterTestCase method testAutoFlushTopLevelValuesForOtherWrites.
/**
* NOTE: This test method tests for the {@code write*()} methods of
* the IonWriter that are not typed.
*
* @see #testAutoFlushTopLevelValuesForTypedWritesContainers()
*/
@SuppressWarnings("deprecation")
@Test
public void testAutoFlushTopLevelValuesForOtherWrites() throws Exception {
IonValue val = system().singleValue("[a, [b, [c]]]");
// ================== IonValue.writeTo(IonWriter) =======================
iw = makeWriter();
val.writeTo(iw);
checkFlushedAfterTopLevelValueWritten();
// ================== IonWriter.writeValue(IonValue) ====================
iw = makeWriter();
iw.writeValue(val);
checkFlushedAfterTopLevelValueWritten();
// ================== IonWriter.writeValues(IonReader) ==================
iw = makeWriter();
IonReader reader = system().newReader(val);
iw.writeValues(reader);
checkFlushedAfterTopLevelValueWritten();
// ================== IonWriter.writeValue(IonReader) ===================
iw = makeWriter();
reader = system().newReader(val);
reader.next();
iw.writeValue(reader);
checkFlushedAfterTopLevelValueWritten();
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class SharedSymbolTableTest method testMalformedSymbolEntry.
public void testMalformedSymbolEntry(String symbolValue) {
IonStruct s = sharedSymtabStruct(system(), "ST", 5);
IonValue entry = system().singleValue(symbolValue);
s.put(SystemSymbols.SYMBOLS).newList(entry);
SymbolTable st = myMaker.newSharedSymtab(system(), s);
checkSharedTable("ST", 5, new String[] { null }, st);
assertEquals(1, st.getMaxId());
checkUnknownSymbol(1, st);
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class SymbolTableTest method testImportWithBadMaxId.
public void testImportWithBadMaxId(SymbolTable expected, String maxIdText) {
String text = LocalSymbolTablePrefix + "{" + " imports:[{name:\"imported\", version:1," + " max_id:" + maxIdText + " }]," + "}\n" + "null";
IonValue v = oneValue(text);
assertSame(expected, v.getSymbolTable().getImportedTables()[0]);
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class SymbolTableTest method testInitialSystemSymtab.
@Test
public void testInitialSystemSymtab() {
final SymbolTable systemTable = system().getSystemSymbolTable(ION_1_0);
assertEquals(ION, systemTable.getName());
String text = "0";
IonValue v = oneValue(text);
SymbolTable st = v.getSymbolTable();
assertSame(systemTable, st.getSystemSymbolTable());
IonDatagram dg = loader().load(text);
IonSymbol sysId = (IonSymbol) dg.systemGet(0);
checkSymbol(ION_1_0, ION_1_0_SID, sysId);
assertSame(systemTable, sysId.getSymbolTable());
v = dg.get(0);
st = v.getSymbolTable();
assertSame(systemTable, st.getSystemSymbolTable());
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class SymbolTableTest method testImportWithBadMaxId.
@Test
public void testImportWithBadMaxId() {
SymbolTable importedV1 = registerImportedV1();
testImportWithBadMaxId(importedV1, "null.int");
testImportWithBadMaxId(importedV1, "null");
testImportWithBadMaxId(importedV1, "not_an_int");
// testImportWithBadMaxId(importedV1, "0"); Zero isn't bad, its zero!
testImportWithBadMaxId(importedV1, "-1");
testImportWithBadMaxId(importedV1, "-2223");
String text = LocalSymbolTablePrefix + "{" + " imports:[{name:\"imported\", version:1}]," + "}\n" + "null";
IonValue v = oneValue(text);
assertSame(importedV1, v.getSymbolTable().getImportedTables()[0]);
SimpleCatalog catalog = (SimpleCatalog) system().getCatalog();
catalog.removeTable(importedV1.getName(), importedV1.getVersion());
badValue(text);
}
Aggregations