THRIFT-3337 Add testBool method to cross tests
This closes #611
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index e1737cd..e618fe9 100755
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -67,6 +67,10 @@
out = thing;
}
+ bool testBool(const bool thing) {
+ printf("[C -> C++] testBool(%s)\n", thing ? "true" : "false");
+ return thing;
+ }
int8_t testByte(const int8_t thing) {
printf("[C -> C++] testByte(%d)\n", (int)thing);
return thing;
diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs
index ec0696a..68949ac 100644
--- a/lib/csharp/test/ThriftTest/TestClient.cs
+++ b/lib/csharp/test/ThriftTest/TestClient.cs
@@ -242,6 +242,13 @@
string s = client.testString("Test");
Console.WriteLine(" = \"" + s + "\"");
+ Console.Write("testBool(true)");
+ bool t = client.testBool((bool)true);
+ Console.WriteLine(" = " + t);
+ Console.Write("testBool(false)");
+ bool f = client.testBool((bool)false);
+ Console.WriteLine(" = " + f);
+
Console.Write("testByte(1)");
sbyte i8 = client.testByte((sbyte)1);
Console.WriteLine(" = " + i8);
diff --git a/lib/csharp/test/ThriftTest/TestServer.cs b/lib/csharp/test/ThriftTest/TestServer.cs
index 0e9fe05..b5cc73c 100644
--- a/lib/csharp/test/ThriftTest/TestServer.cs
+++ b/lib/csharp/test/ThriftTest/TestServer.cs
@@ -73,6 +73,12 @@
return thing;
}
+ public bool testBool(bool thing)
+ {
+ Console.WriteLine("testBool(" + thing + ")");
+ return thing;
+ }
+
public sbyte testByte(sbyte thing)
{
Console.WriteLine("testByte(" + thing + ")");
diff --git a/lib/go/test/tests/thrifttest_handler.go b/lib/go/test/tests/thrifttest_handler.go
index eef45d5..50fe718 100644
--- a/lib/go/test/tests/thrifttest_handler.go
+++ b/lib/go/test/tests/thrifttest_handler.go
@@ -56,6 +56,10 @@
return thing, nil
}
+func (p *ThriftTestHandler) TestBool(thing bool) (r bool, err error) {
+ return thing, nil
+}
+
func (p *ThriftTestHandler) TestByte(thing int8) (r int8, err error) {
return thing, nil
}
diff --git a/lib/java/test/org/apache/thrift/server/ServerTestBase.java b/lib/java/test/org/apache/thrift/server/ServerTestBase.java
index a2836aa..b95779b 100755
--- a/lib/java/test/org/apache/thrift/server/ServerTestBase.java
+++ b/lib/java/test/org/apache/thrift/server/ServerTestBase.java
@@ -65,6 +65,11 @@
System.out.print("testString(\"" + thing + "\")\n");
return thing;
}
+
+ public boolean testBool(boolean thing) {
+ System.out.print("testBool(" + thing + ")\n");
+ return thing;
+ }
public byte testByte(byte thing) {
System.out.print("testByte(" + thing + ")\n");
@@ -305,6 +310,13 @@
public abstract TTransport getClientTransport(TTransport underlyingTransport) throws Exception;
+ private void testBool(ThriftTest.Client testClient) throws TException {
+ boolean t = testClient.testBool(true);
+ assertEquals(true, t);
+ boolean f = testClient.testBool(false);
+ assertEquals(false, f);
+ }
+
private void testByte(ThriftTest.Client testClient) throws TException {
byte i8 = testClient.testByte((byte)1);
assertEquals(1, i8);
@@ -404,6 +416,7 @@
open(transport);
testVoid(testClient);
testString(testClient);
+ testBool(testClient);
testByte(testClient);
testI32(testClient);
testI64(testClient);
@@ -585,6 +598,11 @@
}
@Override
+ public void testBool(boolean thing, AsyncMethodCallback resultHandler) throws TException {
+ resultHandler.onComplete(handler.testBool(thing));
+ }
+
+ @Override
public void testByte(byte thing, AsyncMethodCallback resultHandler) throws TException {
resultHandler.onComplete(handler.testByte(thing));
}
diff --git a/lib/nodejs/test/test-cases.js b/lib/nodejs/test/test-cases.js
index 7872295..2384221 100644
--- a/lib/nodejs/test/test-cases.js
+++ b/lib/nodejs/test/test-cases.js
@@ -49,6 +49,8 @@
['testString', ''],
['testString', stringTest],
['testString', specialCharacters],
+ ['testBool', true],
+ ['testBool', false],
['testByte', 1],
['testByte', 0],
['testByte', -1],
diff --git a/lib/nodejs/test/test_handler.js b/lib/nodejs/test/test_handler.js
index da32906..41df441 100644
--- a/lib/nodejs/test/test_handler.js
+++ b/lib/nodejs/test/test_handler.js
@@ -57,6 +57,7 @@
var identityHandlers = [
'testString',
+ 'testBool',
'testByte',
'testI32',
'testI64',
diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift
index 467968a..a749566 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -144,6 +144,13 @@
string testString(1: string thing),
/**
+ * Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false'
+ * @param bool thing - the bool data to print
+ * @return bool - returns the bool 'thing'
+ */
+ bool testBool(1: bool thing),
+
+ /**
* Prints 'testByte("%d")' with thing as '%d'
* @param byte thing - the byte to print
* @return byte - returns the byte 'thing'
diff --git a/test/c_glib/src/test_client.c b/test/c_glib/src/test_client.c
index dba2daf..b1fe065 100644
--- a/test/c_glib/src/test_client.c
+++ b/test/c_glib/src/test_client.c
@@ -194,11 +194,12 @@
/* Execute the actual tests */
for (test_num = 0; test_num < num_tests; ++test_num) {
if (thrift_transport_open (transport, &error)) {
- gchar *string = NULL;
- gint8 byte = 0;
- gint32 int32 = 0;
- gint64 int64 = 0;
- gdouble dub = 0;
+ gchar *string = NULL;
+ gboolean boolean = 0;
+ gint8 byte = 0;
+ gint32 int32 = 0;
+ gint64 int64 = 0;
+ gdouble dub = 0;
gint byte_thing, i32_thing, inner_byte_thing, inner_i32_thing;
gint64 i64_thing, inner_i64_thing;
@@ -300,6 +301,42 @@
}
/**
+ * BOOL TEST
+ */
+ printf ("testByte(true)");
+ if (t_test_thrift_test_if_test_bool (test_client,
+ &boolean,
+ 1,
+ &error)) {
+ printf (" = %s\n", boolean ? "true" : "false");
+ if (boolean != 1)
+ fail_count++;
+ }
+ else {
+ printf ("%s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+
+ fail_count++;
+ }
+ printf ("testByte(false)");
+ if (t_test_thrift_test_if_test_bool (test_client,
+ &boolean,
+ 0,
+ &error)) {
+ printf (" = %s\n", boolean ? "true" : "false");
+ if (boolean != 0)
+ fail_count++;
+ }
+ else {
+ printf ("%s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+
+ fail_count++;
+ }
+
+ /**
* BYTE TEST
*/
printf ("testByte(1)");
diff --git a/test/c_glib/src/thrift_test_handler.c b/test/c_glib/src/thrift_test_handler.c
index ae273bf..d82befb 100644
--- a/test/c_glib/src/thrift_test_handler.c
+++ b/test/c_glib/src/thrift_test_handler.c
@@ -60,6 +60,21 @@
}
gboolean
+thrift_test_handler_test_bool (TTestThriftTestIf *iface,
+ gboolean *_return,
+ const gboolean thing,
+ GError **error)
+{
+ THRIFT_UNUSED_VAR (iface);
+ THRIFT_UNUSED_VAR (error);
+
+ printf ("testByte(%s)\n", thing ? "true" : "false");
+ *_return = thing;
+
+ return TRUE;
+}
+
+gboolean
thrift_test_handler_test_byte (TTestThriftTestIf *iface,
gint8 *_return,
const gint8 thing,
@@ -796,6 +811,9 @@
base_class->test_string =
klass->test_string =
thrift_test_handler_test_string;
+ base_class->test_bool =
+ klass->test_bool =
+ thrift_test_handler_test_bool;
base_class->test_byte =
klass->test_byte =
thrift_test_handler_test_byte;
diff --git a/test/c_glib/src/thrift_test_handler.h b/test/c_glib/src/thrift_test_handler.h
index a34f90a..957bbda 100644
--- a/test/c_glib/src/thrift_test_handler.h
+++ b/test/c_glib/src/thrift_test_handler.h
@@ -66,6 +66,10 @@
gchar **_return,
const gchar *thing,
GError **error);
+ gboolean (*test_bool) (TTestThriftTestIf *iface,
+ gboolean*_return,
+ const gboolean thing,
+ GError **error);
gboolean (*test_byte) (TTestThriftTestIf *iface,
gint8*_return,
const gint8 thing,
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index fa5b635..1c0254b 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -307,6 +307,21 @@
failCount++;
/**
+ * BOOL TEST
+ */
+ printf("testBool(true)");
+ bool bl = testClient.testBool(true);
+ printf(" = %s\n", bl ? "true" : "false");
+ if (bl != true)
+ failCount++;
+
+ printf("testBool(false)");
+ bl = testClient.testBool(false);
+ printf(" = %s\n", bl ? "true" : "false");
+ if (bl != false)
+ failCount++;
+
+ /**
* BYTE TEST
*/
printf("testByte(1)");
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 7b3c04b..e5bc31e 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -78,6 +78,11 @@
out = thing;
}
+ bool testBool(const bool thing) {
+ printf("testBool(%s)\n", thing ? "true" : "false");
+ return thing;
+ }
+
int8_t testByte(const int8_t thing) {
printf("testByte(%d)\n", (int)thing);
return thing;
@@ -398,6 +403,11 @@
cob(res);
}
+ virtual void testBool(tcxx::function<void(bool const& _return)> cob, const bool thing) {
+ bool res = _delegate->testBool(thing);
+ cob(res);
+ }
+
virtual void testByte(tcxx::function<void(int8_t const& _return)> cob, const int8_t thing) {
int8_t res = _delegate->testByte(thing);
cob(res);
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index f19743a..d0e5ff8 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -75,6 +75,21 @@
t.Fatalf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
}
+ bl, err := client.TestBool(true)
+ if err != nil {
+ t.Fatalf("Unexpected error in TestBool() call: ", err)
+ }
+ if !bl {
+ t.Fatalf("Unexpected TestBool() result expected true, got %f ", bl)
+ }
+ bl, err = client.TestBool(false)
+ if err != nil {
+ t.Fatalf("Unexpected error in TestBool() call: ", err)
+ }
+ if bl {
+ t.Fatalf("Unexpected TestBool() result expected false, got %f ", bl)
+ }
+
b, err := client.TestByte(42)
if err != nil {
t.Fatalf("Unexpected error in TestByte() call: ", err)
@@ -186,10 +201,10 @@
mapmap, err := client.TestMapMap(42)
if err != nil {
- t.Fatalf("Unexpected error in TestMapmap() call: ", err)
+ t.Fatalf("Unexpected error in TestMapMap() call: ", err)
}
if !reflect.DeepEqual(mapmap, rmapmap) {
- t.Fatalf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
+ t.Fatalf("Unexpected TestMapMap() result expected %#v, got %#v ", rmapmap, mapmap)
}
crazy := thrifttest.NewInsanity()
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index a7bd46c..5c8915a 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -89,6 +89,8 @@
gomock.InOrder(
handler.EXPECT().TestVoid(),
handler.EXPECT().TestString("thing").Return("thing", nil),
+ handler.EXPECT().TestBool(true).Return(true, nil),
+ handler.EXPECT().TestBool(false).Return(false, nil),
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),
@@ -125,6 +127,21 @@
t.Errorf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
}
+ bl, err := client.TestBool(true)
+ if err != nil {
+ t.Errorf("Unexpected error in TestBool() call: ", err)
+ }
+ if !bl {
+ t.Errorf("Unexpected TestBool() result expected true, got %f ", bl)
+ }
+ bl, err = client.TestBool(false)
+ if err != nil {
+ t.Errorf("Unexpected error in TestBool() call: ", err)
+ }
+ if bl {
+ t.Errorf("Unexpected TestBool() result expected false, got %f ", bl)
+ }
+
b, err := client.TestByte(42)
if err != nil {
t.Errorf("Unexpected error in TestByte() call: ", err)
diff --git a/test/go/src/common/mock_handler.go b/test/go/src/common/mock_handler.go
index ec7e051..7495fc6 100644
--- a/test/go/src/common/mock_handler.go
+++ b/test/go/src/common/mock_handler.go
@@ -48,6 +48,18 @@
return _m.recorder
}
+func (_m *MockThriftTest) TestBool(_param0 bool) (bool, error) {
+ ret := _m.ctrl.Call(_m, "TestBool", _param0)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestBool(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBool", arg0)
+}
+
+
func (_m *MockThriftTest) TestByte(_param0 int8) (int8, error) {
ret := _m.ctrl.Call(_m, "TestByte", _param0)
ret0, _ := ret[0].(int8)
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
index 8c902d1..bc308b6 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -48,6 +48,17 @@
return thing, nil
}
+// Prints 'testBool("%d")' with thing as 'true' or 'false'
+// @param bool thing - the bool to print
+// @return bool - returns the bool 'thing'
+//
+// Parameters:
+// - Thing
+func (p *printingHandler) TestBool(thing bool) (r bool, err error) {
+ fmt.Printf("testBool(%d)\n", thing)
+ return thing, nil
+}
+
// Prints 'testByte("%d")' with thing as '%d'
// @param byte thing - the byte to print
// @return byte - returns the byte 'thing'
diff --git a/test/go/src/common/simple_handler.go b/test/go/src/common/simple_handler.go
index 97ff52d..944f11c 100644
--- a/test/go/src/common/simple_handler.go
+++ b/test/go/src/common/simple_handler.go
@@ -37,6 +37,10 @@
return thing, nil
}
+func (p *simpleHandler) TestBool(thing []byte) (r []byte, err error) {
+ return thing, nil
+}
+
func (p *simpleHandler) TestByte(thing int8) (r int8, err error) {
return thing, nil
}
diff --git a/test/hs/TestServer.hs b/test/hs/TestServer.hs
index d991de1..fb80cf8 100755
--- a/test/hs/TestServer.hs
+++ b/test/hs/TestServer.hs
@@ -111,6 +111,10 @@
System.IO.putStrLn $ "testString(" ++ show s ++ ")"
return s
+ testBool _ x = do
+ System.IO.putStrLn $ "testBool(" ++ show x ++ ")"
+ return x
+
testByte _ x = do
System.IO.putStrLn $ "testByte(" ++ show x ++ ")"
return x
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index 2f21c3a..97551e2 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -204,6 +204,7 @@
"hs-cpp_compact_framed-ip-ssl",
"hs-cpp_compact_http-ip",
"hs-cpp_compact_http-ip-ssl",
+ "hs-cpp_json_buffered-ip",
"hs-cpp_json_buffered-ip-ssl",
"hs-cpp_json_evhttp-http-ip",
"hs-cpp_json_evhttp-http-ip-ssl",
@@ -274,6 +275,8 @@
"hs-nodejs_json_buffered-ip-ssl",
"hs-nodejs_json_framed-ip",
"hs-nodejs_json_framed-ip-ssl",
+ "hs-php_binary_framed-ip",
+ "hs-php_compact_framed-ip",
"hs-py_binary-accel_buffered-ip-ssl",
"hs-py_binary-accel_framed-ip",
"hs-py_binary-accel_framed-ip-ssl",
@@ -283,6 +286,7 @@
"hs-py_compact_buffered-ip-ssl",
"hs-py_compact_framed-ip",
"hs-py_compact_framed-ip-ssl",
+ "hs-py_json_buffered-ip",
"hs-py_json_buffered-ip-ssl",
"hs-py_json_framed-ip",
"hs-py_json_framed-ip-ssl",
diff --git a/test/perl/TestClient.pl b/test/perl/TestClient.pl
index 0f1ce65..40f8f59 100755
--- a/test/perl/TestClient.pl
+++ b/test/perl/TestClient.pl
@@ -133,6 +133,17 @@
print(" = \"$s\"\n");
#
+# BOOL TEST
+#
+print("testBool(1)");
+my $u8 = $testClient->testBool(1);
+print(" = $u8\n");
+print("testBool(0)");
+my $u8 = $testClient->testBool(0);
+print(" = $u8\n");
+
+
+#
# BYTE TEST
#
print("testByte(1)");
diff --git a/test/perl/TestServer.pl b/test/perl/TestServer.pl
index 57a1367..eebebc8 100644
--- a/test/perl/TestServer.pl
+++ b/test/perl/TestServer.pl
@@ -148,6 +148,14 @@
return $thing;
}
+sub testBool() {
+ my $self = shift;
+ my $thing = shift;
+ my $str = $thing ? "true" : "false";
+ print("testBool($str)\n");
+ return $thing;
+}
+
sub testByte() {
my $self = shift;
my $thing = shift;
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index a810b3f..592a541 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -101,6 +101,10 @@
self.assertEqual(self.client.testString('Python' * 20), 'Python' * 20)
self.assertEqual(self.client.testString(''), '')
+ def testBool(self):
+ self.assertEqual(self.client.testBool(True), True)
+ self.assertEqual(self.client.testBool(False), False)
+
def testByte(self):
self.assertEqual(self.client.testByte(63), 63)
self.assertEqual(self.client.testByte(-127), -127)
diff --git a/test/py/TestServer.py b/test/py/TestServer.py
index bcf9376..89b74da 100755
--- a/test/py/TestServer.py
+++ b/test/py/TestServer.py
@@ -76,6 +76,11 @@
print 'testString(%s)' % str
return str
+ def testBool(self, boolean):
+ if options.verbose > 1:
+ print 'testBool(%s)' % str(boolean).lower()
+ return boolean
+
def testByte(self, byte):
if options.verbose > 1:
print 'testByte(%d)' % byte