Permalink
Browse files

setup.rb - we need to connect at first

  • Loading branch information...
1 parent 17b19b5 commit a61b9ab098855bf3f76c516f3d96d5405954a4cc @pietia pietia committed Oct 20, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/dm-hibernate-adapter/spec/setup.rb
@@ -1,13 +1,29 @@
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
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

0 comments on commit a61b9ab

Please sign in to comment.