use of com.amazon.ion.IonStruct 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);
}
use of com.amazon.ion.IonStruct 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);
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class SymbolTableTest method append_some_data.
private void append_some_data(IonDatagram data) {
IonStruct contents = system().newEmptyStruct();
contents.add("one", system().newInt(1));
contents.add("two", system().newInt(2));
data.add(contents);
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class IonAssert method doAssertIonEquals.
// ========================================================================
private static void doAssertIonEquals(String path, IonValue expected, IonValue actual) {
if (expected == actual)
return;
IonType expectedType = expected.getType();
assertSame(path + " type", expectedType, actual.getType());
assertEqualAnnotations(path, expected, actual);
if (expected.isNullValue() || actual.isNullValue()) {
assertEquals(path, expected, actual);
return;
}
switch(expectedType) {
case BOOL:
case DECIMAL:
case FLOAT:
case INT:
case NULL:
case STRING:
case SYMBOL:
case TIMESTAMP:
{
// "Normal" IonValue.equals()
assertEquals(path + " IonValue", expected, actual);
break;
}
case BLOB:
case CLOB:
{
assertArrayEquals(path, ((IonLob) expected).getBytes(), ((IonLob) actual).getBytes());
break;
}
// user data, not system data.
case DATAGRAM:
case LIST:
case SEXP:
{
assertSequenceEquals(path, (IonSequence) expected, (IonSequence) actual);
break;
}
case STRUCT:
{
assertStructEquals(path, (IonStruct) expected, (IonStruct) actual);
break;
}
}
}
use of com.amazon.ion.IonStruct in project ion-java by amzn.
the class BinaryStreamingTest method testValue2.
@Test
public void testValue2() throws Exception {
String s = "item_view::{item_id:\"B00096H8Q4\",marketplace_id:2," + "product:{item_name:[" + "{value:'''Method 24CT Leather Wipes''',lang:EN_CA}," + "{value:'''Method 24CT Chiffons de Cuir''',lang:FR_CA}]," + "list_price:{value:18.23,unit:EUR},}" + ",index_suppressed:true," + "offline_store_only:true,version:2,}";
IonSystem sys = system();
IonDatagram dg = sys.getLoader().load(s);
IonValue v = dg.get(0);
IonValue v2 = ((IonStruct) v).get("offline_store_only");
SymbolTable sym = v.getSymbolTable();
assert v2.getSymbolTable() == sym;
IonReader ir = system().newReader(s);
Iterator<String> symbols = sym.iterateDeclaredSymbolNames();
SymbolTable u = system().newSharedSymbolTable("items", 1, symbols);
IonBinaryWriter wr = system().newBinaryWriter(u);
wr.writeValues(ir);
byte[] buffer = wr.getBytes();
dumpBuffer(buffer, buffer.length);
ir = getStreamingMode().newIonReader(system().getCatalog(), buffer);
wr = system().newBinaryWriter(u);
wr.writeValues(ir);
buffer = wr.getBytes();
dumpBuffer(buffer, buffer.length);
}
Aggregations