use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestSQLXMLProcessing method testXmlTableSequenceArraySingle.
@Test
public void testXmlTableSequenceArraySingle() throws Exception {
// $NON-NLS-1$
String sql = "select * from xmltable('/a' passing convert('<a><b>first</b></a>', xml) columns x string[] path 'b') as x";
List<?>[] expected = new List<?>[] { Arrays.asList(new ArrayImpl("first")) };
process(sql, expected);
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestArray method testArrayValueSerialization.
@SuppressWarnings("unchecked")
@Test
public void testArrayValueSerialization() throws Exception {
ArrayImpl a1 = new ArrayImpl((Object[]) new Integer[] { 1, null, 3 });
ArrayImpl a2 = new ArrayImpl((Object[]) null);
String[] types = TupleBuffer.getTypeNames(Arrays.asList(new Array(Integer.class, null)));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
BatchSerializer.writeBatch(oos, types, Arrays.asList(Arrays.asList(a1), Arrays.asList(a2)));
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
List<List<Object>> batch = BatchSerializer.readBatch(ois, types);
assertEquals(a1, batch.get(0).get(0));
try {
((java.sql.Array) batch.get(1).get(0)).getArray();
fail();
} catch (SQLException e) {
}
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestArray method testArrayValueToString.
@Test
public void testArrayValueToString() {
ArrayImpl a1 = new ArrayImpl(new Object[] { 1, "x'2", 3 });
assertEquals("(1, 'x''2', 3)", SQLStringVisitor.getSQLString(new Constant(a1)));
a1 = new ArrayImpl((Object[]) new Object[][] { { 1, "x'2" }, { "c" } });
assertEquals("(('1', 'x''2'), ('c',))", SQLStringVisitor.getSQLString(new Constant(a1)));
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestArray method testSerialize.
@Test
public void testSerialize() throws Exception {
ArrayImpl a1 = new ArrayImpl((Object[]) new Integer[] { 1, 2, 3 });
a1 = UnitTestUtil.helpSerialize(a1);
assertEquals(1, a1.getValues()[0]);
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestArray method testZeroBasedArray.
@Test
public void testZeroBasedArray() throws Exception {
ArrayImpl a1 = new ArrayImpl((Object[]) new Integer[] { 1, 2, 3 });
a1.setZeroBased(true);
assertEquals(2, java.lang.reflect.Array.get(a1.getArray(1, 1), 0));
}
Aggregations