use of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo in project jena by apache.
the class TestCompatibility method test_column_type_detection_integer_06.
/**
* Expect xsd:short to be typed as integers
* @throws SQLException
*/
@Test
public void test_column_type_detection_integer_06() throws SQLException {
ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDshort), true, Types.INTEGER, Integer.class.getCanonicalName());
Assert.assertEquals(0, info.getScale());
Assert.assertTrue(info.isSigned());
}
use of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo in project jena by apache.
the class TestCompatibility method test_column_type_detection_float.
/**
* Expect xsd:float to be typed as float
* @throws SQLException
*/
@Test
public void test_column_type_detection_float() throws SQLException {
ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("12.3e4", XSDDatatype.XSDfloat), true, Types.FLOAT, Float.class.getCanonicalName());
Assert.assertEquals(7, info.getScale());
Assert.assertEquals(15, info.getPrecision());
Assert.assertTrue(info.isSigned());
}
use of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo in project jena by apache.
the class TestCompatibility method testColumnTypeDetection.
/**
* Detects a columns types and checks basic information from the detected type, returns the detected column information so tests can make further assertions on this
* @param var Variable Name i.e. Column Label
* @param value Example value to detect from
* @param allowNulls Whether the column allows nulls
* @param jdbcType Expected detected JDBC type
* @param className Expected detected class name
* @return Column Information
* @throws SQLException
*/
private ColumnInfo testColumnTypeDetection(String var, Node value, boolean allowNulls, int jdbcType, String className) throws SQLException {
ColumnInfo info = JdbcCompatibility.detectColumnType(var, value, allowNulls);
Assert.assertEquals(var, info.getLabel());
if (allowNulls) {
Assert.assertEquals(ResultSetMetaData.columnNullable, info.getNullability());
} else {
Assert.assertEquals(ResultSetMetaData.columnNoNulls, info.getNullability());
}
Assert.assertEquals(jdbcType, info.getType());
Assert.assertEquals(className, info.getClassName());
Assert.assertEquals(Node.class.getCanonicalName(), info.getTypeName());
return info;
}
use of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo in project jena by apache.
the class TestCompatibility method test_column_type_detection_integer_07.
/**
* Expect xsd:unsignedShort to be typed as integers
* @throws SQLException
*/
@Test
public void test_column_type_detection_integer_07() throws SQLException {
ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDunsignedShort), true, Types.INTEGER, Integer.class.getCanonicalName());
Assert.assertEquals(0, info.getScale());
Assert.assertFalse(info.isSigned());
}
use of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo in project jena by apache.
the class TestCompatibility method test_column_type_detection_integer_01.
/**
* Expect xsd:integer to be typed as integers
* @throws SQLException
*/
@Test
public void test_column_type_detection_integer_01() throws SQLException {
ColumnInfo info = testColumnTypeDetection("x", NodeFactoryExtra.intToNode(1234), true, Types.BIGINT, Long.class.getCanonicalName());
Assert.assertEquals(0, info.getScale());
Assert.assertTrue(info.isSigned());
}
Aggregations