From: Kevin Clark Date: Wed, 18 Jun 2008 00:49:17 +0000 (+0000) Subject: Reorganize tests X-Git-Tag: 0.2.0~659 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=28580f4544659e3fba61fc613e6507ba8970e1ea;p=common%2Fthrift.git Reorganize tests git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668890 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/rb/Makefile b/test/rb/Makefile index ed0f91b5..3dd8875c 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 a951a9ec..00000000 --- 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 2a42541c..00000000 --- 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 04a4e2b3..00000000 --- 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 similarity index 72% rename from test/rb/TestSmallService.rb rename to test/rb/generation/test_struct.rb index 277b54cc..b6c60bad 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 similarity index 85% rename from test/rb/TestThrift.rb rename to test/rb/integration/test_simple_handler.rb index e35e808b..509f452f 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 00000000..9294c8fe --- /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 00000000..42febdab --- /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