Search in sources :

Example 1 with DebugTdbConnection

use of org.apache.jena.jdbc.tdb.connections.DebugTdbConnection in project jena by apache.

the class TestTdbDiskResultSets method results_ask_true.

/**
     * Test ASK results with a true result
     * 
     * @throws SQLException
     */
@Test
public void results_ask_true() throws SQLException {
    Dataset ds = createDataset(tempDir.getRoot().getAbsolutePath());
    try (DebugTdbConnection connection = new DebugTdbConnection(ds)) {
        Statement stmt = connection.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY);
        ResultSet rset = stmt.executeQuery("ASK { }");
        assertNotNull(rset);
        assertFalse(rset.isClosed());
        assertTrue(rset.isBeforeFirst());
        // Try to move to the result row
        assertTrue(rset.next());
        // Check the boolean return value
        assertTrue(rset.getBoolean(COLUMN_LABEL_ASK));
        // Check no further rows
        assertFalse(rset.next());
        assertTrue(rset.isAfterLast());
        // Close and clean up
        rset.close();
        assertTrue(rset.isClosed());
    }
}
Also used : TDBFactory.createDataset(org.apache.jena.tdb.TDBFactory.createDataset) Dataset(org.apache.jena.query.Dataset) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) DebugTdbConnection(org.apache.jena.jdbc.tdb.connections.DebugTdbConnection) Test(org.junit.Test)

Example 2 with DebugTdbConnection

use of org.apache.jena.jdbc.tdb.connections.DebugTdbConnection in project jena by apache.

the class AbstractTdbResultSetTests method setup.

/**
     * Sets up the tests by creating a fake connection for test use
     * 
     * @throws SQLException
     */
@BeforeClass
public static void setup() throws SQLException {
    connection = new DebugTdbConnection();
    connection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
    connection.setJdbcCompatibilityLevel(JdbcCompatibility.HIGH);
}
Also used : DebugTdbConnection(org.apache.jena.jdbc.tdb.connections.DebugTdbConnection) BeforeClass(org.junit.BeforeClass)

Example 3 with DebugTdbConnection

use of org.apache.jena.jdbc.tdb.connections.DebugTdbConnection in project jena by apache.

the class TestTdbDiskResultSets method results_ask_false.

/**
     * Test ASK results with a false result
     * 
     * @throws SQLException
     */
@Test
public void results_ask_false() throws SQLException {
    Dataset ds = createDataset(tempDir.getRoot().getAbsolutePath());
    try (DebugTdbConnection connection = new DebugTdbConnection(ds)) {
        Statement stmt = connection.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY);
        ResultSet rset = stmt.executeQuery("ASK { FILTER(false) }");
        assertNotNull(rset);
        assertFalse(rset.isClosed());
        assertTrue(rset.isBeforeFirst());
        // Try to move to the result row
        assertTrue(rset.next());
        // Check the boolean return value
        assertFalse(rset.getBoolean(COLUMN_LABEL_ASK));
        // Check no further rows
        assertFalse(rset.next());
        assertTrue(rset.isAfterLast());
        // Close and clean up
        rset.close();
        assertTrue(rset.isClosed());
    }
}
Also used : TDBFactory.createDataset(org.apache.jena.tdb.TDBFactory.createDataset) Dataset(org.apache.jena.query.Dataset) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) DebugTdbConnection(org.apache.jena.jdbc.tdb.connections.DebugTdbConnection) Test(org.junit.Test)

Aggregations

DebugTdbConnection (org.apache.jena.jdbc.tdb.connections.DebugTdbConnection)3 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 Dataset (org.apache.jena.query.Dataset)2 TDBFactory.createDataset (org.apache.jena.tdb.TDBFactory.createDataset)2 Test (org.junit.Test)2 BeforeClass (org.junit.BeforeClass)1