Sha256: f79b632198442f2ec1a7c0fdbd69572e2dacdf65439eaf35ed2de75edf6bd92d

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

# To support the connection pooling in the test, you'll need
# commons-dbcp, commons-pool, and commons-collections.

require 'jdbc_common'

require 'db/jndi_config'

class DerbyJndiTest < Test::Unit::TestCase
  include SimpleTestMethods

  # Derby specifics :
  DbTypeMigration.big_decimal_precision = 31
  ALIVE_SQL = 'SELECT 1 FROM SYS.SYSSCHEMAS'
  
  def self.startup
    ActiveRecord::Base.establish_connection( {
        :connection_alive_sql => ALIVE_SQL 
    }.merge(JNDI_CONFIG) )
  end

  # @override
  #def test_connection_alive_sql; end
  
  test "(raw) connection is a jndi connection" do
    connection = ActiveRecord::Base.connection.raw_connection
    assert_true connection.jndi_connection?
  end

  test "fills username from data source meta-data if missing" do
    connection = ActiveRecord::Base.connection.raw_connection
    assert_true connection.jndi_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

  # @override
  #def test_connection_alive_sql; end
  
  test "(raw) connection is a jndi connection" do
    connection = ActiveRecord::Base.connection.raw_connection
    assert_true connection.jndi_connection?
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.0.beta1 test/jndi_test.rb