summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-10-22 21:23:48 +0000
committerMarc Laukien <marc@zeroc.com>2001-10-22 21:23:48 +0000
commita5074c07a75bc7b6debd20fbc886103831d489dd (patch)
tree2eb80e71dcc528a86d481880b6d42702fb3cbeb4 /cpp/test
parentfixes (diff)
downloadice-a5074c07a75bc7b6debd20fbc886103831d489dd.tar.bz2
ice-a5074c07a75bc7b6debd20fbc886103831d489dd.tar.xz
ice-a5074c07a75bc7b6debd20fbc886103831d489dd.zip
more objects demo stuff
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Ice/objects/AllTests.cpp29
-rw-r--r--cpp/test/Ice/objects/Client.cpp32
-rw-r--r--cpp/test/Ice/objects/TestI.cpp13
3 files changed, 74 insertions, 0 deletions
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp
index 3636834c6c7..7934e8cdc47 100644
--- a/cpp/test/Ice/objects/AllTests.cpp
+++ b/cpp/test/Ice/objects/AllTests.cpp
@@ -29,5 +29,34 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(initial == base);
cout << "ok" << endl;
+ cout << "getting first B... " << flush;
+ BPtr b1 = initial->getB1();
+ test(b1);
+ cout << "ok" << endl;
+
+ cout << "getting second B... " << flush;
+ BPtr b2 = initial->getB2();
+ test(b2);
+ cout << "ok" << endl;
+
+ cout << "getting C... " << flush;
+ CPtr c = initial->getC();
+ test(c);
+ cout << "ok" << endl;
+
+ cout << "getting D... " << flush;
+ DPtr d = initial->getD();
+ test(d);
+ cout << "ok" << endl;
+
+ cout << "checking consistency... " << flush;
+ test(b1 != b2);
+ test(b1 != c);
+ test(b1 != d);
+ test(b2 != c);
+ test(b2 != d);
+ test(c != d);
+ cout << "ok" << endl;
+
return initial;
}
diff --git a/cpp/test/Ice/objects/Client.cpp b/cpp/test/Ice/objects/Client.cpp
index c61fa56625c..d9a019848cd 100644
--- a/cpp/test/Ice/objects/Client.cpp
+++ b/cpp/test/Ice/objects/Client.cpp
@@ -14,9 +14,41 @@
using namespace std;
+class MyObjectFactory : public Ice::ObjectFactory
+{
+public:
+
+ virtual Ice::ObjectPtr create(const string& type)
+ {
+ if (type == "::B")
+ {
+ return new B;
+ }
+ else if (type == "::C")
+ {
+ return new C;
+ }
+ else if (type == "::D")
+ {
+ return new D;
+ }
+ assert(false); // Should never be reached
+ }
+
+ virtual void destroy()
+ {
+ // Nothing to do
+ }
+};
+
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
+ Ice::ObjectFactoryPtr factory = new MyObjectFactory;
+ communicator->addObjectFactory(factory, "::B");
+ communicator->addObjectFactory(factory, "::C");
+ communicator->addObjectFactory(factory, "::D");
+
InitialPrx allTests(const Ice::CommunicatorPtr&);
InitialPrx initial = allTests(communicator);
initial->shutdown();
diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp
index b4170877378..267e389be21 100644
--- a/cpp/test/Ice/objects/TestI.cpp
+++ b/cpp/test/Ice/objects/TestI.cpp
@@ -18,6 +18,19 @@ InitialI::InitialI(const Ice::ObjectAdapterPtr& adapter) :
_c(new C),
_d(new D)
{
+ _b1->a = _b2; // Cyclic reference to another B
+ _b1->b = _b1; // Self reference.
+ _b1->c = 0; // Null reference.
+
+ _b2->a = _b2; // Self reference, using base.
+ _b2->b = _b1; // Cyclic reference to another B
+ _b2->c = _c; // Cyclic reference to a C.
+
+ _c->b = _b2; // Cyclic reference to a B.
+
+ _d->a = _b1; // Reference to a B.
+ _d->b = _b2; // Reference to a B.
+ _d->c = 0; // Reference to a C.
}
void