diff options
author | Bernard Normier <bernard@zeroc.com> | 2018-11-13 15:52:14 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2018-11-13 15:52:14 -0500 |
commit | a5854cfd05fa6aa5b7cc50ecbfcc9336fb32412c (patch) | |
tree | 58b9f74f2132985fe15913f1a7f65e82121b8eba | |
parent | Fix failure related to Slice Scanner fixes (diff) | |
download | ice-a5854cfd05fa6aa5b7cc50ecbfcc9336fb32412c.tar.bz2 ice-a5854cfd05fa6aa5b7cc50ecbfcc9336fb32412c.tar.xz ice-a5854cfd05fa6aa5b7cc50ecbfcc9336fb32412c.zip |
More bidir tests. Fixes #51.
-rw-r--r-- | cpp/test/Ice/ami/AllTests.cpp | 56 | ||||
-rw-r--r-- | cpp/test/Ice/ami/Test.ice | 2 | ||||
-rw-r--r-- | cpp/test/Ice/ami/TestI.cpp | 10 | ||||
-rw-r--r-- | cpp/test/Ice/ami/TestI.h | 2 | ||||
-rw-r--r-- | csharp/test/Ice/ami/AllTests.cs | 40 | ||||
-rw-r--r-- | csharp/test/Ice/ami/Test.ice | 2 | ||||
-rw-r--r-- | csharp/test/Ice/ami/TestI.cs | 13 | ||||
-rw-r--r-- | java-compat/test/lambda/src/main/java/Ice/ami/lambda/AMI.java | 33 | ||||
-rw-r--r-- | java-compat/test/src/main/java/test/Ice/ami/Test.ice | 2 | ||||
-rw-r--r-- | java-compat/test/src/main/java/test/Ice/ami/TestI.java | 7 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/ami/AllTests.java | 39 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/ami/Test.ice | 2 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/ami/TestI.java | 13 | ||||
-rw-r--r-- | matlab/test/Ice/ami/Test.ice | 2 | ||||
-rw-r--r-- | objective-c/test/Ice/ami/AMITest.ice | 2 | ||||
-rw-r--r-- | objective-c/test/Ice/ami/AllTests.m | 31 | ||||
-rw-r--r-- | objective-c/test/Ice/ami/TestI.m | 6 | ||||
-rw-r--r-- | python/test/Ice/ami/AllTests.py | 26 | ||||
-rw-r--r-- | python/test/Ice/ami/Test.ice | 2 | ||||
-rw-r--r-- | python/test/Ice/ami/TestI.py | 5 |
20 files changed, 203 insertions, 92 deletions
diff --git a/cpp/test/Ice/ami/AllTests.cpp b/cpp/test/Ice/ami/AllTests.cpp index f1de69154ef..47aebe2ecf5 100644 --- a/cpp/test/Ice/ami/AllTests.cpp +++ b/cpp/test/Ice/ami/AllTests.cpp @@ -17,6 +17,30 @@ using namespace std; namespace { +class PingReplyI : public Test::PingReply +{ +public: + PingReplyI() : + _received(false) + { + } + + virtual void reply(const Ice::Current&) + { + _received = true; + } + + bool checkReceived() + { + return _received; + } + +private: + bool _received; +}; + +ICE_DEFINE_PTR(PingReplyIPtr, PingReplyI); + enum ThrowType { LocalException, UserException, StandardException, OtherException }; #ifdef ICE_CPP11_MAPPING @@ -2418,6 +2442,22 @@ allTests(Test::TestHelper* helper, bool collocated) cout << "ok" << endl; } + if(p->ice_getConnection()) + { + cout << "testing bidir... " << flush; + auto adapter = communicator->createObjectAdapter(""); + auto replyI = make_shared<PingReplyI>(); + auto reply = Ice::uncheckedCast<Test::PingReplyPrx>(adapter->addWithUUID(replyI)); + adapter->activate(); + + p->ice_getConnection()->setAdapter(adapter); + p->pingBiDir(reply); + test(replyI->checkReceived()); + adapter->destroy(); + + cout << "ok" << endl; + } + p->shutdown(); #else @@ -4085,6 +4125,22 @@ allTests(Test::TestHelper* helper, bool collocated) cout << "ok" << endl; } + if(p->ice_getConnection()) + { + cout << "testing bidir... " << flush; + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(""); + PingReplyIPtr replyI = new PingReplyI(); + Test::PingReplyPrx reply = Test::PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI)); + adapter->activate(); + + p->ice_getConnection()->setAdapter(adapter); + p->pingBiDir(reply); + test(replyI->checkReceived()); + adapter->destroy(); + + cout << "ok" << endl; + } + p->shutdown(); #endif } diff --git a/cpp/test/Ice/ami/Test.ice b/cpp/test/Ice/ami/Test.ice index f940a2229cb..1373db16510 100644 --- a/cpp/test/Ice/ami/Test.ice +++ b/cpp/test/Ice/ami/Test.ice @@ -55,7 +55,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/cpp/test/Ice/ami/TestI.cpp b/cpp/test/Ice/ami/TestI.cpp index 0e3f5f9bed6..587b9d45ed0 100644 --- a/cpp/test/Ice/ami/TestI.cpp +++ b/cpp/test/Ice/ami/TestI.cpp @@ -193,9 +193,15 @@ TestIntfI::supportsFunctionalTests(const Ice::Current&) } void -TestIntfI::pingBiDir(ICE_IN(Ice::Identity) id, const Ice::Current& current) +TestIntfI::pingBiDir(ICE_IN(Test::PingReplyPrxPtr) reply, const Ice::Current& current) { - ICE_UNCHECKED_CAST(Test::PingReplyPrx, current.con->createProxy(id))->reply(); +#ifdef ICE_CPP11_MAPPING + reply->ice_fixed(current.con)->replyAsync().get(); +#else + Test::PingReplyPrx fprx = reply->ice_fixed(current.con); + Ice::AsyncResultPtr result = fprx->begin_reply(); + fprx->end_reply(result); +#endif } void diff --git a/cpp/test/Ice/ami/TestI.h b/cpp/test/Ice/ami/TestI.h index 558d7b325df..c82f0b28ecc 100644 --- a/cpp/test/Ice/ami/TestI.h +++ b/cpp/test/Ice/ami/TestI.h @@ -46,7 +46,7 @@ public: virtual bool supportsAMD(const Ice::Current&); virtual bool supportsFunctionalTests(const Ice::Current&); - virtual void pingBiDir(ICE_IN(Ice::Identity), const Ice::Current&); + virtual void pingBiDir(ICE_IN(Test::PingReplyPrxPtr), const Ice::Current&); private: diff --git a/csharp/test/Ice/ami/AllTests.cs b/csharp/test/Ice/ami/AllTests.cs index c6defebb78c..81629acfcf4 100644 --- a/csharp/test/Ice/ami/AllTests.cs +++ b/csharp/test/Ice/ami/AllTests.cs @@ -23,43 +23,15 @@ namespace Ice { public override void reply(Ice.Current current) { - lock(this) - { - ++_replies; - Monitor.Pulse(this); - } - } - - public void reset() - { - lock(this) - { - _replies = 0; - } + _received = true; } - public bool waitReply(int expectedReplies, long timeout) + public bool checkReceived() { - lock(this) - { - long end = IceInternal.Time.currentMonotonicTimeMillis() + timeout; - while(_replies < expectedReplies) - { - int delay =(int)(end - IceInternal.Time.currentMonotonicTimeMillis()); - if(delay > 0) - { - Monitor.Wait(this, delay); - } - else - { - break; - } - } - return _replies == expectedReplies; - } + return _received; } - private int _replies = 0; + private bool _received = false; } private class Cookie @@ -3854,8 +3826,8 @@ namespace Ice adapter.activate(); p.ice_getConnection().setAdapter(adapter); - p.pingBiDir(reply.ice_getIdentity()); - replyI.waitReply(1, 100); + p.pingBiDir(reply); + test(replyI.checkReceived()); adapter.destroy(); } } diff --git a/csharp/test/Ice/ami/Test.ice b/csharp/test/Ice/ami/Test.ice index 3c36f84e5cc..b25dce15b40 100644 --- a/csharp/test/Ice/ami/Test.ice +++ b/csharp/test/Ice/ami/Test.ice @@ -56,7 +56,7 @@ interface TestIntf ["amd"] void opWithUEAsyncDispatch() throws TestIntfException; - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/csharp/test/Ice/ami/TestI.cs b/csharp/test/Ice/ami/TestI.cs index 1bbc34e6f84..53831e4cefd 100644 --- a/csharp/test/Ice/ami/TestI.cs +++ b/csharp/test/Ice/ami/TestI.cs @@ -152,15 +152,18 @@ namespace Ice } override public void - pingBiDir(Ice.Identity id, Ice.Current current) + pingBiDir(Test.PingReplyPrx reply, Ice.Current current) { - var p = Test.PingReplyPrxHelper.uncheckedCast(current.con.createProxy(id)); - p.replyAsync().ContinueWith( + reply = Test.PingReplyPrxHelper.uncheckedCast(reply.ice_fixed(current.con)); + Thread dispatchThread = Thread.CurrentThread; + reply.replyAsync().ContinueWith( (t) => { - test(Thread.CurrentThread.Name.Contains("Ice.ThreadPool.Server")); + Thread callbackThread = Thread.CurrentThread; + test(dispatchThread != callbackThread); + test(callbackThread.Name.Contains("Ice.ThreadPool.Server")); }, - p.ice_scheduler()).Wait(); + reply.ice_scheduler()).Wait(); } Test.TestIntfPrx diff --git a/java-compat/test/lambda/src/main/java/Ice/ami/lambda/AMI.java b/java-compat/test/lambda/src/main/java/Ice/ami/lambda/AMI.java index e2d18f23939..b1606c063f3 100644 --- a/java-compat/test/lambda/src/main/java/Ice/ami/lambda/AMI.java +++ b/java-compat/test/lambda/src/main/java/Ice/ami/lambda/AMI.java @@ -15,6 +15,8 @@ import test.Ice.ami.Test.TestIntfPrx; import test.Ice.ami.Test.TestIntfPrxHelper; import test.Ice.ami.Test.TestIntfControllerPrx; import test.Ice.ami.Test.TestIntfControllerPrxHelper; +import test.Ice.ami.Test.PingReplyPrx; +import test.Ice.ami.Test.PingReplyPrxHelper; import test.Ice.ami.Test.TestIntfException; import test.Ice.ami.Test.Callback_TestIntf_op; import test.Ice.ami.Test.Callback_TestIntf_opWithResult; @@ -32,6 +34,22 @@ public class AMI } } + public static class PingReplyI extends test.Ice.ami.Test._PingReplyDisp + { + @Override + public void reply(Ice.Current current) + { + _received = true; + } + + public boolean checkReceived() + { + return _received; + } + + private boolean _received = false; + } + private static class CallbackBase { CallbackBase() @@ -1151,5 +1169,20 @@ public class AMI // Excepted when response and exception callback are both null. } out.println("ok"); + + if(!collocated) + { + out.print("testing bidir..."); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter(""); + PingReplyI replyI = new PingReplyI(); + PingReplyPrx reply = PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)); + adapter.activate(); + + p.ice_getConnection().setAdapter(adapter); + p.pingBiDir(reply); + test(replyI.checkReceived()); + adapter.destroy(); + out.println("ok"); + } } } diff --git a/java-compat/test/src/main/java/test/Ice/ami/Test.ice b/java-compat/test/src/main/java/test/Ice/ami/Test.ice index 37ba5fc14c4..00374df0262 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/ami/Test.ice @@ -58,7 +58,7 @@ interface TestIntf float opFloat(float f); double opDouble(double d); - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/java-compat/test/src/main/java/test/Ice/ami/TestI.java b/java-compat/test/src/main/java/test/Ice/ami/TestI.java index 61f23cf8696..1ea1830d665 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/TestI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/TestI.java @@ -13,6 +13,7 @@ import test.Ice.ami.Test._TestIntfDisp; import test.Ice.ami.Test.AMD_TestIntf_startDispatch; import test.Ice.ami.Test.CloseMode; import test.Ice.ami.Test.TestIntfException; +import test.Ice.ami.Test.PingReplyPrx; import test.Ice.ami.Test.PingReplyPrxHelper; public class TestI extends _TestIntfDisp @@ -118,9 +119,11 @@ public class TestI extends _TestIntfDisp } @Override - public void pingBiDir(Ice.Identity id, Ice.Current current) + public void pingBiDir(PingReplyPrx reply, Ice.Current current) { - PingReplyPrxHelper.uncheckedCast(current.con.createProxy(id)).reply(); + reply = PingReplyPrxHelper.uncheckedCast(reply.ice_fixed(current.con)); + Ice.AsyncResult result = reply.begin_reply(); + reply.end_reply(result); } @Override diff --git a/java/test/src/main/java/test/Ice/ami/AllTests.java b/java/test/src/main/java/test/Ice/ami/AllTests.java index fc085875e93..32ce0f45f4e 100644 --- a/java/test/src/main/java/test/Ice/ami/AllTests.java +++ b/java/test/src/main/java/test/Ice/ami/AllTests.java @@ -42,42 +42,17 @@ public class AllTests public static class PingReplyI implements test.Ice.ami.Test.PingReply { @Override - public synchronized void reply(com.zeroc.Ice.Current current) + public void reply(com.zeroc.Ice.Current current) { - ++_replies; - notify(); - } - - public synchronized void reset() - { - _replies = 0; + _received = true; } - public synchronized boolean waitReply(int expectedReplies, long timeout) + public boolean checkReceived() { - long end = System.currentTimeMillis() + timeout; - while(_replies < expectedReplies) - { - long delay = end - System.currentTimeMillis(); - if(delay > 0) - { - try - { - wait(delay); - } - catch(java.lang.InterruptedException ex) - { - } - } - else - { - break; - } - } - return _replies == expectedReplies; + return _received; } - private int _replies; + private boolean _received = false; } private static class Callback @@ -1109,8 +1084,8 @@ public class AllTests adapter.activate(); p.ice_getConnection().setAdapter(adapter); - p.pingBiDir(reply.ice_getIdentity()); - replyI.waitReply(1, 100); + p.pingBiDir(reply); + test(replyI.checkReceived()); adapter.destroy(); } } diff --git a/java/test/src/main/java/test/Ice/ami/Test.ice b/java/test/src/main/java/test/Ice/ami/Test.ice index 37ba5fc14c4..00374df0262 100644 --- a/java/test/src/main/java/test/Ice/ami/Test.ice +++ b/java/test/src/main/java/test/Ice/ami/Test.ice @@ -58,7 +58,7 @@ interface TestIntf float opFloat(float f); double opDouble(double d); - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/java/test/src/main/java/test/Ice/ami/TestI.java b/java/test/src/main/java/test/Ice/ami/TestI.java index 1967c6649a6..b8d0c5699cc 100644 --- a/java/test/src/main/java/test/Ice/ami/TestI.java +++ b/java/test/src/main/java/test/Ice/ami/TestI.java @@ -125,14 +125,17 @@ public class TestI implements TestIntf } @Override - public void pingBiDir(com.zeroc.Ice.Identity id, com.zeroc.Ice.Current current) + public void pingBiDir(PingReplyPrx reply, com.zeroc.Ice.Current current) { - PingReplyPrx p = PingReplyPrx.uncheckedCast(current.con.createProxy(id)); - p.replyAsync().whenCompleteAsync( + reply = reply.ice_fixed(current.con); + final Thread dispatchThread = Thread.currentThread(); + reply.replyAsync().whenCompleteAsync( (result, ex) -> { - test(Thread.currentThread().getName().indexOf("Ice.ThreadPool.Server") != -1); - }, p.ice_executor()).join(); + Thread callbackThread = Thread.currentThread(); + test(callbackThread != dispatchThread); + test(callbackThread.getName().indexOf("Ice.ThreadPool.Server") != -1); + }, reply.ice_executor()).join(); } @Override diff --git a/matlab/test/Ice/ami/Test.ice b/matlab/test/Ice/ami/Test.ice index 0725fd97ef7..86c08e795a7 100644 --- a/matlab/test/Ice/ami/Test.ice +++ b/matlab/test/Ice/ami/Test.ice @@ -57,7 +57,7 @@ interface TestIntf float opFloat(float f); double opDouble(double d); - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/objective-c/test/Ice/ami/AMITest.ice b/objective-c/test/Ice/ami/AMITest.ice index a25f435f9a0..d259556cdd2 100644 --- a/objective-c/test/Ice/ami/AMITest.ice +++ b/objective-c/test/Ice/ami/AMITest.ice @@ -52,7 +52,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/objective-c/test/Ice/ami/AllTests.m b/objective-c/test/Ice/ami/AllTests.m index edf2d18fc61..0cd9fd647d1 100644 --- a/objective-c/test/Ice/ami/AllTests.m +++ b/objective-c/test/Ice/ami/AllTests.m @@ -13,6 +13,23 @@ #import <Foundation/Foundation.h> +@interface TestAMIPingReplyI : TestAMIPingReply<TestAMIPingReply> +{ + BOOL _received; +} +@end + +@implementation TestAMIPingReplyI +-(void) reply:(ICECurrent*)__unused current +{ + _received = YES; +} +-(BOOL) checkReceived +{ + return _received; +} +@end + @interface TestAMICallback : NSObject { BOOL called; @@ -848,5 +865,19 @@ amiAllTests(id<ICECommunicator> communicator, BOOL collocated) tprintf("ok\n"); + if([p ice_getConnection]) + { + tprintf("testing bidir... "); + id<ICEObjectAdapter> adapter = [communicator createObjectAdapter:@""]; + TestAMIPingReplyI* replyI = [TestAMIPingReplyI pingReply]; + id<TestAMIPingReplyPrx> reply = [TestAMIPingReplyPrx uncheckedCast:[adapter addWithUUID:replyI]]; + [adapter activate]; + + [[p ice_getConnection] setAdapter:adapter]; + [p pingBiDir:reply]; + test([replyI checkReceived]); + [adapter destroy]; + tprintf("ok\n"); + } [p shutdown]; } diff --git a/objective-c/test/Ice/ami/TestI.m b/objective-c/test/Ice/ami/TestI.m index c4ccd9fac70..d4fcd89356b 100644 --- a/objective-c/test/Ice/ami/TestI.m +++ b/objective-c/test/Ice/ami/TestI.m @@ -138,9 +138,11 @@ return NO; } --(void) pingBiDir:(ICEIdentity*)id_ current:(ICECurrent *)current +-(void) pingBiDir:(id<TestAMIPingReplyPrx>)reply current:(ICECurrent *)current { - [[TestAMIPingReplyPrx uncheckedCast:[current.con createProxy:id_]] reply]; + reply = [reply ice_fixed:current.con]; + id<ICEAsyncResult> result = [reply begin_reply]; + [reply end_reply:result]; } @end diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py index a85a640dab5..9624bc6c786 100644 --- a/python/test/Ice/ami/AllTests.py +++ b/python/test/Ice/ami/AllTests.py @@ -13,6 +13,17 @@ def test(b): if not b: raise RuntimeError('test assertion failed') +class PingReplyI(Test.PingReply): + def __init__(self): + self._received = False + + def reply(self, current=None): + self._received = True + + def checkReceived(self): + return self._received + + class CallbackBase: def __init__(self): self._called = False @@ -1399,6 +1410,21 @@ def allTestsFuture(helper, communicator, collocated): p.opWithUEAsync(ctx).add_done_callback(cb.opWithUE) cb.check() + # + # TODO: test add_done_callback_async + # + + if not collocated: + adapter = communicator.createObjectAdapter("") + replyI = PingReplyI() + reply = Test.PingReplyPrx.uncheckedCast(adapter.addWithUUID(replyI)) + adapter.activate() + + p.ice_getConnection().setAdapter(adapter) + p.pingBiDir(reply) + test(replyI.checkReceived()) + adapter.destroy() + print("ok") sys.stdout.write("testing local exceptions... ") diff --git a/python/test/Ice/ami/Test.ice b/python/test/Ice/ami/Test.ice index 6ddfca74b25..c614fe5cf27 100644 --- a/python/test/Ice/ami/Test.ice +++ b/python/test/Ice/ami/Test.ice @@ -50,7 +50,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); - void pingBiDir(Ice::Identity id); + void pingBiDir(PingReply* reply); } interface TestIntfController diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py index 757a9afa598..fe89da38c6f 100644 --- a/python/test/Ice/ami/TestI.py +++ b/python/test/Ice/ami/TestI.py @@ -86,8 +86,9 @@ class TestIntfI(Test.TestIntf): def supportsFunctionalTests(self, current=None): return False - def pingBiDir(self, id, current = None): - Test.PingReplyPrx.uncheckedCast(current.con.createProxy(id)).reply() + def pingBiDir(self, reply, current=None): + # TODO: verify correct thread with add_done_callback_async + reply.ice_fixed(current.con).replyAsync().result() class TestIntfII(Test.Outer.Inner.TestIntf): def op(self, i, current): |