Search in sources :

Example 16 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class SharedSymbolTableTest method testDomSharedSymbolTable.

@Test
public void testDomSharedSymbolTable() {
    String[] symbols = { "hello" };
    IonStruct struct = sharedSymtabStruct(system(), "foobar", 1, symbols);
    final SymbolTable table = myMaker.newSharedSymtab(system(), struct);
    checkSharedTable("foobar", 1, new String[] { "hello" }, table);
}
Also used : IonStruct(com.amazon.ion.IonStruct) SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Example 17 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class SharedSymbolTableTest method testMalformedVersion.

public void testMalformedVersion(String versionValue) {
    IonStruct s = sharedSymtabStruct(system(), "ST", 1, "x", "y");
    putParsedValue(s, SystemSymbols.VERSION, versionValue);
    SymbolTable st = myMaker.newSharedSymtab(system(), s);
    checkSharedTable("ST", 1, new String[] { "x", "y" }, st);
}
Also used : IonStruct(com.amazon.ion.IonStruct) SymbolTable(com.amazon.ion.SymbolTable)

Example 18 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class SharedSymbolTableTest method testFindSymbolToken.

// -------------------------------------------------------------------------
// find()
@Test
public void testFindSymbolToken() {
    SymbolTable st = makeAbcTable();
    SymbolToken tok = st.find(OTHER_A);
    assertSame(A, tok.getText());
    assertEquals(st.getImportedMaxId() + 1, tok.getSid());
    tok = st.find("not there");
    assertNull(tok);
}
Also used : SymbolToken(com.amazon.ion.SymbolToken) SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Example 19 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class SymbolTableTest method testExtendingSharedSymbolTableWithHoles.

@Test
public void testExtendingSharedSymbolTableWithHoles() {
    String serializedSymtab = "$ion_shared_symbol_table::{" + "  name:\"Test\", version:3," + "  symbols:[ \"one\", 2, \"three\", null, \"\" ]" + "}";
    registerSharedSymtab(serializedSymtab);
    Iterator<String> newSymbols = Arrays.asList("four", null, "five").iterator();
    SymbolTable v4 = system().newSharedSymbolTable("Test", 4, newSymbols);
    checkSharedTable("Test", 4, new String[] { "one", null, "three", null, null, "four", "five" }, v4);
}
Also used : SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Example 20 with SymbolTable

use of com.amazon.ion.SymbolTable in project ion-java by amzn.

the class SymbolTableTest method testSystemSymtabAddSymbol.

@Test(expected = ReadOnlyValueException.class)
public void testSystemSymtabAddSymbol() {
    SymbolTable st = system().getSystemSymbolTable();
    st.intern("hello");
}
Also used : SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Aggregations

SymbolTable (com.amazon.ion.SymbolTable)177 Test (org.junit.Test)105 IonValue (com.amazon.ion.IonValue)21 IonDatagram (com.amazon.ion.IonDatagram)18 com.amazon.ion.impl._Private_Utils.copyLocalSymbolTable (com.amazon.ion.impl._Private_Utils.copyLocalSymbolTable)17 SymbolToken (com.amazon.ion.SymbolToken)14 IonStruct (com.amazon.ion.IonStruct)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)13 IonWriter (com.amazon.ion.IonWriter)12 SimpleCatalog (com.amazon.ion.system.SimpleCatalog)12 IonReader (com.amazon.ion.IonReader)11 IonSystem (com.amazon.ion.IonSystem)10 IOException (java.io.IOException)9 IonType (com.amazon.ion.IonType)8 ArrayList (java.util.ArrayList)7 IonException (com.amazon.ion.IonException)6 com.amazon.ion.impl._Private_IonBinaryWriterBuilder (com.amazon.ion.impl._Private_IonBinaryWriterBuilder)6 com.amazon.ion.impl.bin._Private_IonRawWriter (com.amazon.ion.impl.bin._Private_IonRawWriter)6 IonCatalog (com.amazon.ion.IonCatalog)5 IonList (com.amazon.ion.IonList)5