summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2022-06-29 00:00:00 +0200
committerJens Geyer <jensg@apache.org>2022-09-05 22:04:20 +0200
commit62445c1d2e8bcca1056abb4559518f1c8d995992 (patch)
treebea3319b780bf3b918997ba5317eae0151e2395b /test
parent6a797b9843f47b455740afc146ac490de95d74c2 (diff)
downloadthrift-62445c1d2e8bcca1056abb4559518f1c8d995992.tar.gz
THRIFT-5591 Add uuid type to IDL and implement reference code (+ improved self-tests)
Client: compiler general, netstd, Delphi Patch: Jens Geyer
Diffstat (limited to 'test')
-rw-r--r--test/ConstantsDemo.thrift2
-rw-r--r--test/DebugProtoTest.thrift1
-rw-r--r--test/ThriftTest.thrift8
-rw-r--r--test/netstd/Client/TestClient.cs22
-rw-r--r--test/netstd/Server/Server.csproj2
-rw-r--r--test/netstd/Server/TestServer.cs6
6 files changed, 39 insertions, 2 deletions
diff --git a/test/ConstantsDemo.thrift b/test/ConstantsDemo.thrift
index 204e805b1..e03f0537d 100644
--- a/test/ConstantsDemo.thrift
+++ b/test/ConstantsDemo.thrift
@@ -65,6 +65,8 @@ const map<i32,thing> GEN_WHAT = { 35 : { 'hello' : 325, 'goodbye' : 325352 } }
const set<i32> GEN_SET = [ 235, 235, 53235 ]
+const uuid GEN_UUID = "00000000-4444-CCCC-ffff-0123456789ab"
+
exception Blah {
1: i32 bing }
diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift
index 5d0face4b..3750d8d93 100644
--- a/test/DebugProtoTest.thrift
+++ b/test/DebugProtoTest.thrift
@@ -48,6 +48,7 @@ struct OneOfEach {
12: list<i8> byte_list = [1, 2, 3],
13: list<i16> i16_list = [1,2,3],
14: list<i64> i64_list = [1,2,3]
+ 15: uuid rfc4122_uuid
}
struct Bonk {
diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift
index 4a1045fcd..42607cc35 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -112,6 +112,7 @@ struct CrazyNesting {
// Do not insert line break as test/go/Makefile.am is removing this line with pattern match
3: required list<map<set<i32> (python.immutable = ""), map<i32,set<list<map<Insanity,string>(python.immutable = "")> (python.immutable = "")>>>> list_field,
4: binary binary_field
+ 5: uuid uuid_field
}
union SomeUnion {
@@ -196,6 +197,13 @@ service ThriftTest
binary testBinary(1: binary thing),
/**
+ * Prints 'testUuid("%s")' where '%s' is the uuid given. Note that the uuid byte order should be correct.
+ * @param uuid thing - the uuid to print
+ * @return uuid - returns the uuid 'thing'
+ */
+ uuid testUuid(1: uuid thing),
+
+ /**
* 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/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index 29c0d2ef3..4700de88b 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -588,8 +588,28 @@ namespace ThriftTest
returnCode |= ErrorBaseTypes;
}
+ // testUuid()
+ var uuidOut = new Guid("{00112233-4455-6677-8899-AABBCCDDEEFF}");
+ Console.Write("testUuid({0})", uuidOut);
+ try
+ {
+ var uuidIn = await client.testUuid(uuidOut, MakeTimeoutToken());
+ Console.WriteLine(" = {0}", uuidIn);
+ if (!uuidIn.Equals(uuidOut))
+ {
+ Console.WriteLine("*** FAILED ***");
+ returnCode |= ErrorBaseTypes;
+ }
+ }
+ catch (Thrift.TApplicationException ex)
+ {
+ Console.WriteLine("*** FAILED ***");
+ returnCode |= ErrorBaseTypes;
+ Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
+ }
+
// testBinary()
- foreach(BinaryTestSize binTestCase in Enum.GetValues(typeof(BinaryTestSize)))
+ foreach (BinaryTestSize binTestCase in Enum.GetValues(typeof(BinaryTestSize)))
{
var binOut = PrepareTestData(true, binTestCase);
diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj
index 8faad9dc9..0a78e8836 100644
--- a/test/netstd/Server/Server.csproj
+++ b/test/netstd/Server/Server.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<!--
Licensed to the Apache Software Foundation(ASF) under one
or more contributor license agreements.See the NOTICE file
diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs
index 86072b0a7..71a2a30a1 100644
--- a/test/netstd/Server/TestServer.cs
+++ b/test/netstd/Server/TestServer.cs
@@ -271,6 +271,12 @@ namespace ThriftTest
return Task.FromResult(thing ?? Array.Empty<byte>());
}
+ public Task<Guid> testUuid(Guid thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testUuid({0})", thing.ToString("B"));
+ return Task.FromResult(thing);
+ }
+
public Task<Xtruct> testStruct(Xtruct? thing, CancellationToken cancellationToken)
{
logger.Invoke("testStruct({{\"{0}\", {1}, {2}, {3}}})", thing?.String_thing ?? "<null>", thing?.Byte_thing ?? 0, thing?.I32_thing ?? 0, thing?.I64_thing ?? 0);