fireruby 0.4.1-mswin32 → 0.4.2-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/README +456 -456
- data/doc/license.txt +411 -411
- 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 +56 -55
- data/test/BackupRestoreTest.rb +99 -99
- data/test/BlobTest.rb +57 -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 +73 -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 +49 -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/AddRemoveUserTest.rb
    CHANGED
    
    | @@ -1,55 +1,56 @@ | |
| 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 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 | 
            -
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 16 | 
            -
                  # Remove existing database files.
         | 
| 17 | 
            -
                  @database = Database.new(DB_FILE)
         | 
| 18 | 
            -
                  if File.exist?(DB_FILE)
         | 
| 19 | 
            -
                     @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                  Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
         | 
| 22 | 
            -
               end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
               def teardown
         | 
| 25 | 
            -
                  # Remove existing database files.
         | 
| 26 | 
            -
                  if File.exist?(DB_FILE)
         | 
| 27 | 
            -
                     @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 28 | 
            -
                  end
         | 
| 29 | 
            -
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 30 | 
            -
               end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
               def test01
         | 
| 33 | 
            -
                  sm = ServiceManager.new('localhost')
         | 
| 34 | 
            -
                  sm.connect(DB_USER_NAME, DB_PASSWORD)
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  au = AddUser.new('newuser', 'password', 'first', 'middle', 'last')
         | 
| 37 | 
            -
                  au.execute(sm)
         | 
| 38 | 
            -
                  sleep(3)
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  cxn = @database.connect('newuser', 'password')
         | 
| 41 | 
            -
                  cxn.close
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                  ru = RemoveUser.new('newuser')
         | 
| 44 | 
            -
                  ru.execute(sm)
         | 
| 45 | 
            -
                  
         | 
| 46 | 
            -
                   | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
                     cxn. | 
| 51 | 
            -
                      | 
| 52 | 
            -
             | 
| 53 | 
            -
                   | 
| 54 | 
            -
             | 
| 55 | 
            -
            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 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 | 
            +
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 16 | 
            +
                  # Remove existing database files.
         | 
| 17 | 
            +
                  @database = Database.new(DB_FILE)
         | 
| 18 | 
            +
                  if File.exist?(DB_FILE)
         | 
| 19 | 
            +
                     @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                  Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
         | 
| 22 | 
            +
               end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
               def teardown
         | 
| 25 | 
            +
                  # Remove existing database files.
         | 
| 26 | 
            +
                  if File.exist?(DB_FILE)
         | 
| 27 | 
            +
                     @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 30 | 
            +
               end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
               def test01
         | 
| 33 | 
            +
                  sm = ServiceManager.new('localhost')
         | 
| 34 | 
            +
                  sm.connect(DB_USER_NAME, DB_PASSWORD)
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  au = AddUser.new('newuser', 'password', 'first', 'middle', 'last')
         | 
| 37 | 
            +
                  au.execute(sm)
         | 
| 38 | 
            +
                  sleep(3)
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  cxn = @database.connect('newuser', 'password')
         | 
| 41 | 
            +
                  cxn.close
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  ru = RemoveUser.new('newuser')
         | 
| 44 | 
            +
                  ru.execute(sm)
         | 
| 45 | 
            +
                  sleep(3)
         | 
| 46 | 
            +
                  
         | 
| 47 | 
            +
                  sm.disconnect
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  begin
         | 
| 50 | 
            +
                     cxn = @database.connect('newuser', 'password')
         | 
| 51 | 
            +
                     cxn.close
         | 
| 52 | 
            +
                     assert(false, "Able to connect as supposedly removed user.")
         | 
| 53 | 
            +
                  rescue FireRubyException
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
               end
         | 
| 56 | 
            +
            end
         | 
    
        data/test/BackupRestoreTest.rb
    CHANGED
    
    | @@ -1,99 +1,99 @@ | |
| 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 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 | 
            -
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 17 | 
            -
                  # Remove existing database files.
         | 
| 18 | 
            -
                  if File.exist?(DB_FILE)
         | 
| 19 | 
            -
                     db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  if File.exist?(BACKUP_FILE)
         | 
| 23 | 
            -
                     File.delete(BACKUP_FILE)
         | 
| 24 | 
            -
                  end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  # Create and populate the database files.
         | 
| 27 | 
            -
                  @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
         | 
| 28 | 
            -
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 29 | 
            -
                     cxn.execute_immediate('create table test(id integer)')
         | 
| 30 | 
            -
                     cxn.execute_immediate('insert into test values (1000)')
         | 
| 31 | 
            -
                     cxn.execute_immediate('insert into test values (2000)')
         | 
| 32 | 
            -
                     cxn.execute_immediate('insert into test values (NULL)')
         | 
| 33 | 
            -
                     cxn.execute_immediate('insert into test values (3000)')
         | 
| 34 | 
            -
                     cxn.execute_immediate('insert into test values (4000)')
         | 
| 35 | 
            -
                  end
         | 
| 36 | 
            -
               end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
               def teardown
         | 
| 39 | 
            -
                  # Remove existing database files.
         | 
| 40 | 
            -
                  if File.exist?(DB_FILE)
         | 
| 41 | 
            -
                     db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                  if File.exist?(BACKUP_FILE)
         | 
| 45 | 
            -
                     File.delete(BACKUP_FILE)
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 48 | 
            -
               end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
               def test01
         | 
| 51 | 
            -
                  sm = ServiceManager.new('localhost')
         | 
| 52 | 
            -
                  sm.connect(DB_USER_NAME, DB_PASSWORD)
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                  b = Backup.new(DB_FILE, BACKUP_FILE)
         | 
| 55 | 
            -
                  b.execute(sm)
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  assert(File.exist?(BACKUP_FILE))
         | 
| 58 | 
            -
                  @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 59 | 
            -
                  assert(File.exists?(DB_FILE) == false)
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  r = Restore.new(BACKUP_FILE, DB_FILE)
         | 
| 62 | 
            -
                  r.execute(sm)
         | 
| 63 | 
            -
                  sm.disconnect
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                  assert(File.exist?(DB_FILE))
         | 
| 66 | 
            -
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 67 | 
            -
                     total = 0
         | 
| 68 | 
            -
                     cxn.execute_immediate('select * from test') do |row|
         | 
| 69 | 
            -
                        assert([1000, 2000, 3000, 4000, nil].include?(row[0]))
         | 
| 70 | 
            -
                        total += 1
         | 
| 71 | 
            -
                     end
         | 
| 72 | 
            -
                     assert(total == 5)
         | 
| 73 | 
            -
                  end
         | 
| 74 | 
            -
               end
         | 
| 75 | 
            -
             | 
| 76 | 
            -
               def test02
         | 
| 77 | 
            -
                  sm = ServiceManager.new('localhost')
         | 
| 78 | 
            -
                  sm.connect(DB_USER_NAME, DB_PASSWORD)
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                  b = Backup.new(DB_FILE, BACKUP_FILE)
         | 
| 81 | 
            -
                  b.metadata_only = true
         | 
| 82 | 
            -
                  b.execute(sm)
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                  assert(File.exist?(BACKUP_FILE))
         | 
| 85 | 
            -
                  @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 86 | 
            -
                  assert(File.exists?(DB_FILE) == false)
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                  r = Restore.new(BACKUP_FILE, DB_FILE)
         | 
| 89 | 
            -
                  r.execute(sm)
         | 
| 90 | 
            -
                  sm.disconnect
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                  assert(File.exist?(DB_FILE))
         | 
| 93 | 
            -
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 94 | 
            -
                     cxn.execute_immediate('select count(*) from test') do |row|
         | 
| 95 | 
            -
                        assert(row[0] == 0)
         | 
| 96 | 
            -
                     end
         | 
| 97 | 
            -
                  end
         | 
| 98 | 
            -
               end
         | 
| 99 | 
            -
            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 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 | 
            +
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 17 | 
            +
                  # Remove existing database files.
         | 
| 18 | 
            +
                  if File.exist?(DB_FILE)
         | 
| 19 | 
            +
                     db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  if File.exist?(BACKUP_FILE)
         | 
| 23 | 
            +
                     File.delete(BACKUP_FILE)
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  # Create and populate the database files.
         | 
| 27 | 
            +
                  @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
         | 
| 28 | 
            +
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 29 | 
            +
                     cxn.execute_immediate('create table test(id integer)')
         | 
| 30 | 
            +
                     cxn.execute_immediate('insert into test values (1000)')
         | 
| 31 | 
            +
                     cxn.execute_immediate('insert into test values (2000)')
         | 
| 32 | 
            +
                     cxn.execute_immediate('insert into test values (NULL)')
         | 
| 33 | 
            +
                     cxn.execute_immediate('insert into test values (3000)')
         | 
| 34 | 
            +
                     cxn.execute_immediate('insert into test values (4000)')
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
               end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
               def teardown
         | 
| 39 | 
            +
                  # Remove existing database files.
         | 
| 40 | 
            +
                  if File.exist?(DB_FILE)
         | 
| 41 | 
            +
                     db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  if File.exist?(BACKUP_FILE)
         | 
| 45 | 
            +
                     File.delete(BACKUP_FILE)
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 48 | 
            +
               end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
               def test01
         | 
| 51 | 
            +
                  sm = ServiceManager.new('localhost')
         | 
| 52 | 
            +
                  sm.connect(DB_USER_NAME, DB_PASSWORD)
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  b = Backup.new(DB_FILE, BACKUP_FILE)
         | 
| 55 | 
            +
                  b.execute(sm)
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  assert(File.exist?(BACKUP_FILE))
         | 
| 58 | 
            +
                  @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 59 | 
            +
                  assert(File.exists?(DB_FILE) == false)
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  r = Restore.new(BACKUP_FILE, DB_FILE)
         | 
| 62 | 
            +
                  r.execute(sm)
         | 
| 63 | 
            +
                  sm.disconnect
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  assert(File.exist?(DB_FILE))
         | 
| 66 | 
            +
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 67 | 
            +
                     total = 0
         | 
| 68 | 
            +
                     cxn.execute_immediate('select * from test') do |row|
         | 
| 69 | 
            +
                        assert([1000, 2000, 3000, 4000, nil].include?(row[0]))
         | 
| 70 | 
            +
                        total += 1
         | 
| 71 | 
            +
                     end
         | 
| 72 | 
            +
                     assert(total == 5)
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
               end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
               def test02
         | 
| 77 | 
            +
                  sm = ServiceManager.new('localhost')
         | 
| 78 | 
            +
                  sm.connect(DB_USER_NAME, DB_PASSWORD)
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                  b = Backup.new(DB_FILE, BACKUP_FILE)
         | 
| 81 | 
            +
                  b.metadata_only = true
         | 
| 82 | 
            +
                  b.execute(sm)
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                  assert(File.exist?(BACKUP_FILE))
         | 
| 85 | 
            +
                  @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 86 | 
            +
                  assert(File.exists?(DB_FILE) == false)
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  r = Restore.new(BACKUP_FILE, DB_FILE)
         | 
| 89 | 
            +
                  r.execute(sm)
         | 
| 90 | 
            +
                  sm.disconnect
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  assert(File.exist?(DB_FILE))
         | 
| 93 | 
            +
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 94 | 
            +
                     cxn.execute_immediate('select count(*) from test') do |row|
         | 
| 95 | 
            +
                        assert(row[0] == 0)
         | 
| 96 | 
            +
                     end
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
               end
         | 
| 99 | 
            +
            end
         | 
    
        data/test/BlobTest.rb
    ADDED
    
    | @@ -0,0 +1,57 @@ | |
| 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 BlobTest < Test::Unit::TestCase
         | 
| 11 | 
            +
               CURDIR      = "#{Dir.getwd}"
         | 
| 12 | 
            +
               DB_FILE     = "#{CURDIR}#{File::SEPARATOR}blob_unit_test.fdb"
         | 
| 13 | 
            +
               TXT_FILE    = "#{CURDIR}#{File::SEPARATOR}data.txt"
         | 
| 14 | 
            +
               DATA        = "aasdfjakhdsfljkashdfslfhaslhasyhfawyufalwuhlhsdlkfhasljlkshflalksjhasjhalsjhdf\nasdflkajshdfjkahsdfjajdfalsdfasdf\nasdfasdfasdkljfhajdfhkjasdfagdsflalkjfgagsdflasdf\nasdfasdfasdf"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
               def setup
         | 
| 17 | 
            +
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 18 | 
            +
                  # Remove existing database files.
         | 
| 19 | 
            +
                  @database = Database.new(DB_FILE)
         | 
| 20 | 
            +
                  if File.exist?(DB_FILE)
         | 
| 21 | 
            +
                     @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                  Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
         | 
| 24 | 
            +
               end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
               def teardown
         | 
| 27 | 
            +
                  # Remove existing database files.
         | 
| 28 | 
            +
                  if File.exist?(DB_FILE)
         | 
| 29 | 
            +
                     @database.drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 33 | 
            +
               end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
               def test01
         | 
| 36 | 
            +
                  d = nil
         | 
| 37 | 
            +
                  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         | 
| 38 | 
            +
                     cxn.execute_immediate('create table blob_test (data blob sub_type 0)')
         | 
| 39 | 
            +
                     cxn.start_transaction do |tx|
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                        s = Statement.new(cxn, tx, 'INSERT INTO BLOB_TEST VALUES(?)', 3)
         | 
| 42 | 
            +
                        s.execute_for([DATA])
         | 
| 43 | 
            +
                        
         | 
| 44 | 
            +
                        # Perform a select of the value inserted.
         | 
| 45 | 
            +
                        r = cxn.execute('SELECT * FROM BLOB_TEST', tx)
         | 
| 46 | 
            +
                        d = r.fetch
         | 
| 47 | 
            +
                        
         | 
| 48 | 
            +
                        assert_equal(d[0].to_s, DATA)
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                        # Clean up.
         | 
| 51 | 
            +
                        s.close
         | 
| 52 | 
            +
                        r.close
         | 
| 53 | 
            +
                     end
         | 
| 54 | 
            +
                     cxn.execute_immediate('DROP TABLE BLOB_TEST')
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
               end
         | 
| 57 | 
            +
            end
         | 
    
        data/test/CharacterSetTest.rb
    CHANGED
    
    | @@ -1,63 +1,63 @@ | |
| 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 CharacterSetTest < Test::Unit::TestCase
         | 
| 11 | 
            -
               CURDIR   = "#{Dir.getwd}"
         | 
| 12 | 
            -
               DB_FILE  = "#{CURDIR}#{File::SEPARATOR}cxnarset_unit_test.fdb"
         | 
| 13 | 
            -
               CHAR_SET = 'WIN1251'
         | 
| 14 | 
            -
               
         | 
| 15 | 
            -
               def setup
         | 
| 16 | 
            -
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 17 | 
            -
                  if File::exist?(DB_FILE)
         | 
| 18 | 
            -
                     Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024,
         | 
| 22 | 
            -
                                              CHAR_SET)
         | 
| 23 | 
            -
               end
         | 
| 24 | 
            -
               
         | 
| 25 | 
            -
               def teardown
         | 
| 26 | 
            -
                  if File::exist?(DB_FILE)
         | 
| 27 | 
            -
                     Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 28 | 
            -
                  end
         | 
| 29 | 
            -
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 30 | 
            -
               end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
               def test01
         | 
| 33 | 
            -
                  db = Database.new(DB_FILE, CHAR_SET)
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                  assert(db.character_set = CHAR_SET)
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                  db.character_set = 'ASCII'
         | 
| 38 | 
            -
                  assert(db.character_set == 'ASCII')
         | 
| 39 | 
            -
               end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
               def test02
         | 
| 42 | 
            -
                  text = "�?����"
         | 
| 43 | 
            -
                  db   = Database.new(DB_FILE, CHAR_SET)
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                  begin
         | 
| 46 | 
            -
                     db.connect("SYSDBA", "masterkey") do |cxn|
         | 
| 47 | 
            -
                        cxn.start_transaction do |tr|
         | 
| 48 | 
            -
                           cxn.execute("CREATE TABLE SAMPLE_TABLE(SAMPLE_FIELD VARCHAR(100))",tr)
         | 
| 49 | 
            -
                        end  
         | 
| 50 | 
            -
                        cxn.start_transaction do |tr|
         | 
| 51 | 
            -
                           cxn.execute("INSERT INTO SAMPLE_TABLE VALUES ('#{win1251_str}')",tr)
         | 
| 52 | 
            -
                           cxn.execute("SELECT * FROM SAMPLE_TABLE WHERE SAMPLE_FIELD = "\
         | 
| 53 | 
            -
                                       "'#{win1251_str}'",tr) do |row|
         | 
| 54 | 
            -
                              # here we have an exception:
         | 
| 55 | 
            -
                              some_var = row['SAMPLE_FIELD']
         | 
| 56 | 
            -
                           end
         | 
| 57 | 
            -
                        end
         | 
| 58 | 
            -
                     end
         | 
| 59 | 
            -
                  rescue => error
         | 
| 60 | 
            -
                     assert("Character set unit test failure.", false)
         | 
| 61 | 
            -
                  end
         | 
| 62 | 
            -
               end
         | 
| 63 | 
            -
            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 CharacterSetTest < Test::Unit::TestCase
         | 
| 11 | 
            +
               CURDIR   = "#{Dir.getwd}"
         | 
| 12 | 
            +
               DB_FILE  = "#{CURDIR}#{File::SEPARATOR}cxnarset_unit_test.fdb"
         | 
| 13 | 
            +
               CHAR_SET = 'WIN1251'
         | 
| 14 | 
            +
               
         | 
| 15 | 
            +
               def setup
         | 
| 16 | 
            +
                  puts "#{self.class.name} started." if TEST_LOGGING
         | 
| 17 | 
            +
                  if File::exist?(DB_FILE)
         | 
| 18 | 
            +
                     Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024,
         | 
| 22 | 
            +
                                              CHAR_SET)
         | 
| 23 | 
            +
               end
         | 
| 24 | 
            +
               
         | 
| 25 | 
            +
               def teardown
         | 
| 26 | 
            +
                  if File::exist?(DB_FILE)
         | 
| 27 | 
            +
                     Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                  puts "#{self.class.name} finished." if TEST_LOGGING
         | 
| 30 | 
            +
               end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
               def test01
         | 
| 33 | 
            +
                  db = Database.new(DB_FILE, CHAR_SET)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  assert(db.character_set = CHAR_SET)
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  db.character_set = 'ASCII'
         | 
| 38 | 
            +
                  assert(db.character_set == 'ASCII')
         | 
| 39 | 
            +
               end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
               def test02
         | 
| 42 | 
            +
                  text = "�?����"
         | 
| 43 | 
            +
                  db   = Database.new(DB_FILE, CHAR_SET)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  begin
         | 
| 46 | 
            +
                     db.connect("SYSDBA", "masterkey") do |cxn|
         | 
| 47 | 
            +
                        cxn.start_transaction do |tr|
         | 
| 48 | 
            +
                           cxn.execute("CREATE TABLE SAMPLE_TABLE(SAMPLE_FIELD VARCHAR(100))",tr)
         | 
| 49 | 
            +
                        end  
         | 
| 50 | 
            +
                        cxn.start_transaction do |tr|
         | 
| 51 | 
            +
                           cxn.execute("INSERT INTO SAMPLE_TABLE VALUES ('#{win1251_str}')",tr)
         | 
| 52 | 
            +
                           cxn.execute("SELECT * FROM SAMPLE_TABLE WHERE SAMPLE_FIELD = "\
         | 
| 53 | 
            +
                                       "'#{win1251_str}'",tr) do |row|
         | 
| 54 | 
            +
                              # here we have an exception:
         | 
| 55 | 
            +
                              some_var = row['SAMPLE_FIELD']
         | 
| 56 | 
            +
                           end
         | 
| 57 | 
            +
                        end
         | 
| 58 | 
            +
                     end
         | 
| 59 | 
            +
                  rescue => error
         | 
| 60 | 
            +
                     assert("Character set unit test failure.", false)
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
               end
         | 
| 63 | 
            +
            end
         |