fireruby 0.2.2-mswin32 → 0.3.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/doc/CVS/Entries +2 -3
  2. data/doc/CVS/Entries.Log +2 -0
  3. data/doc/README +149 -53
  4. data/doc/classes/CVS/Entries +1 -0
  5. data/doc/classes/CVS/Entries.Log +1 -0
  6. data/doc/classes/CVS/Repository +1 -0
  7. data/doc/classes/CVS/Root +1 -0
  8. data/doc/classes/FireRuby/CVS/Entries +1 -0
  9. data/doc/classes/FireRuby/CVS/Entries.Log +7 -0
  10. data/doc/classes/FireRuby/CVS/Repository +1 -0
  11. data/doc/classes/FireRuby/CVS/Root +1 -0
  12. data/doc/classes/FireRuby/Connection.src/CVS/Entries +1 -0
  13. data/doc/classes/FireRuby/Connection.src/CVS/Repository +1 -0
  14. data/doc/classes/FireRuby/Connection.src/CVS/Root +1 -0
  15. data/doc/classes/FireRuby/Database.src/CVS/Entries +1 -0
  16. data/doc/classes/FireRuby/Database.src/CVS/Repository +1 -0
  17. data/doc/classes/FireRuby/Database.src/CVS/Root +1 -0
  18. data/doc/classes/FireRuby/FireRubyError.src/CVS/Entries +1 -0
  19. data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +1 -0
  20. data/doc/classes/FireRuby/FireRubyError.src/CVS/Root +1 -0
  21. data/doc/classes/FireRuby/Generator.src/CVS/Entries +1 -0
  22. data/doc/classes/FireRuby/Generator.src/CVS/Repository +1 -0
  23. data/doc/classes/FireRuby/Generator.src/CVS/Root +1 -0
  24. data/doc/classes/FireRuby/ResultSet.src/CVS/Entries +1 -0
  25. data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +1 -0
  26. data/doc/classes/FireRuby/ResultSet.src/CVS/Root +1 -0
  27. data/doc/classes/FireRuby/Statement.src/CVS/Entries +1 -0
  28. data/doc/classes/FireRuby/Statement.src/CVS/Repository +1 -0
  29. data/doc/classes/FireRuby/Statement.src/CVS/Root +1 -0
  30. data/doc/classes/FireRuby/Transaction.src/CVS/Entries +1 -0
  31. data/doc/classes/FireRuby/Transaction.src/CVS/Repository +1 -0
  32. data/doc/classes/FireRuby/Transaction.src/CVS/Root +1 -0
  33. data/doc/files/CVS/Entries +1 -0
  34. data/doc/files/CVS/Repository +1 -0
  35. data/doc/files/CVS/Root +1 -0
  36. data/lib/CVS/Entries +1 -1
  37. data/lib/fireruby.so +0 -0
  38. data/lib/src.rb +807 -25
  39. data/test/AddRemoveUserTest.rb +50 -0
  40. data/test/BackupRestoreTest.rb +97 -0
  41. data/test/CVS/Entries +13 -9
  42. data/test/ConnectionTest.rb +1 -1
  43. data/test/DDLTest.rb +10 -8
  44. data/test/GeneratorTest.rb +2 -2
  45. data/test/ResultSetTest.rb +42 -8
  46. data/test/RowCountTest.rb +63 -0
  47. data/test/RowTest.rb +93 -5
  48. data/test/SQLTest.rb +16 -8
  49. data/test/ServiceManagerTest.rb +21 -0
  50. data/test/StatementTest.rb +3 -3
  51. data/test/TransactionTest.rb +6 -5
  52. data/test/UnitTest.rb +6 -0
  53. metadata +60 -4
  54. data/lib/fireruby.bundle +0 -0
@@ -0,0 +1,50 @@
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 AddRemoveUserTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}add_remove_user_unit_test.fdb"
13
+
14
+ def setup
15
+ # Remove existing database files.
16
+ @database = Database.new(DB_FILE)
17
+ if File.exist?(DB_FILE)
18
+ @database.drop(DB_USER_NAME, DB_PASSWORD)
19
+ end
20
+ Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
21
+ end
22
+
23
+ def teardown
24
+ # Remove existing database files.
25
+ if File.exist?(DB_FILE)
26
+ @database.drop(DB_USER_NAME, DB_PASSWORD)
27
+ end
28
+ end
29
+
30
+ def test01
31
+ sm = ServiceManager.new('localhost')
32
+ sm.connect(DB_USER_NAME, DB_PASSWORD)
33
+
34
+ au = AddUser.new('newuser', 'password', 'first', 'middle', 'last')
35
+ au.execute(sm)
36
+
37
+ cxn = @database.connect('newuser', 'password')
38
+ cxn.close
39
+
40
+ ru = RemoveUser.new('newuser')
41
+ ru.execute(sm)
42
+
43
+ begin
44
+ cxn = @database.connect('newuser', 'password')
45
+ cxn.close
46
+ assert(false, "Able to connect as supposedly removed user.")
47
+ rescue FireRubyException
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,97 @@
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 BackupRestoreTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}backup_restore_unit_test.fdb"
13
+ BACKUP_FILE = "#{CURDIR}#{File::SEPARATOR}database.bak"
14
+
15
+ def setup
16
+ # Remove existing database files.
17
+ if File.exist?(DB_FILE)
18
+ db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
19
+ end
20
+
21
+ if File.exist?(BACKUP_FILE)
22
+ File.delete(BACKUP_FILE)
23
+ end
24
+
25
+ # Create and populate the database files.
26
+ @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
27
+ @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
28
+ cxn.execute_immediate('create table test(id integer)')
29
+ cxn.execute_immediate('insert into test values (1000)')
30
+ cxn.execute_immediate('insert into test values (2000)')
31
+ cxn.execute_immediate('insert into test values (NULL)')
32
+ cxn.execute_immediate('insert into test values (3000)')
33
+ cxn.execute_immediate('insert into test values (4000)')
34
+ end
35
+ end
36
+
37
+ def teardown
38
+ # Remove existing database files.
39
+ if File.exist?(DB_FILE)
40
+ db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
41
+ end
42
+
43
+ if File.exist?(BACKUP_FILE)
44
+ File.delete(BACKUP_FILE)
45
+ end
46
+ end
47
+
48
+ def test01
49
+ sm = ServiceManager.new('localhost')
50
+ sm.connect(DB_USER_NAME, DB_PASSWORD)
51
+
52
+ b = Backup.new(DB_FILE, BACKUP_FILE)
53
+ b.execute(sm)
54
+
55
+ assert(File.exist?(BACKUP_FILE))
56
+ @database.drop(DB_USER_NAME, DB_PASSWORD)
57
+ assert(File.exists?(DB_FILE) == false)
58
+
59
+ r = Restore.new(BACKUP_FILE, DB_FILE)
60
+ r.execute(sm)
61
+ sm.disconnect
62
+
63
+ assert(File.exist?(DB_FILE))
64
+ @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
65
+ total = 0
66
+ cxn.execute_immediate('select * from test') do |row|
67
+ assert([1000, 2000, 3000, 4000, nil].include?(row[0]))
68
+ total += 1
69
+ end
70
+ assert(total == 5)
71
+ end
72
+ end
73
+
74
+ def test02
75
+ sm = ServiceManager.new('localhost')
76
+ sm.connect(DB_USER_NAME, DB_PASSWORD)
77
+
78
+ b = Backup.new(DB_FILE, BACKUP_FILE)
79
+ b.metadata_only = true
80
+ b.execute(sm)
81
+
82
+ assert(File.exist?(BACKUP_FILE))
83
+ @database.drop(DB_USER_NAME, DB_PASSWORD)
84
+ assert(File.exists?(DB_FILE) == false)
85
+
86
+ r = Restore.new(BACKUP_FILE, DB_FILE)
87
+ r.execute(sm)
88
+ sm.disconnect
89
+
90
+ assert(File.exist?(DB_FILE))
91
+ @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
92
+ cxn.execute_immediate('select count(*) from test') do |row|
93
+ assert(row[0] == 0)
94
+ end
95
+ end
96
+ end
97
+ end
data/test/CVS/Entries CHANGED
@@ -1,12 +1,16 @@
1
- /ConnectionTest.rb/1.2/Mon Mar 21 08:55:55 2005//
2
- /DDLTest.rb/1.2/Mon Mar 21 08:55:55 2005//
1
+ /AddRemoveUserTest.rb/1.1/Mon May 9 09:11:29 2005//
2
+ /BackupRestoreTest.rb/1.1/Mon May 9 09:11:29 2005//
3
+ /ConnectionTest.rb/1.3/Mon May 9 09:08:34 2005//
3
4
  /DatabaseTest.rb/1.3/Thu Mar 31 08:28:48 2005//
4
- /GeneratorTest.rb/1.2/Mon Mar 21 08:55:55 2005//
5
- /ResultSetTest.rb/1.2/Mon Mar 21 08:55:55 2005//
6
- /RowTest.rb/1.1/Mon Mar 21 09:14:27 2005//
7
- /SQLTest.rb/1.2/Mon Mar 21 08:55:55 2005//
8
- /StatementTest.rb/1.3/Thu Mar 31 08:32:09 2005//
5
+ /GeneratorTest.rb/1.3/Mon May 9 09:08:34 2005//
6
+ /ResultSetTest.rb/1.3/Mon May 9 09:08:34 2005//
7
+ /RowCountTest.rb/1.2/Mon May 9 09:11:29 2005//
8
+ /RowTest.rb/1.2/Mon May 9 09:08:34 2005//
9
+ /SQLTest.rb/1.4/Wed May 18 09:07:52 2005//
10
+ /ServiceManagerTest.rb/1.1/Mon May 9 09:11:29 2005//
11
+ /StatementTest.rb/1.4/Mon May 9 09:08:34 2005//
9
12
  /TestSetup.rb/1.1.1.1/Tue Mar 15 10:37:07 2005//
10
- /TransactionTest.rb/1.2/Mon Mar 21 08:55:55 2005//
11
- /UnitTest.rb/1.2/Mon Mar 21 08:55:55 2005//
13
+ /TransactionTest.rb/1.5/Wed May 18 09:07:52 2005//
14
+ /UnitTest.rb/1.5/Wed May 18 09:07:52 2005//
15
+ /DDLTest.rb/1.5/Wed May 18 09:20:15 2005//
12
16
  D
@@ -16,7 +16,7 @@ class ConnectionTest < Test::Unit::TestCase
16
16
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
18
 
19
- @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
19
+ @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
20
20
  @connections = []
21
21
  end
22
22
 
data/test/DDLTest.rb CHANGED
@@ -15,7 +15,7 @@ class DDLTest < Test::Unit::TestCase
15
15
  if File::exist?(DB_FILE)
16
16
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
- @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
18
+ @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
19
19
  end
20
20
 
21
21
  def teardown
@@ -32,18 +32,20 @@ class DDLTest < Test::Unit::TestCase
32
32
  'FIELD03 BIGINT, FIELD04 TIMESTAMP '\
33
33
  'NOT NULL, FIELD05 VARCHAR(600))')
34
34
 
35
- r = cxn.execute_immediate('SELECT COUNT(*) FROM DDL_TABLE_01')
36
- assert(r.fetch[0] == 0)
37
- r.close
35
+ cxn.start_transaction do |tx|
36
+ r = tx.execute('SELECT COUNT(*) FROM DDL_TABLE_01')
37
+ assert(r.fetch[0] == 0)
38
+ r.close
39
+ end
38
40
 
39
41
  cxn.execute_immediate('ALTER TABLE DDL_TABLE_01 ADD PRIMARY KEY '\
40
42
  '(TABLEID)')
41
-
43
+
42
44
  cxn.execute_immediate('CREATE UNIQUE INDEX DDL_TABLE_IDX ON '\
43
- 'DDL_TABLE_01 (TABLEID)')
44
-
45
+ 'DDL_TABLE_01 (TABLEID)')
46
+
45
47
  cxn.execute_immediate('DROP INDEX DDL_TABLE_IDX')
46
-
48
+
47
49
  cxn.execute_immediate('DROP TABLE DDL_TABLE_01')
48
50
  end
49
51
  end
@@ -13,9 +13,9 @@ class GeneratorTest < Test::Unit::TestCase
13
13
 
14
14
  def setup
15
15
  if File::exist?(DB_FILE)
16
- Database.new(DB_USER_NAME, DB_PASSWORD, DB_FILE).drop
16
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
- @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
18
+ @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
19
19
  @connections = []
20
20
 
21
21
  @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
@@ -15,7 +15,7 @@ class ResultSetTest < Test::Unit::TestCase
15
15
  if File::exist?(DB_FILE)
16
16
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
- @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
18
+ @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
19
19
  @connections = []
20
20
  @transactions = []
21
21
 
@@ -58,12 +58,13 @@ class ResultSetTest < Test::Unit::TestCase
58
58
  end
59
59
 
60
60
  def test01
61
- s = Statement.new(@connections[0], @transactions[0],
62
- "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3)
61
+ r = ResultSet.new(@connections[0], @transactions[0],
62
+ "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3, nil)
63
63
 
64
- r = ResultSet.new(s)
65
-
66
- assert(r.statement == s)
64
+ assert(r.connection == @connections[0])
65
+ assert(r.transaction == @transactions[0])
66
+ assert(r.sql == "SELECT * FROM TEST_TABLE ORDER BY TESTID")
67
+ assert(r.dialect == 3)
67
68
 
68
69
  assert(r.fetch != nil)
69
70
  assert(r.fetch.class == Row)
@@ -71,8 +72,10 @@ class ResultSetTest < Test::Unit::TestCase
71
72
  assert(r.fetch[1] == 'Record Four.')
72
73
  r.fetch
73
74
  assert(r.fetch == nil)
75
+ r.close
74
76
 
75
- r = ResultSet.new(s)
77
+ r = ResultSet.new(@connections[0], @transactions[0],
78
+ "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3, nil)
76
79
  assert(r.column_count == 2)
77
80
  assert(r.column_name(0) == 'TESTID')
78
81
  assert(r.column_name(1) == 'TESTINFO')
@@ -86,12 +89,43 @@ class ResultSetTest < Test::Unit::TestCase
86
89
  assert(r.column_alias(1) == 'TESTINFO')
87
90
  assert(r.column_alias(3) == nil)
88
91
  assert(r.column_alias(-1) == nil)
92
+ r.close
89
93
 
90
- r = ResultSet.new(s)
94
+ r = ResultSet.new(@connections[0], @transactions[0],
95
+ "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3, nil)
91
96
  total = 0
92
97
  r.each do |row|
93
98
  total += 1
94
99
  end
95
100
  assert(total == 5)
101
+ r.close
102
+ end
103
+
104
+ def test02
105
+ r = ResultSet.new(@connections[0], @transactions[0],
106
+ 'select * from test_table where testid between ? and ?',
107
+ 3, [20, 40])
108
+ assert(r.exhausted? == false)
109
+ total = 0
110
+ r.each {|row| total += 1}
111
+ assert(total ==3)
112
+ end
113
+
114
+ def test03
115
+ begin
116
+ ResultSet.new(@connections[0], @transactions[0],
117
+ "insert into test_table values(?, ?)", 3,
118
+ [100, 'Should fail.'])
119
+ assert(false, "Created result set with non-query SQL statement.")
120
+ rescue FireRubyException
121
+ end
122
+
123
+ begin
124
+ ResultSet.new(@connections[0], @transactions[0],
125
+ "select * from test_table where testid = ?", 3,
126
+ [])
127
+ assert(false, 'Created result set with insufficient parameters.')
128
+ rescue FireRubyException
129
+ end
96
130
  end
97
131
  end
@@ -0,0 +1,63 @@
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 RowCountTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}row_count_test.fdb"
13
+
14
+ def setup
15
+ # Create the database for use in testing.
16
+ if File.exist?(DB_FILE)
17
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
18
+ end
19
+ @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
20
+
21
+ # Create the test table.
22
+ @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
23
+ cxn.execute_immediate('create table test(id integer)')
24
+ end
25
+ end
26
+
27
+
28
+ def teardown
29
+ if File.exist?(DB_FILE)
30
+ @database.drop(DB_USER_NAME, DB_PASSWORD)
31
+ end
32
+ end
33
+
34
+ def test01
35
+ @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
36
+ cxn.start_transaction do |tx|
37
+ assert(cxn.execute_immediate('insert into test values (1000)') == 1)
38
+ assert(cxn.execute_immediate('insert into test values (1000)') == 1)
39
+ assert(cxn.execute('insert into test values (2000)', tx) == 1)
40
+ assert(cxn.execute('insert into test values (2000)', tx) == 1)
41
+ assert(tx.execute('insert into test values (3000)') == 1)
42
+ assert(tx.execute('insert into test values (3000)') == 1)
43
+ assert(tx.execute('insert into test values (4000)') == 1)
44
+ assert(tx.execute('insert into test values (4000)') == 1)
45
+
46
+ assert(cxn.execute_immediate('update test set id = 10000 where '\
47
+ 'id = 1000') == 2)
48
+ assert(cxn.execute('update test set id = 20000 where id = 2000',
49
+ tx) == 2)
50
+ assert(tx.execute('update test set id = 30000 where id = 3000') == 2)
51
+
52
+ s = Statement.new(cxn, tx, 'update test set id = 40000 where id = ?',
53
+ 3)
54
+ assert(s.execute_for([4000]) == 2)
55
+
56
+
57
+ assert(cxn.execute_immediate('delete from test where id = 10000') == 2)
58
+ assert(cxn.execute('delete from test where id = 20000', tx) == 2)
59
+ assert(tx.execute('delete from test where id = 30000') == 2)
60
+ end
61
+ end
62
+ end
63
+ end
data/test/RowTest.rb CHANGED
@@ -16,19 +16,21 @@ class RowTest < Test::Unit::TestCase
16
16
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
18
 
19
- database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
19
+ database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
20
20
  @connection = database.connect(DB_USER_NAME, DB_PASSWORD)
21
21
  @transaction = @connection.start_transaction
22
- @statement = Statement.new(@connection, @transaction,
23
- 'SELECT * FROM RDB$FIELDS', 3)
24
- @results = ResultSet.new(@statement)
22
+ @results = ResultSet.new(@connection, @transaction,
23
+ 'SELECT * FROM RDB$FIELDS', 3, nil)
25
24
  @empty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26
25
  0, 0, 0, 0, 0, 0, 0, 0, 0]
26
+
27
+ @connection.execute_immediate('create table rowtest (COL01 integer, '\
28
+ 'COL02 varchar(10), COL03 integer)')
29
+ @connection.execute_immediate("insert into rowtest values (1, 'Two', 3)")
27
30
  end
28
31
 
29
32
  def teardown
30
33
  @results.close
31
- @statement.close
32
34
  @transaction.rollback
33
35
  @connection.close
34
36
  if File::exist?(DB_FILE)
@@ -46,4 +48,90 @@ class RowTest < Test::Unit::TestCase
46
48
  assert(row[0] == 0)
47
49
  assert(row['RDB$FIELD_TYPE'] == 0)
48
50
  end
51
+
52
+ def test02
53
+ sql = 'select COL01 one, COL02 two, COL03 three from rowtest'
54
+ rows = @connection.execute_immediate(sql)
55
+ data = rows.fetch
56
+
57
+ count = 0
58
+ data.each do |name, value|
59
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
60
+ assert([1, 'Two', 3].include?(value))
61
+ count += 1
62
+ end
63
+ assert(count == 3)
64
+
65
+ count = 0
66
+ data.each_key do |name|
67
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
68
+ count += 1
69
+ end
70
+ assert(count == 3)
71
+
72
+ count = 0
73
+ data.each_value do |value|
74
+ assert([1, 'Two', 3].include?(value))
75
+ count += 1
76
+ end
77
+ assert(count == 3)
78
+
79
+ assert(data.fetch('COL02') == 'Two')
80
+ assert(data.fetch('COL04', 'LALALA') == 'LALALA')
81
+ assert(data.fetch('COL00') {'NOT FOUND'} == 'NOT FOUND')
82
+ begin
83
+ data.fetch('COL05')
84
+ assert(false, 'Row#fetch succeeded for non-existent column name.')
85
+ rescue IndexError
86
+ end
87
+
88
+ assert(data.has_key?('COL01'))
89
+ assert(data.has_key?('COL10') == false)
90
+
91
+ assert(data.has_alias?('TWO'))
92
+ assert(data.has_alias?('FOUR') == false)
93
+
94
+ assert(data.has_value?(3))
95
+ assert(data.has_value?('LALALA') == false)
96
+
97
+ assert(data.keys.size == 3)
98
+ data.keys.each do |name|
99
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
100
+ end
101
+
102
+ assert(data.aliases.size == 3)
103
+ data.aliases.each do |name|
104
+ assert(['ONE', 'TWO', 'THREE'].include?(name))
105
+ end
106
+
107
+ assert(data.values.size == 3)
108
+ data.values.each do |value|
109
+ assert([1, 'Two', 3].include?(value))
110
+ end
111
+
112
+ array = data.select {|name, value| name == 'COL02'}
113
+ assert(array.size == 1)
114
+ assert(array[0][0] == 'COL02')
115
+ assert(array[0][1] == 'Two')
116
+
117
+ array = data.to_a
118
+ assert(array.size == 3)
119
+ assert(array.include?(['COL01', 1]))
120
+ assert(array.include?(['COL02', 'Two']))
121
+ assert(array.include?(['COL03', 3]))
122
+
123
+ hash = data.to_hash
124
+ assert(hash.length == 3)
125
+ assert(hash['COL01'] == 1)
126
+ assert(hash['COL02'] == 'Two')
127
+ assert(hash['COL03'] == 3)
128
+
129
+ array = data.values_at('COL10', 'COL02', 'COL03')
130
+ assert(array.size == 3)
131
+ assert(array.include?('Two'))
132
+ assert(array.include?(3))
133
+ assert(array.include?(nil))
134
+
135
+ rows.close
136
+ end
49
137
  end
data/test/SQLTest.rb CHANGED
@@ -18,8 +18,7 @@ class SQLTest < Test::Unit::TestCase
18
18
  if File::exist?(DB_FILE)
19
19
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
20
20
  end
21
- @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD,
22
- 1024, 'ASCII')
21
+ @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
23
22
  @connections = []
24
23
  @transactions = []
25
24
 
@@ -57,13 +56,17 @@ class SQLTest < Test::Unit::TestCase
57
56
  t = Time.at(t.to_i + 5)
58
57
  s.execute_for([i, i.to_s, f, t, nil, t])
59
58
  end
59
+
60
+ s.close
60
61
  end
61
62
  end
62
63
 
63
64
  @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
64
- r = @connections[0].execute_immediate("SELECT COUNT(*) FROM TEST_TABLE")
65
- assert(r.fetch[0] == ITERATIONS)
66
- r.close
65
+ @connections[0].start_transaction do |tx|
66
+ r = tx.execute("SELECT COUNT(*) FROM TEST_TABLE")
67
+ assert(r.fetch[0] == ITERATIONS)
68
+ r.close
69
+ end
67
70
  end
68
71
 
69
72
  def test02
@@ -128,6 +131,7 @@ class SQLTest < Test::Unit::TestCase
128
131
  s = Statement.new(@connections[0], tx,
129
132
  "UPDATE TEST_TABLE SET TESTSTAMP = NULL", 3)
130
133
  s.execute()
134
+ s.close
131
135
 
132
136
  r = tx.execute("SELECT TESTSTAMP FROM TEST_TABLE")
133
137
  total = 0
@@ -147,6 +151,7 @@ class SQLTest < Test::Unit::TestCase
147
151
  "TESTFLOAT, TESTSTAMP) VALUES(?, ?, ?, ?)", 3)
148
152
  t = Time.new
149
153
  s.execute_for([25000, 'La la la', 3.14, t])
154
+ s.close
150
155
 
151
156
  # Fetch the record and check the data.
152
157
  r = tx.execute("SELECT TESTTEXT, TESTFLOAT, TESTSTAMP FROM "\
@@ -161,9 +166,12 @@ class SQLTest < Test::Unit::TestCase
161
166
  @connections[0].execute_immediate("DELETE FROM TEST_TABLE WHERE TESTID "\
162
167
  "IN (1, 3, 5, 7, 9, 12, 14, 16, 18, 20)")
163
168
  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
164
- r = cxn.execute_immediate("SELECT COUNT(*) FROM TEST_TABLE")
165
- a = r.fetch
166
- r.close
169
+ a = []
170
+ cxn.start_transaction do |tx|
171
+ r = tx.execute("SELECT COUNT(*) FROM TEST_TABLE")
172
+ a = r.fetch
173
+ r.close
174
+ end
167
175
  assert(a[0] == 11)
168
176
  end
169
177
  end
@@ -0,0 +1,21 @@
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 ServiceManagerTest < Test::Unit::TestCase
11
+ def test01
12
+ sm = ServiceManager.new('localhost')
13
+ assert(sm.connected? == false)
14
+
15
+ assert(sm.connect(DB_USER_NAME, DB_PASSWORD) == sm)
16
+ assert(sm.connected?)
17
+
18
+ assert(sm.disconnect == sm)
19
+ assert(sm.connected? == false)
20
+ end
21
+ end
@@ -15,7 +15,7 @@ class StatementTest < Test::Unit::TestCase
15
15
  if File::exist?(DB_FILE)
16
16
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
- @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
18
+ @database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
19
19
  @connections = []
20
20
  @transactions = []
21
21
  end
@@ -46,7 +46,7 @@ class StatementTest < Test::Unit::TestCase
46
46
  assert(s1.connection == @connections[0])
47
47
  assert(s1.transaction == @transactions[0])
48
48
  assert(s1.dialect == 3)
49
- assert(s1.is_query? == true)
49
+ assert(s1.type == Statement::SELECT_STATEMENT)
50
50
 
51
51
  s2 = Statement.new(@connections[0],
52
52
  @transactions[0],
@@ -56,7 +56,7 @@ class StatementTest < Test::Unit::TestCase
56
56
  assert(s2.connection == @connections[0])
57
57
  assert(s2.transaction == @transactions[0])
58
58
  assert(s2.dialect == 1)
59
- assert(s2.is_query? == false)
59
+ assert(s2.type == Statement::DELETE_STATEMENT)
60
60
  end
61
61
 
62
62
  def test02
@@ -16,7 +16,7 @@ class TransactionTest < Test::Unit::TestCase
16
16
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
17
  end
18
18
 
19
- @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
19
+ @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
20
20
  @connections = []
21
21
  @transactions = []
22
22
 
@@ -95,14 +95,15 @@ class TransactionTest < Test::Unit::TestCase
95
95
  sql.push("SELECT RDB$FIELD_NAME FROM RDB$FIELDS")
96
96
  @transactions.push(Transaction.new(@connections[0]))
97
97
 
98
- assert(@transactions[0].execute(sql[0]) == nil)
99
- assert(@transactions[0].execute(sql[1]) != nil)
100
- assert(@transactions[0].execute(sql[1]).class == ResultSet)
98
+ assert(@transactions[0].execute(sql[0]) == 0)
99
+ r = @transactions[0].execute(sql[1])
100
+ assert(r != nil)
101
+ assert(r.class == ResultSet)
101
102
 
102
103
  total = 0
103
104
  @transactions[0].execute(sql[1]) do |row|
104
105
  total += 1
105
106
  end
106
- assert(total = 88)
107
+ assert(total == 88)
107
108
  end
108
109
  end
data/test/UnitTest.rb CHANGED
@@ -5,7 +5,13 @@ require 'ConnectionTest'
5
5
  require 'TransactionTest'
6
6
  require 'StatementTest'
7
7
  require 'ResultSetTest'
8
+ require 'RowCountTest'
8
9
  require 'RowTest'
9
10
  require 'GeneratorTest'
10
11
  require 'DDLTest'
11
12
  require 'SQLTest'
13
+ require 'ServiceManagerTest'
14
+ if PLATFORM.include?('powerpc-darwin') == false
15
+ require 'BackupRestoreTest'
16
+ require 'AddRemoveUserTest'
17
+ end