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();
}
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();
}
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();
}
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();
}
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();
}
}
}
Aggregations