Search in sources :

Example 11 with ColumnInfo

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());
}
Also used : ColumnInfo(org.apache.jena.jdbc.results.metadata.columns.ColumnInfo) Test(org.junit.Test)

Example 12 with ColumnInfo

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());
}
Also used : ColumnInfo(org.apache.jena.jdbc.results.metadata.columns.ColumnInfo) Test(org.junit.Test)

Example 13 with ColumnInfo

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;
}
Also used : Node(org.apache.jena.graph.Node) ColumnInfo(org.apache.jena.jdbc.results.metadata.columns.ColumnInfo)

Example 14 with ColumnInfo

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());
}
Also used : ColumnInfo(org.apache.jena.jdbc.results.metadata.columns.ColumnInfo) Test(org.junit.Test)

Example 15 with ColumnInfo

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());
}
Also used : ColumnInfo(org.apache.jena.jdbc.results.metadata.columns.ColumnInfo) Test(org.junit.Test)

Aggregations

ColumnInfo (org.apache.jena.jdbc.results.metadata.columns.ColumnInfo)17 Test (org.junit.Test)12 StringColumn (org.apache.jena.jdbc.results.metadata.columns.StringColumn)3 SQLException (java.sql.SQLException)2 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)2 Node (org.apache.jena.graph.Node)2 SparqlColumnInfo (org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo)2 BigDecimal (java.math.BigDecimal)1 Triple (org.apache.jena.graph.Triple)1 BooleanColumn (org.apache.jena.jdbc.results.metadata.columns.BooleanColumn)1 IntegerColumn (org.apache.jena.jdbc.results.metadata.columns.IntegerColumn)1 ShortIntegerColumn (org.apache.jena.jdbc.results.metadata.columns.ShortIntegerColumn)1 Binding (org.apache.jena.sparql.engine.binding.Binding)1