@Test(groups = { "integration" }) public void testValidate() { OracleConfiguration cfg = createEmptyCfg(); assertValidateFail(cfg, "Validate for empty cfg should fail"); cfg.setDataSource("myDS"); cfg.setDriver(null); cfg.setPort(null); cfg.validate(); Assert.assertEquals(ConnectionType.DATASOURCE, cfg.getConnType()); cfg.setHost("anyHost"); assertValidateFail(cfg, "validate must fail for datasource configuration when host is not blank"); cfg.setHost(null); cfg.setPort("1234"); assertValidateFail(cfg, "validate must fail for datasource configuration when port is not blank"); cfg.setPort(null); cfg.setDatabase("myDB"); assertValidateFail(cfg, "validate must fail for custom datasource configuration when database is not blank"); cfg.setDatabase(null); cfg.setDriver("myDriver"); assertValidateFail(cfg, "validate must fail for custom datasource configuration when driver is not blank"); cfg = createEmptyCfg(); cfg.setDataSource("myDS"); cfg.setDriver(null); cfg.setPort(null); cfg.validate(); cfg.setUser("myUser"); assertValidateFail(cfg, "validate must fail for custom datasource configuration , set user and null password"); cfg.setUser(null); cfg.setPassword(new GuardedString("myPassword".toCharArray())); assertValidateFail(cfg, "validate must fail for custom datasource configuration , null user and not null password"); cfg.setUser("myUser"); cfg.validate(); cfg = createEmptyCfg(); cfg.setDriver(OracleSpecifics.THIN_DRIVER); assertValidateFail(cfg, "Validate cfg should fail, not enaough info"); cfg.setHost("localhost"); cfg.setDatabase("XE"); cfg.setUser("user"); cfg.setPassword(new GuardedString(new char[] { 'p' })); cfg.validate(); Assert.assertEquals(ConnectionType.THIN, cfg.getConnType()); cfg = createEmptyCfg(); cfg.setDriver(OracleSpecifics.OCI_DRIVER); assertValidateFail(cfg, "Validate cfg should fail, not enaough info"); cfg.setDatabase("XE"); cfg.setUser("user"); cfg.setPassword(new GuardedString(new char[] { 'p' })); cfg.validate(); Assert.assertEquals(ConnectionType.OCI, cfg.getConnType()); cfg.setDriver("invalidClass"); assertValidateFail(cfg, "Validate cfg should fail, invalid driver class"); cfg.setDriver(Long.class.getName()); assertValidateFail(cfg, "Validate cfg should fail, invalid driver class"); cfg.setDriver(Driver.class.getName()); assertValidateFail(cfg, "Validate cfg should fail, not enough info"); cfg.setUrl("java:jdbc:customUrl"); cfg.setDatabase(null); cfg.setPort(null); cfg.setHost(null); cfg.validate(); Assert.assertEquals(ConnectionType.FULL_URL, cfg.getConnType()); cfg.setHost("myHost"); assertValidateFail(cfg, "validate must fail for custom URL configuration when host is not blank"); cfg.setHost(null); cfg.setPort("1234"); assertValidateFail(cfg, "validate must fail for custom URL configuration when port is not blank"); cfg.setPort(null); cfg.setDatabase("myDB"); assertValidateFail(cfg, "validate must fail for custom URL configuration when database is not blank"); cfg = createDataSourceConfiguration(); cfg.validate(); cfg.setUseDriverForAuthentication(true); cfg.validate(); cfg = createOciConfiguration(); cfg.validate(); cfg.setUseDriverForAuthentication(true); assertValidateFail(cfg, "validate must fail for oci cfg and useDriverForAuthentication=true"); cfg = createThinConfiguration(); cfg.validate(); cfg.setUseDriverForAuthentication(true); assertValidateFail(cfg, "validate must fail for thin cfg and useDriverForAuthentication=true"); }
@Override public void validate() { if (connType != null) { return; } try { new OracleConfigurationValidator(this).validate(); } catch (RuntimeException e) { setConnType(null); throw e; } }
OracleConfiguration extends AbstractConfiguration implements Cloneable { @Override public void validate() { if (connType != null) { return; } try { new OracleConfigurationValidator(this).validate(); } catch (RuntimeException e) { setConnType(null); throw e; } } }
OracleConfiguration extends AbstractConfiguration implements Cloneable { @Override public void validate() { if (connType != null) { return; } try { new OracleConfigurationValidator(this).validate(); } catch (RuntimeException e) { setConnType(null); throw e; } } OracleConfiguration(); }
OracleConfiguration extends AbstractConfiguration implements Cloneable { @Override public void validate() { if (connType != null) { return; } try { new OracleConfigurationValidator(this).validate(); } catch (RuntimeException e) { setConnType(null); throw e; } } OracleConfiguration(); @ConfigurationProperty(order = 0, displayMessageKey = MSG_DATASOURCE_DISPLAY, helpMessageKey = MSG_DATASOURCE_HELP) String getDataSource(); @ConfigurationProperty(order = 1, displayMessageKey = MSG_DSJNDIENV_DISPLAY, helpMessageKey = MSG_DSJNDIENV_HELP) String[] getDsJNDIEnv(); @ConfigurationProperty(order = 2, displayMessageKey = MSG_URL_DISPLAY, helpMessageKey = MSG_URL_HELP) String getUrl(); @ConfigurationProperty(order = 3, displayMessageKey = MSG_DRIVER_DISPLAY, helpMessageKey = MSG_DRIVER_HELP) String getDriver(); @ConfigurationProperty(order = 4, displayMessageKey = MSG_HOST_DISPLAY, helpMessageKey = MSG_HOST_HELP) String getHost(); @ConfigurationProperty(order = 5, displayMessageKey = MSG_PORT_DISPLAY, helpMessageKey = MSG_PORT_HELP) String getPort(); @ConfigurationProperty(order = 6, displayMessageKey = MSG_DATABASE_DISPLAY, helpMessageKey = MSG_DATABASE_HELP) String getDatabase(); @ConfigurationProperty(order = 7, displayMessageKey = MSG_USER_DISPLAY, helpMessageKey = MSG_USER_HELP) String getUser(); @ConfigurationProperty(order = 8, displayMessageKey = MSG_PASSWORD_DISPLAY, helpMessageKey = MSG_PASSWORD_HELP, confidential = true) GuardedString getPassword(); @ConfigurationProperty(order = 9, displayMessageKey = MSG_CS_DISPLAY, helpMessageKey = MSG_CS_HELP, required = true) String getCaseSensitivityString(); @ConfigurationProperty(order = 10, displayMessageKey = MSG_EXTRA_ATTRS_POLICY_DISPLAY, helpMessageKey = MSG_EXTRA_ATTRS_POLICY_HELP) String getExtraAttributesPolicyString(); @ConfigurationProperty(order = 11, displayMessageKey = MSG_SOURCE_TYPE_DISPLAY, helpMessageKey = MSG_SOURCE_TYPE_HELP, required = false) String getSourceType(); @ConfigurationProperty(order = 12, displayMessageKey = MSG_DROP_CASCADE_DISPLAY, helpMessageKey = MSG_DROP_CASCADE_DISPLAY, required = false) boolean isDropCascade(); @ConfigurationProperty(order = 13, displayMessageKey = MSG_NORMALIZER_DISPLAY, helpMessageKey = MSG_NORMALIZER_HELP, required = false) String getNormalizerString(); @ConfigurationProperty(order = 14, displayMessageKey = MSG_USE_DRIVER_FOR_AUTHENTICATION_DISPLAY, helpMessageKey = MSG_USE_DRIVER_FOR_AUTHENTICATION_HELP, required = false) boolean isUseDriverForAuthentication(); void setNormalizerString(String normalizerString); void setExtraAttributesPolicyString(String extraAttributesPolicyString); void setDropCascade(boolean dropCascade); void setHost(String host); void setPort(String port); void setDriver(String driver); void setDatabase(String database); void setUser(String user); void setPassword(GuardedString password); void setDataSource(String dataSource); void setDsJNDIEnv(String[] dsJNDIEnv); void setUseDriverForAuthentication(boolean useDriverForAuthentication); void setUrl(String url); void setCaseSensitivityString(String cs); void setSourceType(String sourceType); @Override void validate(); }
OracleConfiguration extends AbstractConfiguration implements Cloneable { @Override public void validate() { if (connType != null) { return; } try { new OracleConfigurationValidator(this).validate(); } catch (RuntimeException e) { setConnType(null); throw e; } } OracleConfiguration(); @ConfigurationProperty(order = 0, displayMessageKey = MSG_DATASOURCE_DISPLAY, helpMessageKey = MSG_DATASOURCE_HELP) String getDataSource(); @ConfigurationProperty(order = 1, displayMessageKey = MSG_DSJNDIENV_DISPLAY, helpMessageKey = MSG_DSJNDIENV_HELP) String[] getDsJNDIEnv(); @ConfigurationProperty(order = 2, displayMessageKey = MSG_URL_DISPLAY, helpMessageKey = MSG_URL_HELP) String getUrl(); @ConfigurationProperty(order = 3, displayMessageKey = MSG_DRIVER_DISPLAY, helpMessageKey = MSG_DRIVER_HELP) String getDriver(); @ConfigurationProperty(order = 4, displayMessageKey = MSG_HOST_DISPLAY, helpMessageKey = MSG_HOST_HELP) String getHost(); @ConfigurationProperty(order = 5, displayMessageKey = MSG_PORT_DISPLAY, helpMessageKey = MSG_PORT_HELP) String getPort(); @ConfigurationProperty(order = 6, displayMessageKey = MSG_DATABASE_DISPLAY, helpMessageKey = MSG_DATABASE_HELP) String getDatabase(); @ConfigurationProperty(order = 7, displayMessageKey = MSG_USER_DISPLAY, helpMessageKey = MSG_USER_HELP) String getUser(); @ConfigurationProperty(order = 8, displayMessageKey = MSG_PASSWORD_DISPLAY, helpMessageKey = MSG_PASSWORD_HELP, confidential = true) GuardedString getPassword(); @ConfigurationProperty(order = 9, displayMessageKey = MSG_CS_DISPLAY, helpMessageKey = MSG_CS_HELP, required = true) String getCaseSensitivityString(); @ConfigurationProperty(order = 10, displayMessageKey = MSG_EXTRA_ATTRS_POLICY_DISPLAY, helpMessageKey = MSG_EXTRA_ATTRS_POLICY_HELP) String getExtraAttributesPolicyString(); @ConfigurationProperty(order = 11, displayMessageKey = MSG_SOURCE_TYPE_DISPLAY, helpMessageKey = MSG_SOURCE_TYPE_HELP, required = false) String getSourceType(); @ConfigurationProperty(order = 12, displayMessageKey = MSG_DROP_CASCADE_DISPLAY, helpMessageKey = MSG_DROP_CASCADE_DISPLAY, required = false) boolean isDropCascade(); @ConfigurationProperty(order = 13, displayMessageKey = MSG_NORMALIZER_DISPLAY, helpMessageKey = MSG_NORMALIZER_HELP, required = false) String getNormalizerString(); @ConfigurationProperty(order = 14, displayMessageKey = MSG_USE_DRIVER_FOR_AUTHENTICATION_DISPLAY, helpMessageKey = MSG_USE_DRIVER_FOR_AUTHENTICATION_HELP, required = false) boolean isUseDriverForAuthentication(); void setNormalizerString(String normalizerString); void setExtraAttributesPolicyString(String extraAttributesPolicyString); void setDropCascade(boolean dropCascade); void setHost(String host); void setPort(String port); void setDriver(String driver); void setDatabase(String database); void setUser(String user); void setPassword(GuardedString password); void setDataSource(String dataSource); void setDsJNDIEnv(String[] dsJNDIEnv); void setUseDriverForAuthentication(boolean useDriverForAuthentication); void setUrl(String url); void setCaseSensitivityString(String cs); void setSourceType(String sourceType); @Override void validate();  }