You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 02:50:00 UTC
svn commit: r668892 - in /incubator/thrift/trunk:
lib/rb/lib/thrift/transport/ttransport.rb test/rb/core/
test/rb/core/test_exceptions.rb test/rb/core/transport/
test/rb/core/transport/test_ttransport.rb test/rb/test_suite.rb
Author: kclark
Date: Tue Jun 17 17:50:00 2008
New Revision: 668892
URL: http://svn.apache.org/viewvc?rev=668892&view=rev
Log:
Add tests for Ruby TTransport. Only require .rb files in ruby tests.
Added:
incubator/thrift/trunk/test/rb/core/
incubator/thrift/trunk/test/rb/core/test_exceptions.rb
incubator/thrift/trunk/test/rb/core/transport/
incubator/thrift/trunk/test/rb/core/transport/test_ttransport.rb
Modified:
incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb
incubator/thrift/trunk/test/rb/test_suite.rb
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb?rev=668892&r1=668891&r2=668892&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb Tue Jun 17 17:50:00 2008
@@ -28,6 +28,8 @@
end
+# TTransport is basically an abstract class, but isn't raising NotImplementedError
+# TODO: Fix this - Kevin Clark - 3/27/08
class TTransport
def isOpen(); nil; end
Added: incubator/thrift/trunk/test/rb/core/test_exceptions.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/rb/core/test_exceptions.rb?rev=668892&view=auto
==============================================================================
--- incubator/thrift/trunk/test/rb/core/test_exceptions.rb (added)
+++ incubator/thrift/trunk/test/rb/core/test_exceptions.rb Tue Jun 17 17:50:00 2008
@@ -0,0 +1,11 @@
+require File.join(File.dirname(__FILE__), '../test_helper')
+
+require 'thrift/thrift'
+
+class TestTException < Test::Unit::TestCase
+ def test_has_accessible_message
+ msg = "hi there thrift"
+ assert_equal msg, TException.new(msg).message
+ end
+end
+
Added: incubator/thrift/trunk/test/rb/core/transport/test_ttransport.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/rb/core/transport/test_ttransport.rb?rev=668892&view=auto
==============================================================================
--- incubator/thrift/trunk/test/rb/core/transport/test_ttransport.rb (added)
+++ incubator/thrift/trunk/test/rb/core/transport/test_ttransport.rb Tue Jun 17 17:50:00 2008
@@ -0,0 +1,55 @@
+require File.join(File.dirname(__FILE__), '../../test_helper')
+
+require 'thrift/transport/ttransport'
+
+class DummyTransport < TTransport
+ def initialize(data)
+ @data = data
+ end
+
+ def read(size)
+ @data.slice!(0, size)
+ end
+end
+
+# TTransport is basically an abstract class, but isn't raising NotImplementedError
+class TestTTransport < Test::Unit::TestCase
+ def setup
+ @trans = TTransport.new
+ end
+
+ def test_isOpen
+ assert_nil @trans.isOpen
+ end
+
+ def test_open
+ assert_nil @trans.open
+ end
+
+ def test_close
+ assert_nil @trans.close
+ end
+
+ def test_read
+ assert_nil @trans.read(100) # arbitrary size
+ end
+
+ # TODO:
+ # This doesn't necessarily test he right thing.
+ # It _looks_ like read isn't guarenteed to return the length
+ # you ask for and readAll is. This means our test needs to check
+ # for blocking. -- Kevin Clark 3/27/08
+ def test_readAll
+ # Implements read
+ t = DummyTransport.new("hello")
+ assert_equal "hello", t.readAll(5)
+ end
+
+ def test_write
+ assert_nil @trans.write(5) # arbitrary value
+ end
+
+ def test_flush
+ assert_nil @trans.flush
+ end
+end
\ No newline at end of file
Modified: incubator/thrift/trunk/test/rb/test_suite.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/test/rb/test_suite.rb?rev=668892&r1=668891&r2=668892&view=diff
==============================================================================
--- incubator/thrift/trunk/test/rb/test_suite.rb (original)
+++ incubator/thrift/trunk/test/rb/test_suite.rb Tue Jun 17 17:50:00 2008
@@ -1 +1 @@
-Dir["{core,generation,integration}/**/*"].each {|f| require f }
\ No newline at end of file
+Dir["{core,generation,integration}/**/*.rb"].each {|f| require f }
\ No newline at end of file