ruby-oci8 1.0.6-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/ChangeLog +693 -0
  2. data/Makefile +51 -0
  3. data/NEWS +407 -0
  4. data/README +415 -0
  5. data/VERSION +1 -0
  6. data/dist-files +71 -0
  7. data/doc/api.en.html +527 -0
  8. data/doc/api.en.rd +554 -0
  9. data/doc/api.ja.html +525 -0
  10. data/doc/api.ja.rd +557 -0
  11. data/doc/manual.css +35 -0
  12. data/ext/oci8/oci8lib.so +0 -0
  13. data/lib/dbd/OCI8.rb +591 -0
  14. data/lib/oci8.rb +1655 -0
  15. data/lib/oci8.rb.in +1655 -0
  16. data/metaconfig +142 -0
  17. data/pre-distclean.rb +7 -0
  18. data/ruby-oci8.gemspec +54 -0
  19. data/ruby-oci8.spec +62 -0
  20. data/setup.rb +1331 -0
  21. data/support/README +4 -0
  22. data/support/runit/assert.rb +281 -0
  23. data/support/runit/cui/testrunner.rb +101 -0
  24. data/support/runit/error.rb +4 -0
  25. data/support/runit/method_mappable.rb +20 -0
  26. data/support/runit/robserver.rb +25 -0
  27. data/support/runit/setuppable.rb +15 -0
  28. data/support/runit/teardownable.rb +16 -0
  29. data/support/runit/testcase.rb +113 -0
  30. data/support/runit/testfailure.rb +25 -0
  31. data/support/runit/testresult.rb +121 -0
  32. data/support/runit/testsuite.rb +43 -0
  33. data/support/runit/version.rb +3 -0
  34. data/test/README +4 -0
  35. data/test/config.rb +129 -0
  36. data/test/test_all.rb +48 -0
  37. data/test/test_bind_raw.rb +53 -0
  38. data/test/test_bind_time.rb +191 -0
  39. data/test/test_break.rb +81 -0
  40. data/test/test_clob.rb +101 -0
  41. data/test/test_connstr.rb +80 -0
  42. data/test/test_dbi.rb +327 -0
  43. data/test/test_dbi_clob.rb +58 -0
  44. data/test/test_describe.rb +137 -0
  45. data/test/test_metadata.rb +243 -0
  46. data/test/test_oci8.rb +273 -0
  47. data/test/test_oradate.rb +263 -0
  48. data/test/test_oranumber.rb +149 -0
  49. data/test/test_rowid.rb +38 -0
  50. metadata +105 -0
@@ -0,0 +1,16 @@
1
+ require 'runit/method_mappable'
2
+ module RUNIT
3
+ module Teardownable
4
+ include MethodMappable
5
+ @@teardowns = {}
6
+ def attach_teardown(teardown_method, *methods)
7
+ attach_method(@@teardowns, teardown_method, *methods)
8
+ end
9
+ private :attach_teardown
10
+ def invoke_teardown(m)
11
+ invoke_method(@@teardowns, m)
12
+ end
13
+ private :invoke_teardown
14
+ end
15
+ end
16
+
@@ -0,0 +1,113 @@
1
+ require 'observer'
2
+ require 'runit/testsuite'
3
+ require 'runit/robserver'
4
+ require 'runit/error'
5
+ require 'runit/assert'
6
+ require 'runit/setuppable'
7
+ require 'runit/teardownable'
8
+
9
+ module RUNIT
10
+ class TestCase
11
+ alias_method :extend_test, :extend
12
+
13
+ include Assert
14
+ include Observable
15
+
16
+ include Setuppable
17
+ extend Setuppable
18
+ include Teardownable
19
+ extend Teardownable
20
+
21
+ @@test_classes = []
22
+
23
+ def initialize(method, name=self.class.name)
24
+ @method = method
25
+ @name = name
26
+ end
27
+
28
+ def setup
29
+ end
30
+ private :setup
31
+
32
+ def teardown
33
+ end
34
+ private :teardown
35
+
36
+ def name
37
+ @name + "#" + @method
38
+ end
39
+
40
+ def method_name
41
+ @method
42
+ end
43
+
44
+ def count_test_cases
45
+ 1
46
+ end
47
+
48
+ def run(result)
49
+ result.start_test(self)
50
+ begin
51
+ run_bare
52
+ rescue AssertionFailedError
53
+ result.add_failure($@, $!, self.class)
54
+ rescue StandardError, ScriptError
55
+ result.add_error($@, $!, self.class)
56
+ end
57
+ result.end_test(self)
58
+ end
59
+
60
+ def run_bare
61
+ setup
62
+ invoke_setup(@method)
63
+ begin
64
+ send(@method)
65
+ ensure
66
+ begin
67
+ invoke_teardown(@method)
68
+ teardown
69
+ rescue
70
+ changed
71
+ notify_observers(RObserver::ADD_ERROR, $@, $!, self.class)
72
+ end
73
+ end
74
+ end
75
+
76
+ def ==(other)
77
+ other.class == self.class && other.method_name && self.method_name
78
+ end
79
+
80
+ def TestCase.suite
81
+ TestSuite.new(self_test_cases)
82
+ end
83
+
84
+ def TestCase.inherited(sub)
85
+ @@test_classes.push sub
86
+ end
87
+
88
+ def TestCase.self_test_cases
89
+ instance_methods(true).sort.collect {|m|
90
+ new(m, name) if /^test/ =~ m
91
+ }.compact
92
+ end
93
+
94
+ def TestCase.test_cases
95
+ if self == TestCase
96
+ TestSuite.new(*@@test_classes)
97
+ else
98
+ suite
99
+ end
100
+ end
101
+
102
+
103
+ class<<TestCase
104
+ alias test_methods test_cases
105
+ alias all_suite test_cases
106
+ private :self_test_cases
107
+ end
108
+
109
+ def TestCase.test_classes
110
+ @@test_classes
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,25 @@
1
+ module RUNIT
2
+ SKIP_FILES = $:.collect{|path| /#{path}\/runit\//}.push /\/rubyunit\.rb:/
3
+
4
+ class TestFailure
5
+ attr_reader :at, :err
6
+ def initialize(at, err, testclass)
7
+ skip_trace = at.reject{|i|
8
+ SKIP_FILES.find {|pat|
9
+ pat =~ i
10
+ }
11
+ }
12
+ @at = insert_class_name(skip_trace, testclass)
13
+ @err = err
14
+ end
15
+ def to_s
16
+ "#{@at[0]} #{@err}(#{@err.type})"
17
+ end
18
+ def insert_class_name(last_exception_backtrace, testclass)
19
+ tns = testclass.inspect.split("::")
20
+ last_exception_backtrace[0] += "(" + tns[tns.length-1] + ")"
21
+ last_exception_backtrace
22
+ end
23
+ private :insert_class_name
24
+ end
25
+ end
@@ -0,0 +1,121 @@
1
+ require 'observer'
2
+ require 'runit/error'
3
+ require 'runit/robserver'
4
+ require 'runit/testfailure'
5
+
6
+ module RUNIT
7
+ class TestResultItem
8
+ attr_reader :name
9
+ attr_reader :failures
10
+ attr_reader :errors
11
+ attr_accessor :run_asserts
12
+
13
+ def initialize(name)
14
+ @failures = []
15
+ @errors = []
16
+ @name = name
17
+ @run_asserts = 0
18
+ end
19
+
20
+ def add_failure(failure)
21
+ @failures.push failure
22
+ end
23
+
24
+ def add_error(error)
25
+ @errors.push error
26
+ end
27
+ end
28
+
29
+ class TestResult
30
+ include Observable
31
+ include RObserver
32
+
33
+ def initialize
34
+ @result = nil
35
+ @results = []
36
+ @test_start_time = nil
37
+ @test_end_time = nil
38
+ @start_assert_size = 0
39
+ end
40
+
41
+ def items
42
+ @results
43
+ end
44
+
45
+ def run_tests
46
+ @results.size
47
+ end
48
+
49
+ def add_failure(at, err, testclass)
50
+ fail = TestFailure.new(at, err, testclass)
51
+ @result.add_failure(fail)
52
+ changed
53
+ notify_observers(RObserver::ADD_FAILURE, at, err)
54
+ end
55
+
56
+ def add_error(at, err, testclass)
57
+ error = TestFailure.new(at, err, testclass)
58
+ @result.add_error(error)
59
+ changed
60
+ notify_observers(RObserver::ADD_ERROR, at, err)
61
+ end
62
+
63
+ def assert_size
64
+ size = 0
65
+ @results.each do |i|
66
+ size += i.run_asserts
67
+ end
68
+ size
69
+ end
70
+ alias run_asserts assert_size
71
+
72
+ def failure_size
73
+ failures.size
74
+ end
75
+
76
+ def error_size
77
+ errors.size
78
+ end
79
+
80
+ def failures
81
+ @results.collect{|r|
82
+ r.failures
83
+ }.flatten
84
+ end
85
+
86
+ def errors
87
+ @results.collect{|r|
88
+ r.errors
89
+ }.flatten
90
+ end
91
+
92
+ def succeed?
93
+ failure_size == 0 && error_size == 0
94
+ end
95
+
96
+ def running_time
97
+ if @test_end_time && @test_start_time
98
+ @test_end_time - @test_start_time
99
+ else
100
+ 0
101
+ end
102
+ end
103
+
104
+ def start_test(testcase)
105
+ testcase.add_observer(self)
106
+ @result = TestResultItem.new(testcase.name)
107
+ @results.push @result
108
+ @start_assert_size = Assert.run_asserts
109
+ @test_start_time = Time.now if !@test_start_time
110
+ changed
111
+ notify_observers(RObserver::START_TEST, testcase)
112
+ end
113
+
114
+ def end_test(testcase)
115
+ changed
116
+ notify_observers(RObserver::END_TEST, testcase)
117
+ @test_end_time = Time.now
118
+ @result.run_asserts = Assert.run_asserts - @start_assert_size
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,43 @@
1
+ module RUNIT
2
+ class TestSuite < Array
3
+
4
+ def initialize(*test_classes)
5
+ test_classes.each do |k|
6
+ if k.kind_of?(Array)
7
+ concat k
8
+ else
9
+ concat k.suite
10
+ end
11
+ end
12
+ end
13
+
14
+ def run(result)
15
+ each do |t|
16
+ t.run(result)
17
+ end
18
+ end
19
+
20
+ def count_test_cases
21
+ sum = 0
22
+ each do |test|
23
+ sum += test.count_test_cases
24
+ end
25
+ sum
26
+ end
27
+
28
+ def add(test)
29
+ if test.kind_of?(Array)
30
+ concat test
31
+ else
32
+ push test
33
+ end
34
+ end
35
+ alias add_test add
36
+
37
+ def extend_test(*mod)
38
+ each do |t|
39
+ t.extend_test(*mod)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module RUNIT
2
+ VERSION = '0.5.2'
3
+ end
@@ -0,0 +1,4 @@
1
+ This directory includes test cases using RubyUnit.
2
+
3
+ If RubyUnit is installed in your site, it is used to run test cases.
4
+ If not installed, support files in this package are used.
@@ -0,0 +1,129 @@
1
+ # $dbuser must have permission to run DBMS_LOCK.SLEEP
2
+ # connect as sys
3
+ # GRANT EXECUTE ON dbms_lock TO ruby;
4
+ $dbuser = "ruby"
5
+ $dbpass = "oci8"
6
+ $dbname = nil
7
+
8
+ # test_clob.rb
9
+
10
+ nls_lang = ENV['NLS_LANG']
11
+ nls_lang = nls_lang.split('.')[1] unless nls_lang.nil?
12
+ nls_lang = nls_lang.upcase unless nls_lang.nil?
13
+ case nls_lang
14
+ when 'JA16EUC'
15
+ $lobfile = File.dirname(__FILE__) + '/../doc/api.ja.rd' # EUC-JP file
16
+ else
17
+ $lobfile = File.dirname(__FILE__) + '/../doc/api.en.rd' # ASCII file
18
+ end
19
+ $lobreadnum = 256 # counts in charactors
20
+
21
+ # don't modify below.
22
+
23
+ # $oracle_server_version: database compatible level of the Oracle server.
24
+ # $oracle_client_version: Oracle client library version for which oci8 is compiled.
25
+ # $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
26
+ conn = OCI8.new($dbuser, $dbpass, $dbname)
27
+ conn.exec('select value from database_compatible_level') do |row|
28
+ ver = row[0].split('.')
29
+ $oracle_server_version = (ver[0] + ver[1] + ver[2]).to_i
30
+ end
31
+ conn.logoff
32
+ $oracle_client_version = OCI8::CLIENT_VERSION.to_i
33
+ if $oracle_server_version < $oracle_client_version
34
+ $oracle_version = $oracle_server_version
35
+ else
36
+ $oracle_version = $oracle_client_version
37
+ end
38
+
39
+ if $oracle_version <= 805
40
+ $describe_need_object_mode = true
41
+ $test_clob = false
42
+ elsif $oracle_version < 810
43
+ $describe_need_object_mode = false
44
+ $test_clob = false
45
+ else
46
+ $describe_need_object_mode = false
47
+ $test_clob = true
48
+ end
49
+
50
+ def do_connect ()
51
+ begin
52
+ yield
53
+ rescue OCIError
54
+ raise if $!.code != 12516 && $!.code != 12520
55
+ # sleep a few seconds and try again if
56
+ # the error code is ORA-12516 or ORA-12520.
57
+ #
58
+ # ORA-12516 - TNS:listener could not find available handler with
59
+ # matching protocol stack
60
+ # ORA-12520 - TNS:listener could not find available handler for
61
+ # requested type of server
62
+ #
63
+ # Thanks to Christopher Jones.
64
+ #
65
+ # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
66
+ # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
67
+ #
68
+ sleep(5)
69
+ yield
70
+ end
71
+ end
72
+
73
+ $env_is_initialized = false
74
+ def setup_lowapi()
75
+ if ! $env_is_initialized
76
+ if $describe_need_object_mode
77
+ OCIEnv.initialise(OCI_OBJECT)
78
+ else
79
+ OCIEnv.initialise(OCI_DEFAULT)
80
+ end
81
+ $env_is_initialized = true
82
+ end
83
+ env = OCIEnv.init()
84
+ svc = do_connect { env.logon($dbuser, $dbpass, $dbname) }
85
+ stmt = env.alloc(OCIStmt)
86
+ return env, svc, stmt
87
+ end
88
+
89
+ def get_oci_connection()
90
+ do_connect { OCI8.new($dbuser, $dbpass, $dbname) }
91
+ end
92
+
93
+ def get_dbi_connection()
94
+ do_connect { DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) }
95
+ end
96
+
97
+ module RUNIT
98
+ class TestCase
99
+ def drop_table(table_name)
100
+ if $oracle_server_version < 1000
101
+ # Oracle 8 - 9i
102
+ sql = "DROP TABLE #{table_name}"
103
+ else
104
+ # Oracle 10g -
105
+ sql = "DROP TABLE #{table_name} PURGE"
106
+ end
107
+
108
+ if defined? @conn
109
+ begin
110
+ @conn.exec(sql)
111
+ rescue OCIError
112
+ raise if $!.code != 942 # table or view does not exist
113
+ end
114
+ elsif defined? @dbh
115
+ begin
116
+ @dbh.do(sql)
117
+ rescue DBI::DatabaseError
118
+ raise if $!.err != 942 # table or view does not exist
119
+ end
120
+ elsif defined? @stmt
121
+ begin
122
+ @stmt.prepare(sql).execute(@svc)
123
+ rescue OCIError
124
+ raise if $!.code != 942 # table or view does not exist
125
+ end
126
+ end
127
+ end # drop_table
128
+ end
129
+ end