Sha256: 36735e39778f227032e714f948e9f5069ba4d1e57e222e450706152f8207ce5a

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Trinidad::Extensions::MysqlDbpoolWebAppExtension do
  before(:each) do
    @options = {
      :url => 'jdbc:mysql://localhost:3306/test',
      :jndi => 'jdbc/TestDB',
      :maxIdle => 300
    }
    @extension = Trinidad::Extensions::MysqlDbpoolWebAppExtension.new(@options)
    @context = Trinidad::Tomcat::StandardContext.new

    @tomcat = mock
    resource_context = mock
    naming = mock

    naming.stubs(:addResource)
    resource_context.stubs(:naming_resources).returns(naming)
    resource_context.stubs(:naming_resources=)
    @tomcat.stubs(:addContext).returns(resource_context)
  end

  it "sets the mysql driver name as a resource property" do
    resource = configure_extension
    resource.getProperty('driverClassName').should == 'com.mysql.jdbc.Driver'
  end

  it "adds the resource to the tomcat standard context" do
    configure_extension
    @context.naming_resources.find_resource('jdbc/TestDB').should_not be_nil
  end

  it "adds properties to the resource" do
    resource = configure_extension
    resource.getProperty('maxIdle').should == '300'
  end

  it "adds the protocol if the url doesn't include it" do
    @options[:url] = "localhost:3306/test_protocol"
    extension = Trinidad::Extensions::MysqlDbpoolWebAppExtension.new(@options)
    resource = extension.configure(@tomcat, @context)
    resource.get_property('url').should == "jdbc:mysql://localhost:3306/test_protocol"
  end

  def configure_extension
    @extension.configure(@tomcat, @context)
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
trinidad_dbpool-0.2.0 spec/trinidad_mysql_dbpool_extension_spec.rb
trinidad_dbpool-0.1.1 spec/trinidad_mysql_dbpool_extension_spec.rb
trinidad_postgresql_dbpool_extension-0.1.0 spec/trinidad_mysql_dbpool_extension_spec.rb
trinidad_mysql_dbpool_extension-0.1.0 spec/trinidad_mysql_dbpool_extension_spec.rb
trinidad_dbpool-0.1.0 spec/trinidad_mysql_dbpool_extension_spec.rb