From 2bc4b130dead8fdd664be332e16b2b7eb3e809d7 Mon Sep 17 00:00:00 2001 From: henrique Date: Wed, 30 Apr 2014 16:19:35 +0200 Subject: [PATCH] THRIFT-2132 Go: Support for Multiplexing Services on any Transport, Protocol and Server Patch: Aleksey Pesternikov typo This closes #112 ---- commit f362570683f57ad9ee78cedc437babb697c6a8d1 Author: Aleksey Pesternikov Date: 2014-04-30T12:49:11Z THRIFT-2132 broken tests ---- --- .../test/tests/multiplexed_protocol_test.go | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/go/test/tests/multiplexed_protocol_test.go b/lib/go/test/tests/multiplexed_protocol_test.go index ee14ee896..5b8a32870 100644 --- a/lib/go/test/tests/multiplexed_protocol_test.go +++ b/lib/go/test/tests/multiplexed_protocol_test.go @@ -20,11 +20,10 @@ package tests import ( - "MuliplexedProtocolTest" + "MultiplexedProtocolTest" "net" "testing" "thrift" - "time" ) func FindAvailableTCPServerPort() net.Addr { @@ -48,11 +47,6 @@ func (s *SecondImpl) ReturnTwo() (r int64, err error) { return 2, nil } -const TIMEOUT = time.Second - -var addr net.Addr -var server *thrift.TSimpleServer - var processor = thrift.NewTMultiplexedProcessor() func TestInitTwoServers(t *testing.T) { @@ -67,37 +61,37 @@ func TestInitTwoServers(t *testing.T) { } server = thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory) - firstProcessor := MuliplexedProtocolTest.NewFirstProcessor(&FirstImpl{}) + firstProcessor := MultiplexedProtocolTest.NewFirstProcessor(&FirstImpl{}) processor.RegisterProcessor("FirstService", firstProcessor) - secondProcessor := MuliplexedProtocolTest.NewSecondProcessor(&SecondImpl{}) + secondProcessor := MultiplexedProtocolTest.NewSecondProcessor(&SecondImpl{}) processor.RegisterProcessor("SecondService", secondProcessor) go server.Serve() } -var firstClient *MuliplexedProtocolTest.FirstClient +var firstClient *MultiplexedProtocolTest.FirstClient func TestInitClient1(t *testing.T) { socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) transport := thrift.NewTFramedTransport(socket) var protocol thrift.TProtocol = thrift.NewTBinaryProtocolTransport(transport) protocol = thrift.NewTMultiplexedProtocol(protocol, "FirstService") - firstClient = MuliplexedProtocolTest.NewFirstClientProtocol(transport, protocol, protocol) + firstClient = MultiplexedProtocolTest.NewFirstClientProtocol(transport, protocol, protocol) err := transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) } } -var secondClient *MuliplexedProtocolTest.SecondClient +var secondClient *MultiplexedProtocolTest.SecondClient func TestInitClient2(t *testing.T) { socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) transport := thrift.NewTFramedTransport(socket) var protocol thrift.TProtocol = thrift.NewTBinaryProtocolTransport(transport) protocol = thrift.NewTMultiplexedProtocol(protocol, "SecondService") - secondClient = MuliplexedProtocolTest.NewSecondClientProtocol(transport, protocol, protocol) + secondClient = MultiplexedProtocolTest.NewSecondClientProtocol(transport, protocol, protocol) err := transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) @@ -105,11 +99,11 @@ func TestInitClient2(t *testing.T) { } //create client without service prefix -func createLegacyClient(t *testing.T) *MuliplexedProtocolTest.SecondClient { +func createLegacyClient(t *testing.T) *MultiplexedProtocolTest.SecondClient { socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) transport := thrift.NewTFramedTransport(socket) var protocol thrift.TProtocol = thrift.NewTBinaryProtocolTransport(transport) - legacyClient := MuliplexedProtocolTest.NewSecondClientProtocol(transport, protocol, protocol) + legacyClient := MultiplexedProtocolTest.NewSecondClientProtocol(transport, protocol, protocol) err := transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) @@ -145,7 +139,7 @@ func TestCallLegacy(t *testing.T) { t.Fatal("Expecting error") } //register default processor and call again - processor.RegisterDefault(MuliplexedProtocolTest.NewSecondProcessor(&SecondImpl{})) + processor.RegisterDefault(MultiplexedProtocolTest.NewSecondProcessor(&SecondImpl{})) legacyClient = createLegacyClient(t) ret, err = legacyClient.ReturnTwo() if err != nil {