Sha256: b0863fe8700181624af438fe1d28cc39496ea693d9dc8aec8ffbb8d0ec822625

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'jdbc_common'
require 'db/jndi_config'

class JndiConnectionPoolCallbacksTest < Test::Unit::TestCase

  def self.startup
    ActiveRecord::Base.establish_connection JNDI_CONFIG
  end

  def setup
    @logger = stub_everything "logger"
    @config = JNDI_CONFIG
    @connection = ActiveRecord::ConnectionAdapters::JdbcConnection.new @config
    Entry.connection_pool.disconnect!
    assert !Entry.connection_pool.connected?
    class << Entry.connection_pool; public :instance_variable_set; end
  end

  def teardown
    Entry.connection_pool.disconnect!
  end

  def test_should_call_hooks_on_checkout_and_checkin
    @adapter = ActiveRecord::ConnectionAdapters::JdbcAdapter.new @connection, @logger, @config
    Entry.connection_pool.instance_variable_set "@connections", [@adapter]
    assert !@connection.active?

    Entry.connection_pool.checkout
    assert @connection.active?

    Entry.connection_pool.checkin @adapter
    assert !@connection.active?
  end

end if ActiveRecord::Base.respond_to?(:connection_pool)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 test/jndi_callbacks_test.rb
activerecord-jdbc-adapter-1.3.0.beta1 test/jndi_callbacks_test.rb
activerecord-jdbc-adapter-1.2.9 test/jndi_callbacks_test.rb
activerecord-jdbc-adapter-1.2.8 test/jndi_callbacks_test.rb