Search in sources :

Example 16 with IonValue

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();
}
Also used : IonValue(com.amazon.ion.IonValue) IonReader(com.amazon.ion.IonReader) Test(org.junit.Test)

Example 17 with IonValue

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);
}
Also used : IonValue(com.amazon.ion.IonValue) IonStruct(com.amazon.ion.IonStruct) SymbolTable(com.amazon.ion.SymbolTable)

Example 18 with IonValue

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]);
}
Also used : IonValue(com.amazon.ion.IonValue)

Example 19 with IonValue

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());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSymbol(com.amazon.ion.IonSymbol) IonDatagram(com.amazon.ion.IonDatagram) SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Example 20 with IonValue

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);
}
Also used : SimpleCatalog(com.amazon.ion.system.SimpleCatalog) IonValue(com.amazon.ion.IonValue) SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Aggregations

IonValue (com.amazon.ion.IonValue)185 Test (org.junit.Test)115 IonSequence (com.amazon.ion.IonSequence)61 SymbolTable (com.amazon.ion.SymbolTable)21 IonDatagram (com.amazon.ion.IonDatagram)20 IonStruct (com.amazon.ion.IonStruct)18 IonInt (com.amazon.ion.IonInt)16 IOException (java.io.IOException)14 IonReader (com.amazon.ion.IonReader)13 IonSystem (com.amazon.ion.IonSystem)12 Result (software.amazon.qldb.Result)11 SymbolToken (com.amazon.ion.SymbolToken)10 ArrayList (java.util.ArrayList)10 IonString (com.amazon.ion.IonString)9 IonException (com.amazon.ion.IonException)7 IonType (com.amazon.ion.IonType)6 IonObjectMapper (com.fasterxml.jackson.dataformat.ion.IonObjectMapper)6 Event (com.amazon.tools.events.Event)5 com.amazon.ion.impl._Private_IonValue (com.amazon.ion.impl._Private_IonValue)4 EventType (com.amazon.tools.events.EventType)4