Guest User

Untitled

a guest
May 4th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. # This is an example spec_config.rb that can be used to run sequel's
  2. # integration tests.
  3.  
  4. # jars used to run the integration tests for sqlite and mysql
  5. #
  6. # commons-dbcp-1.2.2.jar
  7. # commons-pool-1.4.jar
  8. # fscontext.jar
  9. # mysql-connector-java-5.0.5.jar
  10. # providerutil.jar
  11. # sqlitejdbc-v056.jar
  12. #
  13. Dir[File.expand_path('~/tmp/sequel_integration_jars/*.jar')].each do |jar|
  14. require jar
  15. end
  16.  
  17. # Taken from activerecord-jdbc-adapter
  18. #
  19. require 'fileutils'
  20.  
  21. System = java.lang.System
  22. Context = javax.naming.Context
  23. InitialContext = javax.naming.InitialContext
  24. Reference = javax.naming.Reference
  25. StringRefAddr = javax.naming.StringRefAddr
  26.  
  27. System.set_property(Context::INITIAL_CONTEXT_FACTORY,
  28. 'com.sun.jndi.fscontext.RefFSContextFactory')
  29.  
  30. project_path = File.expand_path(File.dirname(__FILE__) + '/..')
  31. jndi_dir = project_path + '/jndi_test'
  32. jdbc_dir = jndi_dir + '/jdbc'
  33. FileUtils.mkdir_p jdbc_dir unless File.exist?(jdbc_dir)
  34.  
  35. System.set_property(Context::PROVIDER_URL, "file://#{jndi_dir}")
  36.  
  37. ref = Reference.new('javax.sql.DataSource',
  38. 'org.apache.commons.dbcp.BasicDataSourceFactory',
  39. nil)
  40.  
  41. # mysql
  42. #ref.add StringRefAddr.new('driverClassName', 'org.gjt.mm.mysql.Driver')
  43. #ref.add StringRefAddr.new('url', 'jdbc:mysql://localhost:3306/sequel_integration_tests')
  44. #ref.add StringRefAddr.new('username', '')
  45. #ref.add StringRefAddr.new('password', '')
  46.  
  47. # sqlite
  48. ref.add StringRefAddr.new('driverClassName', 'org.sqlite.JDBC')
  49. ref.add StringRefAddr.new('url', 'jdbc:sqlite::memory:')
  50.  
  51. InitialContext.new.rebind("jdbc/sequel_integration_tests", ref)
  52.  
  53. INTEGRATION_DB = Sequel.connect("jdbc:jndi:jdbc/sequel_integration_tests")
Add Comment
Please, Sign In to add comment