Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

setup.rb - we need to connect at first

  • Loading branch information...
commit a61b9ab098855bf3f76c516f3d96d5405954a4cc 1 parent 17b19b5
@pietia pietia authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/dm-hibernate-adapter/spec/setup.rb
View
16 lib/dm-hibernate-adapter/spec/setup.rb
@@ -1,6 +1,16 @@
require 'dm-hibernate-adapter'
require 'dm-core/spec/setup'
+DB_CONFIGS = {
+ :H2_EMB => { :adapter => "hibernate", :dialect => "H2", :username => "sa", :url => "jdbc:h2:target/jibernate" },
+ :DERBY_EMB => { :adapter => "hibernate", :dialect => "Derby", :url => "jdbc:derby:target/jibernate;create=true" },
+ :HSQL_EMB => { :adapter => "hibernate", :dialect => "HSQL", :username => "sa", :url => "jdbc:hsqldb:file:target/testdb;create=true" },
+ :MySQL5 => { :adapter => "hibernate", :dialect => "MySQL5", :username => "root", :password => "root",
+ :url => "jdbc:mysql://localhost:3306/jibernate"},
+ :PostgreSQL => { :adapter => "hibernate", :dialect => "PostgreSQL", :username => "postgres", :password => "postgres",
+ :url => "jdbc:postgresql://localhost:5432/jibernate"}
+}
+
module DataMapper
module Spec
module Adapters
@@ -8,6 +18,12 @@ module Adapters
class HibernateAdapter < Adapter
def setup!
+ adapter = DataMapper.setup(:default, DB_CONFIGS[(ENV['DIALECT'] || :H2_EMB).to_sym])
+
+ test_connection(adapter)
+ adapter
+ rescue Exception => e
+ puts "Could not connect to the database using '#{connection_uri}' because of: #{e.inspect}"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.