fireruby 0.4.1-i586-linux → 0.4.2-i586-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +456 -456
- data/doc/license.txt +0 -0
- data/examples/example01.rb +65 -65
- data/lib/SQLType.rb +223 -227
- data/lib/fireruby.rb +22 -22
- data/lib/fr_lib.so +0 -0
- data/lib/mkdoc +1 -1
- data/lib/src.rb +1795 -1795
- data/test/AddRemoveUserTest.rb +55 -55
- data/test/BackupRestoreTest.rb +99 -99
- data/test/BlobTest.rb +56 -0
- data/test/CharacterSetTest.rb +63 -63
- data/test/ConnectionTest.rb +111 -111
- data/test/DDLTest.rb +54 -54
- data/test/DatabaseTest.rb +83 -83
- data/test/GeneratorTest.rb +50 -50
- data/test/KeyTest.rb +140 -140
- data/test/ResultSetTest.rb +162 -162
- data/test/RoleTest.rb +71 -0
- data/test/RowCountTest.rb +65 -65
- data/test/RowTest.rb +203 -203
- data/test/SQLTest.rb +182 -182
- data/test/SQLTypeTest.rb +101 -101
- data/test/ServiceManagerTest.rb +29 -29
- data/test/StatementTest.rb +135 -135
- data/test/TestSetup.rb +11 -11
- data/test/TransactionTest.rb +112 -112
- data/test/TypeTest.rb +92 -92
- data/test/UnitTest.rb +65 -64
- metadata +47 -110
- data/doc/CVS/Entries +0 -3
- data/doc/CVS/Entries.Log +0 -2
- data/doc/CVS/Repository +0 -1
- data/doc/CVS/Root +0 -1
- data/doc/classes/CVS/Entries +0 -1
- 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 -1
- 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.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Connection.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Connection.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Root +0 -1
- data/doc/files/CVS/Entries +0 -1
- data/doc/files/CVS/Repository +0 -1
- data/doc/files/CVS/Root +0 -1
- data/examples/CVS/Entries +0 -2
- data/examples/CVS/Repository +0 -1
- data/examples/CVS/Root +0 -1
- data/lib/CVS/Entries +0 -6
- data/lib/CVS/Repository +0 -1
- data/lib/CVS/Root +0 -1
- data/test/CVS/Entries +0 -20
- data/test/CVS/Repository +0 -1
- data/test/CVS/Root +0 -1
data/test/ConnectionTest.rb
CHANGED
@@ -1,111 +1,111 @@
|
|
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 ConnectionTest < Test::Unit::TestCase
|
11
|
-
CURDIR = "#{Dir.getwd}"
|
12
|
-
DB_FILE = "#{CURDIR}#{File::SEPARATOR}con_unit_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
|
-
@connections = []
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
@connections.each {|connection| connection.close}
|
26
|
-
@connections.clear
|
27
|
-
|
28
|
-
if File::exist?(DB_FILE)
|
29
|
-
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
30
|
-
end
|
31
|
-
puts "#{self.class.name} finished." if TEST_LOGGING
|
32
|
-
end
|
33
|
-
|
34
|
-
def test01
|
35
|
-
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
36
|
-
|
37
|
-
assert(@connections[0].user == DB_USER_NAME)
|
38
|
-
assert(@connections[0].open?)
|
39
|
-
assert(@connections[0].closed? == false)
|
40
|
-
assert(@connections[0].database == @database)
|
41
|
-
assert(@connections[0].to_s == "#{DB_USER_NAME}@#{DB_FILE} (OPEN)")
|
42
|
-
|
43
|
-
@connections[0].close
|
44
|
-
assert(@connections[0].user == DB_USER_NAME)
|
45
|
-
assert(@connections[0].open? == false)
|
46
|
-
assert(@connections[0].closed?)
|
47
|
-
assert(@connections[0].database == @database)
|
48
|
-
assert(@connections[0].to_s == "(CLOSED)")
|
49
|
-
|
50
|
-
@connections[0] = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
51
|
-
assert(@connections[0].open?)
|
52
|
-
@connections.push(Connection.new(@database, DB_USER_NAME, DB_PASSWORD))
|
53
|
-
assert(@connections[0].open?)
|
54
|
-
assert(@connections[1].open?)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test02
|
58
|
-
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
59
|
-
|
60
|
-
tx = @connections[0].start_transaction
|
61
|
-
assert(tx != nil)
|
62
|
-
assert(tx.class == Transaction)
|
63
|
-
assert(tx.active?)
|
64
|
-
tx.rollback
|
65
|
-
|
66
|
-
tx = nil
|
67
|
-
@connections[0].start_transaction do |transaction|
|
68
|
-
assert(transaction != nil)
|
69
|
-
assert(transaction.class == Transaction)
|
70
|
-
assert(transaction.active?)
|
71
|
-
tx = transaction
|
72
|
-
end
|
73
|
-
assert(tx != nil)
|
74
|
-
assert(tx.class == Transaction)
|
75
|
-
assert(tx.active? == false)
|
76
|
-
end
|
77
|
-
|
78
|
-
def test03
|
79
|
-
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
80
|
-
tx = @connections[0].start_transaction
|
81
|
-
total = 0
|
82
|
-
@connections[0].execute("SELECT RDB$FIELD_NAME FROM RDB$FIELDS", tx) do |row|
|
83
|
-
total = total + 1
|
84
|
-
end
|
85
|
-
assert(total == 88)
|
86
|
-
tx.commit
|
87
|
-
|
88
|
-
total = 0
|
89
|
-
@connections[0].execute_immediate("SELECT RDB$FIELD_NAME FROM RDB$FIELDS") do |row|
|
90
|
-
total = total + 1
|
91
|
-
end
|
92
|
-
assert(total == 88)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test04
|
96
|
-
connection = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
97
|
-
|
98
|
-
tx1 = connection.start_transaction
|
99
|
-
tx2 = connection.start_transaction
|
100
|
-
tx3 = connection.start_transaction
|
101
|
-
|
102
|
-
tx2.rollback
|
103
|
-
assert(tx2.active? == false)
|
104
|
-
|
105
|
-
connection.close
|
106
|
-
|
107
|
-
assert(connection.closed?)
|
108
|
-
assert(tx1.active? == false)
|
109
|
-
assert(tx3.active? == false)
|
110
|
-
end
|
111
|
-
end
|
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 ConnectionTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}con_unit_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
|
+
@connections = []
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
@connections.each {|connection| connection.close}
|
26
|
+
@connections.clear
|
27
|
+
|
28
|
+
if File::exist?(DB_FILE)
|
29
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
30
|
+
end
|
31
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
32
|
+
end
|
33
|
+
|
34
|
+
def test01
|
35
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
36
|
+
|
37
|
+
assert(@connections[0].user == DB_USER_NAME)
|
38
|
+
assert(@connections[0].open?)
|
39
|
+
assert(@connections[0].closed? == false)
|
40
|
+
assert(@connections[0].database == @database)
|
41
|
+
assert(@connections[0].to_s == "#{DB_USER_NAME}@#{DB_FILE} (OPEN)")
|
42
|
+
|
43
|
+
@connections[0].close
|
44
|
+
assert(@connections[0].user == DB_USER_NAME)
|
45
|
+
assert(@connections[0].open? == false)
|
46
|
+
assert(@connections[0].closed?)
|
47
|
+
assert(@connections[0].database == @database)
|
48
|
+
assert(@connections[0].to_s == "(CLOSED)")
|
49
|
+
|
50
|
+
@connections[0] = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
51
|
+
assert(@connections[0].open?)
|
52
|
+
@connections.push(Connection.new(@database, DB_USER_NAME, DB_PASSWORD))
|
53
|
+
assert(@connections[0].open?)
|
54
|
+
assert(@connections[1].open?)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test02
|
58
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
59
|
+
|
60
|
+
tx = @connections[0].start_transaction
|
61
|
+
assert(tx != nil)
|
62
|
+
assert(tx.class == Transaction)
|
63
|
+
assert(tx.active?)
|
64
|
+
tx.rollback
|
65
|
+
|
66
|
+
tx = nil
|
67
|
+
@connections[0].start_transaction do |transaction|
|
68
|
+
assert(transaction != nil)
|
69
|
+
assert(transaction.class == Transaction)
|
70
|
+
assert(transaction.active?)
|
71
|
+
tx = transaction
|
72
|
+
end
|
73
|
+
assert(tx != nil)
|
74
|
+
assert(tx.class == Transaction)
|
75
|
+
assert(tx.active? == false)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test03
|
79
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
80
|
+
tx = @connections[0].start_transaction
|
81
|
+
total = 0
|
82
|
+
@connections[0].execute("SELECT RDB$FIELD_NAME FROM RDB$FIELDS", tx) do |row|
|
83
|
+
total = total + 1
|
84
|
+
end
|
85
|
+
assert(total == 88)
|
86
|
+
tx.commit
|
87
|
+
|
88
|
+
total = 0
|
89
|
+
@connections[0].execute_immediate("SELECT RDB$FIELD_NAME FROM RDB$FIELDS") do |row|
|
90
|
+
total = total + 1
|
91
|
+
end
|
92
|
+
assert(total == 88)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test04
|
96
|
+
connection = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
97
|
+
|
98
|
+
tx1 = connection.start_transaction
|
99
|
+
tx2 = connection.start_transaction
|
100
|
+
tx3 = connection.start_transaction
|
101
|
+
|
102
|
+
tx2.rollback
|
103
|
+
assert(tx2.active? == false)
|
104
|
+
|
105
|
+
connection.close
|
106
|
+
|
107
|
+
assert(connection.closed?)
|
108
|
+
assert(tx1.active? == false)
|
109
|
+
assert(tx3.active? == false)
|
110
|
+
end
|
111
|
+
end
|
data/test/DDLTest.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
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 DDLTest < Test::Unit::TestCase
|
11
|
-
CURDIR = "#{Dir.getwd}"
|
12
|
-
DB_FILE = "#{CURDIR}#{File::SEPARATOR}ddl_unit_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
|
-
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
if File::exist?(DB_FILE)
|
24
|
-
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
25
|
-
end
|
26
|
-
puts "#{self.class.name} finished." if TEST_LOGGING
|
27
|
-
end
|
28
|
-
|
29
|
-
def test01
|
30
|
-
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
31
|
-
cxn.execute_immediate('CREATE TABLE DDL_TABLE_01 (TABLEID '\
|
32
|
-
'INTEGER NOT NULL, '\
|
33
|
-
'FIELD01 FLOAT, FIELD02 CHAR(50), '\
|
34
|
-
'FIELD03 BIGINT, FIELD04 TIMESTAMP '\
|
35
|
-
'NOT NULL, FIELD05 VARCHAR(600))')
|
36
|
-
|
37
|
-
cxn.start_transaction do |tx|
|
38
|
-
r = tx.execute('SELECT COUNT(*) FROM DDL_TABLE_01')
|
39
|
-
assert(r.fetch[0] == 0)
|
40
|
-
r.close
|
41
|
-
end
|
42
|
-
|
43
|
-
cxn.execute_immediate('ALTER TABLE DDL_TABLE_01 ADD PRIMARY KEY '\
|
44
|
-
'(TABLEID)')
|
45
|
-
|
46
|
-
cxn.execute_immediate('CREATE UNIQUE INDEX DDL_TABLE_IDX ON '\
|
47
|
-
'DDL_TABLE_01 (TABLEID)')
|
48
|
-
|
49
|
-
cxn.execute_immediate('DROP INDEX DDL_TABLE_IDX')
|
50
|
-
|
51
|
-
cxn.execute_immediate('DROP TABLE DDL_TABLE_01')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
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 DDLTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}ddl_unit_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
|
+
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
if File::exist?(DB_FILE)
|
24
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
25
|
+
end
|
26
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
27
|
+
end
|
28
|
+
|
29
|
+
def test01
|
30
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
31
|
+
cxn.execute_immediate('CREATE TABLE DDL_TABLE_01 (TABLEID '\
|
32
|
+
'INTEGER NOT NULL, '\
|
33
|
+
'FIELD01 FLOAT, FIELD02 CHAR(50), '\
|
34
|
+
'FIELD03 BIGINT, FIELD04 TIMESTAMP '\
|
35
|
+
'NOT NULL, FIELD05 VARCHAR(600))')
|
36
|
+
|
37
|
+
cxn.start_transaction do |tx|
|
38
|
+
r = tx.execute('SELECT COUNT(*) FROM DDL_TABLE_01')
|
39
|
+
assert(r.fetch[0] == 0)
|
40
|
+
r.close
|
41
|
+
end
|
42
|
+
|
43
|
+
cxn.execute_immediate('ALTER TABLE DDL_TABLE_01 ADD PRIMARY KEY '\
|
44
|
+
'(TABLEID)')
|
45
|
+
|
46
|
+
cxn.execute_immediate('CREATE UNIQUE INDEX DDL_TABLE_IDX ON '\
|
47
|
+
'DDL_TABLE_01 (TABLEID)')
|
48
|
+
|
49
|
+
cxn.execute_immediate('DROP INDEX DDL_TABLE_IDX')
|
50
|
+
|
51
|
+
cxn.execute_immediate('DROP TABLE DDL_TABLE_01')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/test/DatabaseTest.rb
CHANGED
@@ -1,83 +1,83 @@
|
|
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 DatabaseTest < Test::Unit::TestCase
|
11
|
-
CURDIR = "#{Dir.getwd}"
|
12
|
-
DB_FILE = "#{CURDIR}#{File::SEPARATOR}db_unit_test.fdb"
|
13
|
-
CREATE_FILE = "#{CURDIR}#{File::SEPARATOR}db_create_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
|
20
|
-
end
|
21
|
-
if File.exist?(CREATE_FILE)
|
22
|
-
db = Database.new(CREATE_FILE)
|
23
|
-
db.drop
|
24
|
-
end
|
25
|
-
|
26
|
-
Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, 'ASCII')
|
27
|
-
end
|
28
|
-
|
29
|
-
def teardown
|
30
|
-
if File::exist?(DB_FILE)
|
31
|
-
db = Database.new(DB_FILE)
|
32
|
-
db.drop(DB_USER_NAME, DB_PASSWORD)
|
33
|
-
end
|
34
|
-
if File::exist?(CREATE_FILE)
|
35
|
-
db = Database.new(CREATE_FILE)
|
36
|
-
db.drop(DB_USER_NAME, DB_PASSWORD)
|
37
|
-
end
|
38
|
-
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
def test01
|
43
|
-
db = Database.create(CREATE_FILE, DB_USER_NAME, DB_PASSWORD, 2048, 'ASCII')
|
44
|
-
|
45
|
-
assert(File.exist?(CREATE_FILE))
|
46
|
-
assert(db.file == CREATE_FILE)
|
47
|
-
|
48
|
-
begin
|
49
|
-
Database.create(CREATE_FILE, DB_USER_NAME, DB_PASSWORD, 2048, 'ASCII')
|
50
|
-
assert(false,
|
51
|
-
"Successfully created a database file that already exists.")
|
52
|
-
rescue Exception
|
53
|
-
end
|
54
|
-
|
55
|
-
db.drop(DB_USER_NAME, DB_PASSWORD)
|
56
|
-
assert(File.exist?(CREATE_FILE) == false)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test02
|
60
|
-
db = Database.new(DB_FILE);
|
61
|
-
|
62
|
-
assert(db.file == DB_FILE)
|
63
|
-
|
64
|
-
c = db.connect(DB_USER_NAME, DB_PASSWORD)
|
65
|
-
assert(c != nil)
|
66
|
-
c.close
|
67
|
-
end
|
68
|
-
|
69
|
-
def test03
|
70
|
-
db = Database.new(DB_FILE);
|
71
|
-
c = nil
|
72
|
-
|
73
|
-
db.connect(DB_USER_NAME, DB_PASSWORD) do |connection|
|
74
|
-
assert(connection != nil)
|
75
|
-
assert(connection.class == Connection)
|
76
|
-
assert(connection.open?)
|
77
|
-
c = connection
|
78
|
-
end
|
79
|
-
assert(c != nil)
|
80
|
-
assert(c.class == Connection)
|
81
|
-
assert(c.closed?)
|
82
|
-
end
|
83
|
-
end
|
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 DatabaseTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}db_unit_test.fdb"
|
13
|
+
CREATE_FILE = "#{CURDIR}#{File::SEPARATOR}db_create_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
|
+
if File.exist?(CREATE_FILE)
|
22
|
+
db = Database.new(CREATE_FILE)
|
23
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
24
|
+
end
|
25
|
+
|
26
|
+
Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, 'ASCII')
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
if File::exist?(DB_FILE)
|
31
|
+
db = Database.new(DB_FILE)
|
32
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
33
|
+
end
|
34
|
+
if File::exist?(CREATE_FILE)
|
35
|
+
db = Database.new(CREATE_FILE)
|
36
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
37
|
+
end
|
38
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def test01
|
43
|
+
db = Database.create(CREATE_FILE, DB_USER_NAME, DB_PASSWORD, 2048, 'ASCII')
|
44
|
+
|
45
|
+
assert(File.exist?(CREATE_FILE))
|
46
|
+
assert(db.file == CREATE_FILE)
|
47
|
+
|
48
|
+
begin
|
49
|
+
Database.create(CREATE_FILE, DB_USER_NAME, DB_PASSWORD, 2048, 'ASCII')
|
50
|
+
assert(false,
|
51
|
+
"Successfully created a database file that already exists.")
|
52
|
+
rescue Exception
|
53
|
+
end
|
54
|
+
|
55
|
+
db.drop(DB_USER_NAME, DB_PASSWORD)
|
56
|
+
assert(File.exist?(CREATE_FILE) == false)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test02
|
60
|
+
db = Database.new(DB_FILE);
|
61
|
+
|
62
|
+
assert(db.file == DB_FILE)
|
63
|
+
|
64
|
+
c = db.connect(DB_USER_NAME, DB_PASSWORD)
|
65
|
+
assert(c != nil)
|
66
|
+
c.close
|
67
|
+
end
|
68
|
+
|
69
|
+
def test03
|
70
|
+
db = Database.new(DB_FILE);
|
71
|
+
c = nil
|
72
|
+
|
73
|
+
db.connect(DB_USER_NAME, DB_PASSWORD) do |connection|
|
74
|
+
assert(connection != nil)
|
75
|
+
assert(connection.class == Connection)
|
76
|
+
assert(connection.open?)
|
77
|
+
c = connection
|
78
|
+
end
|
79
|
+
assert(c != nil)
|
80
|
+
assert(c.class == Connection)
|
81
|
+
assert(c.closed?)
|
82
|
+
end
|
83
|
+
end
|