[hydra-commits] kpfleming: branch techdemo/kpfleming/slicing r572 - /techdemo/team/kpfleming/...
SVN commits to the Hydra project
hydra-commits at lists.digium.com
Fri Apr 9 16:05:42 CDT 2010
Author: kpfleming
Date: Fri Apr 9 16:05:42 2010
New Revision: 572
URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=572
Log:
initial attempt at extending unit tests to test exception slicing going through a server
Added:
techdemo/team/kpfleming/slicing/exceptions/ClientPrivate.ice
- copied, changed from r569, techdemo/team/kpfleming/slicing/objects/ClientPrivate.ice
Modified:
techdemo/team/kpfleming/slicing/exceptions/AllTests.cpp
techdemo/team/kpfleming/slicing/exceptions/CMakeLists.txt
techdemo/team/kpfleming/slicing/exceptions/Server.cpp
techdemo/team/kpfleming/slicing/exceptions/Test.ice
techdemo/team/kpfleming/slicing/exceptions/TestI.cpp
techdemo/team/kpfleming/slicing/exceptions/TestI.h
Modified: techdemo/team/kpfleming/slicing/exceptions/AllTests.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/AllTests.cpp?view=diff&rev=572&r1=571&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/AllTests.cpp (original)
+++ techdemo/team/kpfleming/slicing/exceptions/AllTests.cpp Fri Apr 9 16:05:42 2010
@@ -10,6 +10,7 @@
#include <Ice/Ice.h>
#include <TestCommon.h>
#include <Test.h>
+#include <ClientPrivate.h>
using namespace std;
using namespace Test;
@@ -325,11 +326,44 @@
typedef IceUtil::Handle<Callback> CallbackPtr;
+class ClientI : virtual public Test::ClientIntf
+{
+public:
+ virtual void baseAsBase(const Ice::Current&)
+ {
+ Base ex;
+ ex.b = "Base";
+ throw ex;
+ }
+
+ virtual void unknownDerivedAsBase(const Ice::Current&)
+ {
+ ClientUnknownDerived ex;
+ ex.ud = "UnknownDerived";
+ ex.b = "Base";
+ throw ex;
+ }
+
+ virtual void unsliceableDerivedAsBase(const Ice::Current&)
+ {
+ ClientUnsliceableDerived ex;
+ ex.ud = "UnsliceableDerived";
+ ex.b = "Base";
+ throw ex;
+ }
+};
+
TestIntfPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
+ Ice::PropertiesPtr properties(communicator->getProperties());
+ properties->setProperty("Ice.Warn.Dispatch", "0");
+ properties->setProperty("ClientAdapter.Endpoints", "default -p 12020 -t 2000");
Ice::ObjectPrx obj = communicator->stringToProxy("Test:default -p 12010");
TestIntfPrx test = TestIntfPrx::checkedCast(obj);
+ Ice::ObjectAdapterPtr adapter(communicator->createObjectAdapter("ClientAdapter"));
+ ClientIntfPrx client = ClientIntfPrx::uncheckedCast(adapter->addWithUUID(new ClientI()));
+ adapter->activate();
cout << "base... " << flush;
{
@@ -369,7 +403,8 @@
catch(const Base& b)
{
test(b.b == "UnknownDerived.b");
- test(b.ice_name() =="Test::Base");
+ cout << "ice_name is " << b.ice_name() << endl;
+ test(b.ice_name() == "Test::Base");
}
catch(...)
{
@@ -718,5 +753,120 @@
}
cout << "ok" << endl;
+ cout << "base pass through server... " << flush;
+ {
+ try
+ {
+ test->clientBaseAsBasePass(client);
+ test(false);
+ }
+ catch(const Base& b)
+ {
+ test(b.b == "Base");
+ test(b.ice_name() =="Test::Base");
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ cout << "ok" << endl;
+
+ cout << "base rethrown by server... " << flush;
+ {
+ try
+ {
+ test->clientBaseAsBaseRethrow(client);
+ test(false);
+ }
+ catch(const Base& b)
+ {
+ test(b.b == "Base");
+ test(b.ice_name() =="Test::Base");
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ cout << "ok" << endl;
+
+ cout << "unknown derived pass through server... " << flush;
+ {
+ try
+ {
+ test->clientUnknownDerivedAsBasePass(client);
+ test(false);
+ }
+ catch(const Base& b)
+ {
+ test(b.b == "Base");
+ test(b.ice_name() =="Test::Base"); // sliced by server
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ cout << "ok" << endl;
+
+ cout << "unknown derived rethrown by server... " << flush;
+ {
+ try
+ {
+ test->clientUnknownDerivedAsBaseRethrow(client);
+ test(false);
+ }
+ catch(const Base& b)
+ {
+ test(b.b == "Base");
+ test(b.ice_name() =="Test::Base"); // sliced by server
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ cout << "ok" << endl;
+
+ cout << "unsliceable derived pass through server... " << flush;
+ {
+ try
+ {
+ test->clientUnsliceableDerivedAsBasePass(client);
+ test(false);
+ }
+ catch(const Base& b)
+ {
+ test(b.b == "Base");
+ cout << "ice_name is " << b.ice_name() << endl;
+ test(b.ice_name() =="Test::ClientUnsliceableDerived"); // *NOT* sliced by server
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ cout << "ok" << endl;
+
+ cout << "unsliceable derived rethrown by server... " << flush;
+ {
+ try
+ {
+ test->clientUnsliceableDerivedAsBaseRethrow(client);
+ test(false);
+ }
+ catch(const Base& b)
+ {
+ test(b.b == "Base");
+ test(b.ice_name() =="Test::ClientUnsliceableDerived"); // *NOT* sliced by server
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ cout << "ok" << endl;
+
return test;
}
Modified: techdemo/team/kpfleming/slicing/exceptions/CMakeLists.txt
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/CMakeLists.txt?view=diff&rev=572&r1=571&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/CMakeLists.txt (original)
+++ techdemo/team/kpfleming/slicing/exceptions/CMakeLists.txt Fri Apr 9 16:05:42 2010
@@ -1,6 +1,7 @@
hydra_slice_include_directories(.)
hydra_compile_slice(exc_Test SOURCES Test.ice)
hydra_compile_slice(exc_TestAMD SOURCES TestAMD.ice)
+hydra_compile_slice(exc_ClientPrivate SOURCES ClientPrivate.ice)
hydra_compile_slice(exc_ServerPrivate SOURCES ServerPrivate.ice)
hydra_compile_slice(exc_ServerPrivateAMD SOURCES ServerPrivateAMD.ice)
@@ -10,6 +11,7 @@
hydra_component_add_file(exc_client Client.cpp)
hydra_component_add_file(exc_client AllTests.cpp)
hydra_component_add_slice(exc_client exc_Test)
+hydra_component_add_slice(exc_client exc_ClientPrivate)
hydra_component_build_standalone(exc_client)
hydra_component_init(exc_server CXX)
Copied: techdemo/team/kpfleming/slicing/exceptions/ClientPrivate.ice (from r569, techdemo/team/kpfleming/slicing/objects/ClientPrivate.ice)
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/ClientPrivate.ice?view=diff&rev=572&p1=techdemo/team/kpfleming/slicing/objects/ClientPrivate.ice&r1=569&p2=techdemo/team/kpfleming/slicing/exceptions/ClientPrivate.ice&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/objects/ClientPrivate.ice (original)
+++ techdemo/team/kpfleming/slicing/exceptions/ClientPrivate.ice Fri Apr 9 16:05:42 2010
@@ -15,16 +15,14 @@
module Test
{
-class D3 extends B
+exception ClientUnknownDerived extends Base
{
- string sd3;
- B pd3;
+ string ud;
};
-class D5 extends BU
+exception ClientUnsliceableDerived extends BaseUnsliceable
{
- string sd5;
- B pd5;
+ string ud;
};
};
Modified: techdemo/team/kpfleming/slicing/exceptions/Server.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/Server.cpp?view=diff&rev=572&r1=571&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/Server.cpp (original)
+++ techdemo/team/kpfleming/slicing/exceptions/Server.cpp Fri Apr 9 16:05:42 2010
@@ -17,7 +17,7 @@
{
Ice::PropertiesPtr properties(communicator->getProperties());
properties->setProperty("Ice.Warn.Dispatch", "0");
- communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 2000");
+ properties->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 2000");
Ice::ObjectAdapterPtr adapter(communicator->createObjectAdapter("TestAdapter"));
Ice::ObjectPtr object(new TestI(communicator));
adapter->add(object, communicator->stringToIdentity("Test"));
Modified: techdemo/team/kpfleming/slicing/exceptions/Test.ice
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/Test.ice?view=diff&rev=572&r1=571&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/Test.ice (original)
+++ techdemo/team/kpfleming/slicing/exceptions/Test.ice Fri Apr 9 16:05:42 2010
@@ -37,6 +37,13 @@
{
};
+interface ClientIntf
+{
+ void baseAsBase() throws Base;
+ void unknownDerivedAsBase() throws Base;
+ void unsliceableDerivedAsBase() throws Base;
+};
+
["ami"] interface TestIntf
{
void baseAsBase() throws Base;
@@ -55,6 +62,13 @@
void unknownMostDerived1AsKnownIntermediate() throws KnownIntermediate;
void unknownMostDerived2AsBase() throws Base;
+ void clientBaseAsBasePass(ClientIntf* client) throws Base;
+ void clientUnknownDerivedAsBasePass(ClientIntf* client) throws Base;
+ void clientUnsliceableDerivedAsBasePass(ClientIntf* client) throws Base;
+ void clientBaseAsBaseRethrow(ClientIntf* client) throws Base;
+ void clientUnknownDerivedAsBaseRethrow(ClientIntf* client) throws Base;
+ void clientUnsliceableDerivedAsBaseRethrow(ClientIntf* client) throws Base;
+
void shutdown();
};
Modified: techdemo/team/kpfleming/slicing/exceptions/TestI.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/TestI.cpp?view=diff&rev=572&r1=571&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/TestI.cpp (original)
+++ techdemo/team/kpfleming/slicing/exceptions/TestI.cpp Fri Apr 9 16:05:42 2010
@@ -18,6 +18,7 @@
{
public:
virtual void createAndThrow() {
+ cout << "factory throwing exception" << endl;
throw Preserver();
}
private:
@@ -27,12 +28,15 @@
vector< ::Ice::Byte > __skippedSlices;
virtual void __write(IceInternal::BasicStream* stream) const
{
+ cout << "writing skipped slices" << endl;
stream->writeBlob(__skippedSlices);
T::__write(stream);
}
virtual void __read(IceInternal::BasicStream* stream, bool rid)
{
+ cout << "trying to get skipped slices" << endl;
stream->readSkippedSlicesBlob(__skippedSlices);
+ cout << "got skipped slices of length " << __skippedSlices.size() << endl;
T::__read(stream, rid);
}
virtual ~Preserver() throw() {}
@@ -168,6 +172,63 @@
}
void
+TestI::clientBaseAsBasePass(const ClientIntfPrx& client, const ::Ice::Current&)
+{
+ client->baseAsBase();
+}
+
+void
+TestI::clientUnknownDerivedAsBasePass(const ClientIntfPrx& client, const ::Ice::Current&)
+{
+ client->unknownDerivedAsBase();
+}
+
+void
+TestI::clientUnsliceableDerivedAsBasePass(const ClientIntfPrx& client, const ::Ice::Current&)
+{
+ client->unsliceableDerivedAsBase();
+}
+
+void
+TestI::clientBaseAsBaseRethrow(const ClientIntfPrx& client, const ::Ice::Current&)
+{
+ try
+ {
+ client->baseAsBase();
+ }
+ catch (Base ex)
+ {
+ throw;
+ }
+}
+
+void
+TestI::clientUnknownDerivedAsBaseRethrow(const ClientIntfPrx& client, const ::Ice::Current&)
+{
+ try
+ {
+ client->unknownDerivedAsBase();
+ }
+ catch (Base ex)
+ {
+ throw;
+ }
+}
+
+void
+TestI::clientUnsliceableDerivedAsBaseRethrow(const ClientIntfPrx& client, const ::Ice::Current&)
+{
+ try
+ {
+ client->unsliceableDerivedAsBase();
+ }
+ catch (Base ex)
+ {
+ throw;
+ }
+}
+
+void
TestI::shutdown(const ::Ice::Current& current)
{
current.adapter->getCommunicator()->shutdown();
Modified: techdemo/team/kpfleming/slicing/exceptions/TestI.h
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/exceptions/TestI.h?view=diff&rev=572&r1=571&r2=572
==============================================================================
--- techdemo/team/kpfleming/slicing/exceptions/TestI.h (original)
+++ techdemo/team/kpfleming/slicing/exceptions/TestI.h Fri Apr 9 16:05:42 2010
@@ -33,6 +33,13 @@
virtual void unknownMostDerived1AsKnownIntermediate(const ::Ice::Current&);
virtual void unknownMostDerived2AsBase(const ::Ice::Current&);
+ virtual void clientBaseAsBasePass(const Test::ClientIntfPrx&, const ::Ice::Current&);
+ virtual void clientUnknownDerivedAsBasePass(const Test::ClientIntfPrx&, const ::Ice::Current&);
+ virtual void clientUnsliceableDerivedAsBasePass(const Test::ClientIntfPrx&, const ::Ice::Current&);
+ virtual void clientBaseAsBaseRethrow(const Test::ClientIntfPrx&, const ::Ice::Current&);
+ virtual void clientUnknownDerivedAsBaseRethrow(const Test::ClientIntfPrx&, const ::Ice::Current&);
+ virtual void clientUnsliceableDerivedAsBaseRethrow(const Test::ClientIntfPrx&, const ::Ice::Current&);
+
virtual void shutdown(const ::Ice::Current&);
};
More information about the asterisk-scf-commits
mailing list