Search in sources :

Example 1 with PostgresUnitDbAdapter

use of org.apache.cayenne.unit.PostgresUnitDbAdapter in project cayenne by apache.

the class ReturnTypesMappingIT method testBLOB.

@Test
public void testBLOB() throws Exception {
    assumeTrue("In postresql blob_column has OID type, but in JAVA it converts into long not into byte.", !(unitDbAdapter instanceof PostgresUnitDbAdapter));
    if (unitDbAdapter.supportsLobs()) {
        String columnName = "BLOB_COLUMN";
        ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
        byte[] blobValue = { 3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60 };
        test.setBlobColumn(blobValue);
        context.commitChanges();
        DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap2")).get(0);
        Object columnValue = testRead.get(columnName);
        assertNotNull(columnValue);
        assertEquals(byte[].class, columnValue.getClass());
        assertTrue(Arrays.equals(blobValue, (byte[]) columnValue));
    }
}
Also used : ReturnTypesMap2(org.apache.cayenne.testdo.return_types.ReturnTypesMap2) PostgresUnitDbAdapter(org.apache.cayenne.unit.PostgresUnitDbAdapter) DataRow(org.apache.cayenne.DataRow) Test(org.junit.Test)

Aggregations

DataRow (org.apache.cayenne.DataRow)1 ReturnTypesMap2 (org.apache.cayenne.testdo.return_types.ReturnTypesMap2)1 PostgresUnitDbAdapter (org.apache.cayenne.unit.PostgresUnitDbAdapter)1 Test (org.junit.Test)1