use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testVARCHAR.
@Test
public void testVARCHAR() throws Exception {
String columnName = "VARCHAR_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
String varcharValue = "VARChar string for tests!";
test.setVarcharColumn(varcharValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(String.class, columnValue.getClass());
assertEquals(varcharValue, columnValue);
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testSMALLINT.
@Test
public void testSMALLINT() throws Exception {
String columnName = "SMALLINT_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Short smallintValue = 32564;
Integer intValue = 32564;
test.setSmallintColumn(smallintValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
if (unitDbAdapter.onlyGenericNumberType()) {
assertEquals(Integer.class, columnValue.getClass());
assertEquals(intValue, columnValue);
} else {
assertEquals(Short.class, columnValue.getClass());
assertEquals(smallintValue, columnValue);
}
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testREAL.
@Test
public void testREAL() throws Exception {
String columnName = "REAL_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Float realValue = 5788.57843f;
test.setRealColumn(realValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
// engine settings
if (unitDbAdapter.onlyGenericNumberType()) {
assertEquals(BigDecimal.class, columnValue.getClass());
} else {
if (unitDbAdapter.realAsDouble()) {
assertEquals(Double.class, columnValue.getClass());
assertEquals(Double.valueOf(realValue), (Double) columnValue, 0.0001);
} else {
assertEquals(Float.class, columnValue.getClass());
assertEquals(realValue, columnValue);
}
}
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testTIMESTAMP.
@Test
public void testTIMESTAMP() throws Exception {
String columnName = "TIMESTAMP_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Date timestampValue = Calendar.getInstance().getTime();
test.setTimestampColumn(timestampValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(Date.class, columnValue.getClass());
// some DB's, noteably MySQL, strip the milliseconds from timestamps,
// so comparing within 1 second precision
long delta = timestampValue.getTime() - ((Date) columnValue).getTime();
assertTrue(delta < 1000);
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testLONGVARCHAR.
@Test
public void testLONGVARCHAR() throws Exception {
String columnName = "LONGVARCHAR_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 500; i++) {
buffer.append("LONGVARCHAR large string for tests!!!!\n");
}
String longvarcharValue = buffer.toString();
test.setLongvarcharColumn(longvarcharValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(String.class, columnValue.getClass());
assertEquals(longvarcharValue, columnValue);
}
Aggregations