summaryrefslogtreecommitdiff
path: root/cppe/test
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2005-08-22 06:38:54 +0000
committerMatthew Newhook <matthew@zeroc.com>2005-08-22 06:38:54 +0000
commit8878eb2d6e1da17022cd85f99e8dc216b0dd3b96 (patch)
treeddb11af48c2648fc76addb48785a2ae489bb6655 /cppe/test
parentmoving MIDP UUID generation to main srcs (diff)
downloadice-8878eb2d6e1da17022cd85f99e8dc216b0dd3b96.tar.bz2
ice-8878eb2d6e1da17022cd85f99e8dc216b0dd3b96.tar.xz
ice-8878eb2d6e1da17022cd85f99e8dc216b0dd3b96.zip
Simplify operations test.
Diffstat (limited to 'cppe/test')
-rw-r--r--cppe/test/IceE/operations/AllTests.cpp30
-rw-r--r--cppe/test/IceE/operations/Collocated.cpp5
-rw-r--r--cppe/test/IceE/operations/Server.cpp7
-rw-r--r--cppe/test/IceE/operations/TestI.cpp9
-rw-r--r--cppe/test/IceE/operations/TestI.h8
5 files changed, 46 insertions, 13 deletions
diff --git a/cppe/test/IceE/operations/AllTests.cpp b/cppe/test/IceE/operations/AllTests.cpp
index 1cc81134eaa..6ed4ba397cf 100644
--- a/cppe/test/IceE/operations/AllTests.cpp
+++ b/cppe/test/IceE/operations/AllTests.cpp
@@ -78,6 +78,36 @@ allTests(const Ice::CommunicatorPtr& communicator)
tprintf("ok\n");
+ tprintf("testing checked cast with context...");
+ ref = communicator->getProperties()->getPropertyWithDefault(
+ "Operations.ContextProxy", "context:default -p 12345 -t 10000");
+ Ice::ObjectPrx cbase = communicator->stringToProxy(ref);
+ test(cbase);
+
+ Test::TestCheckedCastPrx tccp = Test::TestCheckedCastPrx::checkedCast(cbase);
+ Ice::Context c = tccp->getContext();
+ test(c.size() == 0);
+
+ c["one"] = "hello";
+ c["two"] = "world";
+ tccp = Test::TestCheckedCastPrx::checkedCast(cbase, c);
+ Ice::Context c2 = tccp->getContext();
+ test(c == c2);
+
+ //
+ // Now with alternate API
+ //
+ tccp = checkedCast<Test::TestCheckedCastPrx>(cbase);
+ c = tccp->getContext();
+ test(c.size() == 0);
+
+ tccp = checkedCast<Test::TestCheckedCastPrx>(cbase, c);
+ c2 = tccp->getContext();
+ test(c == c2);
+
+ tprintf("ok\n");
+//XXXX:
+
tprintf("testing twoway operations... ");
void twoways(const Ice::CommunicatorPtr&, const Test::MyClassPrx&);
twoways(communicator, cl);
diff --git a/cppe/test/IceE/operations/Collocated.cpp b/cppe/test/IceE/operations/Collocated.cpp
index ea96564540a..d5ff91b6c5a 100644
--- a/cppe/test/IceE/operations/Collocated.cpp
+++ b/cppe/test/IceE/operations/Collocated.cpp
@@ -42,8 +42,9 @@ public:
setCommunicator(Ice::initializeWithProperties(argc, argv, properties));
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new MyDerivedClassI(adapter, Ice::stringToIdentity("test"));
- adapter->add(object, Ice::stringToIdentity("test"));
+ Ice::Identity id = Ice::stringToIdentity("test");
+ adapter->add(new MyDerivedClassI(adapter, id), id);
+ adapter->add(new TestCheckedCastI, Ice::stringToIdentity("context"));
adapter->activate();
Test::MyClassPrx allTests(const Ice::CommunicatorPtr&);
diff --git a/cppe/test/IceE/operations/Server.cpp b/cppe/test/IceE/operations/Server.cpp
index 6b7560e144f..b60bff92b1a 100644
--- a/cppe/test/IceE/operations/Server.cpp
+++ b/cppe/test/IceE/operations/Server.cpp
@@ -36,10 +36,13 @@ public:
setCommunicator(Ice::initializeWithProperties(argc, argv, properties));
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new MyDerivedClassI(adapter, Ice::stringToIdentity("test"));
- adapter->add(object, Ice::stringToIdentity("test"));
+ Ice::Identity id = Ice::stringToIdentity("test");
+ adapter->add(new MyDerivedClassI(adapter, id), id);
+ adapter->add(new TestCheckedCastI, Ice::stringToIdentity("context"));
adapter->activate();
+ adapter->activate();
+
#ifndef _WIN32_WCE
communicator()->waitForShutdown();
#endif
diff --git a/cppe/test/IceE/operations/TestI.cpp b/cppe/test/IceE/operations/TestI.cpp
index 9b4f661ddfb..dbd5615edf0 100644
--- a/cppe/test/IceE/operations/TestI.cpp
+++ b/cppe/test/IceE/operations/TestI.cpp
@@ -11,7 +11,7 @@
#include <TestI.h>
#include <TestCommon.h>
#include <functional>
-
+
MyDerivedClassI::MyDerivedClassI(const Ice::ObjectAdapterPtr& adapter, const Ice::Identity& identity) :
_adapter(adapter),
_identity(identity)
@@ -370,8 +370,9 @@ TestCheckedCastI::getContext(const Ice::Current& c)
return _ctx;
}
-void
-TestCheckedCastI::setContext(const Ice::Context& ctx)
+bool
+TestCheckedCastI::ice_isA(const std::string& s, const Ice::Current& current) const
{
- _ctx = ctx;
+ _ctx = current.ctx;
+ return TestCheckedCast::ice_isA(s, current);
}
diff --git a/cppe/test/IceE/operations/TestI.h b/cppe/test/IceE/operations/TestI.h
index 44a5a4d05a5..2a014968098 100644
--- a/cppe/test/IceE/operations/TestI.h
+++ b/cppe/test/IceE/operations/TestI.h
@@ -165,13 +165,11 @@ class TestCheckedCastI : public Test::TestCheckedCast
public:
virtual Ice::Context getContext(const Ice::Current&);
- void setContext(const Ice::Context& c);
-
+ virtual bool ice_isA(const std::string&, const Ice::Current&) const;
+
private:
- Ice::Context _ctx;
+ mutable Ice::Context _ctx;
};
-typedef IceUtil::Handle<TestCheckedCastI> TestCheckedCastIPtr;
-
#endif