Add tests for Ruby TTransport. Only require .rb files in ruby tests.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668892 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/lib/thrift/transport/ttransport.rb b/lib/rb/lib/thrift/transport/ttransport.rb
index bdf0935..fb41495 100644
--- a/lib/rb/lib/thrift/transport/ttransport.rb
+++ b/lib/rb/lib/thrift/transport/ttransport.rb
@@ -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
diff --git a/test/rb/core/test_exceptions.rb b/test/rb/core/test_exceptions.rb
new file mode 100644
index 0000000..eb63963
--- /dev/null
+++ b/test/rb/core/test_exceptions.rb
@@ -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
+
diff --git a/test/rb/core/transport/test_ttransport.rb b/test/rb/core/transport/test_ttransport.rb
new file mode 100644
index 0000000..5811dec
--- /dev/null
+++ b/test/rb/core/transport/test_ttransport.rb
@@ -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
diff --git a/test/rb/test_suite.rb b/test/rb/test_suite.rb
index 42febda..af686a8 100644
--- a/test/rb/test_suite.rb
+++ b/test/rb/test_suite.rb
@@ -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