Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is an example spec_config.rb that can be used to run sequel's
- # integration tests.
- # jars used to run the integration tests for sqlite and mysql
- #
- # commons-dbcp-1.2.2.jar
- # commons-pool-1.4.jar
- # fscontext.jar
- # mysql-connector-java-5.0.5.jar
- # providerutil.jar
- # sqlitejdbc-v056.jar
- #
- Dir[File.expand_path('~/tmp/sequel_integration_jars/*.jar')].each do |jar|
- require jar
- end
- # Taken from activerecord-jdbc-adapter
- #
- require 'fileutils'
- System = java.lang.System
- Context = javax.naming.Context
- InitialContext = javax.naming.InitialContext
- Reference = javax.naming.Reference
- StringRefAddr = javax.naming.StringRefAddr
- System.set_property(Context::INITIAL_CONTEXT_FACTORY,
- 'com.sun.jndi.fscontext.RefFSContextFactory')
- project_path = File.expand_path(File.dirname(__FILE__) + '/..')
- jndi_dir = project_path + '/jndi_test'
- jdbc_dir = jndi_dir + '/jdbc'
- FileUtils.mkdir_p jdbc_dir unless File.exist?(jdbc_dir)
- System.set_property(Context::PROVIDER_URL, "file://#{jndi_dir}")
- ref = Reference.new('javax.sql.DataSource',
- 'org.apache.commons.dbcp.BasicDataSourceFactory',
- nil)
- # mysql
- #ref.add StringRefAddr.new('driverClassName', 'org.gjt.mm.mysql.Driver')
- #ref.add StringRefAddr.new('url', 'jdbc:mysql://localhost:3306/sequel_integration_tests')
- #ref.add StringRefAddr.new('username', '')
- #ref.add StringRefAddr.new('password', '')
- # sqlite
- ref.add StringRefAddr.new('driverClassName', 'org.sqlite.JDBC')
- ref.add StringRefAddr.new('url', 'jdbc:sqlite::memory:')
- InitialContext.new.rebind("jdbc/sequel_integration_tests", ref)
- INTEGRATION_DB = Sequel.connect("jdbc:jndi:jdbc/sequel_integration_tests")
Add Comment
Please, Sign In to add comment