summaryrefslogtreecommitdiff
path: root/project2/ice/unittests/testClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/ice/unittests/testClient.cpp')
-rw-r--r--project2/ice/unittests/testClient.cpp50
1 files changed, 48 insertions, 2 deletions
diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp
index 4c89184..687ba73 100644
--- a/project2/ice/unittests/testClient.cpp
+++ b/project2/ice/unittests/testClient.cpp
@@ -2,6 +2,8 @@
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include "iceClient.h"
+#include <Ice/ObjectAdapter.h>
+#include <Ice/Service.h>
#include <testOptionsSource.h>
#include <task.h>
#include <exceptions.h>
@@ -10,13 +12,17 @@
#include <testScriptHost.h>
#include <scopeObject.h>
#include <unittest.h>
+#include <unittestComplex.h>
#define XSTR(s) STR(s)
#define STR(s) #s
const auto bindir = boost::filesystem::canonical("/proc/self/exe").parent_path();
+const auto componentdir = bindir.parent_path() / "component";
const boost::filesystem::path iceroot(XSTR(ROOT));
const auto headers = iceroot.parent_path().parent_path();
+BOOST_TEST_DONT_PRINT_LOG_VALUE( ::UnitTestComplex::Date );
+
class Dummy : public UnitTest::SimpleInterface {
public:
Dummy() :
@@ -55,8 +61,38 @@ class Dummy : public UnitTest::SimpleInterface {
execCount += 1;
}
- void SomeTaskParams(Ice::Int, const std::string&, const Ice::Current&)
+ void SomeTaskParams(Ice::Int a, const std::string & b, const Ice::Current&)
+ {
+ BOOST_REQUIRE_EQUAL(a, 1);
+ BOOST_REQUIRE_EQUAL(b, "first");
+ execCount += 1;
+ }
+
+ unsigned int execCount;
+};
+
+class DummyComplex : public UnitTestComplex::ComplexInterface {
+ public:
+ DummyComplex() :
+ execCount(0)
+ {
+ }
+
+ UnitTestComplex::ComplexPtr ComplexRow(const Ice::Current&)
+ {
+ return new UnitTestComplex::Complex { 3, "single", new UnitTestComplex::Date { 1980, 7, 9, 1, 2, 3 } };
+ }
+
+ void ComplexParam(Ice::Int a, const std::string & b, const UnitTestComplex::DatePtr & d, const Ice::Current&)
{
+ BOOST_REQUIRE_EQUAL(a, 1);
+ BOOST_REQUIRE_EQUAL(b, "first");
+ BOOST_REQUIRE_EQUAL(d->year, 1980);
+ BOOST_REQUIRE_EQUAL(d->month, 7);
+ BOOST_REQUIRE_EQUAL(d->day, 9);
+ BOOST_REQUIRE_EQUAL(d->hours, 1);
+ BOOST_REQUIRE_EQUAL(d->minutes, 2);
+ BOOST_REQUIRE_EQUAL(d->seconds, 3);
execCount += 1;
}
@@ -74,6 +110,8 @@ commonTests()
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"));
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"));
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"));
+ BOOST_REQUIRE(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexParam"));
+ BOOST_REQUIRE(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexRow"));
BOOST_TEST_CHECKPOINT("Load test script");
ScriptReaderPtr r = new XmlScriptParser(iceroot / "testClient.xml");
@@ -83,15 +121,19 @@ commonTests()
Ice::CommunicatorPtr ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000");
IceUtil::Handle<Dummy> dummy = new Dummy();
+ IceUtil::Handle<DummyComplex> dummyComplex = new DummyComplex();
adapter->add(dummy, ic->stringToIdentity("testObject"));
+ adapter->add(dummyComplex, ic->stringToIdentity("testObjectComplex"));
adapter->activate();
ScopeObject _([&ic]{ ic->destroy(); });
BOOST_TEST_CHECKPOINT("Execute test script");
boost::intrusive_ptr<TestScriptHost> sr = new TestScriptHost(r);
BOOST_REQUIRE_EQUAL(dummy->execCount, 0);
+ BOOST_REQUIRE_EQUAL(dummyComplex->execCount, 0);
sr->process(NULL);
BOOST_REQUIRE_EQUAL(dummy->execCount, 4);
+ BOOST_REQUIRE_EQUAL(dummyComplex->execCount, 1);
BOOST_REQUIRE_EQUAL(sr->GetPresenterData(), iceroot / "expected" / "clientPresenter.log");
}
@@ -105,6 +147,8 @@ unloadTests()
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"), NotSupported);
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"), NotSupported);
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported);
+ BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexParam"), NotSupported);
+ BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexRow"), NotSupported);
}
void test_client_run(const boost::filesystem::path & tmpdir);
@@ -122,10 +166,10 @@ void test_client_run(const boost::filesystem::path & tmpdir)
{
BOOST_TEST_CHECKPOINT("Configure, compile, link, load");
TestOptionsSource::LoadTestOptions({
- { "library", (bindir / "slicer-yes" / "libunittestr.so").string() },
{ "common.datasourceRoot", iceroot.string() },
{ "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
+ { "ice.client.slicerclient", (iceroot / "unittestComplex.ice").string() },
{ "ice.client.slicerclient", (iceroot / "unittestTypes.ice").string() },
{ "ice.client.slicerclient", (iceroot / "unittest.ice").string() }
});
@@ -133,6 +177,8 @@ void test_client_run(const boost::filesystem::path & tmpdir)
BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.client.so"));
BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so"));
BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.client.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestComplex.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestComplex.client.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });