fireruby 0.3.2-i586-linux → 0.4.0-i586-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/CVS/Entries +4 -0
- data/doc/CVS/Repository +1 -0
- data/doc/CVS/Root +1 -0
- data/doc/README +86 -34
- data/doc/classes/CVS/Entries +1 -0
- data/doc/classes/CVS/Repository +1 -0
- data/doc/classes/CVS/Root +1 -0
- data/doc/classes/FireRuby/CVS/Entries +7 -0
- data/doc/classes/FireRuby/CVS/Repository +1 -0
- data/doc/classes/FireRuby/CVS/Root +1 -0
- data/doc/classes/FireRuby/Connection.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/Connection.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/Connection.src/CVS/Root +1 -0
- data/doc/classes/FireRuby/Database.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/Database.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/Database.src/CVS/Root +1 -0
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Root +1 -0
- data/doc/classes/FireRuby/Generator.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/Generator.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/Generator.src/CVS/Root +1 -0
- data/doc/classes/FireRuby/ResultSet.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/ResultSet.src/CVS/Root +1 -0
- data/doc/classes/FireRuby/Statement.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/Statement.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/Statement.src/CVS/Root +1 -0
- data/doc/classes/FireRuby/Transaction.src/CVS/Entries +1 -0
- data/doc/classes/FireRuby/Transaction.src/CVS/Repository +1 -0
- data/doc/classes/FireRuby/Transaction.src/CVS/Root +1 -0
- data/doc/files/CVS/Entries +1 -0
- data/doc/files/CVS/Repository +1 -0
- data/doc/files/CVS/Root +1 -0
- data/examples/CVS/Entries +2 -0
- data/examples/CVS/Repository +1 -0
- data/examples/CVS/Root +1 -0
- data/examples/example01.rb +9 -4
- data/lib/CVS/Entries +6 -0
- data/lib/CVS/Repository +1 -0
- data/lib/CVS/Root +1 -0
- data/lib/SQLType.rb +228 -0
- data/lib/fireruby.rb +22 -0
- data/lib/fr_lib.so +0 -0
- data/lib/src.rb +52 -6
- data/test/AddRemoveUserTest.rb +7 -2
- data/test/BackupRestoreTest.rb +3 -1
- data/test/CVS/Entries +20 -0
- data/test/CVS/Repository +1 -0
- data/test/CVS/Root +1 -0
- data/test/CharacterSetTest.rb +5 -2
- data/test/ConnectionTest.rb +3 -1
- data/test/DDLTest.rb +3 -1
- data/test/DatabaseTest.rb +3 -1
- data/test/GeneratorTest.rb +3 -1
- data/test/KeyTest.rb +140 -0
- data/test/ResultSetTest.rb +34 -3
- data/test/RowCountTest.rb +3 -1
- data/test/RowTest.rb +90 -24
- data/test/SQLTest.rb +4 -1
- data/test/SQLTypeTest.rb +101 -0
- data/test/ServiceManagerTest.rb +10 -2
- data/test/StatementTest.rb +18 -7
- data/test/TestSetup.rb +1 -0
- data/test/TransactionTest.rb +4 -1
- data/test/TypeTest.rb +92 -0
- data/test/UnitTest.rb +61 -15
- data/test/UnitTest.rb~ +64 -0
- metadata +84 -20
- data/lib/fireruby.so +0 -0
data/test/RowTest.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
5
|
require 'rubygems'
|
6
|
-
|
6
|
+
require 'fireruby'
|
7
7
|
|
8
8
|
include FireRuby
|
9
9
|
|
@@ -12,6 +12,7 @@ class RowTest < Test::Unit::TestCase
|
|
12
12
|
DB_FILE = "#{CURDIR}#{File::SEPARATOR}row_unit_test.fdb"
|
13
13
|
|
14
14
|
def setup
|
15
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
15
16
|
if File::exist?(DB_FILE)
|
16
17
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
18
|
end
|
@@ -21,12 +22,42 @@ class RowTest < Test::Unit::TestCase
|
|
21
22
|
@transaction = @connection.start_transaction
|
22
23
|
@results = ResultSet.new(@connection, @transaction,
|
23
24
|
'SELECT * FROM RDB$FIELDS', 3, nil)
|
24
|
-
@empty = [0,
|
25
|
-
0,
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
@empty = [[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
26
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
27
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
28
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
29
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
30
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
31
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
32
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
33
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
34
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
35
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
36
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
37
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER],
|
38
|
+
[0, SQLType::INTEGER], [0, SQLType::INTEGER]]
|
39
|
+
|
40
|
+
@connection.start_transaction do |tx|
|
41
|
+
tx.execute('create table rowtest (COL01 integer, COL02 varchar(10), '\
|
42
|
+
'COL03 integer)')
|
43
|
+
tx.execute('create table all_types (col01 bigint, col02 blob, '\
|
44
|
+
'col03 char(100), col04 date, col05 decimal(5,2), '\
|
45
|
+
'col06 double precision, col07 float, col08 integer, '\
|
46
|
+
'col09 numeric(10,3), col10 smallint, col11 time, '\
|
47
|
+
'col12 timestamp, col13 varchar(23))')
|
48
|
+
end
|
49
|
+
@connection.start_transaction do |tx|
|
50
|
+
tx.execute("insert into rowtest values (1, 'Two', 3)")
|
51
|
+
|
52
|
+
stmt = Statement.new(@connection, tx,
|
53
|
+
"insert into all_types values(?, ?, ?, ?, ?, ?, "\
|
54
|
+
"?, ?, ?, ?, ?, ?, ?)",
|
55
|
+
3)
|
56
|
+
#stmt.execute_for([nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil])
|
57
|
+
stmt.execute_for([100000, nil, 'La la la', Date.new(2005, 10, 29),
|
58
|
+
10.23, 100.751, 56.25, 12345, 19863.21, 123,
|
59
|
+
Time.new, Time.new, 'The End!'])
|
60
|
+
end
|
30
61
|
end
|
31
62
|
|
32
63
|
def teardown
|
@@ -36,6 +67,7 @@ class RowTest < Test::Unit::TestCase
|
|
36
67
|
if File::exist?(DB_FILE)
|
37
68
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
38
69
|
end
|
70
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
71
|
end
|
40
72
|
|
41
73
|
def test01
|
@@ -56,7 +88,7 @@ class RowTest < Test::Unit::TestCase
|
|
56
88
|
|
57
89
|
count = 0
|
58
90
|
data.each do |name, value|
|
59
|
-
assert(['
|
91
|
+
assert(['ONE', 'TWO', 'THREE'].include?(name))
|
60
92
|
assert([1, 'Two', 3].include?(value))
|
61
93
|
count += 1
|
62
94
|
end
|
@@ -64,7 +96,7 @@ class RowTest < Test::Unit::TestCase
|
|
64
96
|
|
65
97
|
count = 0
|
66
98
|
data.each_key do |name|
|
67
|
-
assert(['
|
99
|
+
assert(['ONE', 'TWO', 'THREE'].include?(name))
|
68
100
|
count += 1
|
69
101
|
end
|
70
102
|
assert(count == 3)
|
@@ -76,17 +108,20 @@ class RowTest < Test::Unit::TestCase
|
|
76
108
|
end
|
77
109
|
assert(count == 3)
|
78
110
|
|
79
|
-
assert(data.fetch('
|
80
|
-
assert(data.fetch('
|
81
|
-
assert(data.fetch('
|
111
|
+
assert(data.fetch('TWO') == 'Two')
|
112
|
+
assert(data.fetch('FOUR', 'LALALA') == 'LALALA')
|
113
|
+
assert(data.fetch('ZERO') {'NOT FOUND'} == 'NOT FOUND')
|
82
114
|
begin
|
83
|
-
data.fetch('
|
115
|
+
data.fetch('FIVE')
|
84
116
|
assert(false, 'Row#fetch succeeded for non-existent column name.')
|
85
117
|
rescue IndexError
|
86
118
|
end
|
87
119
|
|
88
|
-
assert(data.has_key?('
|
89
|
-
assert(data.has_key?('
|
120
|
+
assert(data.has_key?('ONE'))
|
121
|
+
assert(data.has_key?('TEN') == false)
|
122
|
+
|
123
|
+
assert(data.has_column?('COL02'))
|
124
|
+
assert(data.has_column?('COL22') == false)
|
90
125
|
|
91
126
|
assert(data.has_alias?('TWO'))
|
92
127
|
assert(data.has_alias?('FOUR') == false)
|
@@ -96,6 +131,11 @@ class RowTest < Test::Unit::TestCase
|
|
96
131
|
|
97
132
|
assert(data.keys.size == 3)
|
98
133
|
data.keys.each do |name|
|
134
|
+
assert(['ONE', 'TWO', 'THREE'].include?(name))
|
135
|
+
end
|
136
|
+
|
137
|
+
assert(data.names.size == 3)
|
138
|
+
data.names.each do |name|
|
99
139
|
assert(['COL01', 'COL02', 'COL03'].include?(name))
|
100
140
|
end
|
101
141
|
|
@@ -109,24 +149,24 @@ class RowTest < Test::Unit::TestCase
|
|
109
149
|
assert([1, 'Two', 3].include?(value))
|
110
150
|
end
|
111
151
|
|
112
|
-
array = data.select {|name, value| name == '
|
152
|
+
array = data.select {|name, value| name == 'TWO'}
|
113
153
|
assert(array.size == 1)
|
114
|
-
assert(array[0][0] == '
|
154
|
+
assert(array[0][0] == 'TWO')
|
115
155
|
assert(array[0][1] == 'Two')
|
116
156
|
|
117
157
|
array = data.to_a
|
118
158
|
assert(array.size == 3)
|
119
|
-
assert(array.include?(['
|
120
|
-
assert(array.include?(['
|
121
|
-
assert(array.include?(['
|
159
|
+
assert(array.include?(['ONE', 1]))
|
160
|
+
assert(array.include?(['TWO', 'Two']))
|
161
|
+
assert(array.include?(['THREE', 3]))
|
122
162
|
|
123
163
|
hash = data.to_hash
|
124
164
|
assert(hash.length == 3)
|
125
|
-
assert(hash['
|
126
|
-
assert(hash['
|
127
|
-
assert(hash['
|
165
|
+
assert(hash['ONE'] == 1)
|
166
|
+
assert(hash['TWO'] == 'Two')
|
167
|
+
assert(hash['THREE'] == 3)
|
128
168
|
|
129
|
-
array = data.values_at('
|
169
|
+
array = data.values_at('TEN', 'TWO', 'THREE')
|
130
170
|
assert(array.size == 3)
|
131
171
|
assert(array.include?('Two'))
|
132
172
|
assert(array.include?(3))
|
@@ -134,4 +174,30 @@ class RowTest < Test::Unit::TestCase
|
|
134
174
|
|
135
175
|
rows.close
|
136
176
|
end
|
177
|
+
|
178
|
+
def test03
|
179
|
+
results = nil
|
180
|
+
row = nil
|
181
|
+
|
182
|
+
begin
|
183
|
+
results = @connection.execute_immediate('select * from all_types')
|
184
|
+
row = results.fetch
|
185
|
+
|
186
|
+
assert(row.get_base_type(0) == SQLType::BIGINT)
|
187
|
+
assert(row.get_base_type(1) == SQLType::BLOB)
|
188
|
+
assert(row.get_base_type(2) == SQLType::CHAR)
|
189
|
+
assert(row.get_base_type(3) == SQLType::DATE)
|
190
|
+
assert(row.get_base_type(4) == SQLType::DECIMAL)
|
191
|
+
assert(row.get_base_type(5) == SQLType::DOUBLE)
|
192
|
+
assert(row.get_base_type(6) == SQLType::FLOAT)
|
193
|
+
assert(row.get_base_type(7) == SQLType::INTEGER)
|
194
|
+
assert(row.get_base_type(8) == SQLType::NUMERIC)
|
195
|
+
assert(row.get_base_type(9) == SQLType::SMALLINT)
|
196
|
+
assert(row.get_base_type(10) == SQLType::TIME)
|
197
|
+
assert(row.get_base_type(11) == SQLType::TIMESTAMP)
|
198
|
+
assert(row.get_base_type(12) == SQLType::VARCHAR)
|
199
|
+
ensure
|
200
|
+
results.close if results != nil
|
201
|
+
end
|
202
|
+
end
|
137
203
|
end
|
data/test/SQLTest.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
5
|
require 'rubygems'
|
6
|
-
|
6
|
+
require 'fireruby'
|
7
7
|
|
8
8
|
include FireRuby
|
9
9
|
|
@@ -15,6 +15,7 @@ class SQLTest < Test::Unit::TestCase
|
|
15
15
|
INSERT_SQL = "INSERT INTO TEST_TABLE VALUES(?, ?, ?, ?, ?, ?)"
|
16
16
|
|
17
17
|
def setup
|
18
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
18
19
|
if File::exist?(DB_FILE)
|
19
20
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
20
21
|
end
|
@@ -42,6 +43,7 @@ class SQLTest < Test::Unit::TestCase
|
|
42
43
|
if File::exist?(DB_FILE)
|
43
44
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
44
45
|
end
|
46
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
45
47
|
end
|
46
48
|
|
47
49
|
def test01
|
@@ -140,6 +142,7 @@ class SQLTest < Test::Unit::TestCase
|
|
140
142
|
total = total + 1
|
141
143
|
end
|
142
144
|
assert(total == 20)
|
145
|
+
r.close
|
143
146
|
end
|
144
147
|
|
145
148
|
a = []
|
data/test/SQLTypeTest.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'TestSetup'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'fireruby'
|
7
|
+
|
8
|
+
include FireRuby
|
9
|
+
|
10
|
+
class SQLTypeTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_type_test.fdb"
|
13
|
+
|
14
|
+
def setup
|
15
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
16
|
+
if File::exist?(DB_FILE)
|
17
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
18
|
+
end
|
19
|
+
|
20
|
+
@database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
21
|
+
@connection = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
22
|
+
|
23
|
+
@connection.start_transaction do |tx|
|
24
|
+
tx.execute("create table all_types (col01 bigint, col02 blob, "\
|
25
|
+
"col03 char(100), col04 date, col05 decimal(5,2), "\
|
26
|
+
"col06 double precision, col07 float, col08 integer, "\
|
27
|
+
"col09 numeric(10,3), col10 smallint, col11 time, "\
|
28
|
+
"col12 timestamp, col13 varchar(23))")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
@connection.close if @connection != nil && @connection.open?
|
34
|
+
|
35
|
+
if File::exist?(DB_FILE)
|
36
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
37
|
+
end
|
38
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
|
+
end
|
40
|
+
|
41
|
+
def test01
|
42
|
+
types = []
|
43
|
+
types.push(SQLType.new(SQLType::BIGINT))
|
44
|
+
types.push(SQLType.new(SQLType::VARCHAR, 1000))
|
45
|
+
types.push(SQLType.new(SQLType::DECIMAL, nil, 10))
|
46
|
+
types.push(SQLType.new(SQLType::NUMERIC, nil, 5, 3))
|
47
|
+
types.push(SQLType.new(SQLType::BLOB, nil, nil, nil, 1))
|
48
|
+
|
49
|
+
assert(types[0] == types[0])
|
50
|
+
assert(!(types[0] == types[1]))
|
51
|
+
assert(types[1] == SQLType.new(SQLType::VARCHAR, 1000))
|
52
|
+
|
53
|
+
assert(types[0].type == SQLType::BIGINT)
|
54
|
+
assert(types[0].length == nil)
|
55
|
+
assert(types[0].precision == nil)
|
56
|
+
assert(types[0].scale == nil)
|
57
|
+
assert(types[0].subtype == nil)
|
58
|
+
|
59
|
+
assert(types[1].type == SQLType::VARCHAR)
|
60
|
+
assert(types[1].length == 1000)
|
61
|
+
assert(types[1].precision == nil)
|
62
|
+
assert(types[1].scale == nil)
|
63
|
+
assert(types[1].subtype == nil)
|
64
|
+
|
65
|
+
assert(types[2].type == SQLType::DECIMAL)
|
66
|
+
assert(types[2].length == nil)
|
67
|
+
assert(types[2].precision == 10)
|
68
|
+
assert(types[2].scale == nil)
|
69
|
+
assert(types[2].subtype == nil)
|
70
|
+
|
71
|
+
assert(types[3].type == SQLType::NUMERIC)
|
72
|
+
assert(types[3].length == nil)
|
73
|
+
assert(types[3].precision == 5)
|
74
|
+
assert(types[3].scale == 3)
|
75
|
+
assert(types[3].subtype == nil)
|
76
|
+
|
77
|
+
assert(types[4].type == SQLType::BLOB)
|
78
|
+
assert(types[4].length == nil)
|
79
|
+
assert(types[4].precision == nil)
|
80
|
+
assert(types[4].scale == nil)
|
81
|
+
assert(types[4].subtype == 1)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test02
|
85
|
+
types = SQLType.for_table("all_types", @connection)
|
86
|
+
|
87
|
+
assert(types['COL01'] == SQLType.new(SQLType::BIGINT))
|
88
|
+
assert(types['COL02'] == SQLType.new(SQLType::BLOB, nil, nil, nil, 0))
|
89
|
+
assert(types['COL03'] == SQLType.new(SQLType::CHAR, 100))
|
90
|
+
assert(types['COL04'] == SQLType.new(SQLType::DATE))
|
91
|
+
assert(types['COL05'] == SQLType.new(SQLType::DECIMAL, nil, 5, 2))
|
92
|
+
assert(types['COL06'] == SQLType.new(SQLType::DOUBLE))
|
93
|
+
assert(types['COL07'] == SQLType.new(SQLType::FLOAT))
|
94
|
+
assert(types['COL08'] == SQLType.new(SQLType::INTEGER))
|
95
|
+
assert(types['COL09'] == SQLType.new(SQLType::NUMERIC, nil, 10, 3))
|
96
|
+
assert(types['COL10'] == SQLType.new(SQLType::SMALLINT))
|
97
|
+
assert(types['COL11'] == SQLType.new(SQLType::TIME))
|
98
|
+
assert(types['COL12'] == SQLType.new(SQLType::TIMESTAMP))
|
99
|
+
assert(types['COL13'] == SQLType.new(SQLType::VARCHAR, 23))
|
100
|
+
end
|
101
|
+
end
|
data/test/ServiceManagerTest.rb
CHANGED
@@ -3,11 +3,19 @@
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
5
|
require 'rubygems'
|
6
|
-
|
6
|
+
require 'fireruby'
|
7
7
|
|
8
8
|
include FireRuby
|
9
9
|
|
10
10
|
class ServiceManagerTest < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
17
|
+
end
|
18
|
+
|
11
19
|
def test01
|
12
20
|
sm = ServiceManager.new('localhost')
|
13
21
|
assert(sm.connected? == false)
|
@@ -18,4 +26,4 @@ class ServiceManagerTest < Test::Unit::TestCase
|
|
18
26
|
assert(sm.disconnect == sm)
|
19
27
|
assert(sm.connected? == false)
|
20
28
|
end
|
21
|
-
end
|
29
|
+
end
|
data/test/StatementTest.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
5
|
require 'rubygems'
|
6
|
-
|
6
|
+
require 'fireruby'
|
7
7
|
|
8
8
|
include FireRuby
|
9
9
|
|
@@ -12,6 +12,7 @@ class StatementTest < Test::Unit::TestCase
|
|
12
12
|
DB_FILE = "#{CURDIR}#{File::SEPARATOR}stmt_unit_test.fdb"
|
13
13
|
|
14
14
|
def setup
|
15
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
15
16
|
if File::exist?(DB_FILE)
|
16
17
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
18
|
end
|
@@ -32,6 +33,7 @@ class StatementTest < Test::Unit::TestCase
|
|
32
33
|
if File::exist?(DB_FILE)
|
33
34
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
34
35
|
end
|
36
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
35
37
|
end
|
36
38
|
|
37
39
|
def test01
|
@@ -47,6 +49,7 @@ class StatementTest < Test::Unit::TestCase
|
|
47
49
|
assert(s1.transaction == @transactions[0])
|
48
50
|
assert(s1.dialect == 3)
|
49
51
|
assert(s1.type == Statement::SELECT_STATEMENT)
|
52
|
+
s1.close
|
50
53
|
|
51
54
|
s2 = Statement.new(@connections[0],
|
52
55
|
@transactions[0],
|
@@ -57,6 +60,7 @@ class StatementTest < Test::Unit::TestCase
|
|
57
60
|
assert(s2.transaction == @transactions[0])
|
58
61
|
assert(s2.dialect == 1)
|
59
62
|
assert(s2.type == Statement::DELETE_STATEMENT)
|
63
|
+
s2.close
|
60
64
|
end
|
61
65
|
|
62
66
|
def test02
|
@@ -68,7 +72,8 @@ class StatementTest < Test::Unit::TestCase
|
|
68
72
|
"WHERE RDB$FIELD_NAME LIKE ?", 3)
|
69
73
|
|
70
74
|
begin
|
71
|
-
s.execute
|
75
|
+
r = s.execute
|
76
|
+
r.close
|
72
77
|
assert(false,
|
73
78
|
"Executed statement that required parameter without the "\
|
74
79
|
"parameter being specified.")
|
@@ -76,7 +81,8 @@ class StatementTest < Test::Unit::TestCase
|
|
76
81
|
end
|
77
82
|
|
78
83
|
begin
|
79
|
-
s.execute_for([])
|
84
|
+
r = s.execute_for([])
|
85
|
+
r.close
|
80
86
|
assert(false,
|
81
87
|
"Executed statement that required a parameter with an empty "\
|
82
88
|
"parameter set.")
|
@@ -84,20 +90,25 @@ class StatementTest < Test::Unit::TestCase
|
|
84
90
|
end
|
85
91
|
|
86
92
|
begin
|
87
|
-
s.execute_for(['LALALA', 25])
|
93
|
+
r = s.execute_for(['LALALA', 25])
|
94
|
+
r.close
|
88
95
|
assert(false,
|
89
96
|
"Executed statement that required a parameter with too many "\
|
90
97
|
"parameters.")
|
91
98
|
rescue Exception => error
|
92
99
|
end
|
93
100
|
|
94
|
-
|
95
|
-
assert(
|
101
|
+
r = s.execute_for(['LALALA'])
|
102
|
+
assert(r != nil)
|
103
|
+
assert(r.class == ResultSet)
|
104
|
+
r.close
|
105
|
+
|
96
106
|
total = 0
|
97
107
|
s.execute_for(["%"]) do |row|
|
98
108
|
total = total + 1
|
99
109
|
end
|
100
110
|
assert(total = 88)
|
111
|
+
s.close
|
101
112
|
end
|
102
113
|
|
103
114
|
def test03
|
@@ -105,7 +116,7 @@ class StatementTest < Test::Unit::TestCase
|
|
105
116
|
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
106
117
|
cxn.execute_immediate('CREATE TABLE STRING_TEST(TEXT VARCHAR(10))')
|
107
118
|
cxn.start_transaction do |tx|
|
108
|
-
# Perform an
|
119
|
+
# Perform an truncated insert.
|
109
120
|
s = Statement.new(cxn, tx, 'INSERT INTO STRING_TEST VALUES(?)', 3)
|
110
121
|
s.execute_for(['012345678901234'])
|
111
122
|
|
data/test/TestSetup.rb
CHANGED
data/test/TransactionTest.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'TestSetup'
|
4
4
|
require 'test/unit'
|
5
5
|
require 'rubygems'
|
6
|
-
|
6
|
+
require 'fireruby'
|
7
7
|
|
8
8
|
include FireRuby
|
9
9
|
|
@@ -12,6 +12,7 @@ class TransactionTest < Test::Unit::TestCase
|
|
12
12
|
DB_FILE = "#{CURDIR}#{File::SEPARATOR}tx_unit_test.fdb"
|
13
13
|
|
14
14
|
def setup
|
15
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
15
16
|
if File::exist?(DB_FILE)
|
16
17
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
18
|
end
|
@@ -36,6 +37,7 @@ class TransactionTest < Test::Unit::TestCase
|
|
36
37
|
if File::exist?(DB_FILE)
|
37
38
|
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
38
39
|
end
|
40
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
41
|
end
|
40
42
|
|
41
43
|
def test01
|
@@ -99,6 +101,7 @@ class TransactionTest < Test::Unit::TestCase
|
|
99
101
|
r = @transactions[0].execute(sql[1])
|
100
102
|
assert(r != nil)
|
101
103
|
assert(r.class == ResultSet)
|
104
|
+
r.close
|
102
105
|
|
103
106
|
total = 0
|
104
107
|
@transactions[0].execute(sql[1]) do |row|
|
data/test/TypeTest.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'TestSetup'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'fireruby'
|
7
|
+
require 'date'
|
8
|
+
|
9
|
+
include FireRuby
|
10
|
+
|
11
|
+
class TypeTest < Test::Unit::TestCase
|
12
|
+
CURDIR = "#{Dir.getwd}"
|
13
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}types_unit_test.fdb"
|
14
|
+
|
15
|
+
def setup
|
16
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
17
|
+
if File.exist?(DB_FILE)
|
18
|
+
db = Database.new(DB_FILE)
|
19
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
20
|
+
end
|
21
|
+
@db = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
22
|
+
cxn = @db.connect(DB_USER_NAME, DB_PASSWORD)
|
23
|
+
cxn.start_transaction do |tx|
|
24
|
+
tx.execute("create table types_table (COL01 integer, "\
|
25
|
+
"COL02 float, COL03 decimal(10,2), "\
|
26
|
+
"COL04 numeric(5,3), COL05 date, COL06 timestamp, "\
|
27
|
+
"COL07 char(10), COL08 time, COL09 varchar(30))")
|
28
|
+
end
|
29
|
+
|
30
|
+
cxn.start_transaction do |tx|
|
31
|
+
stmt = Statement.new(cxn, tx, "insert into types_table values "\
|
32
|
+
"(?, ?, ?, ?, ?, ?, ?, ?, ?)", 3)
|
33
|
+
stmt.execute_for([10, 100.2, 2378.65, 192.345,
|
34
|
+
Date.new(2005, 10, 21), Time.new, 'La la la',
|
35
|
+
Time.new, "Oobly Joobly"])
|
36
|
+
stmt.close
|
37
|
+
end
|
38
|
+
cxn.close
|
39
|
+
end
|
40
|
+
|
41
|
+
def teardown
|
42
|
+
if File::exist?(DB_FILE)
|
43
|
+
@db.drop(DB_USER_NAME, DB_PASSWORD)
|
44
|
+
end
|
45
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
46
|
+
end
|
47
|
+
|
48
|
+
def test01
|
49
|
+
rows = cxn = nil
|
50
|
+
begin
|
51
|
+
cxn = @db.connect(DB_USER_NAME, DB_PASSWORD)
|
52
|
+
rows = cxn.execute_immediate('select * from types_table')
|
53
|
+
row = rows.fetch
|
54
|
+
assert(row[0].kind_of?(Integer))
|
55
|
+
assert(row[1].instance_of?(Float))
|
56
|
+
assert(row[2].instance_of?(Float))
|
57
|
+
assert(row[3].instance_of?(Float))
|
58
|
+
assert(row[4].instance_of?(Date))
|
59
|
+
assert(row[5].instance_of?(Time))
|
60
|
+
assert(row[6].instance_of?(String))
|
61
|
+
assert(row[7].instance_of?(Time))
|
62
|
+
assert(row[8].instance_of?(String))
|
63
|
+
ensure
|
64
|
+
rows.close if rows != nil
|
65
|
+
cxn.close if cxn != nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test02
|
70
|
+
$FireRubySettings[:DATE_AS_DATE] = false
|
71
|
+
rows = cxn = nil
|
72
|
+
begin
|
73
|
+
cxn = @db.connect(DB_USER_NAME, DB_PASSWORD)
|
74
|
+
rows = cxn.execute_immediate('select * from types_table')
|
75
|
+
row = rows.fetch
|
76
|
+
assert(row[0].kind_of?(Integer))
|
77
|
+
assert(row[1].instance_of?(Float))
|
78
|
+
assert(row[2].instance_of?(Float))
|
79
|
+
assert(row[3].instance_of?(Float))
|
80
|
+
assert(row[4].instance_of?(Time))
|
81
|
+
assert(row[5].instance_of?(Time))
|
82
|
+
assert(row[6].instance_of?(String))
|
83
|
+
assert(row[7].instance_of?(Time))
|
84
|
+
assert(row[8].instance_of?(String))
|
85
|
+
rows.close
|
86
|
+
ensure
|
87
|
+
rows.close if rows != nil
|
88
|
+
cxn.close if cxn != nil
|
89
|
+
end
|
90
|
+
$FireRubySettings[:DATE_AS_DATE] = true
|
91
|
+
end
|
92
|
+
end
|
data/test/UnitTest.rb
CHANGED
@@ -1,18 +1,64 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
#-------------------------------------------------------------------------------
|
4
|
+
# Old Unit Test Suite
|
5
|
+
#
|
6
|
+
# This code has been dropped for two reasons. First, adding new tests requires
|
7
|
+
# that this code be updated. Second, running the tests in a single Ruby
|
8
|
+
# interpreter seems to cause issues as the tests create, use and drop a lot of
|
9
|
+
# database files and this seems to cause intermittent problems with one or more
|
10
|
+
# of the test scripts that doesn't occur when the script is run on its own.
|
11
|
+
# Changing the number of scripts run also seemed to cause the problems to go
|
12
|
+
# away. It didn't seem to matter which scripts where left out which leads me
|
13
|
+
# to believe that the problem is related to timing issues.
|
14
|
+
#
|
15
|
+
# The new unit test suite, below, searches the directory for unit test files
|
16
|
+
# and executes each in their own interpreter. I have left this code here for
|
17
|
+
# reference purposes.
|
18
|
+
#-------------------------------------------------------------------------------
|
19
|
+
#require 'DatabaseTest'
|
20
|
+
#require 'ConnectionTest'
|
21
|
+
#require 'TransactionTest'
|
22
|
+
#require 'StatementTest'
|
23
|
+
#require 'ResultSetTest'
|
24
|
+
#require 'RowCountTest'
|
25
|
+
#require 'RowTest'
|
26
|
+
#require 'GeneratorTest'
|
27
|
+
#require 'DDLTest'
|
28
|
+
#require 'SQLTest'
|
29
|
+
#require 'ServiceManagerTest'
|
30
|
+
#require 'CharacterSetTest'
|
31
|
+
#require 'KeyTest'
|
32
|
+
#require 'TypeTest'
|
33
|
+
#require 'SQLTypeTest'
|
34
|
+
#if PLATFORM.include?('powerpc-darwin') == false
|
35
|
+
# require 'BackupRestoreTest'
|
36
|
+
# require 'AddRemoveUserTest'
|
37
|
+
#end
|
38
|
+
#-------------------------------------------------------------------------------
|
39
|
+
SPECIALS = ['AddRemoveUserTest',
|
40
|
+
'BackupRestoreTest',
|
41
|
+
'ServiceManagerTest']
|
42
|
+
begin
|
43
|
+
files = Dir.entries(".")
|
44
|
+
files.reject! do |name|
|
45
|
+
['.', '..', 'UnitTest.rb'].include?(name) or
|
46
|
+
name[-7,7] != 'Test.rb'
|
47
|
+
end
|
48
|
+
files.each do |name|
|
49
|
+
execute = true
|
50
|
+
if SPECIALS.include?(name)
|
51
|
+
execute = !(PLATFORM.include?('powerpc-darwin'))
|
52
|
+
end
|
53
|
+
|
54
|
+
if execute
|
55
|
+
system("ruby #{name}")
|
56
|
+
|
57
|
+
if $? != 0
|
58
|
+
raise StandardError.new("Error executing '#{name}'. Testing terminated.")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
rescue => error
|
63
|
+
puts "\n\nERROR: #{error.message}"
|
18
64
|
end
|