OracleConnectionConfig extends ConnectionConfig { @Override @Value.Default public String getUrl() { if (getServerDn().isPresent()) { return String.format("jdbc:oracle:thin:@(DESCRIPTION=" + "(ADDRESS=(PROTOCOL=%s)(HOST=%s)(PORT=%s))" + "(CONNECT_DATA=(%s))" + "(SECURITY=(SSL_SERVER_CERT_DN=\"%s\")))", getProtocol().getUrlString(), getHost(), getPort(), connectionDataString(), getServerDn().get()); } else { return String.format("jdbc:oracle:thin:@(DESCRIPTION=" + "(ADDRESS=(PROTOCOL=%s)(HOST=%s)(PORT=%s))" + "(CONNECT_DATA=(%s)))", getProtocol().getUrlString(), getHost(), getPort(), connectionDataString()); } }  abstract String getHost(); abstract int getPort(); @Override @Value.Default String getUrl(); @Override @Value.Derived @JsonIgnore Optional<String> namespace(); @Override @Value.Default String getDriverClass(); @Override @Value.Default String getTestQuery(); abstract Optional<String> getSid(); abstract Optional<ServiceNameConfiguration> serviceNameConfiguration(); abstract Optional<String> getServerDn(); @Value.Default boolean getMatchServerDn(); @Value.Default boolean getTwoWaySsl(); @Value.Default Map<String, String> getConnectionParameters(); @Value.Default ConnectionProtocol getProtocol(); abstract Optional<String> getKeystorePassword(); abstract Optional<String> getKeystorePath(); abstract Optional<String> getTruststorePassword(); abstract Optional<String> getTruststorePath(); @Override @Value.Default @Value.Auxiliary Properties getHikariProperties(); @Override @Value.Derived DBType getDbType(); @Override final String type(); static final String TYPE; }
@Test public void databaseUrlGeneratedCorrectlyFromSid() { OracleConnectionConfig connectionConfig = getBaseBuilder() .sid(SID) .build(); assertThat(connectionConfig.getUrl()).contains("SID=" + SID); }