use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method testBadLocalSymtabCreation.
@Test
public void testBadLocalSymtabCreation() {
SymbolTable systemTable = system().getSystemSymbolTable();
SymbolTable fred1 = Symtabs.CATALOG.getTable("fred", 1);
try {
system().newLocalSymbolTable((SymbolTable) null);
} catch (NullPointerException e) {
}
try {
system().newLocalSymbolTable(fred1, systemTable);
} catch (IllegalArgumentException e) {
}
try {
system().newLocalSymbolTable(fred1, null);
} catch (NullPointerException e) {
}
try {
system().newLocalSymbolTable(fred1, system().newLocalSymbolTable());
} catch (IllegalArgumentException e) {
}
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method testSharedSymtabCreationWithImports.
@Test
public void testSharedSymtabCreationWithImports() {
SymbolTable fred1 = Symtabs.CATALOG.getTable("fred", 1);
SymbolTable ginger1 = Symtabs.CATALOG.getTable("ginger", 1);
String[] syms = { "a", "fred_1", "b" };
SymbolTable st = system().newSharedSymbolTable("ST", 1, Arrays.asList(syms).iterator(), fred1);
checkSharedTable("ST", 1, new String[] { "fred_1", "fred_2", "a", "b" }, st);
assertEquals(fred1.findSymbol("fred_1"), st.findSymbol("fred_1"));
// Again, with two imports
st = system().newSharedSymbolTable("ST", 1, Arrays.asList(syms).iterator(), fred1, ginger1);
checkSharedTable("ST", 1, new String[] { "fred_1", "fred_2", "g1", "g2", "a", "b" }, st);
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method testNewSharedSymtabFromReaderWithImports.
@Test
public void testNewSharedSymtabFromReaderWithImports() {
SymbolTable v1 = registerImportedV1();
String text = SharedSymbolTablePrefix + "{ name:\"ST\", version:1, " + " imports:[{name:\"imported\", version:1," + " max_id:" + v1.getMaxId() + " }]," + " symbols:[\"imported 1\"]" + "}";
SymbolTable st = system().newSharedSymbolTable(system().newReader(text));
assertEquals(v1.findSymbol("imported 1"), st.findSymbol("imported 1"));
}
use of com.amazon.ion.SymbolTable 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.SymbolTable 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