Skip to content

Commit

Permalink
ConnectionProviderSuite fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborgsomogyi committed Jul 8, 2020
1 parent 8caa8e7 commit e919ac4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions
import org.apache.spark.util.Utils

private[jdbc] object ConnectionProvider extends Logging {
val providers = loadProviders()
private val providers = loadProviders()

private def loadProviders(): Seq[JdbcConnectionProvider] = {
def loadProviders(): Seq[JdbcConnectionProvider] = {
val loader = ServiceLoader.load(classOf[JdbcConnectionProvider],
Utils.getContextOrSparkClassLoader)
val providers = mutable.ArrayBuffer[JdbcConnectionProvider]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import javax.security.auth.login.Configuration
class ConnectionProviderSuite extends ConnectionProviderSuiteBase {
test("All built-in provides must be loaded") {
IntentionallyFaultyConnectionProvider.constructed = false
assert(ConnectionProvider.providers.exists(_.isInstanceOf[BasicConnectionProvider]))
assert(ConnectionProvider.providers.exists(_.isInstanceOf[DB2ConnectionProvider]))
assert(ConnectionProvider.providers.exists(_.isInstanceOf[MariaDBConnectionProvider]))
assert(ConnectionProvider.providers.exists(_.isInstanceOf[MSSQLConnectionProvider]))
assert(ConnectionProvider.providers.exists(_.isInstanceOf[PostgresConnectionProvider]))
assert(ConnectionProvider.providers.exists(_.isInstanceOf[OracleConnectionProvider]))
val providers = ConnectionProvider.loadProviders()
assert(providers.exists(_.isInstanceOf[BasicConnectionProvider]))
assert(providers.exists(_.isInstanceOf[DB2ConnectionProvider]))
assert(providers.exists(_.isInstanceOf[MariaDBConnectionProvider]))
assert(providers.exists(_.isInstanceOf[MSSQLConnectionProvider]))
assert(providers.exists(_.isInstanceOf[PostgresConnectionProvider]))
assert(providers.exists(_.isInstanceOf[OracleConnectionProvider]))
assert(IntentionallyFaultyConnectionProvider.constructed)
assert(!ConnectionProvider.providers.
exists(_.isInstanceOf[IntentionallyFaultyConnectionProvider]))
assert(ConnectionProvider.providers.size === 6)
assert(!providers.exists(_.isInstanceOf[IntentionallyFaultyConnectionProvider]))
assert(providers.size === 6)
}

test("Multiple security configs must be reachable") {
Expand Down

0 comments on commit e919ac4

Please sign in to comment.