Search in sources :

Example 1 with ResultsEcho

use of org.apache.jena.jdbc.postprocessing.ResultsEcho in project jena by apache.

the class AbstractJenaConnectionTests method connection_post_processors_04.

/**
     * Tests post-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_post_processors_04() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    // Add a post-processor
    ResultsEcho echo = new ResultsEcho();
    conn.addPostProcessor(echo);
    Assert.assertTrue(conn.getPostProcessors().hasNext());
    // Remove it
    conn.removePostProcessor(0);
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Test(org.junit.Test)

Example 2 with ResultsEcho

use of org.apache.jena.jdbc.postprocessing.ResultsEcho in project jena by apache.

the class AbstractJenaConnectionTests method connection_post_processors_05.

/**
     * Tests post-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_post_processors_05() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    // Add a post-processor
    ResultsEcho echo = new ResultsEcho();
    conn.addPostProcessor(echo);
    Assert.assertTrue(conn.getPostProcessors().hasNext());
    // Remove all
    conn.clearPostProcessors();
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Test(org.junit.Test)

Example 3 with ResultsEcho

use of org.apache.jena.jdbc.postprocessing.ResultsEcho in project jena by apache.

the class AbstractJenaConnectionTests method connection_post_processors_02.

/**
     * Tests post-processor management operations
     * 
     * @throws SQLException
     */
@Test(expected = IndexOutOfBoundsException.class)
public void connection_post_processors_02() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    ResultsEcho echo = new ResultsEcho();
    // Inserting at zero index should be safe
    conn.insertPostProcessor(0, echo);
    Assert.assertTrue(conn.getPostProcessors().hasNext());
    // Inserting at some random index will cause an error
    try {
        conn.insertPostProcessor(50, echo);
    } finally {
        conn.close();
    }
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Test(org.junit.Test)

Example 4 with ResultsEcho

use of org.apache.jena.jdbc.postprocessing.ResultsEcho in project jena by apache.

the class AbstractJenaDriverTests method driver_connect_08.

/**
     * Tests using a driver to create a connection with its own URLs plus the
     * standard pre-processor and post-processor parameter
     * 
     * @throws SQLException
     */
@Test
public void driver_connect_08() throws SQLException {
    String url = this.getConnectionUrl();
    Assume.assumeNotNull(url);
    url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName();
    url = url + "&" + JenaDriver.PARAM_POST_PROCESSOR + "=" + ResultsEcho.class.getCanonicalName();
    JenaDriver driver = this.getDriver();
    JenaConnection conn = (JenaConnection) driver.connect(url, null);
    Assert.assertFalse(conn.isClosed());
    Iterator<CommandPreProcessor> iter = conn.getPreProcessors();
    Assert.assertTrue(iter.hasNext());
    Assert.assertTrue(iter.next() instanceof Echo);
    Assert.assertFalse(iter.hasNext());
    Iterator<ResultsPostProcessor> iter2 = conn.getPostProcessors();
    Assert.assertTrue(iter2.hasNext());
    Assert.assertTrue(iter2.next() instanceof ResultsEcho);
    Assert.assertFalse(iter2.hasNext());
    conn.close();
    Assert.assertTrue(conn.isClosed());
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) ResultsPostProcessor(org.apache.jena.jdbc.postprocessing.ResultsPostProcessor) ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Echo(org.apache.jena.jdbc.preprocessing.Echo) CommandPreProcessor(org.apache.jena.jdbc.preprocessing.CommandPreProcessor) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) Test(org.junit.Test)

Example 5 with ResultsEcho

use of org.apache.jena.jdbc.postprocessing.ResultsEcho in project jena by apache.

the class AbstractJenaConnectionTests method connection_post_processors_03.

/**
     * Tests post-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_post_processors_03() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    // Add a post-processor
    ResultsEcho echo = new ResultsEcho();
    conn.addPostProcessor(echo);
    Assert.assertTrue(conn.getPostProcessors().hasNext());
    // Remove it
    conn.removePostProcessor(echo);
    Assert.assertFalse(conn.getPostProcessors().hasNext());
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Test(org.junit.Test)

Aggregations

ResultsEcho (org.apache.jena.jdbc.postprocessing.ResultsEcho)5 Test (org.junit.Test)5 JenaConnection (org.apache.jena.jdbc.connections.JenaConnection)1 ResultsPostProcessor (org.apache.jena.jdbc.postprocessing.ResultsPostProcessor)1 CommandPreProcessor (org.apache.jena.jdbc.preprocessing.CommandPreProcessor)1 Echo (org.apache.jena.jdbc.preprocessing.Echo)1