Search in sources :

Example 1 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_decimal_01.

/**
     * Test retrieving meta column values
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_decimal_01() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[] { new DecimalColumn("Test", ResultSetMetaData.columnNullable) }, new Object[][] { { new BigDecimal("123.4") } });
    Assert.assertTrue(results.next());
    BigDecimal value = results.getBigDecimal(1);
    Assert.assertEquals(new BigDecimal("123.4"), value);
    Assert.assertFalse(results.wasNull());
    Assert.assertFalse(results.next());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) DecimalColumn(org.apache.jena.jdbc.results.metadata.columns.DecimalColumn) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 2 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_string_01.

/**
     * Test retrieving meta column values
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_string_01() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[] { new StringColumn("Test", ResultSetMetaData.columnNullable) }, new Object[][] { { "value" } });
    Assert.assertTrue(results.next());
    String value = results.getString(1);
    Assert.assertEquals("value", value);
    Assert.assertFalse(results.wasNull());
    Assert.assertFalse(results.next());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) StringColumn(org.apache.jena.jdbc.results.metadata.columns.StringColumn) Test(org.junit.Test)

Example 3 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_boolean_01.

/**
     * Test retrieving meta column values
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_boolean_01() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[] { new BooleanColumn("Test", ResultSetMetaData.columnNullable) }, new Object[][] { { true } });
    Assert.assertTrue(results.next());
    Assert.assertTrue(results.getBoolean(1));
    Assert.assertFalse(results.wasNull());
    Assert.assertFalse(results.next());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) BooleanColumn(org.apache.jena.jdbc.results.metadata.columns.BooleanColumn) Test(org.junit.Test)

Example 4 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_movement_03.

/**
     * Test movement within meta results
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_movement_03() throws SQLException {
    MetaResultSet results = createMetaResultSet(1);
    Assert.assertTrue(results.isBeforeFirst());
    // Move forwards
    Assert.assertTrue(results.next());
    Assert.assertTrue(results.isFirst());
    Assert.assertFalse(results.isBeforeFirst());
    Assert.assertTrue(results.isLast());
    Assert.assertFalse(results.isAfterLast());
    // Move to end
    Assert.assertFalse(results.next());
    Assert.assertTrue(results.isAfterLast());
    // Move backwards
    Assert.assertTrue(results.previous());
    Assert.assertTrue(results.isFirst());
    Assert.assertFalse(results.isBeforeFirst());
    Assert.assertTrue(results.isLast());
    Assert.assertFalse(results.isAfterLast());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) Test(org.junit.Test)

Example 5 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_movement_02.

/**
     * Test movement within meta results
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_movement_02() throws SQLException {
    MetaResultSet results = createMetaResultSet(1);
    Assert.assertTrue(results.isBeforeFirst());
    // Move forwards
    Assert.assertTrue(results.next());
    Assert.assertTrue(results.isFirst());
    Assert.assertFalse(results.isBeforeFirst());
    Assert.assertTrue(results.isLast());
    Assert.assertFalse(results.isAfterLast());
    // Move to end
    Assert.assertFalse(results.next());
    Assert.assertTrue(results.isAfterLast());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) Test(org.junit.Test)

Aggregations

MetaResultSet (org.apache.jena.jdbc.metadata.results.MetaResultSet)28 Test (org.junit.Test)28 LongIntegerColumn (org.apache.jena.jdbc.results.metadata.columns.LongIntegerColumn)4 ShortIntegerColumn (org.apache.jena.jdbc.results.metadata.columns.ShortIntegerColumn)4 ByteColumn (org.apache.jena.jdbc.results.metadata.columns.ByteColumn)3 StringColumn (org.apache.jena.jdbc.results.metadata.columns.StringColumn)3 BigDecimal (java.math.BigDecimal)2 Date (java.sql.Date)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 Time (java.sql.Time)2 BooleanColumn (org.apache.jena.jdbc.results.metadata.columns.BooleanColumn)2 DateColumn (org.apache.jena.jdbc.results.metadata.columns.DateColumn)2 DecimalColumn (org.apache.jena.jdbc.results.metadata.columns.DecimalColumn)2 FloatColumn (org.apache.jena.jdbc.results.metadata.columns.FloatColumn)2 IntegerColumn (org.apache.jena.jdbc.results.metadata.columns.IntegerColumn)2 TimeColumn (org.apache.jena.jdbc.results.metadata.columns.TimeColumn)2 DoubleColumn (org.apache.jena.jdbc.results.metadata.columns.DoubleColumn)1