ICE 3.4.2
[php5-ice-freebsdport.git] / cpp / test / Ice / adapterDeactivation / AllTests.cpp
blob3532bf2ad36bd5c3f18a794047cf91aa58291019
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 #include <Ice/Ice.h>
11 #include <TestCommon.h>
12 #include <Test.h>
14 using namespace std;
15 using namespace Ice;
16 using namespace Test;
18 TestIntfPrx
19 allTests(const CommunicatorPtr& communicator)
21 cout << "testing stringToProxy... " << flush;
22 ObjectPrx base = communicator->stringToProxy("test:default -p 12010");
23 test(base);
24 cout << "ok" << endl;
26 cout << "testing checked cast... " << flush;
27 TestIntfPrx obj = TestIntfPrx::checkedCast(base);
28 test(obj);
29 test(obj == base);
30 cout << "ok" << endl;
33 cout << "creating/destroying/recreating object adapter... " << flush;
34 ObjectAdapterPtr adapter =
35 communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
36 try
38 communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
39 test(false);
41 catch(const AlreadyRegisteredException&)
44 adapter->destroy();
47 // Use a different port than the first adapter to avoid an "address already in use" error.
49 adapter = communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
50 adapter->destroy();
51 cout << "ok" << endl;
54 cout << "creating/activating/deactivating object adapter in one operation... " << flush;
55 obj->transient();
56 cout << "ok" << endl;
58 cout << "deactivating object adapter in the server... " << flush;
59 obj->deactivate();
60 cout << "ok" << endl;
62 cout << "testing whether server is gone... " << flush;
63 try
65 obj->ice_ping();
66 test(false);
68 catch(const LocalException&)
70 cout << "ok" << endl;
73 return obj;