use of com.amazon.ion.IonSymbol 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.IonSymbol in project ion-java by amzn.
the class ValueWriterTest method testWriteValuesWithSymtabIntoContainer.
// TODO more thorough testing that you can't output from DOM w/ bad text
@Test
public void testWriteValuesWithSymtabIntoContainer() throws Exception {
myOutputInList = true;
SymbolTable fredSymtab = Symtabs.register(Symtabs.FRED_NAME, 1, catalog());
SymbolTable gingerSymtab = Symtabs.register(Symtabs.GINGER_NAME, 1, catalog());
String gingerSym = gingerSymtab.findKnownSymbol(1);
// First setup some data to be copied.
IonDatagram dg = system().newDatagram(gingerSymtab);
dg.add().newSymbol(gingerSym);
IonReader r = system().newReader(dg.getBytes());
// Now copy that data into a non-top-level context
iw = makeWriter(fredSymtab);
iw.writeValues(r);
IonDatagram result = reload();
IonList l = (IonList) result.get(0);
assertEquals(1, l.size());
IonSymbol s = (IonSymbol) l.get(0);
// Should've assigned a new SID
checkSymbol(gingerSym, systemMaxId() + Symtabs.FRED_MAX_IDS[1] + 1, s);
}
use of com.amazon.ion.IonSymbol in project ion-java by amzn.
the class IonWriterTestCase method testWriteValuesWithSymtab.
@Test
public void testWriteValuesWithSymtab() throws Exception {
SymbolTable fredSymtab = Symtabs.register(Symtabs.FRED_NAME, 1, catalog());
SymbolTable gingerSymtab = Symtabs.register(Symtabs.GINGER_NAME, 1, catalog());
String gingerSym = gingerSymtab.findKnownSymbol(1);
// First setup some data to be copied.
IonDatagram dg = system().newDatagram(gingerSymtab);
dg.add().newSymbol(gingerSym);
IonReader r = system().newReader(dg.getBytes());
// Now copy that data into a non-top-level context
iw = makeWriter(fredSymtab);
iw.stepIn(IonType.LIST);
iw.writeValues(r);
iw.stepOut();
IonDatagram result = reload();
IonList l = (IonList) result.get(0);
assertEquals(1, l.size());
IonSymbol s = (IonSymbol) l.get(0);
// Should've assigned a new SID
checkSymbol(gingerSym, s);
}
use of com.amazon.ion.IonSymbol in project ion-java by amzn.
the class IonWriterTestCase method testWritingEmptySymtab.
@Test
public void testWritingEmptySymtab() throws Exception {
iw = makeWriter();
iw.addTypeAnnotation(ION_SYMBOL_TABLE);
iw.stepIn(IonType.STRUCT);
iw.stepOut();
iw.writeSymbol("foo");
iw.close();
IonDatagram dg = reload();
IonSymbol foo = (IonSymbol) dg.get(0);
assertEquals(0, foo.getTypeAnnotations().length);
}
use of com.amazon.ion.IonSymbol in project ion-java by amzn.
the class IterationTest method testSimpleIteration.
// =========================================================================
// Test cases
@Test
public void testSimpleIteration() {
Iterator<IonValue> i = system().iterate("abc");
assertTrue(i.hasNext());
IonSymbol value = (IonSymbol) i.next();
checkSymbol("abc", value);
assertFalse(i.hasNext());
checkEmptyIterator(i);
}
Aggregations