/
jndi_test.rb
55 lines (42 loc) · 1.47 KB
/
jndi_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'db/jndi_config'
require 'simple'
class DerbyJndiTest < Test::Unit::TestCase
include SimpleTestMethods
# Derby specifics :
DbTypeMigration.big_decimal_precision = 31
ALIVE_SQL = 'SELECT 1 FROM SYS.SYSSCHEMAS'
def setup
config = { :connection_alive_sql => ALIVE_SQL }.merge(JNDI_CONFIG)
ActiveRecord::Base.establish_connection config
super
end
test "(raw) connection is a jndi connection" do
connection = ActiveRecord::Base.connection.raw_connection
assert_true connection.jndi?
assert_true connection.jndi_connection?
end
test "fills username from data source meta-data if missing" do
connection = ActiveRecord::Base.connection.raw_connection
config = { :jndi => JNDI_CONFIG[:jndi] }
ArJdbc::Derby.adapter_matcher('Derby', config)
assert_equal 'sa', config[:username]
# but only for Derby of course :
config = { :jndi => JNDI_CONFIG[:jndi] }
ArJdbc::Derby.adapter_matcher('DB42', config)
assert_nil config[:username]
end
end
require 'db/jndi_pooled_config'
class DerbyJndiPooledTest < Test::Unit::TestCase
include SimpleTestMethods
def self.startup
ActiveRecord::Base.establish_connection( {
:connection_alive_sql => DerbyJndiTest::ALIVE_SQL
}.merge(JNDI_POOLED_CONFIG) )
end
test "(raw) connection is a jndi connection" do
connection = ActiveRecord::Base.connection.raw_connection
assert_true connection.jndi?
assert_true connection.jndi_connection?
end
end