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 /java | |
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.
Diffstat (limited to 'java')
-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 |
3 files changed, 16 insertions, 38 deletions
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 |