Skip to content

Commit

Permalink
Merge pull request #66 from rsim/tests-allow-oci-via-eazy-connect-url
Browse files Browse the repository at this point in the history
Tests: allow oci via eazy connect url
  • Loading branch information
javornikolov committed Oct 5, 2014
2 parents 944f5bf + 1384fd8 commit 706dc3f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,27 @@
# specify which database version is used (will be verified in one test)
DATABASE_VERSION = ENV['DATABASE_VERSION'] || '10.2.0.4'

def get_eazy_connect_url(svc_separator = "")
"#{DATABASE_HOST}:#{DATABASE_PORT}#{svc_separator}#{DATABASE_SERVICE_NAME}"
end

def get_connection_url
unless defined?(JRUBY_VERSION)
(ENV['DATABASE_USE_TNS'] == 'NO') ? get_eazy_connect_url("/") : DATABASE_NAME
else
"jdbc:oracle:thin:@#{get_eazy_connect_url}"
end
end

def get_connection(user_number = 0)
database_user, database_password = DATABASE_USERS_AND_PASSWORDS[user_number]
unless defined?(JRUBY_VERSION)
try_to_connect(OCIError) do
OCI8.new(database_user, database_password, DATABASE_NAME)
OCI8.new(database_user, database_password, get_connection_url)
end
else
try_to_connect(NativeException) do
java.sql.DriverManager.getConnection("jdbc:oracle:thin:@#{DATABASE_HOST}:#{DATABASE_PORT}#{DATABASE_SERVICE_NAME}",
database_user, database_password)
java.sql.DriverManager.getConnection(get_connection_url, database_user, database_password)
end
end
end
Expand Down

0 comments on commit 706dc3f

Please sign in to comment.