func RunSocketTestSuite(t *testing.T, protocolFactory thrift.TProtocolFactory, transportFactory thrift.TTransportFactory) { // server var err error addr = FindAvailableTCPServerPort() serverTransport, err := thrift.NewTServerSocketTimeout(addr.String(), TIMEOUT) if err != nil { t.Fatal("Unable to create server socket", err) } processor := thrifttest.NewThriftTestProcessor(NewThriftTestHandler()) server = thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory) server.Listen() go server.Serve() // client var transport thrift.TTransport = thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) transport = transportFactory.GetTransport(transport) var protocol thrift.TProtocol = protocolFactory.GetProtocol(transport) thriftTestClient := thrifttest.NewThriftTestClientProtocol(transport, protocol, protocol) err = transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) } driver := NewThriftTestDriver(t, thriftTestClient) driver.Start() }
func TestInitOnewayClient(t *testing.T) { transport := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) protocol := thrift.NewTBinaryProtocolTransport(transport) client = onewaytest.NewOneWayClientProtocol(transport, protocol, protocol) err := transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) } }
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 = multiplexedprotocoltest.NewSecondClientProtocol(transport, protocol, protocol) err := transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) } }
//create client without service prefix func createLegacyClient(t *testing.T) *multiplexedprotocoltest.SecondClient { socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) transport := thrift.NewTFramedTransport(socket) var protocol thrift.TProtocol = thrift.NewTBinaryProtocolTransport(transport) legacyClient := multiplexedprotocoltest.NewSecondClientProtocol(transport, protocol, protocol) err := transport.Open() if err != nil { t.Fatal("Unable to open client socket", err) } return legacyClient }