[ruby-oci8-commit] [237] trunk/ruby-oci8: * test/config.rb, test/test_bind_raw.rb, test/ test_bind_time.rb,

nobody at rubyforge.org nobody at rubyforge.org
Tue Jan 8 09:33:02 EST 2008


Revision: 237
Author:   kubo
Date:     2008-01-08 09:33:01 -0500 (Tue, 08 Jan 2008)

Log Message:
-----------
* test/config.rb, test/test_bind_raw.rb, test/test_bind_time.rb,
  test/test_break.rb, test/test_clob.rb, test/test_datetime.rb,
  test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb,
  test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb,
  test_oranumber.rb: use one OCI8 session for all OCI8 test cases
    and use one DBI session for all DBI test cases.
    Before this changes, connection/disconnection were called
    for each tests. If they are done too frequently and the Oracle
    server is on a remote server, the following error is raised.
      OCIError: ORA-12516: TNS:listener could not find available
      handler with matching protocol stack

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/test/config.rb
    trunk/ruby-oci8/test/test_bind_raw.rb
    trunk/ruby-oci8/test/test_bind_time.rb
    trunk/ruby-oci8/test/test_break.rb
    trunk/ruby-oci8/test/test_clob.rb
    trunk/ruby-oci8/test/test_datetime.rb
    trunk/ruby-oci8/test/test_dbi.rb
    trunk/ruby-oci8/test/test_dbi_clob.rb
    trunk/ruby-oci8/test/test_metadata.rb
    trunk/ruby-oci8/test/test_object.rb
    trunk/ruby-oci8/test/test_oci8.rb
    trunk/ruby-oci8/test/test_oradate.rb
    trunk/ruby-oci8/test/test_oranumber.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/ChangeLog	2008-01-08 14:33:01 UTC (rev 237)
@@ -1,3 +1,16 @@
+2008-01-08  KUBO Takehiro  <kubo at jiubao.org>
+	* test/config.rb, test/test_bind_raw.rb, test/test_bind_time.rb,
+	  test/test_break.rb, test/test_clob.rb, test/test_datetime.rb,
+	  test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb,
+	  test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb,
+	  test_oranumber.rb: use one OCI8 session for all OCI8 test cases
+	    and use one DBI session for all DBI test cases.
+	    Before this changes, connection/disconnection were called
+	    for each tests. If they are done too frequently and the Oracle
+	    server is on a remote server, the following error is raised.
+	      OCIError: ORA-12516: TNS:listener could not find available
+	      handler with matching protocol stack
+
 2008-01-04  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/oci8.h, ext/oci8/stmt.c: 1. add a 'pre_fetch_hook'
 	    callback function to oci8_bind_class_t. This function is

Modified: trunk/ruby-oci8/test/config.rb
===================================================================
--- trunk/ruby-oci8/test/config.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/config.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -20,15 +20,22 @@
 
 # don't modify below.
 
+$dbconn = OCI8.new($dbuser, $dbpass, $dbname)
+begin
+  require 'dbi'
+  $dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+rescue LoadError
+end
+
+
 # $oracle_server_version: database compatible level of the Oracle server.
 # $oracle_client_version: Oracle client library version for which oci8 is compiled.
 # $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
-conn = OCI8.new($dbuser, $dbpass, $dbname)
-conn.exec('select value from database_compatible_level') do |row|
+$dbconn.exec('select value from database_compatible_level') do |row|
   ver = row[0].split('.')
   $oracle_server_version = (ver[0] + ver[1] + ver[2]).to_i
 end
-conn.logoff
+
 $oracle_client_version = OCI8::CLIENT_VERSION.to_i
 if $oracle_server_version < $oracle_client_version
   $oracle_version = $oracle_server_version

Modified: trunk/ruby-oci8/test/test_bind_raw.rb
===================================================================
--- trunk/ruby-oci8/test/test_bind_raw.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_bind_raw.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -13,7 +13,7 @@
   ]
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def test_set_raw
@@ -41,6 +41,6 @@
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 end

Modified: trunk/ruby-oci8/test/test_bind_time.rb
===================================================================
--- trunk/ruby-oci8/test/test_bind_time.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_bind_time.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -12,7 +12,7 @@
   SEC_CHECK_TARGET = [0, 15, 30, 45, 59]
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def test_set_year
@@ -173,6 +173,6 @@
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 end

Modified: trunk/ruby-oci8/test/test_break.rb
===================================================================
--- trunk/ruby-oci8/test/test_break.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_break.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -5,6 +5,15 @@
 
 class TestBreak < Test::Unit::TestCase
 
+  def setup
+    @conn = $dbconn
+  end
+
+  def teardown
+    @conn.non_blocking = false
+    @conn.rollback
+  end
+
   def report(str)
     printf "%d: %s\n", (Time.now - $start_time), str
   end
@@ -37,21 +46,18 @@
   end
 
   def test_blocking_mode
-    conn = OCI8.new($dbuser, $dbpass, $dbname)
-    conn.non_blocking = false
-    assert_equal(false, conn.non_blocking?)
+    @conn.non_blocking = false
+    assert_equal(false, @conn.non_blocking?)
     expect = []
     expect[PLSQL_DONE] = TIME_IN_PLSQL
     expect[OCIBREAK]   = "Invalid status"
     expect[SEND_BREAK] = TIME_IN_PLSQL + TIME_TO_BREAK
-    do_test_ocibreak(conn, expect)
-    conn.logoff()
+    do_test_ocibreak(@conn, expect)
   end
 
   def test_non_blocking_mode
-    conn = OCI8.new($dbuser, $dbpass, $dbname)
-    conn.non_blocking = true
-    assert_equal(true, conn.non_blocking?)
+    @conn.non_blocking = true
+    assert_equal(true, @conn.non_blocking?)
     expect = []
     expect[PLSQL_DONE] = "Invalid status"
     if RUBY_PLATFORM =~ /mswin32|cygwin|mingw32|bccwin32/
@@ -62,7 +68,6 @@
       expect[OCIBREAK] = TIME_TO_BREAK
     end
     expect[SEND_BREAK]   = TIME_TO_BREAK
-    do_test_ocibreak(conn, expect)
-    conn.logoff()
+    do_test_ocibreak(@conn, expect)
   end
 end

Modified: trunk/ruby-oci8/test/test_clob.rb
===================================================================
--- trunk/ruby-oci8/test/test_clob.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_clob.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -6,7 +6,7 @@
 class TestCLob < Test::Unit::TestCase
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def test_insert
@@ -58,6 +58,6 @@
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 end

Modified: trunk/ruby-oci8/test/test_datetime.rb
===================================================================
--- trunk/ruby-oci8/test/test_datetime.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_datetime.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -13,12 +13,12 @@
   end
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
     @local_timezone = timezone_string(*((::Time.now.utc_offset / 60).divmod 60))
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 
   def test_date_select

Modified: trunk/ruby-oci8/test/test_dbi.rb
===================================================================
--- trunk/ruby-oci8/test/test_dbi.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_dbi.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -6,11 +6,11 @@
 class TestDBI < Test::Unit::TestCase
 
   def setup
-    @dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+    @dbh = $dbh
   end
 
   def teardown
-    @dbh.disconnect
+    @dbh.rollback
   end
 
   def test_select

Modified: trunk/ruby-oci8/test/test_dbi_clob.rb
===================================================================
--- trunk/ruby-oci8/test/test_dbi_clob.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_dbi_clob.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -5,7 +5,7 @@
 class TestDbiCLob < Test::Unit::TestCase
 
   def setup
-    @dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+    @dbh = $dbh
   end
 
   def test_insert
@@ -45,6 +45,6 @@
   end
 
   def teardown
-    @dbh.disconnect()
+    @dbh.rollback
   end
 end

Modified: trunk/ruby-oci8/test/test_metadata.rb
===================================================================
--- trunk/ruby-oci8/test/test_metadata.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_metadata.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -5,11 +5,11 @@
 class TestMetadata < Test::Unit::TestCase
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 
   def test_metadata

Modified: trunk/ruby-oci8/test/test_object.rb
===================================================================
--- trunk/ruby-oci8/test/test_object.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_object.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -9,12 +9,12 @@
   Delta = 0.00001
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
     RbTestObj.default_connection = @conn
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 
   class ExpectedValObjElem

Modified: trunk/ruby-oci8/test/test_oci8.rb
===================================================================
--- trunk/ruby-oci8/test/test_oci8.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_oci8.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -5,11 +5,11 @@
 class TestOCI8 < Test::Unit::TestCase
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 
   def test_rename

Modified: trunk/ruby-oci8/test/test_oradate.rb
===================================================================
--- trunk/ruby-oci8/test/test_oradate.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_oradate.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -13,7 +13,7 @@
   SECOND_CHECK_TARGET = [0, 15, 30, 45, 59]
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def check_oradate(target, year, month, day, hour, minute, second)
@@ -251,6 +251,6 @@
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 end

Modified: trunk/ruby-oci8/test/test_oranumber.rb
===================================================================
--- trunk/ruby-oci8/test/test_oranumber.rb	2008-01-04 12:52:59 UTC (rev 236)
+++ trunk/ruby-oci8/test/test_oranumber.rb	2008-01-08 14:33:01 UTC (rev 237)
@@ -53,7 +53,7 @@
   ]
 
   def setup
-    @conn = OCI8.new($dbuser, $dbpass, $dbname)
+    @conn = $dbconn
   end
 
   def test_to_s
@@ -137,6 +137,6 @@
   end
 
   def teardown
-    @conn.logoff
+    @conn.rollback
   end
 end




More information about the ruby-oci8-commit mailing list