Search in sources :

Example 1 with Echo

use of org.apache.jena.jdbc.preprocessing.Echo in project jena by apache.

the class AbstractJenaConnectionTests method connection_pre_processors_04.

/**
     * Tests pre-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_pre_processors_04() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    // Add a pre-processor
    Echo echo = new Echo();
    conn.addPreProcessor(echo);
    Assert.assertTrue(conn.getPreProcessors().hasNext());
    // Remove it
    conn.removePreProcessor(0);
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Echo(org.apache.jena.jdbc.preprocessing.Echo) Test(org.junit.Test)

Example 2 with Echo

use of org.apache.jena.jdbc.preprocessing.Echo in project jena by apache.

the class AbstractJenaConnectionTests method connection_pre_processors_08.

/**
     * Tests pre-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_pre_processors_08() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    // Add a pre-processor
    Echo echo = new Echo();
    conn.addPreProcessor(echo);
    Assert.assertTrue(conn.getPreProcessors().hasNext());
    // Apply the pre-processor
    UpdateRequest input = UpdateFactory.create("DELETE WHERE { ?s ?p ?o }");
    UpdateRequest output = conn.applyPreProcessors(input);
    Assert.assertEquals(input, output);
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Echo(org.apache.jena.jdbc.preprocessing.Echo) UpdateRequest(org.apache.jena.update.UpdateRequest) Test(org.junit.Test)

Example 3 with Echo

use of org.apache.jena.jdbc.preprocessing.Echo in project jena by apache.

the class AbstractJenaConnectionTests method connection_pre_processors_05.

/**
     * Tests pre-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_pre_processors_05() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    // Add a pre-processor
    Echo echo = new Echo();
    conn.addPreProcessor(echo);
    Assert.assertTrue(conn.getPreProcessors().hasNext());
    // Remove all
    conn.clearPreProcessors();
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Echo(org.apache.jena.jdbc.preprocessing.Echo) Test(org.junit.Test)

Example 4 with Echo

use of org.apache.jena.jdbc.preprocessing.Echo in project jena by apache.

the class AbstractJenaConnectionTests method connection_pre_processors_03.

/**
     * Tests pre-processor management operations
     * 
     * @throws SQLException
     */
@Test
public void connection_pre_processors_03() throws SQLException {
    JenaConnection conn = this.getConnection();
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    // Add a pre-processor
    Echo echo = new Echo();
    conn.addPreProcessor(echo);
    Assert.assertTrue(conn.getPreProcessors().hasNext());
    // Remove it
    conn.removePreProcessor(echo);
    Assert.assertFalse(conn.getPreProcessors().hasNext());
    conn.close();
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Echo(org.apache.jena.jdbc.preprocessing.Echo) Test(org.junit.Test)

Example 5 with Echo

use of org.apache.jena.jdbc.preprocessing.Echo in project jena by apache.

the class AbstractJenaDriverTests method driver_config_precedence_04.

/**
     * Tests the precedence rules for connection URL parameters
     * 
     * @throws SQLException
     * @throws IOException
     */
@Test
public void driver_config_precedence_04() throws SQLException, IOException {
    File f = null;
    try {
        f = File.createTempFile("config", ".properties");
        FileWriter writer = new FileWriter(f);
        writer.write("test=external");
        writer.close();
        String url = this.getConnectionUrl();
        Assume.assumeNotNull(url);
        Assume.assumeFalse(url.contains(JenaDriver.PARAM_CONFIG + "="));
        url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName() + "&test=url&" + JenaDriver.PARAM_CONFIG + "=" + f.getAbsolutePath();
        JenaDriver driver = this.getDriver();
        Properties ps = new Properties();
        JenaConnection conn = (JenaConnection) driver.connect(url, ps);
        Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors();
        Assert.assertTrue(preProcessors.hasNext());
        Echo echo = (Echo) preProcessors.next();
        Properties actual = echo.getProperties();
        Assert.assertEquals("url", actual.getProperty("test"));
        conn.close();
    } finally {
        if (f != null && f.exists()) {
            f.delete();
        }
    }
}
Also used : ResultsEcho(org.apache.jena.jdbc.postprocessing.ResultsEcho) Echo(org.apache.jena.jdbc.preprocessing.Echo) CommandPreProcessor(org.apache.jena.jdbc.preprocessing.CommandPreProcessor) FileWriter(java.io.FileWriter) Properties(java.util.Properties) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) File(java.io.File) Test(org.junit.Test)

Aggregations

ResultsEcho (org.apache.jena.jdbc.postprocessing.ResultsEcho)14 Echo (org.apache.jena.jdbc.preprocessing.Echo)14 Test (org.junit.Test)14 JenaConnection (org.apache.jena.jdbc.connections.JenaConnection)7 CommandPreProcessor (org.apache.jena.jdbc.preprocessing.CommandPreProcessor)7 Properties (java.util.Properties)6 File (java.io.File)4 FileWriter (java.io.FileWriter)4 ResultsPostProcessor (org.apache.jena.jdbc.postprocessing.ResultsPostProcessor)1 UpdateRequest (org.apache.jena.update.UpdateRequest)1