/** * Returns whether a result set is expected to type returned columns as * strings * * @param level * Desired compatibility level * @return True if columns should be typed as string, false otherwise */ public static boolean shouldTypeColumnsAsString(int level) { level = normalizeLevel(level); return level >= MEDIUM && level < HIGH; }
@Override protected boolean allowsMultipleValues(String key) { if (PARAM_DEFAULT_GRAPH_URI.equals(key) || PARAM_NAMED_GRAPH_URI.equals(key) || PARAM_USING_GRAPH_URI.equals(key) || PARAM_USING_NAMED_GRAPH_URI.equals(key)) { return true; } else { return super.allowsMultipleValues(key); } }
/** * 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 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); }
/** * Test that an implementation will accept its own URLs * * @throws SQLException */ @Test public void driver_accepts_01() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); JenaDriver driver = this.getDriver(); Assert.assertTrue(driver.acceptsURL(url)); }
/** * Test that with medium compatibility columns will be typed as strings but not detected types */ @Test public void test_level_behaviours_columns_02() { Assert.assertTrue(JdbcCompatibility.shouldTypeColumnsAsString(JdbcCompatibility.MEDIUM)); Assert.assertFalse(JdbcCompatibility.shouldDetectColumnTypes(JdbcCompatibility.MEDIUM)); // This also applies to DEFAULT level Assert.assertTrue(JdbcCompatibility.shouldTypeColumnsAsString(JdbcCompatibility.DEFAULT)); Assert.assertFalse(JdbcCompatibility.shouldDetectColumnTypes(JdbcCompatibility.DEFAULT)); }
/** * Tests that an implementation will not accept an arbitrary URL * * @throws SQLException */ @Test public void driver_accepts_02() throws SQLException { String url = "jdbc:unknown:http://example.org"; JenaDriver driver = this.getDriver(); Assert.assertFalse(driver.acceptsURL(url)); }
/** * 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); }
/** * Returns whether a result set is expected to determine the column types * from the returned data * * @param level * Desired compatibility level * @return True if column types should be detected, false otherwise */ public static boolean shouldDetectColumnTypes(int level) { level = normalizeLevel(level); return level == HIGH; }
/** * 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); } }
/** * Returns whether a result set is expected to type returned columns as * strings * * @param level * Desired compatibility level * @return True if columns should be typed as string, false otherwise */ public static boolean shouldTypeColumnsAsString(int level) { level = normalizeLevel(level); return level >= MEDIUM && level < HIGH; }
/** * 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); }
/** * Returns whether a result set is expected to determine the column types * from the returned data * * @param level * Desired compatibility level * @return True if column types should be detected, false otherwise */ public static boolean shouldDetectColumnTypes(int level) { level = normalizeLevel(level); return level == HIGH; }
/** * 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); }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * By default this is set at the connection level and inherited, however you * may call {@link #setJdbcCompatibilityLevel(int)} to set the compatibility * level for this statement. This allows you to change the compatibility * level on a per-query basis if so desired. * </p> * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { if (level == USE_CONNECTION_COMPATIBILITY) { this.compatibilityLevel = USE_CONNECTION_COMPATIBILITY; } else { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); } }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * By default this is set at the connection level and inherited, however you * may call {@link #setJdbcCompatibilityLevel(int)} to set the compatibility * level for this statement. This allows you to change the compatibility * level on a per-query basis if so desired. * </p> * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { if (level == USE_CONNECTION_COMPATIBILITY) { this.compatibilityLevel = USE_CONNECTION_COMPATIBILITY; } else { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); } }
/** * Tests constants are not normalized to different values */ @Test public void test_level_normalization_01() { Assert.assertEquals(JdbcCompatibility.LOW, JdbcCompatibility.normalizeLevel(JdbcCompatibility.LOW)); Assert.assertEquals(JdbcCompatibility.MEDIUM, JdbcCompatibility.normalizeLevel(JdbcCompatibility.MEDIUM)); Assert.assertEquals(JdbcCompatibility.HIGH, JdbcCompatibility.normalizeLevel(JdbcCompatibility.HIGH)); Assert.assertEquals(JdbcCompatibility.MEDIUM, JdbcCompatibility.normalizeLevel(JdbcCompatibility.DEFAULT)); }
/** * Test all values in acceptable range are left as is */ @Test public void test_level_normalization_03() { for (int i = 1; i <= 9; i++) { Assert.assertEquals(i, JdbcCompatibility.normalizeLevel(i)); } }