THRIFT-2886 Integrate binary type in standard Thrift cross test
Client: C_glib, C++, D, Erlang, Go, Haskell, Lua, Java/Me, JavaScript, Node, Ocaml, Perl, PHP, Python, Ruby
Patch: Jens Geyer
This closes #341
Minimal server-side implementations and TODO stubs for various languages to let "make check" succeeed.
Not contained in this patch and still TODO:
- client side implementations, i.e. calls to testBinary() and appropriate tests
- server side hex printout missing for some languages
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index 2acf6cf..c48df0e 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -107,6 +107,8 @@
t.Fatalf("Unexpected TestDouble() result expected 42.42, got %f ", d)
}
+ // TODO: add TestBinary() call
+
xs := thrifttest.NewXtruct()
xs.StringThing = "thing"
xs.ByteThing = 42
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index 8add041..3b512ad 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -92,6 +92,7 @@
handler.EXPECT().TestByte(int8(42)).Return(int8(42), nil),
handler.EXPECT().TestI32(int32(4242)).Return(int32(4242), nil),
handler.EXPECT().TestI64(int64(424242)).Return(int64(424242), nil),
+ // TODO: add TestBinary()
handler.EXPECT().TestDouble(float64(42.42)).Return(float64(42.42), nil),
handler.EXPECT().TestStruct(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}).Return(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}, nil),
handler.EXPECT().TestNest(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}).Return(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}, nil),
@@ -156,6 +157,8 @@
t.Errorf("Unexpected TestDouble() result expected 42.42, got %f ", d)
}
+ // TODO: add TestBinary() call
+
xs := thrifttest.NewXtruct()
xs.StringThing = "thing"
xs.ByteThing = 42
diff --git a/test/go/src/common/mock_handler.go b/test/go/src/common/mock_handler.go
index d736ed9..8ef3b6e 100644
--- a/test/go/src/common/mock_handler.go
+++ b/test/go/src/common/mock_handler.go
@@ -70,6 +70,17 @@
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestDouble", arg0)
}
+func (_m *MockThriftTest) TestBinary(_param0 []byte) ([]byte, error) {
+ ret := _m.ctrl.Call(_m, "TestBinary", _param0)
+ ret0, _ := ret[0].([]byte)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestBinary(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBinary", arg0)
+}
+
func (_m *MockThriftTest) TestEnum(_param0 thrifttest.Numberz) (thrifttest.Numberz, error) {
ret := _m.ctrl.Call(_m, "TestEnum", _param0)
ret0, _ := ret[0].(thrifttest.Numberz)
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
index 6cc1507..bed7086 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -22,6 +22,7 @@
import (
"errors"
"fmt"
+ "encoding/hex"
. "gen/thrifttest"
"time"
)
@@ -91,6 +92,17 @@
return thing, nil
}
+// Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data
+// @param []byte thing - the binary to print
+// @return []byte - returns the binary 'thing'
+//
+// Parameters:
+// - Thing
+func (p *printingHandler) TestBinary(thing []byte) (r []byte, err error) {
+ fmt.Printf("testBinary(%s)\n", hex.EncodeToString(thing))
+ return thing, nil
+}
+
// Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values
// @param Xtruct thing - the Xtruct to print
// @return Xtruct - returns the Xtruct 'thing'
diff --git a/test/go/src/common/simple_handler.go b/test/go/src/common/simple_handler.go
index 433616d..97ff52d 100644
--- a/test/go/src/common/simple_handler.go
+++ b/test/go/src/common/simple_handler.go
@@ -53,6 +53,10 @@
return thing, nil
}
+func (p *simpleHandler) TestBinary(thing []byte) (r []byte, err error) {
+ return thing, nil
+}
+
func (p *simpleHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
return r, err
}