summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-06-21 09:20:02 +0200
committerBenoit Foucher <benoit@zeroc.com>2018-06-21 09:20:02 +0200
commit4bd01c81331ea7cd3f733a363c1be2ecd6805c85 (patch)
treee9b90e579f0dd659f84dced51dc48656bf5744d4
parentFixed Android >= 8.0 SSL issue (fixes #105 (diff)
downloadice-4bd01c81331ea7cd3f733a363c1be2ecd6805c85.tar.bz2
ice-4bd01c81331ea7cd3f733a363c1be2ecd6805c85.tar.xz
ice-4bd01c81331ea7cd3f733a363c1be2ecd6805c85.zip
Test fixes and improvements for Android testing reliability
-rw-r--r--cpp/test/Ice/dispatcher/AllTests.cpp4
-rw-r--r--cpp/test/Ice/dispatcher/Client.cpp2
-rw-r--r--cpp/test/Ice/location/AllTests.cpp4
-rw-r--r--cpp/test/Ice/timeout/AllTests.cpp2
-rw-r--r--csharp/test/Ice/dispatcher/AllTests.cs8
-rw-r--r--csharp/test/Ice/location/AllTests.cs8
-rw-r--r--csharp/test/Ice/timeout/AllTests.cs2
-rw-r--r--csharp/test/TestCommon/TestHelper.cs14
-rw-r--r--java-compat/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java24
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/Instance.java6
-rw-r--r--java-compat/test/src/main/java/test/Ice/dispatcher/AllTests.java136
-rw-r--r--java-compat/test/src/main/java/test/Ice/location/AllTests.java10
-rw-r--r--java-compat/test/src/main/java/test/Ice/timeout/AllTests.java11
-rw-r--r--java-compat/test/src/main/java/test/TestHelper.java21
-rw-r--r--java/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java29
-rw-r--r--java/android/gradle.properties3
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java6
-rw-r--r--java/test/src/main/java/test/Ice/dispatcher/AllTests.java43
-rw-r--r--java/test/src/main/java/test/Ice/dispatcher/Client.java21
-rw-r--r--java/test/src/main/java/test/Ice/dispatcher/Collocated.java24
-rw-r--r--java/test/src/main/java/test/Ice/dispatcher/Dispatcher.java1
-rw-r--r--java/test/src/main/java/test/Ice/dispatcher/Server.java25
-rw-r--r--java/test/src/main/java/test/Ice/location/AllTests.java8
-rw-r--r--java/test/src/main/java/test/Ice/operations/BatchOneways.java2
-rw-r--r--java/test/src/main/java/test/Ice/operations/Twoways.java2
-rw-r--r--java/test/src/main/java/test/Ice/operations/TwowaysAMI.java2
-rw-r--r--java/test/src/main/java/test/Ice/timeout/AllTests.java19
-rw-r--r--java/test/src/main/java/test/TestHelper.java25
-rw-r--r--matlab/test/Ice/timeout/AllTests.m2
-rw-r--r--python/test/Ice/dispatcher/AllTests.py2
-rw-r--r--python/test/Ice/timeout/AllTests.py2
-rw-r--r--ruby/test/Ice/timeout/AllTests.rb2
-rw-r--r--scripts/Util.py32
33 files changed, 217 insertions, 285 deletions
diff --git a/cpp/test/Ice/dispatcher/AllTests.cpp b/cpp/test/Ice/dispatcher/AllTests.cpp
index c153d535846..272ec7b3f20 100644
--- a/cpp/test/Ice/dispatcher/AllTests.cpp
+++ b/cpp/test/Ice/dispatcher/AllTests.cpp
@@ -175,7 +175,7 @@ allTests(Test::TestHelper* helper)
//
// Expect InvocationTimeoutException.
//
- auto to = p->ice_invocationTimeout(250);
+ auto to = p->ice_invocationTimeout(10);
to->sleepAsync(500,
[cb]()
{
@@ -250,7 +250,7 @@ allTests(Test::TestHelper* helper)
//
// Expect InvocationTimeoutException.
//
- Test::TestIntfPrx to = p->ice_invocationTimeout(250);
+ Test::TestIntfPrx to = p->ice_invocationTimeout(10);
to->begin_sleep(500, Test::newCallback_TestIntf_sleep(cb, &Callback::responseEx, &Callback::exceptionEx));
cb->check();
}
diff --git a/cpp/test/Ice/dispatcher/Client.cpp b/cpp/test/Ice/dispatcher/Client.cpp
index 62798c5f374..6767b901b9f 100644
--- a/cpp/test/Ice/dispatcher/Client.cpp
+++ b/cpp/test/Ice/dispatcher/Client.cpp
@@ -45,6 +45,8 @@ Client::run(int argc, char** argv)
void allTests(Test::TestHelper*);
allTests(this);
+
+ Dispatcher::terminate();
}
DEFINE_TEST(Client)
diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp
index becce4b6e6d..2581d65e292 100644
--- a/cpp/test/Ice/location/AllTests.cpp
+++ b/cpp/test/Ice/location/AllTests.cpp
@@ -282,7 +282,7 @@ allTests(Test::TestHelper* helper, const string& ref)
test(++count == locator->getRequestCount());
basencc->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache.
test(++count == locator->getRequestCount());
- basencc->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
+ basencc->ice_locatorCacheTimeout(2)->ice_ping(); // 2s timeout.
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1300));
basencc->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
@@ -291,7 +291,7 @@ allTests(Test::TestHelper* helper, const string& ref)
communicator->stringToProxy("test")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache.
count += 2;
test(count == locator->getRequestCount());
- communicator->stringToProxy("test")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout
+ communicator->stringToProxy("test")->ice_locatorCacheTimeout(2)->ice_ping(); // 2s timeout
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1300));
communicator->stringToProxy("test")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout
diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp
index 7daff168666..a9787193bc1 100644
--- a/cpp/test/Ice/timeout/AllTests.cpp
+++ b/cpp/test/Ice/timeout/AllTests.cpp
@@ -472,7 +472,7 @@ allTests(Test::TestHelper* helper)
controller->holdAdapter(-1);
IceUtil::Time now = IceUtil::Time::now();
ich.release()->destroy();
- test(IceUtil::Time::now() - now < IceUtil::Time::milliSeconds(700));
+ test(IceUtil::Time::now() - now < IceUtil::Time::milliSeconds(1000));
controller->resumeAdapter();
timeout->op(); // Ensure adapter is active.
}
diff --git a/csharp/test/Ice/dispatcher/AllTests.cs b/csharp/test/Ice/dispatcher/AllTests.cs
index d6f1e193ad0..6a1214f6119 100644
--- a/csharp/test/Ice/dispatcher/AllTests.cs
+++ b/csharp/test/Ice/dispatcher/AllTests.cs
@@ -134,7 +134,7 @@ public class AllTests : Test.AllTests
// Expect InvocationTimeoutException.
//
{
- Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250));
+ Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(10));
to.begin_sleep(500).whenCompleted(
() =>
{
@@ -199,7 +199,7 @@ public class AllTests : Test.AllTests
// Expect InvocationTimeoutException.
//
{
- Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250));
+ Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(10));
to.sleepAsync(500).ContinueWith(
previous =>
{
@@ -232,7 +232,7 @@ public class AllTests : Test.AllTests
// Expect InvocationTimeoutException.
//
{
- Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250));
+ Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(10));
to.sleepAsync(500).ContinueWith(
previous =>
{
@@ -306,7 +306,7 @@ public class AllTests : Test.AllTests
test(Dispatcher.isDispatcherThread());
}
- Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250));
+ Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(10));
try
{
await to.sleepAsync(500);
diff --git a/csharp/test/Ice/location/AllTests.cs b/csharp/test/Ice/location/AllTests.cs
index de7792c8186..a870ea66997 100644
--- a/csharp/test/Ice/location/AllTests.cs
+++ b/csharp/test/Ice/location/AllTests.cs
@@ -225,18 +225,18 @@ public class AllTests : Test.AllTests
test(++count == locator.getRequestCount());
basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
test(++count == locator.getRequestCount());
- basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
+ basencc.ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout.
test(count == locator.getRequestCount());
- System.Threading.Thread.Sleep(1200); // 1200ms
+ System.Threading.Thread.Sleep(1300); // 1300ms
basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
test(++count == locator.getRequestCount());
communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
count += 2;
test(count == locator.getRequestCount());
- communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
+ communicator.stringToProxy("test").ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout
test(count == locator.getRequestCount());
- System.Threading.Thread.Sleep(1200); // 1200ms
+ System.Threading.Thread.Sleep(1300); // 1300ms
communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
count += 2;
test(count == locator.getRequestCount());
diff --git a/csharp/test/Ice/timeout/AllTests.cs b/csharp/test/Ice/timeout/AllTests.cs
index 02898d654fe..b0cb49f3420 100644
--- a/csharp/test/Ice/timeout/AllTests.cs
+++ b/csharp/test/Ice/timeout/AllTests.cs
@@ -418,7 +418,7 @@ public class AllTests : Test.AllTests
controller.holdAdapter(-1);
long begin = System.DateTime.Now.Ticks;
comm.destroy();
- test(((long)new System.TimeSpan(System.DateTime.Now.Ticks - begin).TotalMilliseconds - begin) < 700);
+ test(((long)new System.TimeSpan(System.DateTime.Now.Ticks - begin).TotalMilliseconds - begin) < 1000);
controller.resumeAdapter();
}
WriteLine("ok");
diff --git a/csharp/test/TestCommon/TestHelper.cs b/csharp/test/TestCommon/TestHelper.cs
index d96d786bccc..fbba443e755 100644
--- a/csharp/test/TestCommon/TestHelper.cs
+++ b/csharp/test/TestCommon/TestHelper.cs
@@ -69,28 +69,30 @@ namespace Test
return properties;
}
- public Ice.Communicator initialize(ref string[] args, bool defaultCommunicator = true)
+ public Ice.Communicator initialize(ref string[] args)
{
Ice.InitializationData initData = new Ice.InitializationData();
initData.properties = createTestProperties(ref args);
- return initialize(initData, defaultCommunicator);
+ return initialize(initData);
}
- public Ice.Communicator initialize(Ice.Properties properties, bool defaultCommunicator = true)
+ public Ice.Communicator initialize(Ice.Properties properties)
{
Ice.InitializationData initData = new Ice.InitializationData();
initData.properties = properties;
- return initialize(initData, defaultCommunicator);
+ return initialize(initData);
}
- public Ice.Communicator initialize(Ice.InitializationData initData, bool defaultCommunicator = true)
+
+ public Ice.Communicator initialize(Ice.InitializationData initData)
{
Ice.Communicator communicator = Ice.Util.initialize(initData);
- if(defaultCommunicator)
+ if(_communicator == null)
{
_communicator = communicator;
}
return communicator;
}
+
public Ice.Communicator communicator()
{
return _communicator;
diff --git a/java-compat/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java b/java-compat/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java
index e51ff459927..78c207a517c 100644
--- a/java-compat/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java
+++ b/java-compat/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java
@@ -375,22 +375,12 @@ public class ControllerApp extends Application
});
_helper.run(_args);
- synchronized(this)
- {
- _status = 0;
- _completed = true;
- notifyAll();
- }
+ completed(0);
}
catch(Exception ex)
{
ex.printStackTrace(_helper.getWriter());
- synchronized(this)
- {
- _status = -1;
- _completed = true;
- notifyAll();
- }
+ completed(-1);
}
}
@@ -407,16 +397,16 @@ public class ControllerApp extends Application
return _out.toString();
}
- synchronized private void completed(int status)
+ synchronized public void serverReady()
{
- _completed = true;
- _status = status;
+ _ready = true;
notifyAll();
}
- synchronized public void serverReady()
+ synchronized private void completed(int status)
{
- _ready = true;
+ _completed = true;
+ _status = status;
notifyAll();
}
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/Instance.java b/java-compat/src/Ice/src/main/java/IceInternal/Instance.java
index 400e4279eaf..c93407578a0 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/Instance.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/Instance.java
@@ -69,11 +69,7 @@ public final class Instance implements Ice.ClassResolver
Timer(Ice.Properties props, String threadName)
{
super(1, Util.createThreadFactory(props, threadName)); // Single thread executor
- if(!Util.isAndroid())
- {
- // This API doesn't exist on Android up to API level 20.
- setRemoveOnCancelPolicy(true);
- }
+ setRemoveOnCancelPolicy(true);
setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
_observerHelper = new ThreadObserverHelper(threadName);
}
diff --git a/java-compat/test/src/main/java/test/Ice/dispatcher/AllTests.java b/java-compat/test/src/main/java/test/Ice/dispatcher/AllTests.java
index bb0c9aba85b..3f05929b218 100644
--- a/java-compat/test/src/main/java/test/Ice/dispatcher/AllTests.java
+++ b/java-compat/test/src/main/java/test/Ice/dispatcher/AllTests.java
@@ -21,11 +21,12 @@ import test.Ice.dispatcher.Test.Callback_TestIntf_sleep;
public class AllTests
{
- private static abstract class OpCallback extends Callback_TestIntf_op
+ private static class Callback
{
- OpCallback()
+ Callback()
{
_called = false;
+ _exception = null;
}
public synchronized void check()
@@ -40,10 +41,28 @@ public class AllTests
{
}
}
-
+ if(_exception != null)
+ {
+ throw _exception;
+ }
_called = false;
}
+ public synchronized void exception(Exception ex)
+ {
+ assert(!_called);
+ _called = true;
+ if(ex instanceof RuntimeException)
+ {
+ _exception = (RuntimeException)ex;
+ }
+ else
+ {
+ _exception = new RuntimeException(ex);
+ }
+ notify();
+ }
+
public synchronized void called()
{
assert(!_called);
@@ -52,6 +71,7 @@ public class AllTests
}
private boolean _called;
+ private RuntimeException _exception;
}
private static void
@@ -73,7 +93,8 @@ public class AllTests
test(obj != null);
int mult = 1;
- if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp"))
+ if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp") ||
+ helper.isAndroid())
{
mult = 4;
}
@@ -91,61 +112,59 @@ public class AllTests
{
p.op();
- OpCallback cb = new OpCallback()
+ final Callback cb1 = new Callback();
+ p.begin_op(new Callback_TestIntf_op() {
+ @Override
+ public void
+ response()
{
- @Override
- public void
- response()
- {
- test(dispatcher.isDispatcherThread());
- called();
- }
+ test(dispatcher.isDispatcherThread());
+ cb1.called();
+ }
- @Override
- public void
- exception(Ice.LocalException ex)
- {
- ex.printStackTrace();
- test(false);
- }
- };
- p.begin_op(cb);
- cb.check();
+ @Override
+ public void
+ exception(Ice.LocalException ex)
+ {
+ cb1.exception(ex);
+ }
+ });
+ cb1.check();
+ final Callback cb2 = new Callback();
TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy");
- cb = new OpCallback()
+ i.begin_op(new Callback_TestIntf_op() {
+ @Override
+ public void
+ response()
{
- @Override
- public void
- response()
- {
- test(false);
- }
+ cb2.exception(new RuntimeException());
+ }
- @Override
- public void
- exception(Ice.LocalException ex)
- {
- test(ex instanceof Ice.NoEndpointException);
- test(dispatcher.isDispatcherThread());
- called();
- }
- };
- i.begin_op(cb);
- cb.check();
+ @Override
+ public void
+ exception(Ice.LocalException ex)
+ {
+ test(ex instanceof Ice.NoEndpointException);
+ test(dispatcher.isDispatcherThread());
+ cb2.called();
+ }
+ });
+ cb2.check();
{
//
// Expect InvocationTimeoutException.
//
- TestIntfPrx to = TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250));
- class Callback_TestIntf_sleepImpl extends Callback_TestIntf_sleep
+ TestIntfPrx to = TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(10));
+ final Callback cb3 = new Callback();
+ to.begin_sleep(500 * mult, new Callback_TestIntf_sleep()
{
@Override
public void
response()
{
- test(false);
+ cb3.exception(new RuntimeException());
}
@Override
@@ -154,7 +173,7 @@ public class AllTests
{
test(ex instanceof Ice.InvocationTimeoutException);
test(dispatcher.isDispatcherThread());
- called();
+ cb3.called();
}
@Override
@@ -163,33 +182,8 @@ public class AllTests
{
test(sentSynchronously || dispatcher.isDispatcherThread());
}
-
- public synchronized void check()
- {
- while(!_called)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- _called = false;
- }
- private synchronized void called()
- {
- assert(!_called);
- _called = true;
- notify();
- }
- private boolean _called;
- };
- Callback_TestIntf_sleepImpl callback = new Callback_TestIntf_sleepImpl();
- to.begin_sleep(500 * mult, callback);
- callback.check();
+ });
+ cb3.check();
}
testController.holdAdapter();
diff --git a/java-compat/test/src/main/java/test/Ice/location/AllTests.java b/java-compat/test/src/main/java/test/Ice/location/AllTests.java
index ec99c979ce6..36fcd92381a 100644
--- a/java-compat/test/src/main/java/test/Ice/location/AllTests.java
+++ b/java-compat/test/src/main/java/test/Ice/location/AllTests.java
@@ -279,18 +279,18 @@ public class AllTests
test(++count == locator.getRequestCount());
basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
test(++count == locator.getRequestCount());
- basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
+ basencc.ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout.
test(count == locator.getRequestCount());
- Thread.sleep(1200);
- basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
+ Thread.sleep(1300);
+ basencc.ice_locatorCacheTimeout(2).ice_ping(); // 1s timeout.
test(++count == locator.getRequestCount());
communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
count += 2;
test(count == locator.getRequestCount());
- communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
+ communicator.stringToProxy("test").ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout
test(count == locator.getRequestCount());
- Thread.sleep(1200);
+ Thread.sleep(1300);
communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
count += 2;
test(count == locator.getRequestCount());
diff --git a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java
index c8f65deb840..866357ddaa7 100644
--- a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java
+++ b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java
@@ -164,7 +164,8 @@ public class AllTests
test(obj != null);
int mult = 1;
- if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp"))
+ if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp") ||
+ helper.isAndroid())
{
mult = 4;
}
@@ -242,7 +243,7 @@ public class AllTests
// Expect success.
//
TimeoutPrx to = TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(1000 * mult));
- controller.holdAdapter(200 * mult);
+ controller.holdAdapter(100 * mult);
try
{
to.sendData(new byte[1000000]);
@@ -295,7 +296,7 @@ public class AllTests
//
// Expect success.
//
- TimeoutPrx to = TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(500 * mult));
+ TimeoutPrx to = TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(1000 * mult));
CallbackSuccess cb = new CallbackSuccess();
to.begin_sleep(100 * mult, cb);
cb.check();
@@ -507,13 +508,13 @@ public class AllTests
// Test Ice.Override.CloseTimeout.
//
Ice.Properties properties = communicator.getProperties()._clone();
- properties.setProperty("Ice.Override.CloseTimeout", "100");
+ properties.setProperty("Ice.Override.CloseTimeout", "10");
Ice.Communicator comm = helper.initialize(properties);
comm.stringToProxy(sref).ice_getConnection();
controller.holdAdapter(-1);
long now = System.nanoTime();
comm.destroy();
- test(System.nanoTime() - now < 700 * 1000000);
+ test(System.nanoTime() - now < 2000 * 1000000);
controller.resumeAdapter();
}
out.println("ok");
diff --git a/java-compat/test/src/main/java/test/TestHelper.java b/java-compat/test/src/main/java/test/TestHelper.java
index ada1dc5be7c..1db2964b807 100644
--- a/java-compat/test/src/main/java/test/TestHelper.java
+++ b/java-compat/test/src/main/java/test/TestHelper.java
@@ -138,41 +138,26 @@ public abstract class TestHelper
public Communicator initialize(String[] args)
{
- return initialize(args, true);
- }
-
- public Communicator initialize(String[] args, boolean defaultCommunicator)
- {
InitializationData initData = new InitializationData();
initData.properties = createTestProperties(args);
- return initialize(initData, defaultCommunicator);
+ return initialize(initData);
}
public Communicator initialize(Properties properties)
{
- return initialize(properties, false);
- }
-
- public Communicator initialize(Properties properties, boolean defaultCommunicator)
- {
InitializationData initData = new InitializationData();
initData.properties = properties;
- return initialize(initData, defaultCommunicator);
+ return initialize(initData);
}
public Communicator initialize(InitializationData initData)
{
- return initialize(initData, true);
- }
-
- public Communicator initialize(InitializationData initData, boolean defaultCommunicator)
- {
- Communicator communicator = Ice.Util.initialize(initData);
if(_classLoader != null && initData.classLoader == null)
{
initData.classLoader = _classLoader;
}
+ Communicator communicator = Ice.Util.initialize(initData);
if(defaultCommunicator || _communicator == null)
{
_communicator = communicator;
diff --git a/java/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java b/java/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java
index de313679544..d3582c03d7b 100644
--- a/java/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java
+++ b/java/android/controller/src/main/java/com/zeroc/testcontroller/ControllerApp.java
@@ -195,8 +195,8 @@ public class ControllerApp extends Application
initData.properties = com.zeroc.Ice.Util.createProperties();
initData.properties.setProperty("Ice.ThreadPool.Server.SizeMax", "10");
initData.properties.setProperty("ControllerAdapter.Endpoints", "tcp");
- initData.properties.setProperty("Ice.Trace.Network", "3");
- initData.properties.setProperty("Ice.Trace.Protocol", "1");
+ //initData.properties.setProperty("Ice.Trace.Network", "3");
+ //initData.properties.setProperty("Ice.Trace.Protocol", "1");
initData.properties.setProperty("ControllerAdapter.AdapterId", java.util.UUID.randomUUID().toString());
initData.properties.setProperty("Ice.Override.ConnectTimeout", "1000");
if(!isEmulator())
@@ -312,6 +312,7 @@ public class ControllerApp extends Application
{
_bundle = bundle;
_args = args;
+ _exe = exe;
}
public void communicatorInitialized(Communicator communicator)
@@ -360,22 +361,12 @@ public class ControllerApp extends Application
});
_helper.run(_args);
- synchronized(this)
- {
- _status = 0;
- _completed = true;
- notifyAll();
- }
+ completed(0);
}
catch(Exception ex)
{
ex.printStackTrace(_helper.getWriter());
- synchronized(this)
- {
- _status = -1;
- _completed = true;
- notifyAll();
- }
+ completed(-1);
}
}
@@ -392,16 +383,16 @@ public class ControllerApp extends Application
return _out.toString();
}
- synchronized private void completed(int status)
+ synchronized public void serverReady()
{
- _completed = true;
- _status = status;
+ _ready = true;
notifyAll();
}
- synchronized public void serverReady()
+ synchronized private void completed(int status)
{
- _ready = true;
+ _completed = true;
+ _status = status;
notifyAll();
}
diff --git a/java/android/gradle.properties b/java/android/gradle.properties
index 258b8e622dc..c16ba7a92f3 100644
--- a/java/android/gradle.properties
+++ b/java/android/gradle.properties
@@ -45,6 +45,7 @@ iceBuilderHome =
// Gradle build properties
//
org.gradle.daemon = true
+org.gradle.configureondemand=false
//
// Package build properties
@@ -71,5 +72,3 @@ cppPlatform = x64
// directory.
//
cppConfiguration = Release
-
-org.gradle.configureondemand=false
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java
index cd14ad27cdc..1d334dceb0f 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java
@@ -66,11 +66,7 @@ public final class Instance implements java.util.function.Function<String, Class
Timer(com.zeroc.Ice.Properties props, String threadName)
{
super(1, Util.createThreadFactory(props, threadName)); // Single thread executor
- if(!Util.isAndroid())
- {
- // This API doesn't exist on Android up to API level 20.
- setRemoveOnCancelPolicy(true);
- }
+ setRemoveOnCancelPolicy(true);
setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
_observerHelper = new ThreadObserverHelper(threadName);
}
diff --git a/java/test/src/main/java/test/Ice/dispatcher/AllTests.java b/java/test/src/main/java/test/Ice/dispatcher/AllTests.java
index 7e4b9e50da8..3b3324cebcb 100644
--- a/java/test/src/main/java/test/Ice/dispatcher/AllTests.java
+++ b/java/test/src/main/java/test/Ice/dispatcher/AllTests.java
@@ -24,6 +24,7 @@ public class AllTests
Callback()
{
_called = false;
+ _exception = null;
}
public synchronized void check()
@@ -38,10 +39,28 @@ public class AllTests
{
}
}
-
+ if(_exception != null)
+ {
+ throw _exception;
+ }
_called = false;
}
+ public synchronized void exception(Throwable ex)
+ {
+ assert(!_called);
+ _called = true;
+ if(ex instanceof RuntimeException)
+ {
+ _exception = (RuntimeException)ex;
+ }
+ else
+ {
+ _exception = new RuntimeException(ex);
+ }
+ notify();
+ }
+
public synchronized void called()
{
assert(!_called);
@@ -50,6 +69,7 @@ public class AllTests
}
private boolean _called;
+ private RuntimeException _exception;
}
private static void test(boolean b)
@@ -70,7 +90,8 @@ public class AllTests
test(obj != null);
int mult = 1;
- if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp"))
+ if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp") ||
+ helper.isAndroid())
{
mult = 4;
}
@@ -94,8 +115,7 @@ public class AllTests
{
if(ex != null)
{
- ex.printStackTrace();
- test(false);
+ cb.exception(ex);
}
else
{
@@ -112,8 +132,7 @@ public class AllTests
{
if(ex != null)
{
- ex.printStackTrace();
- test(false);
+ cb.exception(ex);
}
else
{
@@ -137,7 +156,7 @@ public class AllTests
}
else
{
- test(false);
+ cb.exception(new RuntimeException());
}
}, dispatcher);
cb.check();
@@ -156,7 +175,7 @@ public class AllTests
}
else
{
- test(false);
+ cb.exception(new RuntimeException());
}
}, p.ice_executor());
cb.check();
@@ -166,7 +185,7 @@ public class AllTests
//
// Expect InvocationTimeoutException.
//
- TestIntfPrx to = p.ice_invocationTimeout(250);
+ TestIntfPrx to = p.ice_invocationTimeout(10);
final Callback cb = new Callback();
CompletableFuture<Void> r = to.sleepAsync(500 * mult);
r.whenCompleteAsync((result, ex) ->
@@ -179,7 +198,7 @@ public class AllTests
}
else
{
- test(false);
+ cb.exception(new RuntimeException());
}
}, dispatcher);
com.zeroc.Ice.Util.getInvocationFuture(r).whenSentAsync((sentSynchronously, ex) ->
@@ -194,7 +213,7 @@ public class AllTests
//
// Expect InvocationTimeoutException.
//
- TestIntfPrx to = p.ice_invocationTimeout(250);
+ TestIntfPrx to = p.ice_invocationTimeout(10);
final Callback cb = new Callback();
CompletableFuture<Void> r = to.sleepAsync(500 * mult);
r.whenCompleteAsync((result, ex) ->
@@ -207,7 +226,7 @@ public class AllTests
}
else
{
- test(false);
+ cb.exception(new RuntimeException());
}
}, dispatcher);
com.zeroc.Ice.Util.getInvocationFuture(r).whenSentAsync((sentSynchronously, ex) ->
diff --git a/java/test/src/main/java/test/Ice/dispatcher/Client.java b/java/test/src/main/java/test/Ice/dispatcher/Client.java
index d4f6c08ea8a..13738aa715c 100644
--- a/java/test/src/main/java/test/Ice/dispatcher/Client.java
+++ b/java/test/src/main/java/test/Ice/dispatcher/Client.java
@@ -17,31 +17,18 @@ public class Client extends test.TestHelper
initData.properties = createTestProperties(args);
initData.properties.setProperty("Ice.Package.Test", "test.Ice.dispatcher");
- assert(_dispatcher == null);
- _dispatcher = new Dispatcher();
+ Dispatcher dispatcher = new Dispatcher();
//
// Limit the send buffer size, this test relies on the socket
// send() blocking after sending a given amount of data.
//
initData.properties.setProperty("Ice.TCP.SndSize", "50000");
- initData.dispatcher = _dispatcher;
+ initData.dispatcher = dispatcher;
try(com.zeroc.Ice.Communicator communicator = initialize(initData))
{
- AllTests.allTests(this, _dispatcher);
+ AllTests.allTests(this, dispatcher);
}
+ dispatcher.terminate();
}
-
- Dispatcher getDispatcher()
- {
- return _dispatcher;
- }
-
- //
- // The Dispatcher class uses a static "_instance" member in other language
- // mappings. In Java, we avoid the use of static members because we need to
- // maintain support for Android (in which the client and server run in the
- // same process).
- //
- private Dispatcher _dispatcher;
}
diff --git a/java/test/src/main/java/test/Ice/dispatcher/Collocated.java b/java/test/src/main/java/test/Ice/dispatcher/Collocated.java
index 68fea2018ea..fb0cc69e63a 100644
--- a/java/test/src/main/java/test/Ice/dispatcher/Collocated.java
+++ b/java/test/src/main/java/test/Ice/dispatcher/Collocated.java
@@ -14,11 +14,10 @@ public class Collocated extends test.TestHelper
public void run(String[] args)
{
com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData();
- assert(_dispatcher == null);
- _dispatcher = new Dispatcher();
+ Dispatcher dispatcher = new Dispatcher();
initData.properties = createTestProperties(args);
initData.properties.setProperty("Ice.Package.Test", "test.Ice.dispatcher");
- initData.dispatcher = _dispatcher;
+ initData.dispatcher = dispatcher;
try(com.zeroc.Ice.Communicator communicator = initialize(initData))
{
communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
@@ -27,26 +26,13 @@ public class Collocated extends test.TestHelper
com.zeroc.Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
com.zeroc.Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("ControllerAdapter");
- assert(_dispatcher != null);
- adapter.add(new TestI(_dispatcher), com.zeroc.Ice.Util.stringToIdentity("test"));
+ adapter.add(new TestI(dispatcher), com.zeroc.Ice.Util.stringToIdentity("test"));
//adapter.activate(); // Don't activate OA to ensure collocation is used.
adapter2.add(new TestControllerI(adapter), com.zeroc.Ice.Util.stringToIdentity("testController"));
//adapter2.activate(); // Don't activate OA to ensure collocation is used.
- AllTests.allTests(this, _dispatcher);
+ AllTests.allTests(this, dispatcher);
}
+ dispatcher.terminate();
}
-
- Dispatcher getDispatcher()
- {
- return _dispatcher;
- }
-
- //
- // The Dispatcher class uses a static "_instance" member in other language
- // mappings. In Java, we avoid the use of static members because we need to
- // maintain support for Android (in which the client and server run in the
- // same process).
- //
- private Dispatcher _dispatcher;
}
diff --git a/java/test/src/main/java/test/Ice/dispatcher/Dispatcher.java b/java/test/src/main/java/test/Ice/dispatcher/Dispatcher.java
index a1b6323b0bb..ec9aeed7012 100644
--- a/java/test/src/main/java/test/Ice/dispatcher/Dispatcher.java
+++ b/java/test/src/main/java/test/Ice/dispatcher/Dispatcher.java
@@ -66,6 +66,7 @@ public class Dispatcher implements Runnable,
catch(Exception ex)
{
// Exceptions should never propagate here.
+ ex.printStackTrace();
test(false);
}
}
diff --git a/java/test/src/main/java/test/Ice/dispatcher/Server.java b/java/test/src/main/java/test/Ice/dispatcher/Server.java
index 811d26c3bdf..d4c753e6cf1 100644
--- a/java/test/src/main/java/test/Ice/dispatcher/Server.java
+++ b/java/test/src/main/java/test/Ice/dispatcher/Server.java
@@ -14,8 +14,7 @@ public class Server extends test.TestHelper
public void run(String[] args)
{
com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData();
- assert(_dispatcher == null);
- _dispatcher = new Dispatcher();
+ Dispatcher dispatcher = new Dispatcher();
initData.properties = createTestProperties(args);
initData.properties.setProperty("Ice.Package.Test", "test.Ice.dispatcher");
//
@@ -23,7 +22,7 @@ public class Server extends test.TestHelper
// send() blocking after sending a given amount of data.
//
initData.properties.setProperty("Ice.TCP.RcvSize", "50000");
- initData.dispatcher = _dispatcher;
+ initData.dispatcher = dispatcher;
try(com.zeroc.Ice.Communicator communicator = initialize(initData))
{
communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
@@ -33,29 +32,13 @@ public class Server extends test.TestHelper
com.zeroc.Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter");
com.zeroc.Ice.ObjectAdapter adapter2 = communicator().createObjectAdapter("ControllerAdapter");
- assert(_dispatcher != null);
- adapter.add(new TestI(_dispatcher), com.zeroc.Ice.Util.stringToIdentity("test"));
+ adapter.add(new TestI(dispatcher), com.zeroc.Ice.Util.stringToIdentity("test"));
adapter.activate();
adapter2.add(new TestControllerI(adapter), com.zeroc.Ice.Util.stringToIdentity("testController"));
adapter2.activate();
serverReady();
communicator.waitForShutdown();
}
+ dispatcher.terminate();
}
-
- public void terminate()
- {
- if(_dispatcher != null)
- {
- _dispatcher.terminate();
- }
- }
-
- //
- // The Dispatcher class uses a static "_instance" member in other language
- // mappings. In Java, we avoid the use of static members because we need to
- // maintain support for Android (in which the client and server run in the
- // same process).
- //
- private Dispatcher _dispatcher;
}
diff --git a/java/test/src/main/java/test/Ice/location/AllTests.java b/java/test/src/main/java/test/Ice/location/AllTests.java
index f4cba401625..3b8bb8b4537 100644
--- a/java/test/src/main/java/test/Ice/location/AllTests.java
+++ b/java/test/src/main/java/test/Ice/location/AllTests.java
@@ -271,18 +271,18 @@ public class AllTests
test(++count == locator.getRequestCount());
basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
test(++count == locator.getRequestCount());
- basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
+ basencc.ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout.
test(count == locator.getRequestCount());
- Thread.sleep(1200);
+ Thread.sleep(1300);
basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
test(++count == locator.getRequestCount());
communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
count += 2;
test(count == locator.getRequestCount());
- communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
+ communicator.stringToProxy("test").ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout
test(count == locator.getRequestCount());
- Thread.sleep(1200);
+ Thread.sleep(1300);
communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
count += 2;
test(count == locator.getRequestCount());
diff --git a/java/test/src/main/java/test/Ice/operations/BatchOneways.java b/java/test/src/main/java/test/Ice/operations/BatchOneways.java
index c7cfbb3c16a..0eb9fe8133c 100644
--- a/java/test/src/main/java/test/Ice/operations/BatchOneways.java
+++ b/java/test/src/main/java/test/Ice/operations/BatchOneways.java
@@ -148,7 +148,7 @@ class BatchOneways
initData.properties = properties._clone();
BatchRequestInterceptorI interceptor = new BatchRequestInterceptorI();
initData.batchRequestInterceptor = interceptor;
- try(com.zeroc.Ice.Communicator ic = helper.initialize(initData, false))
+ try(com.zeroc.Ice.Communicator ic = helper.initialize(initData))
{
batch = MyClassPrx.uncheckedCast(ic.stringToProxy(p.toString())).ice_batchOneway();
diff --git a/java/test/src/main/java/test/Ice/operations/Twoways.java b/java/test/src/main/java/test/Ice/operations/Twoways.java
index a81ce784da5..ad5e14c1e4b 100644
--- a/java/test/src/main/java/test/Ice/operations/Twoways.java
+++ b/java/test/src/main/java/test/Ice/operations/Twoways.java
@@ -1404,7 +1404,7 @@ class Twoways
com.zeroc.Ice.Properties properties = communicator.getProperties()._clone();
properties.setProperty("Ice.ImplicitContext", impls[i]);
- try(Communicator ic = helper.initialize(properties, false))
+ try(Communicator ic = helper.initialize(properties))
{
Map<String, String> ctx = new HashMap<>();
diff --git a/java/test/src/main/java/test/Ice/operations/TwowaysAMI.java b/java/test/src/main/java/test/Ice/operations/TwowaysAMI.java
index 4a9bdbc7db1..c64af790997 100644
--- a/java/test/src/main/java/test/Ice/operations/TwowaysAMI.java
+++ b/java/test/src/main/java/test/Ice/operations/TwowaysAMI.java
@@ -1568,7 +1568,7 @@ class TwowaysAMI
com.zeroc.Ice.Properties properties = communicator.getProperties()._clone();
properties.setProperty("Ice.ImplicitContext", impls[i]);
- try(com.zeroc.Ice.Communicator ic = helper.initialize(properties, false))
+ try(com.zeroc.Ice.Communicator ic = helper.initialize(properties))
{
java.util.Map<String, String> ctx = new java.util.HashMap<>();
ctx.put("one", "ONE");
diff --git a/java/test/src/main/java/test/Ice/timeout/AllTests.java b/java/test/src/main/java/test/Ice/timeout/AllTests.java
index a0c8d016ff5..d927c07d96d 100644
--- a/java/test/src/main/java/test/Ice/timeout/AllTests.java
+++ b/java/test/src/main/java/test/Ice/timeout/AllTests.java
@@ -86,7 +86,8 @@ public class AllTests
test(obj != null);
int mult = 1;
- if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp"))
+ if(!communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp").equals("tcp") ||
+ helper.isAndroid())
{
mult = 4;
}
@@ -165,7 +166,7 @@ public class AllTests
// Expect success.
//
TimeoutPrx to = timeout.ice_timeout(1000 * mult);
- controller.holdAdapter(200 * mult);
+ controller.holdAdapter(100 * mult);
try
{
to.sendData(new byte[1000000]);
@@ -222,7 +223,7 @@ public class AllTests
//
// Expect success.
//
- TimeoutPrx to = timeout.ice_invocationTimeout(500 * mult);
+ TimeoutPrx to = timeout.ice_invocationTimeout(1000 * mult);
Callback cb = new Callback();
to.sleepAsync(100 * mult).whenComplete((result, ex) ->
{
@@ -331,7 +332,7 @@ public class AllTests
com.zeroc.Ice.Properties properties = communicator.getProperties()._clone();
properties.setProperty("Ice.Override.ConnectTimeout", "250");
properties.setProperty("Ice.Override.Timeout", "100");
- try(com.zeroc.Ice.Communicator comm = helper.initialize(properties, false))
+ try(com.zeroc.Ice.Communicator comm = helper.initialize(properties))
{
TimeoutPrx to = TimeoutPrx.uncheckedCast(comm.stringToProxy(sref));
connect(to);
@@ -381,7 +382,7 @@ public class AllTests
properties.setProperty("Ice.Override.ConnectTimeout", "2500");
}
- try(com.zeroc.Ice.Communicator comm = helper.initialize(properties, false))
+ try(com.zeroc.Ice.Communicator comm = helper.initialize(properties))
{
TimeoutPrx to = TimeoutPrx.uncheckedCast(comm.stringToProxy(sref));
controller.holdAdapter(-1);
@@ -438,14 +439,14 @@ public class AllTests
// Test Ice.Override.CloseTimeout.
//
com.zeroc.Ice.Properties properties = communicator.getProperties()._clone();
- properties.setProperty("Ice.Override.CloseTimeout", "100");
- try(com.zeroc.Ice.Communicator comm = helper.initialize(properties, false))
+ properties.setProperty("Ice.Override.CloseTimeout", "10");
+ try(com.zeroc.Ice.Communicator comm = helper.initialize(properties))
{
comm.stringToProxy(sref).ice_getConnection();
controller.holdAdapter(-1);
long now = System.nanoTime();
comm.destroy();
- test(System.nanoTime() - now < 700 * 1000000);
+ test(System.nanoTime() - now < 2000 * 1000000);
controller.resumeAdapter();
}
}
@@ -463,7 +464,7 @@ public class AllTests
proxy = proxy.ice_invocationTimeout(100);
try
{
- proxy.sleep(500) ;
+ proxy.sleep(500);
test(false);
}
catch(com.zeroc.Ice.InvocationTimeoutException ex)
diff --git a/java/test/src/main/java/test/TestHelper.java b/java/test/src/main/java/test/TestHelper.java
index dec5266b331..49c16f48c26 100644
--- a/java/test/src/main/java/test/TestHelper.java
+++ b/java/test/src/main/java/test/TestHelper.java
@@ -140,42 +140,27 @@ public abstract class TestHelper
public Communicator initialize(String[] args)
{
- return initialize(args, true);
- }
-
- public Communicator initialize(String[] args, boolean defaultCommunicator)
- {
InitializationData initData = new InitializationData();
initData.properties = createTestProperties(args);
- return initialize(initData, defaultCommunicator);
+ return initialize(initData);
}
public Communicator initialize(Properties properties)
{
- return initialize(properties, true);
- }
-
- public Communicator initialize(Properties properties, boolean defaultCommunicator)
- {
InitializationData initData = new InitializationData();
initData.properties = properties;
- return initialize(initData, defaultCommunicator);
+ return initialize(initData);
}
public Communicator initialize(InitializationData initData)
{
- return initialize(initData, true);
- }
-
- public Communicator initialize(InitializationData initData, boolean defaultCommunicator)
- {
- Communicator communicator = Util.initialize(initData);
if(_classLoader != null && initData.classLoader == null)
{
initData.classLoader = _classLoader;
}
- if(defaultCommunicator)
+ Communicator communicator = Util.initialize(initData);
+ if(_communicator == null)
{
_communicator = communicator;
}
@@ -185,7 +170,7 @@ public abstract class TestHelper
_controllerHelper.communicatorInitialized(communicator);
}
- return communicator;
+ return communicator;
}
public void setControllerHelper(ControllerHelper controllerHelper)
diff --git a/matlab/test/Ice/timeout/AllTests.m b/matlab/test/Ice/timeout/AllTests.m
index 0e68469f866..7cace58f3a7 100644
--- a/matlab/test/Ice/timeout/AllTests.m
+++ b/matlab/test/Ice/timeout/AllTests.m
@@ -335,7 +335,7 @@ classdef AllTests
controller.holdAdapter(-1);
tic();
comm.destroy();
- assert(toc() < .7);
+ assert(toc() < 1.0);
controller.resumeAdapter();
timeout.op(); % Ensure adapter is active.
diff --git a/python/test/Ice/dispatcher/AllTests.py b/python/test/Ice/dispatcher/AllTests.py
index 2d692204cdd..797c06ec051 100644
--- a/python/test/Ice/dispatcher/AllTests.py
+++ b/python/test/Ice/dispatcher/AllTests.py
@@ -84,7 +84,7 @@ def allTests(communicator, collocated):
#
# Expect InvocationTimeoutException.
#
- to = p.ice_invocationTimeout(250);
+ to = p.ice_invocationTimeout(10);
to.sleepAsync(500).add_done_callback_async(cb.exceptionEx)
cb.check()
diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py
index b142769e5ab..c18f559bfb6 100644
--- a/python/test/Ice/timeout/AllTests.py
+++ b/python/test/Ice/timeout/AllTests.py
@@ -286,7 +286,7 @@ def allTests(communicator):
controller.holdAdapter(-1)
now = time.clock()
comm.destroy()
- test((time.clock() - now) < 0.7)
+ test((time.clock() - now) < 1.0)
controller.resumeAdapter()
print("ok")
diff --git a/ruby/test/Ice/timeout/AllTests.rb b/ruby/test/Ice/timeout/AllTests.rb
index 47a388154fb..0d2cdd9a99d 100644
--- a/ruby/test/Ice/timeout/AllTests.rb
+++ b/ruby/test/Ice/timeout/AllTests.rb
@@ -235,7 +235,7 @@ def allTests(communicator)
controller.holdAdapter(-1);
now = Time.now
comm.destroy();
- test((Time.now - now) < 0.7);
+ test((Time.now - now) < 1.0);
controller.resumeAdapter()
puts "ok"
diff --git a/scripts/Util.py b/scripts/Util.py
index 04c1575e60d..0ef811d664f 100644
--- a/scripts/Util.py
+++ b/scripts/Util.py
@@ -23,10 +23,23 @@ import Expect
toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
-def run(cmd, cwd=None, err=False):
- p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd)
+def run(cmd, cwd=None, err=False, stdout=False, stdin=None, stdinRepeat=True):
+ if stdout:
+ p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
+ else:
+ p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd)
try:
- out = p.stdout.read().decode('UTF-8').strip()
+ if stdin:
+ try:
+ while True:
+ p.stdin.write(stdin)
+ if not stdinRepeat:
+ break
+ time.sleep(1)
+ except:
+ pass
+
+ out = (p.stderr if stdout else p.stdout).read().decode('UTF-8').strip()
if(not err and p.wait() != 0) or (err and p.wait() == 0) :
raise RuntimeError(cmd + " failed:\n" + out)
finally:
@@ -35,7 +48,8 @@ def run(cmd, cwd=None, err=False):
#
# ResourceWarning: unclosed file <_io.TextIOWrapper name=3 encoding='cp1252'>
#
- p.stdout.close()
+ (p.stderr if stdout else p.stdout).close()
+ p.stdin.close()
return out
def val(v, escapeQuotes=False, quoteValue=True):
@@ -2191,7 +2205,7 @@ class AndroidProcessController(RemoteProcessController):
raise RuntimeError("cannot find free port in range 5554-5584, to run android emulator")
self.device = "emulator-{}".format(port)
- cmd = "emulator -avd {0} -port {1} -noaudio -partition-size 768 -no-window -no-snapshot".format(avd, port)
+ cmd = "emulator -avd {0} -port {1} -noaudio -partition-size 768 -no-snapshot".format(avd, port)
self.emulator = subprocess.Popen(cmd, shell=True)
if self.emulator.poll():
@@ -2216,7 +2230,6 @@ class AndroidProcessController(RemoteProcessController):
if (time.time() - t) > 300:
raise RuntimeError("couldn't start the Android emulator `{}'".format(avd))
time.sleep(2)
- print(" ok")
def startControllerApp(self, current, ident):
@@ -2229,11 +2242,12 @@ class AndroidProcessController(RemoteProcessController):
elif current.config.androidemulator:
# Create Android Virtual Device
sdk = current.testcase.getMapping().getSDKPackage()
+ print("creating virtual device ({0})... ".format(sdk))
try:
run("avdmanager delete avd -n IceTests") # Delete the created device
except:
pass
- run("sdkmanager \"{0}\"".format(sdk))
+ run("sdkmanager \"{0}\"".format(sdk), stdout=True, stdin="yes", stdinRepeat=True) # yes to accept licenses
run("avdmanager create avd -k \"{0}\" -d \"Nexus 6\" -n IceTests".format(sdk))
self.startEmulator("IceTests")
elif not self.device:
@@ -2242,7 +2256,7 @@ class AndroidProcessController(RemoteProcessController):
apk = os.path.join(current.testcase.getMapping().getPath(),
"controller/build/outputs/apk/debug/testController-debug.apk")
run("{} install -t -r {}".format(self.adb(), apk))
- run("{} shell am start -n com.zeroc.testcontroller/.ControllerActivity".format(self.adb()))
+ run("{} shell am start -n \"com.zeroc.testcontroller/.ControllerActivity\" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER".format(self.adb()))
def stopControllerApp(self, ident):
try:
@@ -3107,7 +3121,7 @@ class AndroidMapping(AndroidMappingMixin, JavaMapping): # Note: the inheritance
AndroidMappingMixin.__init__(self, JavaMapping)
def getSDKPackage(self):
- return "system-images;android-25;google_apis;x86_64"
+ return "system-images;android-27;google_apis;x86"
class AndroidCompatMapping(AndroidMappingMixin, JavaCompatMapping): # Note: the inheritance order is important