Exemplo n.º 1
0
func TestCallLegacy(t *testing.T) {
	legacyClient := createLegacyClient(t)
	ret, err := legacyClient.ReturnTwo()
	//expect error since default processor is not registered
	if err == nil {
		t.Fatal("Expecting error")
	}
	//register default processor and call again
	processor.RegisterDefault(MuliplexedProtocolTest.NewSecondProcessor(&SecondImpl{}))
	legacyClient = createLegacyClient(t)
	ret, err = legacyClient.ReturnTwo()
	if err != nil {
		t.Fatal("Unable to call legacy server:", err)
	}
	if ret != 2 {
		t.Fatal("Unexpected result from server: ", ret)
	}
}
Exemplo n.º 2
0
func TestInitTwoServers(t *testing.T) {
	var err error
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transportFactory := thrift.NewTTransportFactory()
	transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
	addr = FindAvailableTCPServerPort()
	serverTransport, err := thrift.NewTServerSocketTimeout(addr.String(), TIMEOUT)
	if err != nil {
		t.Fatal("Unable to create server socket", err)
	}
	server = thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)

	firstProcessor := MuliplexedProtocolTest.NewFirstProcessor(&FirstImpl{})
	processor.RegisterProcessor("FirstService", firstProcessor)

	secondProcessor := MuliplexedProtocolTest.NewSecondProcessor(&SecondImpl{})
	processor.RegisterProcessor("SecondService", secondProcessor)

	go server.Serve()
}