summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-02-24 01:17:01 +0000
committerMark Spruiell <mes@zeroc.com>2004-02-24 01:17:01 +0000
commit77a6cfbb8aad38be3d323f628681b0359f38f38e (patch)
treed332cb72abaaf71ed5580181494b0dd19ad36e59 /cpp/test
parentcerts (diff)
downloadice-77a6cfbb8aad38be3d323f628681b0359f38f38e.tar.bz2
ice-77a6cfbb8aad38be3d323f628681b0359f38f38e.tar.xz
ice-77a6cfbb8aad38be3d323f628681b0359f38f38e.zip
adding ice_preMarshal/ice_postUnmarshal, and tests in Ice/objects
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Ice/objects/AllTests.cpp20
-rw-r--r--cpp/test/Ice/objects/Client.cpp8
-rw-r--r--cpp/test/Ice/objects/Makefile7
-rw-r--r--cpp/test/Ice/objects/Test.ice9
-rw-r--r--cpp/test/Ice/objects/TestI.cpp94
-rw-r--r--cpp/test/Ice/objects/TestI.h48
6 files changed, 174 insertions, 12 deletions
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp
index 53ab064d30e..4e6b4cb2ebc 100644
--- a/cpp/test/Ice/objects/AllTests.cpp
+++ b/cpp/test/Ice/objects/AllTests.cpp
@@ -67,6 +67,15 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
test(BPtr::dynamicCast(b1->theA)->theB == b1);
test(CPtr::dynamicCast(BPtr::dynamicCast(b1->theA)->theC));
test(CPtr::dynamicCast(BPtr::dynamicCast(b1->theA)->theC)->theB == b1->theA);
+ if(!collocated)
+ {
+ test(b1->preMarshalInvoked);
+ test(b1->postUnmarshalInvoked());
+ test(b1->theA->preMarshalInvoked);
+ test(b1->theA->postUnmarshalInvoked());
+ test(BPtr::dynamicCast(b1->theA)->theC->preMarshalInvoked);
+ test(BPtr::dynamicCast(b1->theA)->theC->postUnmarshalInvoked());
+ }
// More tests possible for b2 and d, but I think this is already sufficient.
test(b2->theA == b2);
test(d->theC == 0);
@@ -127,6 +136,17 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
test(d->theA == b1);
test(d->theB == b2);
test(d->theC == 0);
+ if(!collocated)
+ {
+ test(d->preMarshalInvoked);
+ test(d->postUnmarshalInvoked());
+ test(d->theA->preMarshalInvoked);
+ test(d->theA->postUnmarshalInvoked());
+ test(d->theB->preMarshalInvoked);
+ test(d->theB->postUnmarshalInvoked());
+ test(d->theB->theC->preMarshalInvoked);
+ test(d->theB->theC->postUnmarshalInvoked());
+ }
cout << "ok" << endl;
//
diff --git a/cpp/test/Ice/objects/Client.cpp b/cpp/test/Ice/objects/Client.cpp
index 9a6a80c1873..2eea6e63466 100644
--- a/cpp/test/Ice/objects/Client.cpp
+++ b/cpp/test/Ice/objects/Client.cpp
@@ -14,7 +14,7 @@
#include <Ice/Ice.h>
#include <TestCommon.h>
-#include <Test.h>
+#include <TestI.h>
using namespace std;
@@ -26,15 +26,15 @@ public:
{
if(type == "::B")
{
- return new B;
+ return new BI;
}
else if(type == "::C")
{
- return new C;
+ return new CI;
}
else if(type == "::D")
{
- return new D;
+ return new DI;
}
assert(false); // Should never be reached
return 0;
diff --git a/cpp/test/Ice/objects/Makefile b/cpp/test/Ice/objects/Makefile
index f3502da1d93..9f7c5f346b7 100644
--- a/cpp/test/Ice/objects/Makefile
+++ b/cpp/test/Ice/objects/Makefile
@@ -21,15 +21,14 @@ COLLOCATED = collocated
TARGETS = $(CLIENT) $(SERVER) $(COLLOCATED)
OBJS = Test.o \
+ TestI.o
COBJS = Client.o \
AllTests.o
-SOBJS = TestI.o \
- Server.o
+SOBJS = Server.o
-COLOBJS = TestI.o \
- Collocated.o \
+COLOBJS = Collocated.o \
AllTests.o
SRCS = $(OBJS:.o=.cpp) \
diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice
index e1d696af92c..c6c94c810ee 100644
--- a/cpp/test/Ice/objects/Test.ice
+++ b/cpp/test/Ice/objects/Test.ice
@@ -22,6 +22,9 @@ class A
{
B theB;
C theC;
+
+ bool preMarshalInvoked;
+ bool postUnmarshalInvoked();
};
class B extends A
@@ -32,6 +35,9 @@ class B extends A
class C
{
B theB;
+
+ bool preMarshalInvoked;
+ bool postUnmarshalInvoked();
};
class D
@@ -39,6 +45,9 @@ class D
A theA;
B theB;
C theC;
+
+ bool preMarshalInvoked;
+ bool postUnmarshalInvoked();
};
class Initial
diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp
index ef961501878..5dd46076762 100644
--- a/cpp/test/Ice/objects/TestI.cpp
+++ b/cpp/test/Ice/objects/TestI.cpp
@@ -15,12 +15,81 @@
#include <Ice/Ice.h>
#include <TestI.h>
+BI::BI() :
+ _postUnmarshalInvoked(false)
+{
+}
+
+bool
+BI::postUnmarshalInvoked(const Ice::Current&)
+{
+ return _postUnmarshalInvoked;
+}
+
+void
+BI::ice_preMarshal()
+{
+ preMarshalInvoked = true;
+}
+
+void
+BI::ice_postUnmarshal()
+{
+ _postUnmarshalInvoked = true;
+}
+
+CI::CI() :
+ _postUnmarshalInvoked(false)
+{
+}
+
+bool
+CI::postUnmarshalInvoked(const Ice::Current&)
+{
+ return _postUnmarshalInvoked;
+}
+
+void
+CI::ice_preMarshal()
+{
+ preMarshalInvoked = true;
+}
+
+void
+CI::ice_postUnmarshal()
+{
+ _postUnmarshalInvoked = true;
+}
+
+DI::DI() :
+ _postUnmarshalInvoked(false)
+{
+}
+
+bool
+DI::postUnmarshalInvoked(const Ice::Current&)
+{
+ return _postUnmarshalInvoked;
+}
+
+void
+DI::ice_preMarshal()
+{
+ preMarshalInvoked = true;
+}
+
+void
+DI::ice_postUnmarshal()
+{
+ _postUnmarshalInvoked = true;
+}
+
InitialI::InitialI(const Ice::ObjectAdapterPtr& adapter) :
_adapter(adapter),
- _b1(new B),
- _b2(new B),
- _c(new C),
- _d(new D)
+ _b1(new BI),
+ _b2(new BI),
+ _c(new CI),
+ _d(new DI)
{
_b1->theA = _b2; // Cyclic reference to another B
_b1->theB = _b1; // Self reference.
@@ -64,30 +133,47 @@ InitialI::shutdown(const Ice::Current&)
BPtr
InitialI::getB1(const Ice::Current&)
{
+ _b1->preMarshalInvoked = false;
+ _b2->preMarshalInvoked = false;
+ _c->preMarshalInvoked = false;
return _b1;
}
BPtr
InitialI::getB2(const Ice::Current&)
{
+ _b1->preMarshalInvoked = false;
+ _b2->preMarshalInvoked = false;
+ _c->preMarshalInvoked = false;
return _b2;
}
CPtr
InitialI::getC(const Ice::Current&)
{
+ _b1->preMarshalInvoked = false;
+ _b2->preMarshalInvoked = false;
+ _c->preMarshalInvoked = false;
return _c;
}
DPtr
InitialI::getD(const Ice::Current&)
{
+ _b1->preMarshalInvoked = false;
+ _b2->preMarshalInvoked = false;
+ _c->preMarshalInvoked = false;
+ _d->preMarshalInvoked = false;
return _d;
}
void
InitialI::getAll(BPtr& b1, BPtr& b2, CPtr& c, DPtr& d, const Ice::Current&)
{
+ _b1->preMarshalInvoked = false;
+ _b2->preMarshalInvoked = false;
+ _c->preMarshalInvoked = false;
+ _d->preMarshalInvoked = false;
b1 = _b1;
b2 = _b2;
c = _c;
diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h
index f21e677677f..b03ff8d43b3 100644
--- a/cpp/test/Ice/objects/TestI.h
+++ b/cpp/test/Ice/objects/TestI.h
@@ -17,6 +17,54 @@
#include <Test.h>
+class BI : public B
+{
+public:
+
+ BI();
+
+ virtual bool postUnmarshalInvoked(const Ice::Current&);
+
+ virtual void ice_preMarshal();
+ virtual void ice_postUnmarshal();
+
+private:
+
+ bool _postUnmarshalInvoked;
+};
+
+class CI : public C
+{
+public:
+
+ CI();
+
+ virtual bool postUnmarshalInvoked(const Ice::Current&);
+
+ virtual void ice_preMarshal();
+ virtual void ice_postUnmarshal();
+
+private:
+
+ bool _postUnmarshalInvoked;
+};
+
+class DI : public D
+{
+public:
+
+ DI();
+
+ virtual bool postUnmarshalInvoked(const Ice::Current&);
+
+ virtual void ice_preMarshal();
+ virtual void ice_postUnmarshal();
+
+private:
+
+ bool _postUnmarshalInvoked;
+};
+
class InitialI : public Initial
{
public: