summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2009-12-10 16:48:41 -0330
committerMatthew Newhook <matthew@zeroc.com>2009-12-10 16:48:41 -0330
commitb100f685d9c06ca4f37e8c6cef181d8b57dd953c (patch)
tree67dee355f300ee282795b19da8e04aa4206cc0c8
parentBug 4467 - Glacier2 callback demo failing (diff)
downloadice-b100f685d9c06ca4f37e8c6cef181d8b57dd953c.tar.bz2
ice-b100f685d9c06ca4f37e8c6cef181d8b57dd953c.tar.xz
ice-b100f685d9c06ca4f37e8c6cef181d8b57dd953c.zip
Squashed commit of the following:
commit ee95291dd7f78c2c1d663ea54171aa56d418471b Author: Matthew Newhook <matthew@november.matthew.zeroc.com> Date: Thu Dec 10 16:47:47 2009 -0330 align all location tests. Fix bug with AMI with java/C#.
-rw-r--r--cpp/test/Ice/location/AllTests.cpp88
-rw-r--r--cs/test/Ice/location/AllTests.cs209
-rw-r--r--java/test/Ice/location/AllTests.java233
-rw-r--r--java/test/Ice/location/Client.java21
4 files changed, 210 insertions, 341 deletions
diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp
index 7616986ebb8..a191e30e8f0 100644
--- a/cpp/test/Ice/location/AllTests.cpp
+++ b/cpp/test/Ice/location/AllTests.cpp
@@ -12,6 +12,7 @@
#include <IceUtil/IceUtil.h>
#include <TestCommon.h>
#include <Test.h>
+#include <list>
using namespace std;
using namespace Test;
@@ -27,45 +28,10 @@ public:
}
};
-class ResponseCounter : public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- ResponseCounter(int expected) : _expected(expected)
- {
- }
-
- void response()
- {
- Lock sync(*this);
- if(--_expected == 0)
- {
- notifyAll();
- }
- }
-
- void waitForAllResponses()
- {
- Lock sync(*this);
- while(_expected > 0)
- {
- wait();
- }
- }
-
- void reset(int expected)
- {
- _expected = expected;
- }
-private:
-
- int _expected;
-};
-
class AMICallback : public IceUtil::Shared
{
public:
- AMICallback(ResponseCounter& c) : _counter(c)
+ AMICallback()
{
}
@@ -77,14 +43,12 @@ public:
void
exception2(const Ice::Exception& ex)
{
- _counter.response();
test(dynamic_cast<const Ice::NotRegisteredException*>(&ex));
}
void
response1()
{
- _counter.response();
}
void
@@ -92,10 +56,6 @@ public:
{
test(false);
}
-
-private:
-
- ResponseCounter& _counter;
};
typedef IceUtil::Handle<AMICallback> AMICallbackPtr;
@@ -155,9 +115,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
cout << "testing checked cast... " << flush;
TestIntfPrx obj = TestIntfPrx::checkedCast(base);
- obj = TestIntfPrx::checkedCast(communicator->stringToProxy("test@TestAdapter"));
- obj = TestIntfPrx::checkedCast(communicator->stringToProxy("test @TestAdapter"));
- obj = TestIntfPrx::checkedCast(communicator->stringToProxy("test@ TestAdapter"));
test(obj);
TestIntfPrx obj2 = TestIntfPrx::checkedCast(base2);
test(obj2);
@@ -176,7 +133,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
manager->startServer();
try
{
- obj2 = TestIntfPrx::checkedCast(base2);
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -191,7 +147,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
manager->startServer();
try
{
- obj6 = TestIntfPrx::checkedCast(base6);
obj6->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -206,7 +161,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
manager->startServer();
try
{
- obj3 = TestIntfPrx::checkedCast(base3);
obj3->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -216,7 +170,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
}
try
{
- obj2 = TestIntfPrx::checkedCast(base2);
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -228,7 +181,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
manager->startServer();
try
{
- obj2 = TestIntfPrx::checkedCast(base2);
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -238,7 +190,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
}
try
{
- obj3 = TestIntfPrx::checkedCast(base3);
obj3->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -251,7 +202,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
try
{
- obj2 = TestIntfPrx::checkedCast(base2);
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -263,7 +213,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
manager->startServer();
try
{
- obj3 = TestIntfPrx::checkedCast(base3);
obj3->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -275,7 +224,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
manager->startServer();
try
{
- obj2 = TestIntfPrx::checkedCast(base2);
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -288,7 +236,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
try
{
- obj5 = TestIntfPrx::checkedCast(base5);
obj5->ice_ping();
}
catch(const Ice::LocalException& ex)
@@ -379,13 +326,20 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
test(++count == locator->getRequestCount());
int i;
- ResponseCounter counter(1000);
+ list<Ice::AsyncResultPtr> results;
+ AMICallbackPtr cb = new AMICallback;
for(i = 0; i < 1000; i++)
{
- AMICallbackPtr cb = new AMICallback(counter);
- hello->begin_sayHello(newCallback_Hello_sayHello(cb, &AMICallback::response1, &AMICallback::exception1));
+ Ice::AsyncResultPtr result = hello->begin_sayHello(
+ newCallback_Hello_sayHello(cb, &AMICallback::response1, &AMICallback::exception1));
+ results.push_back(result);
+ }
+ while(!results.empty())
+ {
+ Ice::AsyncResultPtr result = results.front();
+ results.pop_front();
+ result->waitForCompleted();
}
- counter.waitForAllResponses();
test(locator->getRequestCount() > count && locator->getRequestCount() < count + 999);
if(locator->getRequestCount() > count + 800)
{
@@ -393,13 +347,18 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
}
count = locator->getRequestCount();
hello = hello->ice_adapterId("unknown");
- counter.reset(1000);
for(i = 0; i < 1000; i++)
{
- AMICallbackPtr cb = new AMICallback(counter);
- hello->begin_sayHello(newCallback_Hello_sayHello(cb, &AMICallback::response2, &AMICallback::exception2));
+ Ice::AsyncResultPtr result = hello->begin_sayHello(
+ newCallback_Hello_sayHello(cb, &AMICallback::response2, &AMICallback::exception2));
+ results.push_back(result);
+ }
+ while(!results.empty())
+ {
+ Ice::AsyncResultPtr result = results.front();
+ results.pop_front();
+ result->waitForCompleted();
}
- counter.waitForAllResponses();
// Take into account the retries.
test(locator->getRequestCount() > count && locator->getRequestCount() < count + 1999);
if(locator->getRequestCount() > count + 800)
@@ -409,7 +368,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
cout << "ok" << endl;
cout << "testing adapter locator cache... " << flush;
-
try
{
communicator->stringToProxy("test@TestAdapter3")->ice_ping();
@@ -569,7 +527,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1200));
- // The following requets should trigger the background updates but still use the cached endpoints
+ // The following request should trigger the background updates but still use the cached endpoints
// and therefore succeed.
ic->stringToProxy("test@TestAdapter5")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
ic->stringToProxy("test3")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
diff --git a/cs/test/Ice/location/AllTests.cs b/cs/test/Ice/location/AllTests.cs
index db55c4ad1f8..c3fc367d74c 100644
--- a/cs/test/Ice/location/AllTests.cs
+++ b/cs/test/Ice/location/AllTests.cs
@@ -9,6 +9,7 @@
using System;
using Test;
+using System.Collections.Generic;
public class AllTests
{
@@ -72,11 +73,6 @@ public class AllTests
test(@base.ice_getRouter() == null);
Console.Out.WriteLine("ok");
- //
- // Start a server, get the port of the adapter it's listening on,
- // and add it to the configuration so that the client can locate
- // the TestAdapter adapter.
- //
Console.Out.Write("starting server... ");
Console.Out.Flush();
manager.startServer();
@@ -132,7 +128,6 @@ public class AllTests
manager.startServer();
try
{
- obj3 = TestIntfPrxHelper.checkedCast(base3);
obj3.ice_ping();
}
catch(Ice.LocalException)
@@ -141,7 +136,6 @@ public class AllTests
}
try
{
- obj2 = TestIntfPrxHelper.checkedCast(base2);
obj2.ice_ping();
}
catch(Ice.LocalException)
@@ -152,7 +146,6 @@ public class AllTests
manager.startServer();
try
{
- obj2 = TestIntfPrxHelper.checkedCast(base2);
obj2.ice_ping();
}
catch(Ice.LocalException)
@@ -161,7 +154,6 @@ public class AllTests
}
try
{
- obj3 = TestIntfPrxHelper.checkedCast(base3);
obj3.ice_ping();
}
catch(Ice.LocalException)
@@ -172,7 +164,6 @@ public class AllTests
manager.startServer();
try
{
- obj2 = TestIntfPrxHelper.checkedCast(base2);
obj2.ice_ping();
}
catch(Ice.LocalException)
@@ -183,7 +174,6 @@ public class AllTests
manager.startServer();
try
{
- obj3 = TestIntfPrxHelper.checkedCast(base2);
obj3.ice_ping();
}
catch(Ice.LocalException)
@@ -274,37 +264,38 @@ public class AllTests
Console.Out.Flush();
obj = TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter"));
HelloPrx hello = obj.getHello();
- hello.sayHello();
test(hello.ice_getAdapterId().Equals("TestAdapter"));
- hello = obj.getReplicatedHello();
hello.sayHello();
+ hello = obj.getReplicatedHello();
test(hello.ice_getAdapterId().Equals("ReplicatedAdapter"));
- Console.Out.WriteLine("ok");
-
- Console.Out.Write("testing proxy from server after shutdown... ");
- Console.Out.Flush();
- obj.shutdown();
- manager.startServer();
hello.sayHello();
Console.Out.WriteLine("ok");
-
+
Console.Out.Write("testing locator request queuing... ");
Console.Out.Flush();
hello = (HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false);
count = locator.getRequestCount();
hello.ice_ping();
test(++count == locator.getRequestCount());
+ List<Ice.AsyncResult<Test.Callback_Hello_sayHello> > results =
+ new List<Ice.AsyncResult<Test.Callback_Hello_sayHello> >();
for(int i = 0; i < 1000; i++)
{
- hello.begin_sayHello().whenCompleted(delegate()
- {
- },
- delegate(Ice.Exception ex)
- {
- test(false);
- });
+ Ice.AsyncResult<Test.Callback_Hello_sayHello> result = hello.begin_sayHello().
+ whenCompleted(delegate()
+ {
+ },
+ delegate(Ice.Exception ex)
+ {
+ test(false);
+ });
+ results.Add(result);
}
- hello.ice_ping();
+ foreach(Ice.AsyncResult<Test.Callback_Hello_sayHello> result in results)
+ {
+ result.waitForCompleted();
+ }
+ results.Clear();
test(locator.getRequestCount() > count && locator.getRequestCount() < count + 999);
if(locator.getRequestCount() > count + 800)
{
@@ -314,23 +305,23 @@ public class AllTests
hello = (HelloPrx)hello.ice_adapterId("unknown");
for(int i = 0; i < 1000; i++)
{
- hello.begin_sayHello().whenCompleted(delegate()
- {
- test(false);
- },
- delegate(Ice.Exception ex)
- {
- test(ex is Ice.NotRegisteredException);
- });
+ Ice.AsyncResult<Test.Callback_Hello_sayHello> result = hello.begin_sayHello().
+ whenCompleted(delegate()
+ {
+ test(false);
+ },
+ delegate(Ice.Exception ex)
+ {
+ test(ex is Ice.NotRegisteredException);
+ });
+ results.Add(result);
}
- try
- {
- hello.ice_ping();
- test(false);
- }
- catch(Ice.NotRegisteredException)
+ foreach(Ice.AsyncResult<Test.Callback_Hello_sayHello> result in results)
{
+ result.waitForCompleted();
}
+ results.Clear();
+ // XXX:
// Take into account the retries.
test(locator.getRequestCount() > count && locator.getRequestCount() < count + 1999);
if(locator.getRequestCount() > count + 800)
@@ -351,29 +342,11 @@ public class AllTests
test(ex.kindOfObject == "object adapter");
test(ex.id.Equals("TestAdapter3"));
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
try
{
communicator.stringToProxy("test@TestAdapter3").ice_ping();
- try
- {
- registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp"));
communicator.stringToProxy("test@TestAdapter3").ice_ping();
}
catch(Ice.LocalException)
@@ -397,16 +370,7 @@ public class AllTests
catch(Ice.LocalException)
{
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
try
{
communicator.stringToProxy("test@TestAdapter3").ice_ping();
@@ -431,17 +395,7 @@ public class AllTests
test(ex.id.Equals("TestUnknown"));
}
registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update
- try
- {
- registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
-
+ registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
try
{
communicator.stringToProxy("test3").ice_ping();
@@ -450,16 +404,7 @@ public class AllTests
catch(Ice.LocalException)
{
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter"));
try
{
communicator.stringToProxy("test3").ice_ping();
@@ -469,16 +414,7 @@ public class AllTests
test(false);
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
try
{
communicator.stringToProxy("test3").ice_ping();
@@ -541,41 +477,24 @@ public class AllTests
initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1");
Ice.Communicator ic = Ice.Util.initialize(initData);
- try
- {
- registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter"));
- registry.addObject(communicator.stringToProxy("test3@TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter"));
+ registry.addObject(communicator.stringToProxy("test3@TestAdapter"));
count = locator.getRequestCount();
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
count += 3;
test(count == locator.getRequestCount());
- try
- {
- registry.setAdapterDirectProxy("TestAdapter5", null);
- }
- catch(Ice.AdapterAlreadyActiveException)
- {
- }
- catch(Ice.AdapterNotFoundException)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter5", null);
registry.addObject(communicator.stringToProxy("test3:tcp"));
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
test(count == locator.getRequestCount());
System.Threading.Thread.Sleep(new System.TimeSpan(10 * 1200 * 1000));
- // The following requets should trigger the background updates but still use the cached endpoints
- // and therefore succeed.
+ // The following request should trigger the background
+ // updates but still use the cached endpoints and
+ // therefore succeed.
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
@@ -607,6 +526,14 @@ public class AllTests
}
Console.Out.WriteLine("ok");
+ Console.Out.Write("testing proxy from server after shutdown... ");
+ Console.Out.Flush();
+ hello = obj.getReplicatedHello();
+ obj.shutdown();
+ manager.startServer();
+ hello.sayHello();
+ Console.Out.WriteLine("ok");
+
Console.Out.Write("testing object migration... ");
Console.Out.Flush();
hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello"));
@@ -618,9 +545,13 @@ public class AllTests
hello.sayHello();
Console.Out.WriteLine("ok");
- Console.Out.Write("testing whether server is gone... ");
+ Console.Out.Write("shutdown server... ");
Console.Out.Flush();
obj.shutdown();
+ Console.Out.WriteLine("ok");
+
+ Console.Out.Write("testing whether server is gone... ");
+ Console.Out.Flush();
try
{
obj2.ice_ping();
@@ -628,12 +559,32 @@ public class AllTests
}
catch(Ice.LocalException)
{
- Console.Out.WriteLine("ok");
}
+ try
+ {
+ obj3.ice_ping();
+ test(false);
+ }
+ catch(Ice.LocalException)
+ {
+ }
+ try
+ {
+ obj5.ice_ping();
+ test(false);
+ }
+ catch(Ice.LocalException)
+ {
+ }
+ Console.Out.WriteLine("ok");
Console.Out.Write("testing indirect proxies to collocated objects... ");
Console.Out.Flush();
+ //
+ // Set up test for calling a collocated object through an
+ // indirect, adapterless reference.
+ //
Ice.Properties properties = communicator.getProperties();
properties.setProperty("Ice.PrintAdapterReady", "0");
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");
@@ -653,9 +604,9 @@ public class AllTests
}
catch(Ice.CollocationOptimizationException)
{
- Console.Out.WriteLine("ok");
}
adapter.deactivate();
+ Console.Out.WriteLine("ok");
Console.Out.Write("shutdown server manager... ");
Console.Out.Flush();
diff --git a/java/test/Ice/location/AllTests.java b/java/test/Ice/location/AllTests.java
index f119333a501..5c411549b11 100644
--- a/java/test/Ice/location/AllTests.java
+++ b/java/test/Ice/location/AllTests.java
@@ -36,6 +36,7 @@ public class AllTests
public static void
allTests(Ice.Communicator communicator, PrintWriter out)
+ throws Ice.AdapterAlreadyActiveException, Ice.AdapterNotFoundException, InterruptedException
{
ServerManagerPrx manager = ServerManagerPrxHelper.checkedCast(
communicator.stringToProxy("ServerManager :default -p 12010"));
@@ -46,9 +47,9 @@ public class AllTests
TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry());
test(registry != null);
+
out.print("testing stringToProxy... ");
out.flush();
-
Ice.ObjectPrx base = communicator.stringToProxy("test @ TestAdapter");
Ice.ObjectPrx base2 = communicator.stringToProxy("test @ TestAdapter");
Ice.ObjectPrx base3 = communicator.stringToProxy("test");
@@ -89,11 +90,6 @@ public class AllTests
test(base.ice_getRouter() == null);
out.println("ok");
- //
- // Start a server, get the port of the adapter it's listening on,
- // and add it to the configuration so that the client can locate
- // the TestAdapter adapter.
- //
out.print("starting server... ");
out.flush();
manager.startServer();
@@ -136,7 +132,6 @@ public class AllTests
manager.startServer();
try
{
- obj6 = TestIntfPrxHelper.checkedCast(base6);
obj6.ice_ping();
}
catch(Ice.LocalException ex)
@@ -152,7 +147,6 @@ public class AllTests
manager.startServer();
try
{
- obj3 = TestIntfPrxHelper.checkedCast(base3);
obj3.ice_ping();
}
catch(Ice.LocalException ex)
@@ -162,7 +156,6 @@ public class AllTests
}
try
{
- obj2 = TestIntfPrxHelper.checkedCast(base2);
obj2.ice_ping();
}
catch(Ice.LocalException ex)
@@ -174,7 +167,6 @@ public class AllTests
manager.startServer();
try
{
- obj2 = TestIntfPrxHelper.checkedCast(base2);
obj2.ice_ping();
}
catch(Ice.LocalException ex)
@@ -184,7 +176,6 @@ public class AllTests
}
try
{
- obj3 = TestIntfPrxHelper.checkedCast(base3);
obj3.ice_ping();
}
catch(Ice.LocalException ex)
@@ -194,9 +185,9 @@ public class AllTests
}
obj.shutdown();
manager.startServer();
+
try
{
- obj2 = TestIntfPrxHelper.checkedCast(base2);
obj2.ice_ping();
}
catch(Ice.LocalException ex)
@@ -208,7 +199,6 @@ public class AllTests
manager.startServer();
try
{
- obj3 = TestIntfPrxHelper.checkedCast(base2);
obj3.ice_ping();
}
catch(Ice.LocalException ex)
@@ -220,15 +210,25 @@ public class AllTests
manager.startServer();
try
{
- obj5 = TestIntfPrxHelper.checkedCast(base5);
- obj5.ice_ping();
+ obj2.ice_ping();
}
catch(Ice.LocalException ex)
{
ex.printStackTrace();
test(false);
}
+ obj.shutdown();
+ manager.startServer();
+ try
+ {
+ obj5.ice_ping();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ test(false);
+ }
out.println("ok");
out.print("testing proxy with unknown identity... ");
@@ -271,13 +271,7 @@ public class AllTests
test(++count == locator.getRequestCount());
communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
test(count == locator.getRequestCount());
- try
- {
- Thread.sleep(1200);
- }
- catch(InterruptedException ex)
- {
- }
+ Thread.sleep(1200);
communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
test(++count == locator.getRequestCount());
@@ -286,13 +280,7 @@ public class AllTests
test(count == locator.getRequestCount());
communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
test(count == locator.getRequestCount());
- try
- {
- Thread.sleep(1200);
- }
- catch(InterruptedException ex)
- {
- }
+ Thread.sleep(1200);
communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
count += 2;
test(count == locator.getRequestCount());
@@ -320,12 +308,20 @@ public class AllTests
hello.sayHello();
out.println("ok");
+ out.print("testing proxy from server after shutdown... ");
+ out.flush();
+ obj.shutdown();
+ manager.startServer();
+ hello.sayHello();
+ out.println("ok");
+
out.print("testing locator request queuing... ");
out.flush();
hello = (HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false);
count = locator.getRequestCount();
hello.ice_ping();
test(++count == locator.getRequestCount());
+ java.util.List<Ice.AsyncResult> results = new java.util.LinkedList<Ice.AsyncResult>();
for(int i = 0; i < 1000; i++)
{
class AMICallback extends Callback_Hello_sayHello
@@ -344,9 +340,14 @@ public class AllTests
{
}
};
- hello.begin_sayHello(new AMICallback());
+ Ice.AsyncResult result = hello.begin_sayHello(new AMICallback());
+ results.add(result);
+ }
+ while(!results.isEmpty())
+ {
+ Ice.AsyncResult result = results.remove(0);
+ result.waitForCompleted();
}
- hello.ice_ping();
test(locator.getRequestCount() > count && locator.getRequestCount() < count + 999);
if(locator.getRequestCount() > count + 800)
{
@@ -362,6 +363,11 @@ public class AllTests
public void
exception(Ice.LocalException ex)
{
+ if(ex instanceof Ice.CommunicatorDestroyedException)
+ {
+ ex.printStackTrace();
+ assert false;
+ }
test(ex instanceof Ice.NotRegisteredException);
}
@@ -372,17 +378,15 @@ public class AllTests
test(false);
}
};
- hello.begin_sayHello(new AMICallback());
- }
- try
- {
- hello.ice_ping();
- test(false);
+ Ice.AsyncResult result = hello.begin_sayHello(new AMICallback());
+ results.add(result);
}
- catch(Ice.NotRegisteredException ex)
+ while(!results.isEmpty())
{
+ Ice.AsyncResult result = results.remove(0);
+ result.waitForCompleted();
}
- // We need to take into account the retries.
+ // Take into account the retries.
test(locator.getRequestCount() > count && locator.getRequestCount() < count + 1999);
if(locator.getRequestCount() > count + 800)
{
@@ -402,29 +406,11 @@ public class AllTests
test(ex.kindOfObject == "object adapter");
test(ex.id.equals("TestAdapter3"));
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
try
{
communicator.stringToProxy("test@TestAdapter3").ice_ping();
- try
- {
- registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp"));
communicator.stringToProxy("test@TestAdapter3").ice_ping();
}
catch(Ice.LocalException ex)
@@ -449,16 +435,7 @@ public class AllTests
catch(Ice.LocalException ex)
{
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
try
{
communicator.stringToProxy("test@TestAdapter3").ice_ping();
@@ -472,6 +449,7 @@ public class AllTests
out.print("testing well-known object locator cache... ");
out.flush();
+
registry.addObject(communicator.stringToProxy("test3@TestUnknown"));
try
{
@@ -484,16 +462,7 @@ public class AllTests
test(ex.id.equals("TestUnknown"));
}
registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update
- try
- {
- registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
try
{
@@ -503,16 +472,7 @@ public class AllTests
catch(Ice.LocalException ex)
{
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter"));
try
{
communicator.stringToProxy("test3").ice_ping();
@@ -523,16 +483,7 @@ public class AllTests
test(false);
}
- try
- {
- registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp"));
try
{
communicator.stringToProxy("test3").ice_ping();
@@ -596,46 +547,22 @@ public class AllTests
initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1");
Ice.Communicator ic = Ice.Util.initialize(initData);
- try
- {
- registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter"));
- registry.addObject(communicator.stringToProxy("test3@TestAdapter"));
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter"));
+ registry.addObject(communicator.stringToProxy("test3@TestAdapter"));
count = locator.getRequestCount();
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
count += 3;
test(count == locator.getRequestCount());
- try
- {
- registry.setAdapterDirectProxy("TestAdapter5", null);
- }
- catch(Ice.AdapterAlreadyActiveException ex)
- {
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- }
+ registry.setAdapterDirectProxy("TestAdapter5", null);
registry.addObject(communicator.stringToProxy("test3:tcp"));
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
test(count == locator.getRequestCount());
- try
- {
- Thread.sleep(1200);
- }
- catch(InterruptedException ex)
- {
- }
+ Thread.sleep(1200);
- // The following requets should trigger the background updates but still use the cached endpoints
+ // The following request should trigger the background updates but still use the cached endpoints
// and therefore succeed.
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
@@ -645,13 +572,7 @@ public class AllTests
while(true)
{
ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
- try
- {
- Thread.sleep(10);
- }
- catch(InterruptedException ex)
- {
- }
+ Thread.sleep(10);
}
}
catch(Ice.LocalException ex)
@@ -663,13 +584,7 @@ public class AllTests
while(true)
{
ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
- try
- {
- Thread.sleep(10);
- }
- catch(InterruptedException ex)
- {
- }
+ Thread.sleep(10);
}
}
catch(Ice.LocalException ex)
@@ -699,9 +614,13 @@ public class AllTests
hello.sayHello();
out.println("ok");
- out.print("testing whether server is gone... ");
+ out.print("shutdown server... ");
out.flush();
obj.shutdown();
+ out.println("ok");
+
+ out.print("testing whether server is gone... ");
+ out.flush();
try
{
obj2.ice_ping();
@@ -709,10 +628,30 @@ public class AllTests
}
catch(Ice.LocalException ex)
{
- out.println("ok");
}
+ try
+ {
+ obj3.ice_ping();
+ test(false);
+ }
+ catch(Ice.LocalException ex)
+ {
+ }
+ try
+ {
+ obj5.ice_ping();
+ test(false);
+ }
+ catch(Ice.LocalException ex)
+ {
+ }
+ out.println("ok");
out.print("testing indirect proxies to collocated objects... ");
+ //
+ // Set up test for calling a collocated object through an
+ // indirect, adapterless reference.
+ //
Ice.Properties properties = communicator.getProperties();
properties.setProperty("Ice.PrintAdapterReady", "0");
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");
@@ -725,6 +664,8 @@ public class AllTests
try
{
+ // Note the quotes are necessary here due to ":" in the
+ // java generated UUID.
HelloPrx helloPrx = HelloPrxHelper.checkedCast(
communicator.stringToProxy("\"" + communicator.identityToString(id) + "\""));
Ice.Connection connection = helloPrx.ice_getConnection();
@@ -732,9 +673,9 @@ public class AllTests
}
catch(Ice.CollocationOptimizationException ex)
{
- out.println("ok");
}
- adapter.destroy();
+ adapter.deactivate();
+ out.println("ok");
out.print("shutdown server manager... ");
out.flush();
diff --git a/java/test/Ice/location/Client.java b/java/test/Ice/location/Client.java
index 8f32d31cbd1..619cd5c3870 100644
--- a/java/test/Ice/location/Client.java
+++ b/java/test/Ice/location/Client.java
@@ -14,7 +14,26 @@ public class Client extends test.Util.Application
public int run(String[] args)
{
Ice.Communicator communicator = communicator();
- AllTests.allTests(communicator, getWriter());
+ try
+ {
+ AllTests.allTests(communicator, getWriter());
+ }
+ catch(Ice.AdapterAlreadyActiveException ex)
+ {
+ ex.printStackTrace();
+ throw new RuntimeException();
+ }
+ catch(Ice.AdapterNotFoundException ex)
+ {
+ ex.printStackTrace();
+ throw new RuntimeException();
+ }
+ catch(InterruptedException ex)
+ {
+ ex.printStackTrace();
+ throw new RuntimeException();
+ }
+
return 0;
}