@Test public void testGetConnectionWithNullUsername() throws SQLException { DBConnectionManager dbcManagerSpy = getDBConnectionManagerSpyWithPooling(); exception.expect(SQLException.class); exception.expectMessage("Failed to check out connection,username is empty. dburl = " + DB_URL); dbcManagerSpy.getConnection(aDbType, EMPTY_STRING, DB_URL, EMPTY_STRING, DHARMA_PASSWORD, null); }
public synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties) throws SQLException { if (isEmpty(aDbUrl)) { throw new SQLException("Failed to check out connection dbUrl is empty"); } if (aDbType == null || !(MSSQL_DB_TYPE.equalsIgnoreCase(aDbType.toString()) && AUTH_WINDOWS.equalsIgnoreCase(aAuthType))) { if (isEmpty(aUsername)) { throw new SQLException("Failed to check out connection,username is empty. dburl = " + aDbUrl); } if (isEmpty(aPassword)) { throw new SQLException("Failed to check out connection, password is empty. username = " + aUsername + " dbUrl = " + aDbUrl); } } customizeDBConnectionManager(properties); if (!this.isPoolingEnabled) { return this.getPlainConnection(aDbUrl, aUsername, aPassword); } else { if (aDbType == null) { throw new SQLException("Failed to check out connection db type is null"); } if (datasourceCleaner.getState() == STATE_CLEANER.SHUTDOWN) { cleanerThread = new Thread(datasourceCleaner); cleanerThread.setPriority(Thread.MIN_PRIORITY); cleanerThread.start(); } return getPooledConnection(aDbType, aDbUrl, aUsername, aPassword); } }
DBConnectionManager { public synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties) throws SQLException { if (isEmpty(aDbUrl)) { throw new SQLException("Failed to check out connection dbUrl is empty"); } if (aDbType == null || !(MSSQL_DB_TYPE.equalsIgnoreCase(aDbType.toString()) && AUTH_WINDOWS.equalsIgnoreCase(aAuthType))) { if (isEmpty(aUsername)) { throw new SQLException("Failed to check out connection,username is empty. dburl = " + aDbUrl); } if (isEmpty(aPassword)) { throw new SQLException("Failed to check out connection, password is empty. username = " + aUsername + " dbUrl = " + aDbUrl); } } customizeDBConnectionManager(properties); if (!this.isPoolingEnabled) { return this.getPlainConnection(aDbUrl, aUsername, aPassword); } else { if (aDbType == null) { throw new SQLException("Failed to check out connection db type is null"); } if (datasourceCleaner.getState() == STATE_CLEANER.SHUTDOWN) { cleanerThread = new Thread(datasourceCleaner); cleanerThread.setPriority(Thread.MIN_PRIORITY); cleanerThread.start(); } return getPooledConnection(aDbType, aDbUrl, aUsername, aPassword); } } }
DBConnectionManager { public synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties) throws SQLException { if (isEmpty(aDbUrl)) { throw new SQLException("Failed to check out connection dbUrl is empty"); } if (aDbType == null || !(MSSQL_DB_TYPE.equalsIgnoreCase(aDbType.toString()) && AUTH_WINDOWS.equalsIgnoreCase(aAuthType))) { if (isEmpty(aUsername)) { throw new SQLException("Failed to check out connection,username is empty. dburl = " + aDbUrl); } if (isEmpty(aPassword)) { throw new SQLException("Failed to check out connection, password is empty. username = " + aUsername + " dbUrl = " + aDbUrl); } } customizeDBConnectionManager(properties); if (!this.isPoolingEnabled) { return this.getPlainConnection(aDbUrl, aUsername, aPassword); } else { if (aDbType == null) { throw new SQLException("Failed to check out connection db type is null"); } if (datasourceCleaner.getState() == STATE_CLEANER.SHUTDOWN) { cleanerThread = new Thread(datasourceCleaner); cleanerThread.setPriority(Thread.MIN_PRIORITY); cleanerThread.start(); } return getPooledConnection(aDbType, aDbUrl, aUsername, aPassword); } } protected  DBConnectionManager(); }
DBConnectionManager { public synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties) throws SQLException { if (isEmpty(aDbUrl)) { throw new SQLException("Failed to check out connection dbUrl is empty"); } if (aDbType == null || !(MSSQL_DB_TYPE.equalsIgnoreCase(aDbType.toString()) && AUTH_WINDOWS.equalsIgnoreCase(aAuthType))) { if (isEmpty(aUsername)) { throw new SQLException("Failed to check out connection,username is empty. dburl = " + aDbUrl); } if (isEmpty(aPassword)) { throw new SQLException("Failed to check out connection, password is empty. username = " + aUsername + " dbUrl = " + aDbUrl); } } customizeDBConnectionManager(properties); if (!this.isPoolingEnabled) { return this.getPlainConnection(aDbUrl, aUsername, aPassword); } else { if (aDbType == null) { throw new SQLException("Failed to check out connection db type is null"); } if (datasourceCleaner.getState() == STATE_CLEANER.SHUTDOWN) { cleanerThread = new Thread(datasourceCleaner); cleanerThread.setPriority(Thread.MIN_PRIORITY); cleanerThread.start(); } return getPooledConnection(aDbType, aDbUrl, aUsername, aPassword); } } protected  DBConnectionManager(); static DBConnectionManager getInstance(); void finalize(); synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties); void cleanDataSources(); synchronized void shutdownDbmsPools(); int getDbmsPoolSize(); int getConnectionSize(DBType aDbType, String aDbUrl); int getCheckedOutConnectionSize(DBType aDbType, String aDbUrl); int getCheckedInConnectionSize(DBType aDbType, String aDbUrl); int getTotalConnectionSize(); int getTotalCheckedOutConnectionSize(); int getTotalCheckedInConnectionSize(); }
DBConnectionManager { public synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties) throws SQLException { if (isEmpty(aDbUrl)) { throw new SQLException("Failed to check out connection dbUrl is empty"); } if (aDbType == null || !(MSSQL_DB_TYPE.equalsIgnoreCase(aDbType.toString()) && AUTH_WINDOWS.equalsIgnoreCase(aAuthType))) { if (isEmpty(aUsername)) { throw new SQLException("Failed to check out connection,username is empty. dburl = " + aDbUrl); } if (isEmpty(aPassword)) { throw new SQLException("Failed to check out connection, password is empty. username = " + aUsername + " dbUrl = " + aDbUrl); } } customizeDBConnectionManager(properties); if (!this.isPoolingEnabled) { return this.getPlainConnection(aDbUrl, aUsername, aPassword); } else { if (aDbType == null) { throw new SQLException("Failed to check out connection db type is null"); } if (datasourceCleaner.getState() == STATE_CLEANER.SHUTDOWN) { cleanerThread = new Thread(datasourceCleaner); cleanerThread.setPriority(Thread.MIN_PRIORITY); cleanerThread.start(); } return getPooledConnection(aDbType, aDbUrl, aUsername, aPassword); } } protected  DBConnectionManager(); static DBConnectionManager getInstance(); void finalize(); synchronized Connection getConnection(DBType aDbType, String aAuthType, String aDbUrl, String aUsername, String aPassword, Properties properties); void cleanDataSources(); synchronized void shutdownDbmsPools(); int getDbmsPoolSize(); int getConnectionSize(DBType aDbType, String aDbUrl); int getCheckedOutConnectionSize(DBType aDbType, String aDbUrl); int getCheckedInConnectionSize(DBType aDbType, String aDbUrl); int getTotalConnectionSize(); int getTotalCheckedOutConnectionSize(); int getTotalCheckedInConnectionSize();  }