use of com.amazon.ion.IonList in project ion-java by amzn.
the class SymbolTableTest method writeIonRep.
IonStruct writeIonRep(SymbolTable st) throws IOException {
IonList container = system().newEmptyList();
st.writeTo(system().newTreeWriter(container));
IonStruct stStruct = (IonStruct) container.get(0);
return stStruct;
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class SymbolTableTest method serialize.
public IonList serialize(final SymbolTable table) throws IOException {
final IonList container = system().newEmptyList();
table.writeTo(system().newWriter(container));
return container;
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class SymbolTableTest method insert_local_symbol_table.
private void insert_local_symbol_table(IonDatagram data) {
IonStruct local_symbol_table = system().newEmptyStruct();
local_symbol_table.addTypeAnnotation("$ion_symbol_table");
IonList symbols = system().newEmptyList();
symbols.add(system().newString("one"));
symbols.add(system().newString("two"));
local_symbol_table.add("symbols", symbols);
data.add(local_symbol_table);
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class SymbolTableTest method testInjectingMaxIdIntoImport.
@Test
public // TODO implement
void testInjectingMaxIdIntoImport() {
SymbolTable importedTable = registerImportedV1();
String text = LocalSymbolTablePrefix + "{" + " imports:[{name:'''imported''',version:1}],\n" + "}\n" + "null";
IonDatagram dg = loader().load(text);
SymbolTable symbolTable = dg.get(0).getSymbolTable();
checkLocalTable(symbolTable);
SymbolTable[] imported = symbolTable.getImportedTables();
assertEquals(1, imported.length);
assertSame(importedTable, imported[0]);
// Check that the encoded table has max_id on import
byte[] binary = dg.getBytes();
dg = loader().load(binary);
IonStruct symtabStruct = (IonStruct) dg.systemGet(1);
IonList imports = (IonList) symtabStruct.get("imports");
IonStruct importStruct = (IonStruct) imports.get(0);
checkString("imported", importStruct.get("name"));
IonValue maxIdValue = importStruct.get("max_id");
assertNotNull("max_id wasn't injected into import", maxIdValue);
checkInt(IMPORTED_1_MAX_ID, maxIdValue);
}
use of com.amazon.ion.IonList in project ion-java by amzn.
the class TreeReaderTest method testModificationDuringRead.
@Test
public void testModificationDuringRead() {
IonList list = system().newEmptyList();
list.add().newString("abc");
list.add().newString("def");
in = system().newReader(list);
assertEquals(IonType.LIST, in.next());
in.stepIn();
assertEquals(IonType.STRING, in.next());
// Violate the contract by modifying the value.
list.remove(0);
// Since the value was modified while it was being written, the result of the following is undefined. But
// one thing is for sure: it should not cause an infinite loop.
in.next();
}
Aggregations