summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Clark <kclark@apache.org>2008-06-18 00:49:17 +0000
committerKevin Clark <kclark@apache.org>2008-06-18 00:49:17 +0000
commit28580f4544659e3fba61fc613e6507ba8970e1ea (patch)
treece751804c7f119e8e08f98ea2fc4eebf34b1c3ad
parent18cb21a125df42c6a7864769ce9710137c99f96e (diff)
downloadthrift-28580f4544659e3fba61fc613e6507ba8970e1ea.tar.gz
Reorganize tests
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668890 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--test/rb/Makefile2
-rw-r--r--test/rb/TestClient-nb.rb35
-rw-r--r--test/rb/TestHandler.rb73
-rw-r--r--test/rb/TestSuite.rb5
-rw-r--r--test/rb/generation/test_struct.rb (renamed from test/rb/TestSmallService.rb)12
-rw-r--r--test/rb/integration/test_simple_handler.rb (renamed from test/rb/TestThrift.rb)40
-rw-r--r--test/rb/test_helper.rb4
-rw-r--r--test/rb/test_suite.rb1
8 files changed, 42 insertions, 130 deletions
diff --git a/test/rb/Makefile b/test/rb/Makefile
index ed0f91b5a..3dd8875cf 100644
--- a/test/rb/Makefile
+++ b/test/rb/Makefile
@@ -16,7 +16,7 @@ stubs: ../ThriftTest.thrift ../SmallTest.thrift
$(THRIFT) --gen rb ../SmallTest.thrift
tests: stubs
- ruby TestSuite.rb
+ ruby test_suite.rb
clean:
$(RM) -r gen-rb
diff --git a/test/rb/TestClient-nb.rb b/test/rb/TestClient-nb.rb
deleted file mode 100644
index a951a9ec3..000000000
--- a/test/rb/TestClient-nb.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.push('gen-rb')
-$:.push('../../lib/rb/lib')
-
-require 'thrift/transport/tsocket'
-require 'thrift/protocol/tbinaryprotocol'
-require 'ThriftTest'
-
-t = TFramedTransport.new(TSocket.new('localhost', 9090))
-p = TBinaryProtocol.new(t)
-c = Thrift::Test::ThriftTest::Client.new(p)
-
-t.open()
-
-puts c.testString('string')
-puts c.testByte(8)
-puts c.testByte(-8)
-puts c.testI32(32)
-puts c.testI32(-32)
-puts c.testI64(64)
-puts c.testI64(-64)
-puts c.testDouble(3.14)
-puts c.testDouble(-3.14)
-puts c.testMap({1 => 1, 2 => 2, 3 => 3})
-puts c.testList([1,2,3,4,5])
-puts c.testSet({1 => true, 2 => true, 3 => true})
-struct = Thrift::Test::Xtruct.new({'string_thing' => 'hi!', 'i32_thing' => 4 })
-puts c.testStruct(struct)
-puts c.testNest(Thrift::Test::Xtruct2.new({'struct_thing' => struct, 'i32_thing' => 10}))
-insane = Thrift::Test::Insanity.new({'userMap' => { Thrift::Test::Numberz::ONE => 44 }, 'xtructs' => [struct, Thrift::Test::Xtruct.new({'string_thing' => 'hi again', 'i32_thing' => 12})]})
-puts c.testInsanity(insane)
-puts c.testMapMap(4).inspect
-
-t.close()
diff --git a/test/rb/TestHandler.rb b/test/rb/TestHandler.rb
deleted file mode 100644
index 2a42541c6..000000000
--- a/test/rb/TestHandler.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.push('gen-rb')
-$:.push('../../lib/rb/lib')
-
-require 'ThriftTest'
-
-class TestHandler
- def testVoid
- end
-
- def testString(thing)
- return thing
- end
-
- def testByte(thing)
- return thing
- end
-
- def testI32(thing)
- return thing
- end
-
- def testI64(thing)
- return thing
- end
-
- def testDouble(thing)
- return thing
- end
-
- def testStruct(thing)
- return thing
- end
-
- def testMap(thing)
- return thing
- end
-
- def testSet(thing)
- return thing
- end
-
- def testList(thing)
- return thing
- end
-
- def testNest(thing)
- return thing
- end
-
- def testInsanity(thing)
- num, uid = thing.userMap.find { true }
- return {uid => {num => thing}}
- end
-
- def testMapMap(thing)
- return {thing => {thing => thing}}
- end
-
- def testEnum(thing)
- return thing
- end
-
- def testTypedef(thing)
- return thing
- end
-
- def testException(thing)
- raise Thrift::Test::Xception, 'error'
- end
-
-end
diff --git a/test/rb/TestSuite.rb b/test/rb/TestSuite.rb
deleted file mode 100644
index 04a4e2b3c..000000000
--- a/test/rb/TestSuite.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'TestThrift'
-require 'TestSmallService'
diff --git a/test/rb/TestSmallService.rb b/test/rb/generation/test_struct.rb
index 277b54cc0..b6c60bad4 100644
--- a/test/rb/TestSmallService.rb
+++ b/test/rb/generation/test_struct.rb
@@ -1,15 +1,9 @@
-#!/usr/bin/env ruby
-
-$:.push('gen-rb')
-$:.push('../../lib/rb/lib')
-
+require File.join(File.dirname(__FILE__), '../test_helper')
require 'SmallService'
-require 'rubygems'
-require 'test/unit'
-class TestSmallService < Test::Unit::TestCase
+class TestStructGeneration < Test::Unit::TestCase
- def test_default_value
+ def test_default_values
hello = Hello.new
assert_kind_of(Hello, hello)
diff --git a/test/rb/TestThrift.rb b/test/rb/integration/test_simple_handler.rb
index e35e808ba..509f452fa 100644
--- a/test/rb/TestThrift.rb
+++ b/test/rb/integration/test_simple_handler.rb
@@ -1,17 +1,43 @@
-#!/usr/bin/env ruby
-
-$:.push('gen-rb')
-$:.push('../../lib/rb/lib')
+require File.join(File.dirname(__FILE__), '../test_helper')
require 'thrift/transport/tsocket'
require 'thrift/protocol/tbinaryprotocol'
require 'thrift/server/tserver'
require 'ThriftTest'
-require 'TestHandler'
-require 'rubygems'
-require 'test/unit'
+class TestHandler
+ [:testString, :testByte, :testI32, :testI64, :testDouble,
+ :testStruct, :testMap, :testSet, :testList, :testNest,
+ :testEnum, :testTypedef].each do |meth|
+
+ define_method(meth) do |thing|
+ thing
+ end
+
+ end
+
+ def testInsanity(thing)
+ num, uid = thing.userMap.find { true }
+ return {uid => {num => thing}}
+ end
+
+ def testMapMap(thing)
+ return {thing => {thing => thing}}
+ end
+
+ def testEnum(thing)
+ return thing
+ end
+
+ def testTypedef(thing)
+ return thing
+ end
+
+ def testException(thing)
+ raise Thrift::Test::Xception, 'error'
+ end
+end
class TestThrift < Test::Unit::TestCase
@@INIT = nil
diff --git a/test/rb/test_helper.rb b/test/rb/test_helper.rb
new file mode 100644
index 000000000..9294c8fee
--- /dev/null
+++ b/test/rb/test_helper.rb
@@ -0,0 +1,4 @@
+$:.push File.dirname(__FILE__) + '/gen-rb'
+$:.push File.join(File.dirname(__FILE__), '../../lib/rb/lib')
+
+require 'test/unit'
diff --git a/test/rb/test_suite.rb b/test/rb/test_suite.rb
new file mode 100644
index 000000000..42febdab7
--- /dev/null
+++ b/test/rb/test_suite.rb
@@ -0,0 +1 @@
+Dir["{core,generation,integration}/**/*"].each {|f| require f } \ No newline at end of file