activerecord-jdbc-adapter 0.9.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +163 -0
- data/Manifest.txt +130 -65
- data/README.txt +64 -72
- data/lib/active_record/connection_adapters/derby_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/h2_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/hsqldb_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/informix_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +1 -633
- data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -13
- data/lib/activerecord-jdbc-adapter.rb +6 -0
- data/lib/arel/engines/sql/compilers/db2_compiler.rb +9 -0
- data/lib/arel/engines/sql/compilers/derby_compiler.rb +6 -0
- data/lib/arel/engines/sql/compilers/h2_compiler.rb +6 -0
- data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +15 -0
- data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +6 -0
- data/lib/arel/engines/sql/compilers/mssql_compiler.rb +46 -0
- data/lib/arel/visitors/db2.rb +15 -0
- data/lib/arel/visitors/derby.rb +19 -0
- data/lib/arel/visitors/hsqldb.rb +24 -0
- data/lib/arel/visitors/mssql.rb +44 -0
- data/lib/arjdbc.rb +29 -0
- data/lib/arjdbc/db2.rb +2 -0
- data/lib/arjdbc/db2/adapter.rb +413 -0
- data/lib/arjdbc/derby.rb +7 -0
- data/lib/{jdbc_adapter/jdbc_derby.rb → arjdbc/derby/adapter.rb} +58 -132
- data/lib/arjdbc/derby/connection_methods.rb +18 -0
- data/lib/arjdbc/discover.rb +92 -0
- data/lib/arjdbc/firebird.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_firebird.rb → arjdbc/firebird/adapter.rb} +36 -14
- data/lib/arjdbc/h2.rb +4 -0
- data/lib/arjdbc/h2/adapter.rb +36 -0
- data/lib/arjdbc/h2/connection_methods.rb +12 -0
- data/lib/arjdbc/hsqldb.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_hsqldb.rb → arjdbc/hsqldb/adapter.rb} +34 -62
- data/lib/arjdbc/hsqldb/connection_methods.rb +14 -0
- data/lib/arjdbc/informix.rb +3 -0
- data/lib/{jdbc_adapter/jdbc_informix.rb → arjdbc/informix/adapter.rb} +10 -19
- data/lib/arjdbc/informix/connection_methods.rb +10 -0
- data/lib/arjdbc/jdbc.rb +2 -0
- data/lib/arjdbc/jdbc/adapter.rb +285 -0
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/callbacks.rb +44 -0
- data/lib/arjdbc/jdbc/column.rb +38 -0
- data/lib/arjdbc/jdbc/compatibility.rb +51 -0
- data/lib/arjdbc/jdbc/connection.rb +128 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +16 -0
- data/lib/arjdbc/jdbc/core_ext.rb +24 -0
- data/lib/arjdbc/jdbc/discover.rb +18 -0
- data/lib/arjdbc/jdbc/driver.rb +44 -0
- data/lib/arjdbc/jdbc/extension.rb +47 -0
- data/lib/arjdbc/jdbc/java.rb +14 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/jdbc.rake +36 -26
- data/lib/{jdbc_adapter → arjdbc/jdbc}/missing_functionality_helper.rb +5 -5
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +28 -0
- data/lib/arjdbc/jdbc/railtie.rb +9 -0
- data/lib/arjdbc/jdbc/rake_tasks.rb +10 -0
- data/lib/arjdbc/jdbc/require_driver.rb +16 -0
- data/lib/arjdbc/jdbc/type_converter.rb +126 -0
- data/lib/arjdbc/mimer.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_mimer.rb → arjdbc/mimer/adapter.rb} +17 -16
- data/lib/arjdbc/mssql.rb +4 -0
- data/lib/arjdbc/mssql/adapter.rb +472 -0
- data/lib/arjdbc/mssql/connection_methods.rb +30 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +92 -0
- data/lib/{jdbc_adapter → arjdbc/mssql}/tsql_helper.rb +2 -1
- data/lib/arjdbc/mysql.rb +4 -0
- data/lib/arjdbc/mysql/adapter.rb +416 -0
- data/lib/arjdbc/mysql/connection_methods.rb +27 -0
- data/lib/arjdbc/oracle.rb +3 -0
- data/lib/{jdbc_adapter/jdbc_oracle.rb → arjdbc/oracle/adapter.rb} +68 -33
- data/lib/arjdbc/oracle/connection_methods.rb +11 -0
- data/lib/arjdbc/postgresql.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_postgre.rb → arjdbc/postgresql/adapter.rb} +147 -72
- data/lib/arjdbc/postgresql/connection_methods.rb +21 -0
- data/lib/arjdbc/sqlite3.rb +4 -0
- data/lib/arjdbc/sqlite3/adapter.rb +381 -0
- data/lib/arjdbc/sqlite3/connection_methods.rb +34 -0
- data/lib/arjdbc/sybase.rb +2 -0
- data/lib/arjdbc/sybase/adapter.rb +46 -0
- data/lib/arjdbc/version.rb +8 -0
- data/lib/generators/jdbc/jdbc_generator.rb +9 -0
- data/lib/jdbc_adapter.rb +2 -27
- data/lib/jdbc_adapter/rake_tasks.rb +3 -10
- data/lib/jdbc_adapter/version.rb +3 -5
- data/lib/pg.rb +23 -1
- data/rails_generators/jdbc_generator.rb +2 -2
- data/rails_generators/templates/{jdbc.rb → config/initializers/jdbc.rb} +1 -1
- data/rails_generators/templates/{jdbc.rake → lib/tasks/jdbc.rake} +2 -2
- data/rakelib/compile.rake +5 -3
- data/rakelib/db.rake +19 -0
- data/rakelib/package.rake +12 -6
- data/rakelib/test.rake +24 -14
- data/src/java/{jdbc_adapter/JdbcDerbySpec.java → arjdbc/derby/DerbyModule.java} +63 -34
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +70 -0
- data/src/java/{jdbc_adapter/MssqlRubyJdbcConnection.java → arjdbc/informix/InformixRubyJdbcConnection.java} +15 -12
- data/src/java/{jdbc_adapter/JdbcAdapterInternalService.java → arjdbc/jdbc/AdapterJavaService.java} +21 -8
- data/src/java/{jdbc_adapter → arjdbc/jdbc}/JdbcConnectionFactory.java +6 -6
- data/src/java/{jdbc_adapter → arjdbc/jdbc}/RubyJdbcConnection.java +210 -67
- data/src/java/arjdbc/jdbc/SQLBlock.java +48 -0
- data/src/java/arjdbc/mssql/MssqlRubyJdbcConnection.java +127 -0
- data/src/java/{jdbc_adapter/JdbcMySQLSpec.java → arjdbc/mysql/MySQLModule.java} +12 -12
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +87 -0
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +85 -0
- data/src/java/{jdbc_adapter/PostgresRubyJdbcConnection.java → arjdbc/postgresql/PostgresqlRubyJdbcConnection.java} +11 -9
- data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +64 -0
- data/test/abstract_db_create.rb +98 -19
- data/test/activerecord/connection_adapters/type_conversion_test.rb +1 -1
- data/test/db/db2.rb +4 -2
- data/test/db/derby.rb +12 -14
- data/test/db/hsqldb.rb +3 -2
- data/test/db/jndi_config.rb +22 -12
- data/test/db/mssql.rb +5 -5
- data/test/db/sqlite3.rb +2 -6
- data/test/db2_simple_test.rb +56 -0
- data/test/derby_migration_test.rb +50 -3
- data/test/derby_simple_test.rb +87 -0
- data/test/generic_jdbc_connection_test.rb +21 -1
- data/test/h2_simple_test.rb +35 -0
- data/test/jdbc_common.rb +4 -5
- data/test/jndi_callbacks_test.rb +3 -1
- data/test/jndi_test.rb +1 -11
- data/test/models/entry.rb +20 -0
- data/test/models/mixed_case.rb +7 -2
- data/test/models/string_id.rb +18 -0
- data/test/mssql_db_create_test.rb +26 -0
- data/test/mssql_identity_insert_test.rb +19 -0
- data/test/mssql_legacy_types_test.rb +58 -0
- data/test/mssql_limit_offset_test.rb +136 -0
- data/test/mssql_multibyte_test.rb +18 -0
- data/test/mssql_simple_test.rb +49 -0
- data/test/mysql_db_create_test.rb +8 -6
- data/test/mysql_info_test.rb +123 -0
- data/test/mysql_simple_test.rb +19 -1
- data/test/oracle_simple_test.rb +9 -20
- data/test/oracle_specific_test.rb +83 -0
- data/test/pick_rails_version.rb +3 -0
- data/test/postgres_db_create_test.rb +11 -0
- data/test/postgres_drop_db_test.rb +16 -0
- data/test/postgres_mixed_case_test.rb +11 -1
- data/test/postgres_nonseq_pkey_test.rb +0 -2
- data/test/postgres_schema_search_path_test.rb +44 -0
- data/test/postgres_simple_test.rb +53 -0
- data/test/postgres_table_alias_length_test.rb +15 -0
- data/test/simple.rb +103 -9
- data/test/sqlite3_simple_test.rb +1 -0
- data/test/sybase_jtds_simple_test.rb +22 -0
- metadata +239 -137
- data/lib/active_record/connection_adapters/cachedb_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/jdbc_adapter_spec.rb +0 -26
- data/lib/jdbc_adapter/jdbc_adapter_internal.jar +0 -0
- data/lib/jdbc_adapter/jdbc_cachedb.rb +0 -33
- data/lib/jdbc_adapter/jdbc_db2.rb +0 -191
- data/lib/jdbc_adapter/jdbc_mssql.rb +0 -333
- data/lib/jdbc_adapter/jdbc_mysql.rb +0 -236
- data/lib/jdbc_adapter/jdbc_sqlite3.rb +0 -379
- data/lib/jdbc_adapter/jdbc_sybase.rb +0 -50
- data/src/java/jdbc_adapter/SQLBlock.java +0 -27
- data/src/java/jdbc_adapter/Sqlite3RubyJdbcConnection.java +0 -41
- data/test/cachedb_simple_test.rb +0 -6
- data/test/db/cachedb.rb +0 -9
- data/test/jdbc_adapter/jdbc_db2_test.rb +0 -26
- data/test/jdbc_adapter/jdbc_sybase_test.rb +0 -33
- data/test/minirunit.rb +0 -109
- data/test/minirunit/testConnect.rb +0 -14
- data/test/minirunit/testH2.rb +0 -73
- data/test/minirunit/testHsqldb.rb +0 -73
- data/test/minirunit/testLoadActiveRecord.rb +0 -3
- data/test/minirunit/testMysql.rb +0 -83
- data/test/minirunit/testRawSelect.rb +0 -24
@@ -1,50 +0,0 @@
|
|
1
|
-
module JdbcSpec
|
2
|
-
module Sybase
|
3
|
-
def self.adapter_matcher(name, *)
|
4
|
-
name =~ /sybase|tds/i ? self : false
|
5
|
-
end
|
6
|
-
|
7
|
-
def add_limit_offset!(sql, options) # :nodoc:
|
8
|
-
@limit = options[:limit]
|
9
|
-
@offset = options[:offset]
|
10
|
-
if use_temp_table?
|
11
|
-
# Use temp table to hack offset with Sybase
|
12
|
-
sql.sub!(/ FROM /i, ' INTO #artemp FROM ')
|
13
|
-
elsif zero_limit?
|
14
|
-
# "SET ROWCOUNT 0" turns off limits, so we havesy
|
15
|
-
# to use a cheap trick.
|
16
|
-
if sql =~ /WHERE/i
|
17
|
-
sql.sub!(/WHERE/i, 'WHERE 1 = 2 AND ')
|
18
|
-
elsif sql =~ /ORDER\s+BY/i
|
19
|
-
sql.sub!(/ORDER\s+BY/i, 'WHERE 1 = 2 ORDER BY')
|
20
|
-
else
|
21
|
-
sql << 'WHERE 1 = 2'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# If limit is not set at all, we can ignore offset;
|
27
|
-
# if limit *is* set but offset is zero, use normal select
|
28
|
-
# with simple SET ROWCOUNT. Thus, only use the temp table
|
29
|
-
# if limit is set and offset > 0.
|
30
|
-
def use_temp_table?
|
31
|
-
!@limit.nil? && !@offset.nil? && @offset > 0
|
32
|
-
end
|
33
|
-
|
34
|
-
def zero_limit?
|
35
|
-
!@limit.nil? && @limit == 0
|
36
|
-
end
|
37
|
-
|
38
|
-
def modify_types(tp) #:nodoc:
|
39
|
-
tp[:primary_key] = "NUMERIC(22,0) IDENTITY PRIMARY KEY"
|
40
|
-
tp[:integer][:limit] = nil
|
41
|
-
tp[:boolean] = {:name => "bit"}
|
42
|
-
tp[:binary] = {:name => "image"}
|
43
|
-
tp
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove_index(table_name, options = {})
|
47
|
-
execute "DROP INDEX #{table_name}.#{index_name(table_name, options)}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* To change this template, choose Tools | Templates
|
3
|
-
* and open the template in the editor.
|
4
|
-
*/
|
5
|
-
|
6
|
-
package jdbc_adapter;
|
7
|
-
|
8
|
-
import java.sql.Connection;
|
9
|
-
import java.sql.ResultSet;
|
10
|
-
import java.sql.SQLException;
|
11
|
-
import java.sql.Statement;
|
12
|
-
|
13
|
-
/**
|
14
|
-
*
|
15
|
-
* @author nicksieger
|
16
|
-
*/
|
17
|
-
public abstract class SQLBlock {
|
18
|
-
abstract Object call(Connection c) throws SQLException;
|
19
|
-
|
20
|
-
public void close(Statement statement) {
|
21
|
-
RubyJdbcConnection.close(statement);
|
22
|
-
}
|
23
|
-
|
24
|
-
public void close(ResultSet resultSet) {
|
25
|
-
RubyJdbcConnection.close(resultSet);
|
26
|
-
}
|
27
|
-
}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* To change this template, choose Tools | Templates
|
3
|
-
* and open the template in the editor.
|
4
|
-
*/
|
5
|
-
|
6
|
-
package jdbc_adapter;
|
7
|
-
|
8
|
-
import org.jruby.Ruby;
|
9
|
-
import org.jruby.RubyClass;
|
10
|
-
import org.jruby.runtime.ObjectAllocator;
|
11
|
-
import org.jruby.runtime.ThreadContext;
|
12
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
13
|
-
|
14
|
-
/**
|
15
|
-
*
|
16
|
-
* @author enebo
|
17
|
-
*/
|
18
|
-
public class Sqlite3RubyJdbcConnection extends RubyJdbcConnection {
|
19
|
-
protected Sqlite3RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
20
|
-
super(runtime, metaClass);
|
21
|
-
}
|
22
|
-
|
23
|
-
public static RubyClass createSqlite3JdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
24
|
-
RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).defineClassUnder("Sqlite3JdbcConnection",
|
25
|
-
jdbcConnection, SQLITE3_JDBCCONNECTION_ALLOCATOR);
|
26
|
-
clazz.defineAnnotatedMethods(Sqlite3RubyJdbcConnection.class);
|
27
|
-
|
28
|
-
return clazz;
|
29
|
-
}
|
30
|
-
|
31
|
-
private static ObjectAllocator SQLITE3_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
|
32
|
-
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
33
|
-
return new Sqlite3RubyJdbcConnection(runtime, klass);
|
34
|
-
}
|
35
|
-
};
|
36
|
-
|
37
|
-
@Override
|
38
|
-
protected IRubyObject tables(ThreadContext context, String catalog, String schemaPattern, String tablePattern, String[] types) {
|
39
|
-
return (IRubyObject) withConnectionAndRetry(context, tableLookupBlock(context.getRuntime(), catalog, schemaPattern, tablePattern, types, true));
|
40
|
-
}
|
41
|
-
}
|
data/test/cachedb_simple_test.rb
DELETED
data/test/db/cachedb.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'java'
|
2
|
-
require 'lib/jdbc_adapter/jdbc_db2'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class JdbcSpec::DB2Test < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@inst = Object.new
|
8
|
-
@inst.extend JdbcSpec::DB2
|
9
|
-
@column = Object.new
|
10
|
-
class <<@column
|
11
|
-
attr_accessor :type
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_quote_decimal
|
16
|
-
assert_equal %q{'123.45'}, @inst.quote("123.45")
|
17
|
-
@column.type = :decimal
|
18
|
-
assert_equal %q{123.45}, @inst.quote("123.45", @column), "decimal columns should not have quotes"
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_primary_key_generation
|
22
|
-
@column.type = :primary_key
|
23
|
-
assert_equal 'int not null generated by default as identity (start with 1) primary key', @inst.modify_types({:string => {}, :integer => {}, :boolean => {}})[:primary_key]
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'jdbc_adapter'
|
3
|
-
|
4
|
-
class MockConnection
|
5
|
-
|
6
|
-
def adapter=( adapt )
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
module ActiveRecord
|
12
|
-
module ConnectionAdapters
|
13
|
-
|
14
|
-
class SybaseAdapterSelectionTest < Test::Unit::TestCase
|
15
|
-
|
16
|
-
def testJtdsSelectionUsingDialect()
|
17
|
-
config = {
|
18
|
-
:driver => 'net.sourceforge.jtds.Driver',
|
19
|
-
:dialect => 'sybase'
|
20
|
-
}
|
21
|
-
adapt = JdbcAdapter.new(MockConnection.new, nil, config)
|
22
|
-
assert adapt.kind_of?(JdbcSpec::Sybase), "Should be a sybase adapter"
|
23
|
-
end
|
24
|
-
|
25
|
-
def testJtdsSelectionNotUsingDialect
|
26
|
-
config = { :driver => 'net.sourceforge.jtds.Driver' }
|
27
|
-
adapt = JdbcAdapter.new(MockConnection.new, nil, config)
|
28
|
-
assert adapt.kind_of?(JdbcSpec::MsSQL), "Should be a MsSQL apdater"
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/test/minirunit.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
|
2
|
-
$silentTests = false
|
3
|
-
$testnum=0
|
4
|
-
$ntest=0
|
5
|
-
$failed = []
|
6
|
-
$curtestOK=true
|
7
|
-
|
8
|
-
module MiniRUnit
|
9
|
-
class Failure
|
10
|
-
def initialize(what, testnum, msg, where)
|
11
|
-
@what, @testnum, @msg, @where = what, testnum, msg, where
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_s
|
15
|
-
sprintf("FAILED %s %d %s-- %s\n", @what, @testnum, @msg, @where)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Error
|
20
|
-
def initialize(what, testnum, boom)
|
21
|
-
@what, @testnum, @boom = what, testnum, boom
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_s
|
25
|
-
sprintf("EXCEPTION raised %s %d -- \n\tException: %s\n\t%s",
|
26
|
-
@what, @testnum, @boom.to_s, @boom.backtrace.join("\n\t"))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def test_check(what)
|
33
|
-
printf "%s : ", what unless $silentTests
|
34
|
-
$what = what
|
35
|
-
$testnum = 0
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_ok(cond, msg="")
|
39
|
-
$testnum+=1
|
40
|
-
$ntest+=1
|
41
|
-
if cond
|
42
|
-
print "." unless $silentTests
|
43
|
-
else
|
44
|
-
where = caller.reject {|where| where =~ /minirunit/}[0]
|
45
|
-
$failed.push(MiniRUnit::Failure.new($what, $testnum, msg, where))
|
46
|
-
print "F" unless $silentTests
|
47
|
-
$curtestOK=false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_fail(msg="")
|
52
|
-
test_ok(false, msg)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_equal(a,b)
|
56
|
-
test_ok(a == b, "expected #{a.inspect}, found #{b.inspect}")
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_no_exception(&proc)
|
60
|
-
raised = false
|
61
|
-
begin
|
62
|
-
proc.call
|
63
|
-
rescue exception
|
64
|
-
raised = x
|
65
|
-
end
|
66
|
-
test_ok(!raised, "unexpected exception #{raised}")
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_exception(type=Exception, &proc)
|
70
|
-
raised = false
|
71
|
-
begin
|
72
|
-
proc.call
|
73
|
-
rescue type=>e
|
74
|
-
raised = true
|
75
|
-
end
|
76
|
-
test_ok(raised, "#{type} expected")
|
77
|
-
e
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_get_last_failed
|
81
|
-
if $failed.empty?
|
82
|
-
return nil
|
83
|
-
end
|
84
|
-
return $failed.last
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_print_report
|
88
|
-
puts
|
89
|
-
puts "-" * 80
|
90
|
-
$failed.each { |error| puts error }
|
91
|
-
puts "-" * 80
|
92
|
-
puts "Tests: #$ntest. (Ok: #{$ntest - $failed.size}; Failed: #{$failed.size})"
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_load(test)
|
96
|
-
begin
|
97
|
-
$curtestOK=true
|
98
|
-
load(test)
|
99
|
-
rescue Exception => boom
|
100
|
-
puts 'ERROR' unless $silentTests
|
101
|
-
$failed.push(MiniRUnit::Error.new($what, $testnum, boom))
|
102
|
-
else
|
103
|
-
if $curtestOK
|
104
|
-
puts 'OK' unless $silentTests
|
105
|
-
else
|
106
|
-
puts 'FAILED' unless $silentTests
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test/minirunit'
|
2
|
-
RAILS_CONNECTION_ADAPTERS = ['abstract', 'jdbc']
|
3
|
-
require 'active_record'
|
4
|
-
|
5
|
-
connspec = ActiveRecord::Base.establish_connection(
|
6
|
-
:adapter => 'jdbc',
|
7
|
-
:driver => 'com.mysql.jdbc.Driver',
|
8
|
-
:url => 'jdbc:mysql://localhost:3306/test',
|
9
|
-
:username => 'rlsmgr',
|
10
|
-
:password => ''
|
11
|
-
)
|
12
|
-
|
13
|
-
puts "#{connspec}"
|
14
|
-
puts "#{ActiveRecord::Base.connection}"
|
data/test/minirunit/testH2.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'minirunit'
|
3
|
-
|
4
|
-
config = {
|
5
|
-
:adapter => 'jdbc',
|
6
|
-
:username => 'sa',
|
7
|
-
:password => '',
|
8
|
-
:driver => 'org.h2.Driver',
|
9
|
-
:url => 'jdbc:h2:test.db'
|
10
|
-
}
|
11
|
-
RAILS_CONNECTION_ADAPTERS = ['abstract', 'jdbc']
|
12
|
-
|
13
|
-
require 'active_record'
|
14
|
-
|
15
|
-
ActiveRecord::Base.establish_connection(config)
|
16
|
-
require 'logger'
|
17
|
-
ActiveRecord::Base.logger = Logger.new($stdout)
|
18
|
-
ActiveRecord::Base.logger.level = Logger::DEBUG
|
19
|
-
|
20
|
-
class CreateEntries < ActiveRecord::Migration
|
21
|
-
def self.up
|
22
|
-
create_table "entries", :force => true do |t|
|
23
|
-
t.column :title, :string, :limit => 100
|
24
|
-
t.column :updated_on, :datetime
|
25
|
-
t.column :content, :text
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.down
|
30
|
-
drop_table "entries"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
CreateEntries.up
|
35
|
-
|
36
|
-
test_ok ActiveRecord::Base.connection.tables.include?('entries')
|
37
|
-
|
38
|
-
class Entry < ActiveRecord::Base
|
39
|
-
end
|
40
|
-
|
41
|
-
Entry.delete_all
|
42
|
-
|
43
|
-
test_equal 0, Entry.count
|
44
|
-
|
45
|
-
TITLE = "First post!"
|
46
|
-
CONTENT = "Hello from JRuby on Rails!"
|
47
|
-
NEW_TITLE = "First post updated title"
|
48
|
-
|
49
|
-
post = Entry.new
|
50
|
-
post.title = TITLE
|
51
|
-
post.content = CONTENT
|
52
|
-
post.save
|
53
|
-
|
54
|
-
test_equal 1, Entry.count
|
55
|
-
|
56
|
-
post = Entry.find(:first)
|
57
|
-
test_equal TITLE, post.title
|
58
|
-
test_equal CONTENT, post.content
|
59
|
-
|
60
|
-
post.title = NEW_TITLE
|
61
|
-
post.save
|
62
|
-
|
63
|
-
post = Entry.find(:first)
|
64
|
-
test_equal NEW_TITLE, post.title
|
65
|
-
|
66
|
-
post.destroy
|
67
|
-
|
68
|
-
test_equal 0, Entry.count
|
69
|
-
|
70
|
-
CreateEntries.down
|
71
|
-
|
72
|
-
# Clean up hsqldb when done
|
73
|
-
Dir['test.db*'].each {|f| File.delete(f)}
|
@@ -1,73 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'minirunit'
|
3
|
-
|
4
|
-
config = {
|
5
|
-
:adapter => 'jdbc',
|
6
|
-
:username => 'sa',
|
7
|
-
:password => '',
|
8
|
-
:driver => 'org.hsqldb.jdbcDriver',
|
9
|
-
:url => 'jdbc:hsqldb:test.db'
|
10
|
-
}
|
11
|
-
RAILS_CONNECTION_ADAPTERS = ['abstract', 'jdbc']
|
12
|
-
|
13
|
-
require 'active_record'
|
14
|
-
|
15
|
-
ActiveRecord::Base.establish_connection(config)
|
16
|
-
require 'logger'
|
17
|
-
ActiveRecord::Base.logger = Logger.new($stdout)
|
18
|
-
ActiveRecord::Base.logger.level = Logger::DEBUG
|
19
|
-
|
20
|
-
class CreateEntries < ActiveRecord::Migration
|
21
|
-
def self.up
|
22
|
-
create_table "entries", :force => true do |t|
|
23
|
-
t.column :title, :string, :limit => 100
|
24
|
-
t.column :updated_on, :datetime
|
25
|
-
t.column :content, :text
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.down
|
30
|
-
drop_table "entries"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
CreateEntries.up
|
35
|
-
|
36
|
-
test_ok ActiveRecord::Base.connection.tables.include?('entries')
|
37
|
-
|
38
|
-
class Entry < ActiveRecord::Base
|
39
|
-
end
|
40
|
-
|
41
|
-
Entry.delete_all
|
42
|
-
|
43
|
-
test_equal 0, Entry.count
|
44
|
-
|
45
|
-
TITLE = "First post!"
|
46
|
-
CONTENT = "Hello from JRuby on Rails!"
|
47
|
-
NEW_TITLE = "First post updated title"
|
48
|
-
|
49
|
-
post = Entry.new
|
50
|
-
post.title = TITLE
|
51
|
-
post.content = CONTENT
|
52
|
-
post.save
|
53
|
-
|
54
|
-
test_equal 1, Entry.count
|
55
|
-
|
56
|
-
post = Entry.find(:first)
|
57
|
-
test_equal TITLE, post.title
|
58
|
-
test_equal CONTENT, post.content
|
59
|
-
|
60
|
-
post.title = NEW_TITLE
|
61
|
-
post.save
|
62
|
-
|
63
|
-
post = Entry.find(:first)
|
64
|
-
test_equal NEW_TITLE, post.title
|
65
|
-
|
66
|
-
post.destroy
|
67
|
-
|
68
|
-
test_equal 0, Entry.count
|
69
|
-
|
70
|
-
CreateEntries.down
|
71
|
-
|
72
|
-
# Clean up hsqldb when done
|
73
|
-
Dir['test.db*'].each {|f| File.delete(f)}
|