@Test public void testSetUpNoDbName() throws ClassNotFoundException, SQLException { MSSqlDatabase mSSqlDatabase = new MSSqlDatabase(); final SQLInputs sqlInputs = getSqlInputsForMSSql(EMPTY, DB_SERVER, AUTH_WINDOWS, INSTANCE); final List<String> dbUrls = mSSqlDatabase.setUp(sqlInputs); assertEquals("jdbc:sqlserver: assertEquals(1, dbUrls.size()); }
@Override public List<String> setUp(@NotNull final SQLInputs sqlInputs) { try { final List<String> dbUrls = new ArrayList<>(); if (sqlInputs.getDbClass() != null && sqlInputs.getDbClass().equals(SQLSERVER_JDBC_DRIVER)) { if (isNoneEmpty(sqlInputs.getDbUrl())) { final String dbUrl = MSSqlDatabase.addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), sqlInputs.getDbUrl()); dbUrls.add(dbUrl); } } loadJdbcDriver(sqlInputs.getDbClass(), sqlInputs.getAuthenticationType(), sqlInputs.getAuthLibraryPath()); String host; String[] serverInstanceComponents = null; if (sqlInputs.getDbServer().contains(BACK_SLASH)) { serverInstanceComponents = sqlInputs.getDbServer().split("\\\\"); host = serverInstanceComponents[0]; } else { host = sqlInputs.getDbServer(); } final Address address = new Address(host); host = address.getURIIPV6Literal(); if (isValidAuthType(sqlInputs.getAuthenticationType())) { final StringBuilder dbUrlMSSQL = new StringBuilder(Constants.MSSQL_URL + host + COLON + sqlInputs.getDbPort() + SEMI_COLON + DATABASE_NAME_CAP + EQUALS + sqlInputs.getDbName()); if (serverInstanceComponents != null) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(serverInstanceComponents[1]); } else if (isNoneEmpty(sqlInputs.getInstance())) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(sqlInputs.getInstance()); } if (AUTH_WINDOWS.equalsIgnoreCase(sqlInputs.getAuthenticationType())) { dbUrlMSSQL.append(SEMI_COLON + INTEGRATED_SECURITY + EQUALS).append(TRUE); } final String connectionString = addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), dbUrlMSSQL.toString()); dbUrls.add(connectionString); } else { throw new SQLException(INVALID_AUTHENTICATION_TYPE_FOR_MS_SQL + sqlInputs.getAuthenticationType()); } return dbUrls; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } }
MSSqlDatabase implements SqlDatabase { @Override public List<String> setUp(@NotNull final SQLInputs sqlInputs) { try { final List<String> dbUrls = new ArrayList<>(); if (sqlInputs.getDbClass() != null && sqlInputs.getDbClass().equals(SQLSERVER_JDBC_DRIVER)) { if (isNoneEmpty(sqlInputs.getDbUrl())) { final String dbUrl = MSSqlDatabase.addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), sqlInputs.getDbUrl()); dbUrls.add(dbUrl); } } loadJdbcDriver(sqlInputs.getDbClass(), sqlInputs.getAuthenticationType(), sqlInputs.getAuthLibraryPath()); String host; String[] serverInstanceComponents = null; if (sqlInputs.getDbServer().contains(BACK_SLASH)) { serverInstanceComponents = sqlInputs.getDbServer().split("\\\\"); host = serverInstanceComponents[0]; } else { host = sqlInputs.getDbServer(); } final Address address = new Address(host); host = address.getURIIPV6Literal(); if (isValidAuthType(sqlInputs.getAuthenticationType())) { final StringBuilder dbUrlMSSQL = new StringBuilder(Constants.MSSQL_URL + host + COLON + sqlInputs.getDbPort() + SEMI_COLON + DATABASE_NAME_CAP + EQUALS + sqlInputs.getDbName()); if (serverInstanceComponents != null) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(serverInstanceComponents[1]); } else if (isNoneEmpty(sqlInputs.getInstance())) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(sqlInputs.getInstance()); } if (AUTH_WINDOWS.equalsIgnoreCase(sqlInputs.getAuthenticationType())) { dbUrlMSSQL.append(SEMI_COLON + INTEGRATED_SECURITY + EQUALS).append(TRUE); } final String connectionString = addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), dbUrlMSSQL.toString()); dbUrls.add(connectionString); } else { throw new SQLException(INVALID_AUTHENTICATION_TYPE_FOR_MS_SQL + sqlInputs.getAuthenticationType()); } return dbUrls; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } } }
MSSqlDatabase implements SqlDatabase { @Override public List<String> setUp(@NotNull final SQLInputs sqlInputs) { try { final List<String> dbUrls = new ArrayList<>(); if (sqlInputs.getDbClass() != null && sqlInputs.getDbClass().equals(SQLSERVER_JDBC_DRIVER)) { if (isNoneEmpty(sqlInputs.getDbUrl())) { final String dbUrl = MSSqlDatabase.addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), sqlInputs.getDbUrl()); dbUrls.add(dbUrl); } } loadJdbcDriver(sqlInputs.getDbClass(), sqlInputs.getAuthenticationType(), sqlInputs.getAuthLibraryPath()); String host; String[] serverInstanceComponents = null; if (sqlInputs.getDbServer().contains(BACK_SLASH)) { serverInstanceComponents = sqlInputs.getDbServer().split("\\\\"); host = serverInstanceComponents[0]; } else { host = sqlInputs.getDbServer(); } final Address address = new Address(host); host = address.getURIIPV6Literal(); if (isValidAuthType(sqlInputs.getAuthenticationType())) { final StringBuilder dbUrlMSSQL = new StringBuilder(Constants.MSSQL_URL + host + COLON + sqlInputs.getDbPort() + SEMI_COLON + DATABASE_NAME_CAP + EQUALS + sqlInputs.getDbName()); if (serverInstanceComponents != null) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(serverInstanceComponents[1]); } else if (isNoneEmpty(sqlInputs.getInstance())) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(sqlInputs.getInstance()); } if (AUTH_WINDOWS.equalsIgnoreCase(sqlInputs.getAuthenticationType())) { dbUrlMSSQL.append(SEMI_COLON + INTEGRATED_SECURITY + EQUALS).append(TRUE); } final String connectionString = addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), dbUrlMSSQL.toString()); dbUrls.add(connectionString); } else { throw new SQLException(INVALID_AUTHENTICATION_TYPE_FOR_MS_SQL + sqlInputs.getAuthenticationType()); } return dbUrls; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } }  }
MSSqlDatabase implements SqlDatabase { @Override public List<String> setUp(@NotNull final SQLInputs sqlInputs) { try { final List<String> dbUrls = new ArrayList<>(); if (sqlInputs.getDbClass() != null && sqlInputs.getDbClass().equals(SQLSERVER_JDBC_DRIVER)) { if (isNoneEmpty(sqlInputs.getDbUrl())) { final String dbUrl = MSSqlDatabase.addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), sqlInputs.getDbUrl()); dbUrls.add(dbUrl); } } loadJdbcDriver(sqlInputs.getDbClass(), sqlInputs.getAuthenticationType(), sqlInputs.getAuthLibraryPath()); String host; String[] serverInstanceComponents = null; if (sqlInputs.getDbServer().contains(BACK_SLASH)) { serverInstanceComponents = sqlInputs.getDbServer().split("\\\\"); host = serverInstanceComponents[0]; } else { host = sqlInputs.getDbServer(); } final Address address = new Address(host); host = address.getURIIPV6Literal(); if (isValidAuthType(sqlInputs.getAuthenticationType())) { final StringBuilder dbUrlMSSQL = new StringBuilder(Constants.MSSQL_URL + host + COLON + sqlInputs.getDbPort() + SEMI_COLON + DATABASE_NAME_CAP + EQUALS + sqlInputs.getDbName()); if (serverInstanceComponents != null) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(serverInstanceComponents[1]); } else if (isNoneEmpty(sqlInputs.getInstance())) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(sqlInputs.getInstance()); } if (AUTH_WINDOWS.equalsIgnoreCase(sqlInputs.getAuthenticationType())) { dbUrlMSSQL.append(SEMI_COLON + INTEGRATED_SECURITY + EQUALS).append(TRUE); } final String connectionString = addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), dbUrlMSSQL.toString()); dbUrls.add(connectionString); } else { throw new SQLException(INVALID_AUTHENTICATION_TYPE_FOR_MS_SQL + sqlInputs.getAuthenticationType()); } return dbUrls; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } }  @Override List<String> setUp(@NotNull final SQLInputs sqlInputs); }
MSSqlDatabase implements SqlDatabase { @Override public List<String> setUp(@NotNull final SQLInputs sqlInputs) { try { final List<String> dbUrls = new ArrayList<>(); if (sqlInputs.getDbClass() != null && sqlInputs.getDbClass().equals(SQLSERVER_JDBC_DRIVER)) { if (isNoneEmpty(sqlInputs.getDbUrl())) { final String dbUrl = MSSqlDatabase.addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), sqlInputs.getDbUrl()); dbUrls.add(dbUrl); } } loadJdbcDriver(sqlInputs.getDbClass(), sqlInputs.getAuthenticationType(), sqlInputs.getAuthLibraryPath()); String host; String[] serverInstanceComponents = null; if (sqlInputs.getDbServer().contains(BACK_SLASH)) { serverInstanceComponents = sqlInputs.getDbServer().split("\\\\"); host = serverInstanceComponents[0]; } else { host = sqlInputs.getDbServer(); } final Address address = new Address(host); host = address.getURIIPV6Literal(); if (isValidAuthType(sqlInputs.getAuthenticationType())) { final StringBuilder dbUrlMSSQL = new StringBuilder(Constants.MSSQL_URL + host + COLON + sqlInputs.getDbPort() + SEMI_COLON + DATABASE_NAME_CAP + EQUALS + sqlInputs.getDbName()); if (serverInstanceComponents != null) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(serverInstanceComponents[1]); } else if (isNoneEmpty(sqlInputs.getInstance())) { dbUrlMSSQL.append(SEMI_COLON + INSTANCE + EQUALS) .append(sqlInputs.getInstance()); } if (AUTH_WINDOWS.equalsIgnoreCase(sqlInputs.getAuthenticationType())) { dbUrlMSSQL.append(SEMI_COLON + INTEGRATED_SECURITY + EQUALS).append(TRUE); } final String connectionString = addSslEncryptionToConnection(sqlInputs.isTrustAllRoots(), sqlInputs.getTrustStore(), sqlInputs.getTrustStorePassword(), dbUrlMSSQL.toString()); dbUrls.add(connectionString); } else { throw new SQLException(INVALID_AUTHENTICATION_TYPE_FOR_MS_SQL + sqlInputs.getAuthenticationType()); } return dbUrls; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e.getCause()); } }  @Override List<String> setUp(@NotNull final SQLInputs sqlInputs);  }