fireruby 0.1.0-powerpc-darwin → 0.2.0-powerpc-darwin
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +297 -31
- data/examples/example01.rb +60 -0
- data/lib/doc.tar.gz +0 -0
- data/lib/fireruby.bundle +0 -0
- data/lib/mkdoc +1 -1
- data/lib/src.rb +158 -15
- data/test/ConnectionTest.rb +11 -10
- data/test/DDLTest.rb +7 -6
- data/test/DatabaseTest.rb +13 -14
- data/test/GeneratorTest.rb +4 -3
- data/test/ResultSetTest.rb +6 -5
- data/test/RowTest.rb +49 -0
- data/test/SQLTest.rb +43 -26
- data/test/StatementTest.rb +6 -5
- data/test/TransactionTest.rb +7 -6
- data/test/UnitTest.rb +1 -0
- metadata +11 -135
- data/doc/CVS/Entries +0 -10
- data/doc/CVS/Repository +0 -1
- data/doc/CVS/Root +0 -1
- data/doc/classes/CVS/Entries +0 -2
- data/doc/classes/CVS/Entries.Log +0 -1
- data/doc/classes/CVS/Repository +0 -1
- data/doc/classes/CVS/Root +0 -1
- data/doc/classes/FireRuby/CVS/Entries +0 -8
- data/doc/classes/FireRuby/CVS/Entries.Log +0 -7
- data/doc/classes/FireRuby/CVS/Repository +0 -1
- data/doc/classes/FireRuby/CVS/Root +0 -1
- data/doc/classes/FireRuby/Connection.html +0 -364
- data/doc/classes/FireRuby/Connection.src/CVS/Entries +0 -10
- data/doc/classes/FireRuby/Connection.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Connection.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Connection.src/M000046.html +0 -17
- data/doc/classes/FireRuby/Connection.src/M000047.html +0 -17
- data/doc/classes/FireRuby/Connection.src/M000048.html +0 -17
- data/doc/classes/FireRuby/Connection.src/M000049.html +0 -17
- data/doc/classes/FireRuby/Connection.src/M000050.html +0 -17
- data/doc/classes/FireRuby/Connection.src/M000051.html +0 -17
- data/doc/classes/FireRuby/Connection.src/M000052.html +0 -18
- data/doc/classes/FireRuby/Connection.src/M000053.html +0 -18
- data/doc/classes/FireRuby/Connection.src/M000054.html +0 -18
- data/doc/classes/FireRuby/Database.html +0 -292
- data/doc/classes/FireRuby/Database.src/CVS/Entries +0 -7
- data/doc/classes/FireRuby/Database.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Database.src/M000035.html +0 -17
- data/doc/classes/FireRuby/Database.src/M000036.html +0 -17
- data/doc/classes/FireRuby/Database.src/M000037.html +0 -17
- data/doc/classes/FireRuby/Database.src/M000038.html +0 -18
- data/doc/classes/FireRuby/Database.src/M000039.html +0 -17
- data/doc/classes/FireRuby/Database.src/M000040.html +0 -17
- data/doc/classes/FireRuby/FireRubyError.html +0 -221
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Entries +0 -6
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/M000041.html +0 -17
- data/doc/classes/FireRuby/FireRubyError.src/M000042.html +0 -17
- data/doc/classes/FireRuby/FireRubyError.src/M000043.html +0 -17
- data/doc/classes/FireRuby/FireRubyError.src/M000044.html +0 -17
- data/doc/classes/FireRuby/FireRubyError.src/M000045.html +0 -17
- data/doc/classes/FireRuby/Generator.html +0 -343
- data/doc/classes/FireRuby/Generator.src/CVS/Entries +0 -9
- data/doc/classes/FireRuby/Generator.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Generator.src/M000001.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000002.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000003.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000004.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000005.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000006.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000007.html +0 -17
- data/doc/classes/FireRuby/Generator.src/M000008.html +0 -17
- data/doc/classes/FireRuby/ResultSet.html +0 -343
- data/doc/classes/FireRuby/ResultSet.src/CVS/Entries +0 -10
- data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/ResultSet.src/M000026.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000027.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000028.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000029.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000030.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000031.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000032.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000033.html +0 -17
- data/doc/classes/FireRuby/ResultSet.src/M000034.html +0 -17
- data/doc/classes/FireRuby/Statement.html +0 -349
- data/doc/classes/FireRuby/Statement.src/CVS/Entries +0 -10
- data/doc/classes/FireRuby/Statement.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Statement.src/M000017.html +0 -17
- data/doc/classes/FireRuby/Statement.src/M000018.html +0 -17
- data/doc/classes/FireRuby/Statement.src/M000019.html +0 -17
- data/doc/classes/FireRuby/Statement.src/M000020.html +0 -17
- data/doc/classes/FireRuby/Statement.src/M000021.html +0 -17
- data/doc/classes/FireRuby/Statement.src/M000022.html +0 -17
- data/doc/classes/FireRuby/Statement.src/M000023.html +0 -18
- data/doc/classes/FireRuby/Statement.src/M000024.html +0 -18
- data/doc/classes/FireRuby/Statement.src/M000025.html +0 -17
- data/doc/classes/FireRuby/Transaction.html +0 -484
- data/doc/classes/FireRuby/Transaction.src/CVS/Entries +0 -9
- data/doc/classes/FireRuby/Transaction.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Transaction.src/M000009.html +0 -17
- data/doc/classes/FireRuby/Transaction.src/M000010.html +0 -17
- data/doc/classes/FireRuby/Transaction.src/M000011.html +0 -17
- data/doc/classes/FireRuby/Transaction.src/M000012.html +0 -17
- data/doc/classes/FireRuby/Transaction.src/M000013.html +0 -17
- data/doc/classes/FireRuby/Transaction.src/M000014.html +0 -17
- data/doc/classes/FireRuby/Transaction.src/M000015.html +0 -18
- data/doc/classes/FireRuby/Transaction.src/M000016.html +0 -17
- data/doc/classes/FireRuby.html +0 -116
- data/doc/created.rid +0 -1
- data/doc/files/CVS/Entries +0 -2
- data/doc/files/CVS/Repository +0 -1
- data/doc/files/CVS/Root +0 -1
- data/doc/files/src_rb.html +0 -119
- data/doc/fr_class_index.html +0 -34
- data/doc/fr_file_index.html +0 -27
- data/doc/fr_method_index.html +0 -80
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -175
- data/test/example.c +0 -91
- data/test/fb.c +0 -297
- data/test/mfb +0 -1
- data/test/sql_unit_test.fdb +0 -0
- data/test/test.fdb +0 -0
data/test/ConnectionTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -12,8 +13,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def setup
|
14
15
|
if File::exist?(DB_FILE)
|
15
|
-
|
16
|
-
db.drop
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
17
|
end
|
18
18
|
|
19
19
|
@database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
@@ -25,34 +25,35 @@ class ConnectionTest < Test::Unit::TestCase
|
|
25
25
|
@connections.clear
|
26
26
|
|
27
27
|
if File::exist?(DB_FILE)
|
28
|
-
|
29
|
-
db.drop
|
28
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
def test01
|
34
|
-
@connections.push(@database.connect)
|
33
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
35
34
|
|
35
|
+
assert(@connections[0].user == DB_USER_NAME)
|
36
36
|
assert(@connections[0].open?)
|
37
37
|
assert(@connections[0].closed? == false)
|
38
38
|
assert(@connections[0].database == @database)
|
39
39
|
assert(@connections[0].to_s == "#{DB_USER_NAME}@#{DB_FILE} (OPEN)")
|
40
40
|
|
41
41
|
@connections[0].close
|
42
|
+
assert(@connections[0].user == DB_USER_NAME)
|
42
43
|
assert(@connections[0].open? == false)
|
43
44
|
assert(@connections[0].closed?)
|
44
45
|
assert(@connections[0].database == @database)
|
45
46
|
assert(@connections[0].to_s == "(CLOSED)")
|
46
47
|
|
47
|
-
@connections[0] = @database.connect
|
48
|
+
@connections[0] = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
48
49
|
assert(@connections[0].open?)
|
49
|
-
@connections.push(Connection.new(@database))
|
50
|
+
@connections.push(Connection.new(@database, DB_USER_NAME, DB_PASSWORD))
|
50
51
|
assert(@connections[0].open?)
|
51
52
|
assert(@connections[1].open?)
|
52
53
|
end
|
53
54
|
|
54
55
|
def test02
|
55
|
-
@connections.push(@database.connect)
|
56
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
56
57
|
|
57
58
|
tx = @connections[0].start_transaction
|
58
59
|
assert(tx != nil)
|
@@ -73,7 +74,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def test03
|
76
|
-
@connections.push(@database.connect)
|
77
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
77
78
|
tx = @connections[0].start_transaction
|
78
79
|
total = 0
|
79
80
|
@connections[0].execute("SELECT RDB$FIELD_NAME FROM RDB$FIELDS", tx) do |row|
|
data/test/DDLTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -12,19 +13,19 @@ class DDLTest < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def setup
|
14
15
|
if File::exist?(DB_FILE)
|
15
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
16
17
|
end
|
17
|
-
@database
|
18
|
+
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
18
19
|
end
|
19
20
|
|
20
21
|
def teardown
|
21
22
|
if File::exist?(DB_FILE)
|
22
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
23
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def test01
|
27
|
-
@database.connect do |cxn|
|
28
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
28
29
|
cxn.execute_immediate('CREATE TABLE DDL_TABLE_01 (TABLEID '\
|
29
30
|
'INTEGER NOT NULL, '\
|
30
31
|
'FIELD01 FLOAT, FIELD02 CHAR(50), '\
|
@@ -32,7 +33,7 @@ class DDLTest < Test::Unit::TestCase
|
|
32
33
|
'NOT NULL, FIELD05 VARCHAR(600))')
|
33
34
|
|
34
35
|
r = cxn.execute_immediate('SELECT COUNT(*) FROM DDL_TABLE_01')
|
35
|
-
assert(r.fetch ==
|
36
|
+
assert(r.fetch[0] == 0)
|
36
37
|
r.close
|
37
38
|
|
38
39
|
cxn.execute_immediate('ALTER TABLE DDL_TABLE_01 ADD PRIMARY KEY '\
|
data/test/DatabaseTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -13,11 +14,11 @@ class DatabaseTest < Test::Unit::TestCase
|
|
13
14
|
|
14
15
|
def setup
|
15
16
|
if File.exist?(DB_FILE)
|
16
|
-
db = Database.new(
|
17
|
+
db = Database.new(DB_FILE)
|
17
18
|
db.drop
|
18
19
|
end
|
19
20
|
if File.exist?(CREATE_FILE)
|
20
|
-
db = Database.new(
|
21
|
+
db = Database.new(CREATE_FILE)
|
21
22
|
db.drop
|
22
23
|
end
|
23
24
|
|
@@ -26,12 +27,12 @@ class DatabaseTest < Test::Unit::TestCase
|
|
26
27
|
|
27
28
|
def teardown
|
28
29
|
if File::exist?(DB_FILE)
|
29
|
-
db = Database.new(
|
30
|
-
db.drop
|
30
|
+
db = Database.new(DB_FILE)
|
31
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
31
32
|
end
|
32
33
|
if File::exist?(CREATE_FILE)
|
33
|
-
db = Database.new(
|
34
|
-
db.drop
|
34
|
+
db = Database.new(CREATE_FILE)
|
35
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -41,7 +42,6 @@ class DatabaseTest < Test::Unit::TestCase
|
|
41
42
|
db = Database.create(CREATE_FILE, DB_USER_NAME, DB_PASSWORD, 2048, 'ASCII')
|
42
43
|
|
43
44
|
assert(File.exist?(CREATE_FILE))
|
44
|
-
assert(db.user == DB_USER_NAME)
|
45
45
|
assert(db.file == CREATE_FILE)
|
46
46
|
|
47
47
|
begin
|
@@ -51,27 +51,26 @@ class DatabaseTest < Test::Unit::TestCase
|
|
51
51
|
rescue Exception
|
52
52
|
end
|
53
53
|
|
54
|
-
db.drop
|
54
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
55
55
|
assert(File.exist?(CREATE_FILE) == false)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test02
|
59
59
|
puts "Executing test02.\n\n"
|
60
|
-
db = Database.new(
|
60
|
+
db = Database.new(DB_FILE);
|
61
61
|
|
62
|
-
assert(db.user == DB_USER_NAME)
|
63
62
|
assert(db.file == DB_FILE)
|
64
63
|
|
65
|
-
c = db.connect
|
64
|
+
c = db.connect(DB_USER_NAME, DB_PASSWORD)
|
66
65
|
assert(c != nil)
|
67
66
|
c.close
|
68
67
|
end
|
69
68
|
|
70
69
|
def test03
|
71
|
-
db = Database.new(
|
70
|
+
db = Database.new(DB_FILE);
|
72
71
|
c = nil
|
73
72
|
|
74
|
-
db.connect do |connection|
|
73
|
+
db.connect(DB_USER_NAME, DB_PASSWORD) do |connection|
|
75
74
|
assert(connection != nil)
|
76
75
|
assert(connection.class == Connection)
|
77
76
|
assert(connection.open?)
|
data/test/GeneratorTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -17,7 +18,7 @@ class GeneratorTest < Test::Unit::TestCase
|
|
17
18
|
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
18
19
|
@connections = []
|
19
20
|
|
20
|
-
@connections.push(@database.connect)
|
21
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
21
22
|
end
|
22
23
|
|
23
24
|
def teardown
|
@@ -26,7 +27,7 @@ class GeneratorTest < Test::Unit::TestCase
|
|
26
27
|
end
|
27
28
|
@connections.clear
|
28
29
|
if File::exist?(DB_FILE)
|
29
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
30
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
data/test/ResultSetTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -12,13 +13,13 @@ class ResultSetTest < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def setup
|
14
15
|
if File::exist?(DB_FILE)
|
15
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
16
17
|
end
|
17
18
|
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
18
19
|
@connections = []
|
19
20
|
@transactions = []
|
20
21
|
|
21
|
-
@connections.push(@database.connect)
|
22
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
22
23
|
|
23
24
|
@connections[0].start_transaction do |tx|
|
24
25
|
tx.execute("CREATE TABLE TEST_TABLE (TESTID INTEGER NOT NULL "\
|
@@ -52,7 +53,7 @@ class ResultSetTest < Test::Unit::TestCase
|
|
52
53
|
end
|
53
54
|
@connections.clear
|
54
55
|
if File::exist?(DB_FILE)
|
55
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
56
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
@@ -65,7 +66,7 @@ class ResultSetTest < Test::Unit::TestCase
|
|
65
66
|
assert(r.statement == s)
|
66
67
|
|
67
68
|
assert(r.fetch != nil)
|
68
|
-
assert(r.fetch.class ==
|
69
|
+
assert(r.fetch.class == Row)
|
69
70
|
assert(r.fetch[0] == 30)
|
70
71
|
assert(r.fetch[1] == 'Record Four.')
|
71
72
|
r.fetch
|
data/test/RowTest.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'TestSetup'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
7
|
+
|
8
|
+
include FireRuby
|
9
|
+
|
10
|
+
class RowTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}row_unit_test.fdb"
|
13
|
+
|
14
|
+
def setup
|
15
|
+
if File::exist?(DB_FILE)
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
|
+
end
|
18
|
+
|
19
|
+
database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
20
|
+
@connection = database.connect(DB_USER_NAME, DB_PASSWORD)
|
21
|
+
@transaction = @connection.start_transaction
|
22
|
+
@statement = Statement.new(@connection, @transaction,
|
23
|
+
'SELECT * FROM RDB$FIELDS', 3)
|
24
|
+
@results = ResultSet.new(@statement)
|
25
|
+
@empty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
26
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0]
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
@results.close
|
31
|
+
@statement.close
|
32
|
+
@transaction.rollback
|
33
|
+
@connection.close
|
34
|
+
if File::exist?(DB_FILE)
|
35
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test01
|
40
|
+
row = Row.new(@results, @empty, 100)
|
41
|
+
|
42
|
+
assert(row.column_count == 28)
|
43
|
+
assert(row.number == 100)
|
44
|
+
assert(row.column_name(0) == 'RDB$FIELD_NAME')
|
45
|
+
assert(row.column_alias(10) == 'RDB$FIELD_TYPE')
|
46
|
+
assert(row[0] == 0)
|
47
|
+
assert(row['RDB$FIELD_TYPE'] == 0)
|
48
|
+
end
|
49
|
+
end
|
data/test/SQLTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -15,17 +16,17 @@ class SQLTest < Test::Unit::TestCase
|
|
15
16
|
|
16
17
|
def setup
|
17
18
|
if File::exist?(DB_FILE)
|
18
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
19
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
19
20
|
end
|
20
21
|
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD,
|
21
22
|
1024, 'ASCII')
|
22
23
|
@connections = []
|
23
24
|
@transactions = []
|
24
25
|
|
25
|
-
@database.connect do |cxn|
|
26
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
26
27
|
cxn.execute_immediate('CREATE TABLE TEST_TABLE (TESTID INTEGER '\
|
27
28
|
'NOT NULL PRIMARY KEY, TESTTEXT VARCHAR(100), '\
|
28
|
-
'TESTFLOAT
|
29
|
+
'TESTFLOAT NUMERIC(8,2), TESTDATE DATE, TESTTIME '\
|
29
30
|
'TIME, TESTSTAMP TIMESTAMP)')
|
30
31
|
end
|
31
32
|
end
|
@@ -39,13 +40,13 @@ class SQLTest < Test::Unit::TestCase
|
|
39
40
|
cxn.close if cxn.open?
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
if File::exist?(DB_FILE)
|
44
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
45
|
+
end
|
45
46
|
end
|
46
47
|
|
47
48
|
def test01
|
48
|
-
@database.connect do |cxn|
|
49
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
49
50
|
cxn.start_transaction do |tx|
|
50
51
|
s = Statement.new(cxn, tx, INSERT_SQL, 3)
|
51
52
|
f = 0.0
|
@@ -59,7 +60,7 @@ class SQLTest < Test::Unit::TestCase
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
|
-
@connections.push(@database.connect)
|
63
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
63
64
|
r = @connections[0].execute_immediate("SELECT COUNT(*) FROM TEST_TABLE")
|
64
65
|
assert(r.fetch[0] == ITERATIONS)
|
65
66
|
r.close
|
@@ -67,7 +68,7 @@ class SQLTest < Test::Unit::TestCase
|
|
67
68
|
|
68
69
|
def test02
|
69
70
|
f = 0.0
|
70
|
-
@database.connect do |cxn|
|
71
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
71
72
|
1.upto(20) do |i|
|
72
73
|
f += i
|
73
74
|
sql = "INSERT INTO TEST_TABLE VALUES (#{i}, "\
|
@@ -76,7 +77,7 @@ class SQLTest < Test::Unit::TestCase
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
@connections.push(@database.connect)
|
80
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
80
81
|
@transactions.push(@connections[0].start_transaction)
|
81
82
|
r = @transactions[0].execute("SELECT COUNT(*) FROM TEST_TABLE")
|
82
83
|
assert(r.fetch[0] == 20)
|
@@ -85,24 +86,39 @@ class SQLTest < Test::Unit::TestCase
|
|
85
86
|
r = @transactions[0].execute("SELECT * FROM TEST_TABLE WHERE TESTID IN "\
|
86
87
|
"(2, 4, 6, 8, 10) ORDER BY TESTID ASCENDING")
|
87
88
|
a = r.fetch
|
88
|
-
assert(a
|
89
|
-
assert(a ==
|
89
|
+
assert(a[0] == 2)
|
90
|
+
assert(a[1] == '3.0')
|
91
|
+
assert(a[2] == 3.0)
|
92
|
+
assert(a[3] == nil)
|
93
|
+
assert(a[4] == nil)
|
90
94
|
|
91
95
|
a = r.fetch
|
92
|
-
assert(a
|
93
|
-
assert(a ==
|
96
|
+
assert(a[0] == 4)
|
97
|
+
assert(a[1] == '10.0')
|
98
|
+
assert(a[2] == 10.0)
|
99
|
+
assert(a[3] == nil)
|
100
|
+
assert(a[4] == nil)
|
94
101
|
|
95
102
|
a = r.fetch
|
96
|
-
assert(a
|
97
|
-
assert(a ==
|
103
|
+
assert(a[0] == 6)
|
104
|
+
assert(a[1] == '21.0')
|
105
|
+
assert(a[2] == 21.0)
|
106
|
+
assert(a[3] == nil)
|
107
|
+
assert(a[4] == nil)
|
98
108
|
|
99
109
|
a = r.fetch
|
100
|
-
assert(a
|
101
|
-
assert(a ==
|
110
|
+
assert(a[0] == 8)
|
111
|
+
assert(a[1] == '36.0')
|
112
|
+
assert(a[2] == 36.0)
|
113
|
+
assert(a[3] == nil)
|
114
|
+
assert(a[4] == nil)
|
102
115
|
|
103
116
|
a = r.fetch
|
104
|
-
assert(a
|
105
|
-
assert(a ==
|
117
|
+
assert(a[0] == 10)
|
118
|
+
assert(a[1] == '55.0')
|
119
|
+
assert(a[2] == 55.0)
|
120
|
+
assert(a[3] == nil)
|
121
|
+
assert(a[4] == nil)
|
106
122
|
|
107
123
|
r.close
|
108
124
|
|
@@ -123,6 +139,7 @@ class SQLTest < Test::Unit::TestCase
|
|
123
139
|
end
|
124
140
|
|
125
141
|
a = []
|
142
|
+
t = nil
|
126
143
|
@connections[0].start_transaction do |tx|
|
127
144
|
# Perform an insert via a parameterized statement.
|
128
145
|
s = Statement.new(@connections[0], tx,
|
@@ -136,18 +153,18 @@ class SQLTest < Test::Unit::TestCase
|
|
136
153
|
"TEST_TABLE WHERE TESTID = 25000")
|
137
154
|
a = r.fetch
|
138
155
|
r.close
|
139
|
-
puts ['La la la', 3.14, t].join(', ')
|
140
|
-
puts a.join(', ')
|
141
156
|
end
|
142
|
-
assert(a ==
|
157
|
+
assert(a[0] == 'La la la')
|
158
|
+
assert(a[1] == 3.14)
|
159
|
+
assert(a[2].to_i == t.to_i)
|
143
160
|
|
144
161
|
@connections[0].execute_immediate("DELETE FROM TEST_TABLE WHERE TESTID "\
|
145
162
|
"IN (1, 3, 5, 7, 9, 12, 14, 16, 18, 20)")
|
146
|
-
@database.connect do |cxn|
|
163
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
147
164
|
r = cxn.execute_immediate("SELECT COUNT(*) FROM TEST_TABLE")
|
148
165
|
a = r.fetch
|
149
166
|
r.close
|
150
|
-
assert(a[0] ==
|
167
|
+
assert(a[0] == 11)
|
151
168
|
end
|
152
169
|
end
|
153
170
|
end
|
data/test/StatementTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -12,7 +13,7 @@ class StatementTest < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def setup
|
14
15
|
if File::exist?(DB_FILE)
|
15
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
16
17
|
end
|
17
18
|
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
18
19
|
@connections = []
|
@@ -29,12 +30,12 @@ class StatementTest < Test::Unit::TestCase
|
|
29
30
|
end
|
30
31
|
@connections.clear
|
31
32
|
if File::exist?(DB_FILE)
|
32
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
33
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
def test01
|
37
|
-
@connections.push(@database.connect)
|
38
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
38
39
|
@transactions.push(@connections.last.start_transaction)
|
39
40
|
|
40
41
|
s1 = Statement.new(@connections[0],
|
@@ -59,7 +60,7 @@ class StatementTest < Test::Unit::TestCase
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def test02
|
62
|
-
@connections.push(@database.connect)
|
63
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
63
64
|
@transactions.push(@connections[0].start_transaction)
|
64
65
|
|
65
66
|
s = Statement.new(@connections[0], @transactions[0],
|
data/test/TransactionTest.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
|
-
require '
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
6
7
|
|
7
8
|
include FireRuby
|
8
9
|
|
@@ -12,16 +13,16 @@ class TransactionTest < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def setup
|
14
15
|
if File::exist?(DB_FILE)
|
15
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
16
17
|
end
|
17
18
|
|
18
19
|
@database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
19
20
|
@connections = []
|
20
21
|
@transactions = []
|
21
22
|
|
22
|
-
@connections.push(@database.connect)
|
23
|
-
@connections.push(@database.connect)
|
24
|
-
@connections.push(@database.connect)
|
23
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
24
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
25
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
25
26
|
end
|
26
27
|
|
27
28
|
def teardown
|
@@ -33,7 +34,7 @@ class TransactionTest < Test::Unit::TestCase
|
|
33
34
|
cxn.close if cxn.open?
|
34
35
|
end
|
35
36
|
if File::exist?(DB_FILE)
|
36
|
-
Database.new(DB_USER_NAME, DB_PASSWORD
|
37
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|