/** * Tests using a driver to create a connection with its own URLs plus the * standard post-processor parameter but setting the post-processor to a * value that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_05() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a class that exists but isn't a ResultsPostProcessor url = url + "&" + JenaDriver.PARAM_POST_PROCESSOR + "=" + Node.class.getCanonicalName(); JenaDriver driver = this.getDriver(); driver.connect(url, null); }
JenaDriver driver = this.getDriver(); JenaConnection conn = (JenaConnection) driver.connect(url, null); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());
/** * Tests using a driver to create a connection with its own URLs plus the * standard pre-processor parameter but setting the pre-processor to a value * that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_03() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a class that exists but isn't a CommandPreProcessor url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Node.class.getCanonicalName(); JenaDriver driver = this.getDriver(); driver.connect(url, null); }
/** * Tests using a driver to create a connection with its own URLs * * @throws SQLException */ @Test public void driver_connect_01() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); JenaDriver driver = this.getDriver(); Connection conn = driver.connect(url, null); Assert.assertFalse(conn.isClosed()); conn.close(); Assert.assertTrue(conn.isClosed()); }
ps.put("test", "props"); JenaConnection conn = (JenaConnection) driver.connect(url, ps); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());
JenaConnection conn = (JenaConnection) driver.connect(url, ps); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());
/** * Tests using a driver to create a connection with its own URLs which are * known to be bad * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_01() throws SQLException { String url = this.getBadConnectionUrl(); Assume.assumeNotNull(url); JenaDriver driver = this.getDriver(); driver.connect(url, null); }
/** * Tests the precedence rules for connection URL parameters * * @throws SQLException */ @Test public void driver_config_precedence_01() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName() + "&test=url"; JenaDriver driver = this.getDriver(); Properties ps = new Properties(); ps.put("test", "props"); 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("props", actual.getProperty("test")); conn.close(); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard logging parameter but setting it to a value that creates an * error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_06() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a non-existent file/class path resource url = url + "&" + JenaDriver.PARAM_LOGGING + "=/nosuch.properties"; JenaDriver driver = this.getDriver(); driver.connect(url, null); }
/** * Tests the precedence rules for connection URL parameters * * @throws SQLException */ @Test public void driver_config_precedence_02() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName() + "&test=url"; 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(); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard config parameter but setting it to a value that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_07() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a non-existent file/class path resource url = url + "&" + JenaDriver.PARAM_CONFIG + "=/nosuch.properties"; JenaDriver driver = this.getDriver(); driver.connect(url, null); } }
/** * Tests using a driver to create a connection with its own URLs plus the * standard post-processor parameter but setting the post-processor to a * value that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_04() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a class that doesn't exist url = url + "&" + JenaDriver.PARAM_POST_PROCESSOR + "=NoSuchClass"; JenaDriver driver = this.getDriver(); driver.connect(url, null); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard pre-processor parameter but setting the pre-processor to a value * that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_02() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a class that doesn't exist url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=NoSuchClass"; JenaDriver driver = this.getDriver(); driver.connect(url, null); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard pre-processor parameter * * @throws SQLException */ @Test public void driver_connect_07() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // We can register it twice if we want url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName(); url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.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()); iter.next(); Assert.assertTrue(iter.hasNext()); iter.next(); Assert.assertFalse(iter.hasNext()); conn.close(); Assert.assertTrue(conn.isClosed()); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard pre-processor parameter * * @throws SQLException */ @Test public void driver_connect_06() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.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()); iter.next(); Assert.assertFalse(iter.hasNext()); conn.close(); Assert.assertTrue(conn.isClosed()); }
/** * 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()); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard JDBC compatibility parameter * * @throws SQLException */ @Test public void driver_connect_05() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + Integer.MAX_VALUE; JenaDriver driver = this.getDriver(); JenaConnection conn = (JenaConnection) driver.connect(url, null); Assert.assertFalse(conn.isClosed()); Assert.assertEquals(JdbcCompatibility.HIGH, conn.getJdbcCompatibilityLevel()); conn.close(); Assert.assertTrue(conn.isClosed()); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard JDBC compatibility parameter * * @throws SQLException */ @Test public void driver_connect_03() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + Integer.MIN_VALUE; JenaDriver driver = this.getDriver(); JenaConnection conn = (JenaConnection) driver.connect(url, null); Assert.assertFalse(conn.isClosed()); Assert.assertEquals(JdbcCompatibility.LOW, conn.getJdbcCompatibilityLevel()); conn.close(); Assert.assertTrue(conn.isClosed()); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard JDBC compatibility parameter * * @throws SQLException */ @Test public void driver_connect_04() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + JdbcCompatibility.HIGH; JenaDriver driver = this.getDriver(); JenaConnection conn = (JenaConnection) driver.connect(url, null); Assert.assertFalse(conn.isClosed()); Assert.assertEquals(JdbcCompatibility.HIGH, conn.getJdbcCompatibilityLevel()); conn.close(); Assert.assertTrue(conn.isClosed()); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard JDBC compatibility parameter * * @throws SQLException */ @Test public void driver_connect_02() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + JdbcCompatibility.LOW; JenaDriver driver = this.getDriver(); JenaConnection conn = (JenaConnection) driver.connect(url, null); Assert.assertFalse(conn.isClosed()); Assert.assertEquals(JdbcCompatibility.LOW, conn.getJdbcCompatibilityLevel()); conn.close(); Assert.assertTrue(conn.isClosed()); }