ruby-oci8 2.0.4-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1912 -0
- data/Makefile +96 -0
- data/NEWS +223 -0
- data/README +86 -0
- data/VERSION +1 -0
- data/dist-files +77 -0
- data/doc/api.en.html +527 -0
- data/doc/api.en.rd +554 -0
- data/doc/api.ja.html +525 -0
- data/doc/api.ja.rd +557 -0
- data/doc/manual.css +35 -0
- data/lib/.document +1 -0
- data/lib/dbd/OCI8.rb +591 -0
- data/lib/oci8.rb +82 -0
- data/lib/oci8.rb.in +82 -0
- data/lib/oci8/.document +5 -0
- data/lib/oci8/bindtype.rb +319 -0
- data/lib/oci8/compat.rb +113 -0
- data/lib/oci8/datetime.rb +619 -0
- data/lib/oci8/encoding-init.rb +40 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2077 -0
- data/lib/oci8/object.rb +562 -0
- data/lib/oci8/oci8.rb +571 -0
- data/lib/oci8/oracle_version.rb +144 -0
- data/lib/oci8lib_18.so +0 -0
- data/lib/oci8lib_191.so +0 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +63 -0
- data/setup.rb +1331 -0
- data/test/README +4 -0
- data/test/config.rb +109 -0
- data/test/test_all.rb +50 -0
- data/test/test_appinfo.rb +63 -0
- data/test/test_array_dml.rb +333 -0
- data/test/test_bind_raw.rb +46 -0
- data/test/test_bind_time.rb +178 -0
- data/test/test_break.rb +83 -0
- data/test/test_clob.rb +79 -0
- data/test/test_connstr.rb +81 -0
- data/test/test_datetime.rb +622 -0
- data/test/test_dbi.rb +366 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +100 -0
- data/test/test_metadata.rb +257 -0
- data/test/test_oci8.rb +434 -0
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +256 -0
- data/test/test_oranumber.rb +655 -0
- data/test/test_rowid.rb +33 -0
- metadata +108 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# Low-level API
|
2
|
+
require 'oci8'
|
3
|
+
require 'test/unit'
|
4
|
+
require File.dirname(__FILE__) + '/config'
|
5
|
+
|
6
|
+
class TestBindRaw < Test::Unit::TestCase
|
7
|
+
CHECK_TARGET = [
|
8
|
+
["0123456789:;<=>?", "303132333435363738393A3B3C3D3E3F"],
|
9
|
+
["@ABCDEFGHIJKLMNO", "404142434445464748494A4B4C4D4E4F"],
|
10
|
+
["PQRSTUVWXYZ[\\]^_", "505152535455565758595A5B5C5D5E5F"],
|
11
|
+
["`abcdefghijklmno", "606162636465666768696A6B6C6D6E6F"],
|
12
|
+
["pqrstuvwxyz{|}~", "707172737475767778797A7B7C7D7E"],
|
13
|
+
]
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@conn = get_oci8_connection()
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_set_raw
|
20
|
+
cursor = @conn.parse("BEGIN :hex := RAWTOHEX(:raw); END;")
|
21
|
+
cursor.bind_param(:raw, nil, OCI8::RAW, 16)
|
22
|
+
cursor.bind_param(:hex, nil, String, 32)
|
23
|
+
|
24
|
+
CHECK_TARGET.each do |raw, hex|
|
25
|
+
cursor[:raw] = raw
|
26
|
+
cursor.exec
|
27
|
+
assert_equal(hex, cursor[:hex])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_raw
|
32
|
+
cursor = @conn.parse("BEGIN :raw := HEXTORAW(:hex); END;")
|
33
|
+
cursor.bind_param(:hex, nil, String, 32)
|
34
|
+
cursor.bind_param(:raw, nil, OCI8::RAW, 16)
|
35
|
+
|
36
|
+
CHECK_TARGET.each do |raw, hex|
|
37
|
+
cursor[:hex] = hex
|
38
|
+
cursor.exec
|
39
|
+
assert_equal(raw, cursor[:raw])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def teardown
|
44
|
+
@conn.logoff
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'oci8'
|
2
|
+
require 'test/unit'
|
3
|
+
require File.dirname(__FILE__) + '/config'
|
4
|
+
|
5
|
+
class TestBindTime < Test::Unit::TestCase
|
6
|
+
|
7
|
+
YEAR_CHECK_TARGET = [1971, 1989, 2002, 2037]
|
8
|
+
MON_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
9
|
+
DAY_CHECK_TARGET = [1, 10, 20, 31] # days of January.
|
10
|
+
HOUR_CHECK_TARGET = [0, 6, 12, 18, 23]
|
11
|
+
MIN_CHECK_TARGET = [0, 15, 30, 45, 59]
|
12
|
+
SEC_CHECK_TARGET = [0, 15, 30, 45, 59]
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@conn = get_oci8_connection
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_set_year
|
19
|
+
cursor = @conn.parse("BEGIN :year := TO_NUMBER(TO_CHAR(:time, 'SYYYY'), '9999'); END;")
|
20
|
+
cursor.bind_param(:time, Time)
|
21
|
+
cursor.bind_param(:year, Fixnum)
|
22
|
+
|
23
|
+
YEAR_CHECK_TARGET.each do |i|
|
24
|
+
# set year
|
25
|
+
cursor[:time] = Time.local(i, 1)
|
26
|
+
# check result
|
27
|
+
cursor.exec
|
28
|
+
assert_equal(i, cursor[:year])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_get_year
|
33
|
+
cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
|
34
|
+
cursor.bind_param(:year, Fixnum)
|
35
|
+
cursor.bind_param(:time, Time)
|
36
|
+
YEAR_CHECK_TARGET.each do |i|
|
37
|
+
# set time via oracle.
|
38
|
+
cursor[:year] = i
|
39
|
+
cursor.exec
|
40
|
+
# check Time#year
|
41
|
+
assert_equal(i, cursor[:time].year)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_set_mon
|
46
|
+
cursor = @conn.parse("BEGIN :mon := TO_NUMBER(TO_CHAR(:time, 'MM'), '99'); END;")
|
47
|
+
cursor.bind_param(:time, Time)
|
48
|
+
cursor.bind_param(:mon, Fixnum)
|
49
|
+
MON_CHECK_TARGET.each do |i|
|
50
|
+
# set mon
|
51
|
+
cursor[:time] = Time.local(2001, i)
|
52
|
+
# check result via oracle.
|
53
|
+
cursor.exec
|
54
|
+
assert_equal(i, cursor[:mon])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_get_mon
|
59
|
+
cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:mon, '99'), 'MM'); END;")
|
60
|
+
cursor.bind_param(:mon, Fixnum)
|
61
|
+
cursor.bind_param(:time, Time)
|
62
|
+
MON_CHECK_TARGET.each do |i|
|
63
|
+
# set time via oracle.
|
64
|
+
cursor[:mon] = i;
|
65
|
+
cursor.exec
|
66
|
+
# check Time#mon
|
67
|
+
assert_equal(i, cursor[:time].mon)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_set_day
|
72
|
+
cursor = @conn.parse("BEGIN :day := TO_NUMBER(TO_CHAR(:time, 'DD'), '99'); END;")
|
73
|
+
cursor.bind_param(:time, Time)
|
74
|
+
cursor.bind_param(:day, Fixnum)
|
75
|
+
DAY_CHECK_TARGET.each do |i|
|
76
|
+
# set day
|
77
|
+
cursor[:time] = Time.local(2001, 1, i)
|
78
|
+
# check result via oracle.
|
79
|
+
cursor.exec
|
80
|
+
assert_equal(i, cursor[:day])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_get_day
|
85
|
+
cursor = @conn.parse("BEGIN :time := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
|
86
|
+
day_in = cursor.bind_param(:day, Fixnum)
|
87
|
+
time_out = cursor.bind_param(:time, Time)
|
88
|
+
DAY_CHECK_TARGET.each do |i|
|
89
|
+
# set time via oracle.
|
90
|
+
cursor[:day] = i;
|
91
|
+
cursor.exec
|
92
|
+
# check Time#day
|
93
|
+
assert_equal(i, cursor[:time].day)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_set_hour
|
98
|
+
cursor = @conn.parse("BEGIN :hour := TO_NUMBER(TO_CHAR(:time, 'HH24'), '99'); END;")
|
99
|
+
cursor.bind_param(:time, Time)
|
100
|
+
cursor.bind_param(:hour, Fixnum)
|
101
|
+
HOUR_CHECK_TARGET.each do |i|
|
102
|
+
# set hour
|
103
|
+
cursor[:time] = Time.local(2001, 1, 1, i)
|
104
|
+
# check result via oracle.
|
105
|
+
cursor.exec
|
106
|
+
assert_equal(i, cursor[:hour])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_get_hour
|
111
|
+
cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
|
112
|
+
cursor.bind_param(:hour, Fixnum)
|
113
|
+
cursor.bind_param(:time, Time)
|
114
|
+
HOUR_CHECK_TARGET.each do |i|
|
115
|
+
# set time via oracle.
|
116
|
+
cursor[:hour] = i
|
117
|
+
cursor.exec
|
118
|
+
# check Time#hour
|
119
|
+
assert_equal(i, cursor[:time].hour)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_set_min
|
124
|
+
cursor = @conn.parse("BEGIN :min := TO_NUMBER(TO_CHAR(:time, 'MI'), '99'); END;")
|
125
|
+
cursor.bind_param(:time, Time)
|
126
|
+
cursor.bind_param(:min, Fixnum)
|
127
|
+
MIN_CHECK_TARGET.each do |i|
|
128
|
+
# set min
|
129
|
+
cursor[:time] = Time.local(2001, 1, 1, 0, i)
|
130
|
+
# check result via oracle.
|
131
|
+
cursor.exec
|
132
|
+
assert_equal(i, cursor[:min])
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_get_min
|
137
|
+
cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:min, '99'), 'MI'); END;")
|
138
|
+
cursor.bind_param(:min, Fixnum)
|
139
|
+
cursor.bind_param(:time, Time)
|
140
|
+
MIN_CHECK_TARGET.each do |i|
|
141
|
+
# set time via oracle.
|
142
|
+
cursor[:min] = i;
|
143
|
+
cursor.exec
|
144
|
+
# check Time#min
|
145
|
+
assert_equal(i, cursor[:time].min)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_set_sec
|
150
|
+
cursor = @conn.parse("BEGIN :sec := TO_NUMBER(TO_CHAR(:time, 'SS'), '99'); END;")
|
151
|
+
cursor.bind_param(:time, Time)
|
152
|
+
cursor.bind_param(:sec, Fixnum)
|
153
|
+
SEC_CHECK_TARGET.each do |i|
|
154
|
+
# set sec
|
155
|
+
cursor[:time] = Time.local(2001, 1, 1, 0, 0, i)
|
156
|
+
# check result via oracle.
|
157
|
+
cursor.exec
|
158
|
+
assert_equal(i, cursor[:sec])
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_get_sec
|
163
|
+
cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:sec, '99'), 'SS'); END;")
|
164
|
+
cursor.bind_param(:sec, Fixnum)
|
165
|
+
cursor.bind_param(:time, Time)
|
166
|
+
SEC_CHECK_TARGET.each do |i|
|
167
|
+
# set time via oracle.
|
168
|
+
cursor[:sec] = i
|
169
|
+
cursor.exec
|
170
|
+
# check Time#sec
|
171
|
+
assert_equal(i, cursor[:time].sec)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def teardown
|
176
|
+
@conn.logoff
|
177
|
+
end
|
178
|
+
end
|
data/test/test_break.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# High-level API
|
2
|
+
require 'oci8'
|
3
|
+
require 'test/unit'
|
4
|
+
require File.dirname(__FILE__) + '/config'
|
5
|
+
|
6
|
+
class TestBreak < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@conn = get_oci8_connection
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
@conn.logoff
|
14
|
+
end
|
15
|
+
|
16
|
+
def report(str)
|
17
|
+
printf "%d: %s\n", (Time.now - $start_time), str
|
18
|
+
end
|
19
|
+
|
20
|
+
PLSQL_DONE = 1
|
21
|
+
OCIBREAK = 2
|
22
|
+
SEND_BREAK = 3
|
23
|
+
|
24
|
+
TIME_IN_PLSQL = 5
|
25
|
+
TIME_TO_BREAK = 2
|
26
|
+
MARGIN = 0.1
|
27
|
+
|
28
|
+
def do_test_ocibreak(conn, expect)
|
29
|
+
$start_time = Time.now
|
30
|
+
|
31
|
+
th = Thread.start do
|
32
|
+
begin
|
33
|
+
conn.exec("BEGIN DBMS_LOCK.SLEEP(#{TIME_IN_PLSQL}); END;")
|
34
|
+
assert_equal(expect[PLSQL_DONE], (Time.now - $start_time + MARGIN).to_i, 'PLSQL_DONE')
|
35
|
+
rescue OCIBreak
|
36
|
+
assert_equal(expect[OCIBREAK], (Time.now - $start_time + MARGIN).to_i, 'OCIBREAK')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
sleep(0.01) # make a time to run DBMS_LOCK.SLEEP
|
41
|
+
sleep(TIME_TO_BREAK)
|
42
|
+
assert_equal(expect[SEND_BREAK], (Time.now - $start_time + MARGIN).to_i, 'SEND_BREAK')
|
43
|
+
conn.break()
|
44
|
+
th.join
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_blocking_mode
|
48
|
+
@conn.non_blocking = false
|
49
|
+
assert_equal(false, @conn.non_blocking?)
|
50
|
+
expect = []
|
51
|
+
expect[PLSQL_DONE] = TIME_IN_PLSQL
|
52
|
+
expect[OCIBREAK] = "Invalid status"
|
53
|
+
expect[SEND_BREAK] = TIME_IN_PLSQL + TIME_TO_BREAK
|
54
|
+
do_test_ocibreak(@conn, expect)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_non_blocking_mode
|
58
|
+
is_windows_server = false
|
59
|
+
@conn.exec('select banner from v$version') do |row|
|
60
|
+
is_windows_server = true if row[0].include? 'Windows'
|
61
|
+
end
|
62
|
+
|
63
|
+
@conn.non_blocking = true
|
64
|
+
assert_equal(true, @conn.non_blocking?)
|
65
|
+
expect = []
|
66
|
+
if is_windows_server
|
67
|
+
if $oracle_server_version >= OCI8::ORAVER_9_0
|
68
|
+
# raise after sleeping #{TIME_IN_PLSQL} seconds.
|
69
|
+
expect[PLSQL_DONE] = "Invalid status"
|
70
|
+
expect[OCIBREAK] = TIME_IN_PLSQL
|
71
|
+
else
|
72
|
+
expect[PLSQL_DONE] = TIME_IN_PLSQL
|
73
|
+
expect[OCIBREAK] = "Invalid status"
|
74
|
+
end
|
75
|
+
else
|
76
|
+
# raise immediately by OCI8#break.
|
77
|
+
expect[PLSQL_DONE] = "Invalid status"
|
78
|
+
expect[OCIBREAK] = TIME_TO_BREAK
|
79
|
+
end
|
80
|
+
expect[SEND_BREAK] = TIME_TO_BREAK
|
81
|
+
do_test_ocibreak(@conn, expect)
|
82
|
+
end
|
83
|
+
end
|
data/test/test_clob.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Low-level API
|
2
|
+
require 'oci8'
|
3
|
+
require 'test/unit'
|
4
|
+
require File.dirname(__FILE__) + '/config'
|
5
|
+
|
6
|
+
class TestCLob < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@conn = get_oci8_connection
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_insert
|
13
|
+
filename = File.basename($lobfile)
|
14
|
+
@conn.exec("DELETE FROM test_clob WHERE filename = :1", filename)
|
15
|
+
@conn.exec("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", filename)
|
16
|
+
cursor = @conn.exec("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)
|
17
|
+
lob = cursor.fetch[0]
|
18
|
+
open($lobfile) do |f|
|
19
|
+
while f.gets()
|
20
|
+
lob.write($_)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
lob.close
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_insert_with_flush
|
27
|
+
filename = File.basename($lobfile)
|
28
|
+
@conn.exec("DELETE FROM test_clob WHERE filename = :1", filename)
|
29
|
+
@conn.exec("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", filename)
|
30
|
+
cursor = @conn.exec("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)
|
31
|
+
lob = cursor.fetch[0]
|
32
|
+
lob.sync = false
|
33
|
+
open($lobfile) do |f|
|
34
|
+
while f.gets()
|
35
|
+
lob.write($_)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
lob.flush
|
39
|
+
lob.close
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_insert_symbol
|
43
|
+
filename = 'test_symbol'
|
44
|
+
value = :foo_bar
|
45
|
+
@conn.exec("DELETE FROM test_clob WHERE filename = :1", filename)
|
46
|
+
@conn.exec("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", filename)
|
47
|
+
cursor = @conn.exec("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)
|
48
|
+
lob = cursor.fetch[0]
|
49
|
+
lob.write(value)
|
50
|
+
lob.rewind
|
51
|
+
assert_equal(value.to_s, lob.read);
|
52
|
+
lob.close
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_read
|
56
|
+
test_insert() # first insert data.
|
57
|
+
filename = File.basename($lobfile)
|
58
|
+
cursor = @conn.exec("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)
|
59
|
+
lob = cursor.fetch[0]
|
60
|
+
|
61
|
+
open($lobfile) do |f|
|
62
|
+
while buf = lob.read($lobreadnum)
|
63
|
+
fbuf = f.read(buf.size)
|
64
|
+
assert_equal(fbuf, buf)
|
65
|
+
# offset += buf.size will not work fine,
|
66
|
+
# Though buf.size counts in byte,
|
67
|
+
# offset and $lobreadnum count in character.
|
68
|
+
end
|
69
|
+
assert_equal(nil, buf)
|
70
|
+
assert(f.eof?)
|
71
|
+
assert(lob.eof?)
|
72
|
+
end
|
73
|
+
lob.close
|
74
|
+
end
|
75
|
+
|
76
|
+
def teardown
|
77
|
+
@conn.logoff
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'oci8'
|
2
|
+
require 'test/unit'
|
3
|
+
require File.dirname(__FILE__) + '/config'
|
4
|
+
|
5
|
+
class TestConnStr < Test::Unit::TestCase
|
6
|
+
TEST_CASES =
|
7
|
+
[
|
8
|
+
# success cases:
|
9
|
+
# [ 'connect_string', expected result as an array]
|
10
|
+
# error cases:
|
11
|
+
# [ 'connect_string', ExceptionClass]
|
12
|
+
["hr/hr@host/service_name", ["hr", "hr", "host/service_name", nil]],
|
13
|
+
["sys/syspw@host/service_name AS SYSdba ", ["sys", "syspw", "host/service_name", :SYSDBA]],
|
14
|
+
["sys/syspw@host:1521/service_name as sysdba", ["sys", "syspw", "host:1521/service_name", :SYSDBA]],
|
15
|
+
# error cases
|
16
|
+
["service_name", ArgumentError],
|
17
|
+
["", ArgumentError],
|
18
|
+
["foo bar/baz", ArgumentError],
|
19
|
+
["foo@bar/baz", ArgumentError],
|
20
|
+
# raise error in connecting but no error in parse_connect_string.
|
21
|
+
["foo/bar as sysdbaaa", ["foo", "bar", nil, "sysdbaaa"]],
|
22
|
+
|
23
|
+
##
|
24
|
+
## following test cases are contributed by Shiwei Zhang.
|
25
|
+
##
|
26
|
+
#"username/password"
|
27
|
+
["username/password", ["username", "password", nil, nil]],
|
28
|
+
#"username/password@[//]host[:port][/service_name]"
|
29
|
+
["username/password@host", ["username", "password", "host", nil]],
|
30
|
+
["username/password@host/service_name", ["username", "password", "host/service_name", nil]],
|
31
|
+
["username/password@host:1521", ["username", "password", "host:1521", nil]],
|
32
|
+
["username/password@host:1521/service_name", ["username", "password", "host:1521/service_name", nil]],
|
33
|
+
["username/password@//host", ["username", "password", "//host", nil]],
|
34
|
+
["username/password@//host/service_name", ["username", "password", "//host/service_name", nil]],
|
35
|
+
["username/password@//host:1521", ["username", "password", "//host:1521", nil]],
|
36
|
+
["username/password@//host:1521/service_name", ["username", "password", "//host:1521/service_name", nil]],
|
37
|
+
#"username/password as{sysoper|sysdba}"
|
38
|
+
["username/password as sysoper", ["username", "password", nil, :SYSOPER]],
|
39
|
+
["username/password as sysdba", ["username", "password", nil, :SYSDBA]],
|
40
|
+
#"username/password@[//]host[:port][/service_name] as {sysoper|sysdba}"
|
41
|
+
["username/password@host as sysoper", ["username", "password", "host", :SYSOPER]],
|
42
|
+
["username/password@host as sysdba", ["username", "password", "host", :SYSDBA]],
|
43
|
+
["username/password@host/service_name as sysoper", ["username", "password", "host/service_name", :SYSOPER]],
|
44
|
+
["username/password@host/service_name as sysdba", ["username", "password", "host/service_name", :SYSDBA]],
|
45
|
+
["username/password@host:1521 as sysoper", ["username", "password", "host:1521", :SYSOPER]],
|
46
|
+
["username/password@host:1521 as sysdba", ["username", "password", "host:1521", :SYSDBA]],
|
47
|
+
["username/password@host:1521/service_name as sysoper", ["username", "password", "host:1521/service_name", :SYSOPER]],
|
48
|
+
["username/password@host:1521/service_name as sysdba", ["username", "password", "host:1521/service_name", :SYSDBA]],
|
49
|
+
["username/password@//host as sysoper", ["username", "password", "//host", :SYSOPER]],
|
50
|
+
["username/password@//host as sysdba", ["username", "password", "//host", :SYSDBA]],
|
51
|
+
["username/password@//host/service_name as sysoper", ["username", "password", "//host/service_name", :SYSOPER]],
|
52
|
+
["username/password@//host/service_name as sysdba", ["username", "password", "//host/service_name", :SYSDBA]],
|
53
|
+
["username/password@//host:1521 as sysoper", ["username", "password", "//host:1521", :SYSOPER]],
|
54
|
+
["username/password@//host:1521 as sysdba", ["username", "password", "//host:1521", :SYSDBA]],
|
55
|
+
["username/password@//host:1521/service_name as sysoper", ["username", "password", "//host:1521/service_name", :SYSOPER]],
|
56
|
+
["username/password@//host:1521/service_name as sysdba", ["username", "password", "//host:1521/service_name", :SYSDBA]],
|
57
|
+
["/passwd@192.168.19.19:1521/orcl as sysdba", ["", "passwd", "192.168.19.19:1521/orcl", :SYSDBA]],
|
58
|
+
["/", [nil, nil, nil, nil]],
|
59
|
+
["/ as sysdba", [nil, nil, nil, :SYSDBA]],
|
60
|
+
]
|
61
|
+
|
62
|
+
def test_connstr
|
63
|
+
obj = OCI8.allocate # create an uninitialized object.
|
64
|
+
TEST_CASES.each do |test_case|
|
65
|
+
case test_case[1]
|
66
|
+
when Array
|
67
|
+
# use instance_eval to call a private method parse_connect_string.
|
68
|
+
result = obj.instance_eval { parse_connect_string(test_case[0]) }
|
69
|
+
assert_equal(test_case[1], result, test_case[0])
|
70
|
+
when Class
|
71
|
+
assert_raises(test_case[1]) do
|
72
|
+
result = obj.instance_eval { parse_connect_string(test_case[0]) }
|
73
|
+
end
|
74
|
+
else
|
75
|
+
raise "unsupported testcase"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
Test::Unit::AutoRunner.run() if $0 == __FILE__
|