[ruby-oci8-commit] [265] tags: tag ruby-oci8-1.0.2
nobody at rubyforge.org
nobody at rubyforge.org
Thu Jun 26 10:30:44 EDT 2008
Revision: 265
Author: kubo
Date: 2008-06-26 10:30:44 -0400 (Thu, 26 Jun 2008)
Log Message:
-----------
tag ruby-oci8-1.0.2
Added Paths:
-----------
tags/ruby-oci8-1.0.2/
tags/ruby-oci8-1.0.2/test/
tags/ruby-oci8-1.0.2/test/test_clob.rb
Removed Paths:
-------------
tags/ruby-oci8-1.0.2/test/
tags/ruby-oci8-1.0.2/test/test_clob.rb
Copied: tags/ruby-oci8-1.0.2 (from rev 264, branches/ruby-oci8-1.0)
Copied: tags/ruby-oci8-1.0.2/test (from rev 263, branches/ruby-oci8-1.0/test)
Deleted: tags/ruby-oci8-1.0.2/test/test_clob.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_clob.rb 2008-06-24 09:36:18 UTC (rev 263)
+++ tags/ruby-oci8-1.0.2/test/test_clob.rb 2008-06-26 14:30:44 UTC (rev 265)
@@ -1,98 +0,0 @@
-# Low-level API
-require 'oci8'
-require 'runit/testcase'
-require 'runit/cui/testrunner'
-require File.dirname(__FILE__) + '/config'
-
-class TestCLob < RUNIT::TestCase
-
- def setup
- @env, @svc, @stmt = setup_lowapi()
- end
-
- def test_insert
- @stmt.prepare("DELETE FROM test_clob WHERE filename = :1")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.execute(@svc)
-
- @stmt.prepare("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.execute(@svc)
-
- lob = @env.alloc(OCILobLocator)
- @stmt.prepare("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.defineByPos(1, OCI_TYPECODE_CLOB, lob)
- @stmt.execute(@svc, 1)
- offset = 1 # count by charactor, not byte.
- open($lobfile) do |f|
- while f.gets()
- num_of_chars = lob.write(@svc, offset, $_)
- offset += num_of_chars
- end
- end
- lob.free()
- end
-
- def test_insert_with_open_close
- @stmt.prepare("DELETE FROM test_clob WHERE filename = :1")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.execute(@svc)
-
- @stmt.prepare("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.execute(@svc)
-
- lob = @env.alloc(OCILobLocator)
- @stmt.prepare("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.defineByPos(1, OCI_TYPECODE_CLOB, lob)
- @stmt.execute(@svc, 1)
- lob.open(@svc)
- begin
- offset = 1 # count by charactor, not byte.
- open($lobfile) do |f|
- while f.gets()
- offset += lob.write(@svc, offset, $_)
- end
- end
- ensure
- lob.close(@svc)
- end
- lob.free()
- end
-
- def test_read
- test_insert() # first insert data.
- lob = @env.alloc(OCILobLocator)
- @stmt.prepare("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE")
- @stmt.bindByPos(1, String, $lobfile.size).set($lobfile)
- @stmt.defineByPos(1, OCI_TYPECODE_CLOB, lob)
- @stmt.execute(@svc, 1)
-
- open($lobfile) do |f|
- offset = 1
- while buf = lob.read(@svc, offset, $lobreadnum)
- fbuf = f.read(buf.size)
- assert_equal(fbuf, buf)
- offset += $lobreadnum
- # offset += buf.size will not work fine,
- # Though buf.size counts in byte,
- # offset and $lobreadnum count in character.
- end
- assert_equal(nil, buf)
- assert_equal(true, f.eof?)
- end
- lob.free()
- end
-
- def teardown
- @stmt.free()
- @svc.logoff()
- @env.free()
- end
-end
-
-if $0 == __FILE__
- RUNIT::CUI::TestRunner.run(TestCLob.suite())
-end
Copied: tags/ruby-oci8-1.0.2/test/test_clob.rb (from rev 264, branches/ruby-oci8-1.0/test/test_clob.rb)
===================================================================
--- tags/ruby-oci8-1.0.2/test/test_clob.rb (rev 0)
+++ tags/ruby-oci8-1.0.2/test/test_clob.rb 2008-06-26 14:30:44 UTC (rev 265)
@@ -0,0 +1,101 @@
+# Low-level API
+require 'oci8'
+require 'runit/testcase'
+require 'runit/cui/testrunner'
+require File.dirname(__FILE__) + '/config'
+
+class TestCLob < RUNIT::TestCase
+
+ def setup
+ @env, @svc, @stmt = setup_lowapi()
+ end
+
+ def test_insert
+ filename = File.basename($lobfile)
+ @stmt.prepare("DELETE FROM test_clob WHERE filename = :1")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.execute(@svc)
+
+ @stmt.prepare("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.execute(@svc)
+
+ lob = @env.alloc(OCILobLocator)
+ @stmt.prepare("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.defineByPos(1, OCI_TYPECODE_CLOB, lob)
+ @stmt.execute(@svc, 1)
+ offset = 1 # count by charactor, not byte.
+ open($lobfile) do |f|
+ while f.gets()
+ num_of_chars = lob.write(@svc, offset, $_)
+ offset += num_of_chars
+ end
+ end
+ lob.free()
+ end
+
+ def test_insert_with_open_close
+ filename = File.basename($lobfile)
+ @stmt.prepare("DELETE FROM test_clob WHERE filename = :1")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.execute(@svc)
+
+ @stmt.prepare("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.execute(@svc)
+
+ lob = @env.alloc(OCILobLocator)
+ @stmt.prepare("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.defineByPos(1, OCI_TYPECODE_CLOB, lob)
+ @stmt.execute(@svc, 1)
+ lob.open(@svc)
+ begin
+ offset = 1 # count by charactor, not byte.
+ open($lobfile) do |f|
+ while f.gets()
+ offset += lob.write(@svc, offset, $_)
+ end
+ end
+ ensure
+ lob.close(@svc)
+ end
+ lob.free()
+ end
+
+ def test_read
+ filename = File.basename($lobfile)
+ test_insert() # first insert data.
+ lob = @env.alloc(OCILobLocator)
+ @stmt.prepare("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE")
+ @stmt.bindByPos(1, String, filename.size).set(filename)
+ @stmt.defineByPos(1, OCI_TYPECODE_CLOB, lob)
+ @stmt.execute(@svc, 1)
+
+ open($lobfile) do |f|
+ offset = 1
+ while buf = lob.read(@svc, offset, $lobreadnum)
+ fbuf = f.read(buf.size)
+ assert_equal(fbuf, buf)
+ offset += $lobreadnum
+ # offset += buf.size will not work fine,
+ # Though buf.size counts in byte,
+ # offset and $lobreadnum count in character.
+ end
+ assert_equal(nil, buf)
+ assert_equal(true, f.eof?)
+ end
+ lob.free()
+ end
+
+ def teardown
+ @stmt.free()
+ @svc.logoff()
+ @env.free()
+ end
+end
+
+if $0 == __FILE__
+ RUNIT::CUI::TestRunner.run(TestCLob.suite())
+end
More information about the ruby-oci8-commit
mailing list