diff options
Diffstat (limited to 'cpp/test')
217 files changed, 18630 insertions, 18630 deletions
diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index 7012c50f038..fdc3850b8a9 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -32,22 +32,22 @@ validate(const Complex::ComplexDict& m) Parser myParser; for(p = m.begin(); p != m.end(); ++p) { - // - // Verify the stored record is correct. - // + // + // Verify the stored record is correct. + // // COMPILERFIX: VC.NET reports an unhandled // exception if the test is written this way: // - //test(p->first.result == p->second->calc()); + //test(p->first.result == p->second->calc()); // Complex::NodePtr n = p->second; - test(p->first.result == n->calc()); + test(p->first.result == n->calc()); - // - // Verify that the expression & result again. - // - Complex::NodePtr root = myParser.parse(p->first.expression); - test(root->calc() == p->first.result); + // + // Verify that the expression & result again. + // + Complex::NodePtr root = myParser.parse(p->first.expression); + test(root->calc() == p->first.result); } cout << "ok" << endl; @@ -71,12 +71,12 @@ populate(Complex::ComplexDict& m) Parser myParser; for(size_t i = 0 ; i < nexpressions; ++i) { - Complex::NodePtr root = myParser.parse(expressions[i]); - assert(root); - Complex::Key k; - k.expression = expressions[i]; - k.result = root->calc(); - m.put(pair<const Complex::Key, const Complex::NodePtr>(k, root)); + Complex::NodePtr root = myParser.parse(expressions[i]); + assert(root); + Complex::Key k; + k.expression = expressions[i]; + k.result = root->calc(); + m.put(pair<const Complex::Key, const Complex::NodePtr>(k, root)); } cout << "ok" << endl; @@ -87,8 +87,8 @@ static void usage(const char* name) { cerr << "Usage: " << name << " [options] validate|populate\n"; - cerr << - "Options:\n" + cerr << + "Options:\n" "--dbdir Location of the database directory.\n"; } @@ -105,11 +105,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, Complex::C if(argc > 1 && strcmp(argv[1], "populate") == 0) { - return populate(m); + return populate(m); } if(argc > 1 && strcmp(argv[1], "validate") == 0) { - return validate(m); + return validate(m); } usage(argv[0]); @@ -126,59 +126,59 @@ main(int argc, char* argv[]) try { - // - // Scan for --dbdir command line argument. - // - int i = 1; - while(i < argc) - { - if(strcmp(argv[i], "--dbdir") == 0) - { - if(i +1 >= argc) - { - usage(argv[0]); - return EXIT_FAILURE; - } - - envName = argv[i+1]; - envName += "/"; - envName += "db"; - - // - // Consume arguments - // - while(i < argc - 2) - { - argv[i] = argv[i+2]; - ++i; - } - argc -= 2; - } - else - { - ++i; - } - } - - communicator = Ice::initialize(argc, argv); - Freeze::ConnectionPtr connection = createConnection(communicator, envName); - Complex::ComplexDict m(connection, "test"); - status = run(argc, argv, communicator, m); + // + // Scan for --dbdir command line argument. + // + int i = 1; + while(i < argc) + { + if(strcmp(argv[i], "--dbdir") == 0) + { + if(i +1 >= argc) + { + usage(argv[0]); + return EXIT_FAILURE; + } + + envName = argv[i+1]; + envName += "/"; + envName += "db"; + + // + // Consume arguments + // + while(i < argc - 2) + { + argv[i] = argv[i+2]; + ++i; + } + argc -= 2; + } + else + { + ++i; + } + } + + communicator = Ice::initialize(argc, argv); + Freeze::ConnectionPtr connection = createConnection(communicator, envName); + Complex::ComplexDict m(connection, "test"); + status = run(argc, argv, communicator, m); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } try { - communicator->destroy(); + communicator->destroy(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } return status; diff --git a/cpp/test/Freeze/complex/NodeI.h b/cpp/test/Freeze/complex/NodeI.h index 40479c2e2ba..296b3096260 100644 --- a/cpp/test/Freeze/complex/NodeI.h +++ b/cpp/test/Freeze/complex/NodeI.h @@ -26,12 +26,12 @@ public: NumberNodeI(int n) { - number = n; + number = n; } virtual int calc(const Ice::Current&) { - return number; + return number; } }; @@ -45,13 +45,13 @@ public: AddNodeI(const NodePtr& l, const NodePtr& r) { - left = l; - right = r; + left = l; + right = r; } virtual int calc(const Ice::Current&) { - return left->calc() + right->calc(); + return left->calc() + right->calc(); } }; @@ -65,13 +65,13 @@ public: MultiplyNodeI(const NodePtr& l, const NodePtr& r) { - left = l; - right = r; + left = l; + right = r; } virtual int calc(const Ice::Current&) { - return left->calc() * right->calc(); + return left->calc() * right->calc(); } }; @@ -81,26 +81,26 @@ public: virtual Ice::ObjectPtr create(const std::string& type) { - if(type == "::Complex::MultiplyNode") - { - return new MultiplyNodeI(); - } - if(type == "::Complex::AddNode") - { - return new AddNodeI(); - } - if(type == "::Complex::NumberNode") - { - return new NumberNodeI(); - } - std::cout << "create: " << type << std::endl; - assert(false); - return 0; + if(type == "::Complex::MultiplyNode") + { + return new MultiplyNodeI(); + } + if(type == "::Complex::AddNode") + { + return new AddNodeI(); + } + if(type == "::Complex::NumberNode") + { + return new NumberNodeI(); + } + std::cout << "create: " << type << std::endl; + assert(false); + return 0; } virtual void destroy() { - // Nothing to do + // Nothing to do } }; diff --git a/cpp/test/Freeze/complex/Parser.cpp b/cpp/test/Freeze/complex/Parser.cpp index 96616e9daa1..6114668e970 100644 --- a/cpp/test/Freeze/complex/Parser.cpp +++ b/cpp/test/Freeze/complex/Parser.cpp @@ -45,7 +45,7 @@ Parser::parse(const string& commands, bool debug) if(_errors) { - return 0; + return 0; } return _result; @@ -70,17 +70,17 @@ Parser::getInput(char* buf, int& result, int maxSize) if(!_buf.empty()) { #if defined(_MSC_VER) && !defined(_STLP_MSVC) - // COMPILERBUG: Stupid Visual C++ defines min and max as macros - result = _MIN(maxSize, static_cast<int>(_buf.length())); + // COMPILERBUG: Stupid Visual C++ defines min and max as macros + result = _MIN(maxSize, static_cast<int>(_buf.length())); #else - result = min(maxSize, static_cast<int>(_buf.length())); + result = min(maxSize, static_cast<int>(_buf.length())); #endif - strncpy(buf, _buf.c_str(), result); - _buf.erase(0, result); + strncpy(buf, _buf.c_str(), result); + _buf.erase(0, result); } else { - result = 0; + result = 0; } } diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp index 77f705b8a58..09ab3c7d745 100644 --- a/cpp/test/Freeze/dbmap/Client.cpp +++ b/cpp/test/Freeze/dbmap/Client.cpp @@ -64,27 +64,27 @@ populateDB(const Freeze::ConnectionPtr& connection, ByteIntMap& m) for(;;) { - try - { - TransactionHolder txHolder(connection); - for(size_t j = 0; j < length; ++j) - { - m.put(ByteIntMap::value_type(alphabet[j], static_cast<Int>(j))); - } - txHolder.commit(); - break; - } - catch(const DeadlockException&) - { + try + { + TransactionHolder txHolder(connection); + for(size_t j = 0; j < length; ++j) + { + m.put(ByteIntMap::value_type(alphabet[j], static_cast<Int>(j))); + } + txHolder.commit(); + break; + } + catch(const DeadlockException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "t" << flush; + cerr << "t" << flush; #endif - length = length / 2; - // - // Try again - // - } + length = length / 2; + // + // Try again + // + } } } @@ -93,45 +93,45 @@ class ReadThread : public IceUtil::Thread public: ReadThread(const CommunicatorPtr& communicator, const string& envName, const string& dbName) : - _connection(createConnection(communicator, envName)), - _map(_connection, dbName) + _connection(createConnection(communicator, envName)), + _map(_connection, dbName) { } virtual void run() { - for(int i = 0; i < 10; ++i) - { - for(;;) - { - try - { - for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) - { - test(p->first == p->second + 'a'); - IceUtil::ThreadControl::yield(); - } - break; // for(;;) - } - catch(const DeadlockException&) - { + for(int i = 0; i < 10; ++i) + { + for(;;) + { + try + { + for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) + { + test(p->first == p->second + 'a'); + IceUtil::ThreadControl::yield(); + } + break; // for(;;) + } + catch(const DeadlockException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "r" << flush; + cerr << "r" << flush; #endif - // - // Try again - // - } - catch(const InvalidPositionException&) - { + // + // Try again + // + } + catch(const InvalidPositionException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "i" << flush; + cerr << "i" << flush; #endif - break; - } - } - } + break; + } + } + } } private: @@ -146,51 +146,51 @@ class WriteThread : public IceUtil::Thread public: WriteThread(const CommunicatorPtr& communicator, const string& envName, const string& dbName) : - _connection(createConnection(communicator, envName)), - _map(_connection, dbName) + _connection(createConnection(communicator, envName)), + _map(_connection, dbName) { } virtual void run() { - // - // Delete an recreate each object - // - for(int i = 0; i < 4; ++i) - { - for(;;) - { - try - { - TransactionHolder txHolder(_connection); - for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) - { - p.set(p->second + 1); - _map.erase(p); - } - break; // for(;;) - txHolder.commit(); - } - catch(const DeadlockException&) - { + // + // Delete an recreate each object + // + for(int i = 0; i < 4; ++i) + { + for(;;) + { + try + { + TransactionHolder txHolder(_connection); + for(ByteIntMap::iterator p = _map.begin(); p != _map.end(); ++p) + { + p.set(p->second + 1); + _map.erase(p); + } + break; // for(;;) + txHolder.commit(); + } + catch(const DeadlockException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "w" << flush; + cerr << "w" << flush; #endif - // - // Try again - // - } - catch(const InvalidPositionException&) - { + // + // Try again + // + } + catch(const InvalidPositionException&) + { #ifdef SHOW_EXCEPTIONS - cerr << "I" << flush; + cerr << "I" << flush; #endif - break; - } - } - populateDB(_connection, _map); - } + break; + } + } + populateDB(_connection, _map); + } } private: @@ -222,18 +222,18 @@ run(const CommunicatorPtr& communicator, const string& envName) // for(j = alphabet.begin(); j != alphabet.end(); ++j) { - p = m.find(*j); - test(p != m.end()); - test(p->first == *j && p->second == j - alphabet.begin()); + p = m.find(*j); + test(p != m.end()); + test(p->first == *j && p->second == j - alphabet.begin()); } // // Next try const iterator // for(j = alphabet.begin(); j != alphabet.end(); ++j) { - cp = m.find(*j); - test(cp != m.end()); - test(cp->first == *j && cp->second == j - alphabet.begin()); + cp = m.find(*j); + test(cp != m.end()); + test(cp->first == *j && cp->second == j - alphabet.begin()); } test(!m.empty()); @@ -262,27 +262,27 @@ run(const CommunicatorPtr& communicator, const string& envName) bytes.push_back('c'); for(j = bytes.begin(); j != bytes.end(); ++j) { - p = m.find(*j); - test(p != m.end()); - m.erase(p); - - // - // Release locks to avoid self deadlock - // - p = m.end(); - - p = m.find(*j); - test(p == m.end()); - vector<Byte>::iterator r = find(alphabet.begin(), alphabet.end(), *j); - test(r != alphabet.end()); - alphabet.erase(r); + p = m.find(*j); + test(p != m.end()); + m.erase(p); + + // + // Release locks to avoid self deadlock + // + p = m.end(); + + p = m.find(*j); + test(p == m.end()); + vector<Byte>::iterator r = find(alphabet.begin(), alphabet.end(), *j); + test(r != alphabet.end()); + alphabet.erase(r); } for(j = alphabet.begin(); j != alphabet.end(); ++j) { - cp = m.find(*j); - test(cp != m.end()); - test(cp->first == *j && cp->second == (j - alphabet.begin()) + offset); + cp = m.find(*j); + test(cp != m.end()); + test(cp->first == *j && cp->second == (j - alphabet.begin()) + offset); } cout << "ok" << endl; @@ -486,8 +486,8 @@ run(const CommunicatorPtr& communicator, const string& envName) map<Byte, const Int>::const_iterator pit; for(pit = pairs.begin(); pit != pairs.end(); ++pit) { - p = m.find(pit->first); - test(p != m.end()); + p = m.find(pit->first); + test(p != m.end()); } cout << "ok" << endl; @@ -498,10 +498,10 @@ run(const CommunicatorPtr& communicator, const string& envName) size_t length = alphabet.size(); for(size_t k = 0; k < length; ++k) { - p = m.findByValue(static_cast<Int>(k)); - test(p != m.end()); - test(p->first == alphabet[k]); - test(++p == m.end()); + p = m.findByValue(static_cast<Int>(k)); + test(p != m.end()); + test(p->first == alphabet[k]); + test(++p == m.end()); } // @@ -531,12 +531,12 @@ run(const CommunicatorPtr& communicator, const string& envName) try { - p.set(18); - test(false); + p.set(18); + test(false); } catch(const DatabaseException&) { - // Expected + // Expected } test(p->first == alphabet[17] || p->first == alphabet[21]); test(++p == m.end()); @@ -551,177 +551,177 @@ run(const CommunicatorPtr& communicator, const string& envName) vector<IceUtil::ThreadControl> controls; for(int i = 0; i < 5; ++i) { - IceUtil::ThreadPtr rt = new ReadThread(communicator, envName, dbName); - controls.push_back(rt->start()); - IceUtil::ThreadPtr wt = new WriteThread(communicator, envName, dbName); - controls.push_back(wt->start()); + IceUtil::ThreadPtr rt = new ReadThread(communicator, envName, dbName); + controls.push_back(rt->start()); + IceUtil::ThreadPtr wt = new WriteThread(communicator, envName, dbName); + controls.push_back(wt->start()); } for(vector<IceUtil::ThreadControl>::iterator q = controls.begin(); q != controls.end(); ++q) { - q->join(); + q->join(); } cout << "ok" << endl; cout << "testing index creation... " << flush; { - IntIdentityMap iim(connection, "intIdentity"); - - Ice::Identity odd; - odd.name = "foo"; - odd.category = "odd"; - - Ice::Identity even; - even.name = "bar"; - even.category = "even"; - - TransactionHolder txHolder(connection); - for(int i = 0; i < 1000; i++) - { - if(i % 2 == 0) - { - iim.put(IntIdentityMap::value_type(i, even)); - } - else - { - iim.put(IntIdentityMap::value_type(i, odd)); - } - } - txHolder.commit(); + IntIdentityMap iim(connection, "intIdentity"); + + Ice::Identity odd; + odd.name = "foo"; + odd.category = "odd"; + + Ice::Identity even; + even.name = "bar"; + even.category = "even"; + + TransactionHolder txHolder(connection); + for(int i = 0; i < 1000; i++) + { + if(i % 2 == 0) + { + iim.put(IntIdentityMap::value_type(i, even)); + } + else + { + iim.put(IntIdentityMap::value_type(i, odd)); + } + } + txHolder.commit(); } { - IntIdentityMapWithIndex iim(connection, "intIdentity"); - test(iim.categoryCount("even") == 500); - test(iim.categoryCount("odd") == 500); - - { - int count = 0; - IntIdentityMapWithIndex::iterator p = iim.findByCategory("even"); - while(p != iim.end()) - { - test(p->first % 2 == 0); - ++p; - ++count; - } - test(count == 500); - } - - { - int count = 0; - IntIdentityMapWithIndex::iterator p = iim.findByCategory("odd"); - while(p != iim.end()) - { - test(p->first % 2 == 1); - ++p; - ++count; - } - test(count == 500); - } - iim.clear(); + IntIdentityMapWithIndex iim(connection, "intIdentity"); + test(iim.categoryCount("even") == 500); + test(iim.categoryCount("odd") == 500); + + { + int count = 0; + IntIdentityMapWithIndex::iterator p = iim.findByCategory("even"); + while(p != iim.end()) + { + test(p->first % 2 == 0); + ++p; + ++count; + } + test(count == 500); + } + + { + int count = 0; + IntIdentityMapWithIndex::iterator p = iim.findByCategory("odd"); + while(p != iim.end()) + { + test(p->first % 2 == 1); + ++p; + ++count; + } + test(count == 500); + } + iim.clear(); } cout << "ok" << endl; cout << "testing sorting... " << flush; { - SortedMap sm(connection, "sortedMap"); - - TransactionHolder txHolder(connection); - for(int i = 0; i < 1000; i++) - { - int k = rand() % 1000; - - Ice::Identity id; - id.name = "foo"; - id.category = 'a' + static_cast<char>(k % 26); - - sm.put(SortedMap::value_type(k, id)); - } - txHolder.commit(); + SortedMap sm(connection, "sortedMap"); + + TransactionHolder txHolder(connection); + for(int i = 0; i < 1000; i++) + { + int k = rand() % 1000; + + Ice::Identity id; + id.name = "foo"; + id.category = 'a' + static_cast<char>(k % 26); + + sm.put(SortedMap::value_type(k, id)); + } + txHolder.commit(); } { - SortedMap sm(connection, "sortedMap"); - { - for(int i = 0; i < 100; ++i) - { - int k = rand() % 1000; - SortedMap::iterator p = sm.lower_bound(k); - if(p != sm.end()) - { - test(p->first >= k); - SortedMap::iterator q = sm.upper_bound(k); - if(q == sm.end()) - { - test(p->first == k); - } - else - { - test((p->first == k && q->first > k) || - (p->first > k && q->first == p->first)); - } - } - } - } - - { - for(int i = 0; i < 100; ++i) - { - string category; - category = static_cast<char>('a' + rand() % 26); - - SortedMap::iterator p = sm.findByCategory(category); - if(p != sm.end()) - { - SortedMap::iterator q = sm.lowerBoundForCategory(category); - test(p == q); - do - { - q++; - } while(q != sm.end() && q->second.category == category); - - if(q != sm.end()) - { - test(q == sm.upperBoundForCategory(category)); - } - } - else - { - SortedMap::iterator q = sm.lowerBoundForCategory(category); - if(q != sm.end()) - { - test(p != q); - test(q->second.category < category); - category = q->second.category; - - do - { - q++; - } while(q != sm.end() && q->second.category == category); - - if(q != sm.end()) - { - test(q == sm.upperBoundForCategory(category)); - } - } - } - } - } - - { - string category = "z"; - SortedMap::iterator p = sm.lowerBoundForCategory(category); - - while(p != sm.end()) - { - test(p->second.category <= category); - category = p->second.category; - // cerr << category << ":" << p->first << endl; - ++p; - } - } - - sm.clear(); + SortedMap sm(connection, "sortedMap"); + { + for(int i = 0; i < 100; ++i) + { + int k = rand() % 1000; + SortedMap::iterator p = sm.lower_bound(k); + if(p != sm.end()) + { + test(p->first >= k); + SortedMap::iterator q = sm.upper_bound(k); + if(q == sm.end()) + { + test(p->first == k); + } + else + { + test((p->first == k && q->first > k) || + (p->first > k && q->first == p->first)); + } + } + } + } + + { + for(int i = 0; i < 100; ++i) + { + string category; + category = static_cast<char>('a' + rand() % 26); + + SortedMap::iterator p = sm.findByCategory(category); + if(p != sm.end()) + { + SortedMap::iterator q = sm.lowerBoundForCategory(category); + test(p == q); + do + { + q++; + } while(q != sm.end() && q->second.category == category); + + if(q != sm.end()) + { + test(q == sm.upperBoundForCategory(category)); + } + } + else + { + SortedMap::iterator q = sm.lowerBoundForCategory(category); + if(q != sm.end()) + { + test(p != q); + test(q->second.category < category); + category = q->second.category; + + do + { + q++; + } while(q != sm.end() && q->second.category == category); + + if(q != sm.end()) + { + test(q == sm.upperBoundForCategory(category)); + } + } + } + } + } + + { + string category = "z"; + SortedMap::iterator p = sm.lowerBoundForCategory(category); + + while(p != sm.end()) + { + test(p->second.category <= category); + category = p->second.category; + // cerr << category << ":" << p->first << endl; + ++p; + } + } + + sm.clear(); } cout << "ok" << endl; @@ -729,29 +729,29 @@ run(const CommunicatorPtr& communicator, const string& envName) cout << "testing wstring... " << flush; { - WstringWstringMap wsm(connection, "wstringMap"); - - TransactionHolder txHolder(connection); - wsm.put(WstringWstringMap::value_type(L"AAAAA", L"aaaaa")); - wsm.put(WstringWstringMap::value_type(L"BBBBB", L"bbbbb")); - wsm.put(WstringWstringMap::value_type(L"CCCCC", L"ccccc")); - wsm.put(WstringWstringMap::value_type(L"DDDDD", L"ddddd")); - wsm.put(WstringWstringMap::value_type(L"EEEEE", L"eeeee")); - txHolder.commit(); + WstringWstringMap wsm(connection, "wstringMap"); + + TransactionHolder txHolder(connection); + wsm.put(WstringWstringMap::value_type(L"AAAAA", L"aaaaa")); + wsm.put(WstringWstringMap::value_type(L"BBBBB", L"bbbbb")); + wsm.put(WstringWstringMap::value_type(L"CCCCC", L"ccccc")); + wsm.put(WstringWstringMap::value_type(L"DDDDD", L"ddddd")); + wsm.put(WstringWstringMap::value_type(L"EEEEE", L"eeeee")); + txHolder.commit(); } { - WstringWstringMap wsm(connection, "wstringMap"); - { - WstringWstringMap::iterator p = wsm.find(L"BBBBB"); - test(p != wsm.end()); - test(p->second == L"bbbbb"); - - p = wsm.findByValue(L"ddddd"); - test(p != wsm.end()); - test(p->first == L"DDDDD"); - } - wsm.clear(); + WstringWstringMap wsm(connection, "wstringMap"); + { + WstringWstringMap::iterator p = wsm.find(L"BBBBB"); + test(p != wsm.end()); + test(p->second == L"bbbbb"); + + p = wsm.findByValue(L"ddddd"); + test(p != wsm.end()); + test(p->first == L"DDDDD"); + } + wsm.clear(); } cout << "ok" << endl; @@ -769,30 +769,30 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - if(argc != 1) - { - envName = argv[1]; - envName += "/"; - envName += "db"; - } + communicator = Ice::initialize(argc, argv); + if(argc != 1) + { + envName = argv[1]; + envName += "/"; + envName += "db"; + } - status = run(communicator, envName); + status = run(communicator, envName); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } try { - communicator->destroy(); + communicator->destroy(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } return status; diff --git a/cpp/test/Freeze/evictor/Client.cpp b/cpp/test/Freeze/evictor/Client.cpp index 41ee315faf2..cfafd704ef7 100644 --- a/cpp/test/Freeze/evictor/Client.cpp +++ b/cpp/test/Freeze/evictor/Client.cpp @@ -29,35 +29,35 @@ class ReadThread : public Thread public: ReadThread(vector<Test::ServantPrx>& servants) : - _servants(servants) + _servants(servants) { } virtual void run() { - int loops = 10; - while(loops-- > 0) - { - try - { - _servants[0]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - catch(...) - { - test(false); - } - - for(int i = 1; i < static_cast<int>(_servants.size()); ++i) - { - test(_servants[i]->getValue() == i); - } - } + int loops = 10; + while(loops-- > 0) + { + try + { + _servants[0]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + catch(...) + { + test(false); + } + + for(int i = 1; i < static_cast<int>(_servants.size()); ++i) + { + test(_servants[i]->getValue() == i); + } + } } private: @@ -71,72 +71,72 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; ReadForeverThread(vector<Test::ServantPrx>& servants) : - _servants(servants), - _state(StateRunning) + _servants(servants), + _state(StateRunning) { } virtual void run() { - for(;;) - { - try - { - for(int i = 0; i < static_cast<int>(_servants.size()); ++i) - { - if(getState() == StateDeactivated) - { - _servants[i]->slowGetValue(); - test(false); - } - else - { - test(_servants[i]->slowGetValue() == i); - } - } - } - catch(const Ice::SocketException&) - { - // - // Expected - // - test(validEx()); - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(...) - { - test(false); - return; - } - } + for(;;) + { + try + { + for(int i = 0; i < static_cast<int>(_servants.size()); ++i) + { + if(getState() == StateDeactivated) + { + _servants[i]->slowGetValue(); + test(false); + } + else + { + test(_servants[i]->slowGetValue() == i); + } + } + } + catch(const Ice::SocketException&) + { + // + // Expected + // + test(validEx()); + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; + test(false); + return; + } + catch(...) + { + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -152,99 +152,99 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; AddForeverThread(const Test::RemoteEvictorPrx& evictor, int prefix) : - _evictor(evictor), - _state(StateRunning) + _evictor(evictor), + _state(StateRunning) { - ostringstream ostr; - ostr << prefix; - _prefix = ostr.str(); + ostringstream ostr; + ostr << prefix; + _prefix = ostr.str(); } virtual void run() { - int index = 0; - - for(;;) - { - ostringstream ostr; - ostr << _prefix << "-" << index; - index++; - string id = ostr.str(); - try - { - if(getState() == StateDeactivated) - { - _evictor->createServant(id, 0); - test(false); - } - else - { - _evictor->createServant(id, 0); - } - } - catch(const Test::EvictorDeactivatedException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::ObjectNotExistException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(const IceUtil::Exception& e) - { - cerr << "Caught IceUtil::Exception : " << e << endl; - cerr << "Index is " << index << endl; - test(false); - return; - } - catch(const std::exception& e) - { - cerr << "Caught std::exception : " << e.what() << endl; - test(false); - return; - } - catch(...) - { - cerr << "Caught unknown exception" << endl; + int index = 0; + + for(;;) + { + ostringstream ostr; + ostr << _prefix << "-" << index; + index++; + string id = ostr.str(); + try + { + if(getState() == StateDeactivated) + { + _evictor->createServant(id, 0); + test(false); + } + else + { + _evictor->createServant(id, 0); + } + } + catch(const Test::EvictorDeactivatedException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::ObjectNotExistException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; test(false); - return; - } - } + return; + } + catch(const IceUtil::Exception& e) + { + cerr << "Caught IceUtil::Exception : " << e << endl; + cerr << "Index is " << index << endl; + test(false); + return; + } + catch(const std::exception& e) + { + cerr << "Caught std::exception : " << e.what() << endl; + test(false); + return; + } + catch(...) + { + cerr << "Caught unknown exception" << endl; + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -259,96 +259,96 @@ class CreateDestroyThread : public Thread public: CreateDestroyThread(const Test::RemoteEvictorPrx& evictor, int id, int size) : - _evictor(evictor), - _size(size) + _evictor(evictor), + _size(size) { - ostringstream ostr; - ostr << id; - _id = ostr.str(); + ostringstream ostr; + ostr << id; + _id = ostr.str(); } virtual void run() { - try - { - int loops = 50; - while(loops-- > 0) - { - for(int i = 0; i < _size; i++) - { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - if(id == _id) - { - // - // Create when odd, destroy when even. - // - - if(loops % 2 == 0) - { - Test::ServantPrx servant = _evictor->getServant(id); - servant->destroy(); - - // - // Twice - // - try - { - servant->destroy(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } - else - { - Test::ServantPrx servant = _evictor->createServant(id, i); - - // - // Twice - // - try - { - servant = _evictor->createServant(id, 0); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - // Expected - } - } - } - else - { - // - // Just read/write the value - // - Test::ServantPrx servant = _evictor->getServant(id); - try - { - int val = servant->getValue(); - test(val == i || val == -i); - servant->setValue(-val); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected from time to time - } - } - } - } - } - catch(...) - { - // - // Unexpected! - // - test(false); - } + try + { + int loops = 50; + while(loops-- > 0) + { + for(int i = 0; i < _size; i++) + { + ostringstream ostr; + ostr << i; + string id = ostr.str(); + if(id == _id) + { + // + // Create when odd, destroy when even. + // + + if(loops % 2 == 0) + { + Test::ServantPrx servant = _evictor->getServant(id); + servant->destroy(); + + // + // Twice + // + try + { + servant->destroy(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } + else + { + Test::ServantPrx servant = _evictor->createServant(id, i); + + // + // Twice + // + try + { + servant = _evictor->createServant(id, 0); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + // Expected + } + } + } + else + { + // + // Just read/write the value + // + Test::ServantPrx servant = _evictor->getServant(id); + try + { + int val = servant->getValue(); + test(val == i || val == -i); + servant->setValue(-val); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected from time to time + } + } + } + } + } + catch(...) + { + // + // Unexpected! + // + test(false); + } } private: Test::RemoteEvictorPrx _evictor; @@ -379,32 +379,32 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) vector<Test::ServantPrx> servants; for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->ice_ping(); - - Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); - try - { - facet1->ice_ping(); - test(false); - } - catch(const Ice::FacetNotExistException&) - { - // Expected - } - - servants[i]->addFacet("facet1", "data"); - facet1->ice_ping(); - facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i); - facet1->addFacet("facet2", "moreData"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->ice_ping(); + + Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); + try + { + facet1->ice_ping(); + test(false); + } + catch(const Ice::FacetNotExistException&) + { + // Expected + } + + servants[i]->addFacet("facet1", "data"); + facet1->ice_ping(); + facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i); + facet1->addFacet("facet2", "moreData"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i); } // @@ -414,14 +414,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i); - test(facet1->getData() == "data"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getData() == "moreData"); + test(servants[i]->getValue() == i); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i); + test(facet1->getData() == "data"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getData() == "moreData"); } // @@ -429,13 +429,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->setValue(i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i + 100); + servants[i]->setValue(i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i + 100); } // @@ -445,13 +445,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getValue() == 100 * i + 100); + test(servants[i]->getValue() == i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getValue() == 100 * i + 100); } // // Test saving while busy @@ -459,24 +459,24 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Test::AMI_Servant_setValueAsyncPtr setCB = new AMI_Servant_setValueAsyncI; for(i = 0; i < size; i++) { - // - // Start a mutating operation so that the object is not idle. - // - servants[i]->setValueAsync_async(setCB, i + 300); - - test(servants[i]->getValue() == i + 100); - // - // This operation modifies the object state but is not saved - // because the setValueAsync operation is still pending. - // - servants[i]->setValue(i + 200); - test(servants[i]->getValue() == i + 200); + // + // Start a mutating operation so that the object is not idle. + // + servants[i]->setValueAsync_async(setCB, i + 300); + + test(servants[i]->getValue() == i + 100); + // + // This operation modifies the object state but is not saved + // because the setValueAsync operation is still pending. + // + servants[i]->setValue(i + 200); + test(servants[i]->getValue() == i + 200); - // - // Force the response to setValueAsync - // - servants[i]->releaseAsync(); - test(servants[i]->getValue() == i + 300); + // + // Force the response to setValueAsync + // + servants[i]->releaseAsync(); + test(servants[i]->getValue() == i + 300); } // @@ -484,14 +484,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->addFacet("facet1", "foobar"); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - } + try + { + servants[i]->addFacet("facet1", "foobar"); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + } } // @@ -499,8 +499,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // try { - servants[0]->removeFacet("facet3"); - test(false); + servants[0]->removeFacet("facet3"); + test(false); } catch(const Test::NotRegisteredException&) { @@ -512,8 +512,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->removeFacet("facet1"); - servants[i]->removeFacet("facet2"); + servants[i]->removeFacet("facet1"); + servants[i]->removeFacet("facet2"); } // @@ -521,10 +521,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); - test(facet2 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); + test(facet2 == 0); } evictor->setSize(0); @@ -532,10 +532,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 300); + test(servants[i]->getValue() == i + 300); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); } // @@ -543,26 +543,26 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->destroy(); - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - - try - { - servants[i]->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } + servants[i]->destroy(); + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + + try + { + servants[i]->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } } // @@ -571,11 +571,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->setTransientValue(i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->setTransientValue(i); } // @@ -590,7 +590,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } // @@ -598,9 +598,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->keepInCache(); - servants[i]->keepInCache(); - servants[i]->setTransientValue(i); + servants[i]->keepInCache(); + servants[i]->keepInCache(); + servants[i]->setTransientValue(i); } evictor->saveNow(); evictor->setSize(0); @@ -612,7 +612,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -620,14 +620,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -635,14 +635,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } @@ -651,15 +651,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->release(); - test(false); - } - catch(const Test::NotRegisteredException&) - { - // Expected - } + try + { + servants[i]->release(); + test(false); + } + catch(const Test::NotRegisteredException&) + { + // Expected + } } @@ -673,12 +673,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) {
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
- servants[i] = evictor->getServant(id); - test(servants[i]->getValue() == i); + servants[i] = evictor->getServant(id); + test(servants[i]->getValue() == i); } // @@ -689,19 +689,19 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants[0]->destroy(); { - const int threadCount = size * 2; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadThread(servants); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size * 2; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadThread(servants); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -715,35 +715,35 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // CreateDestroy threads // { - const int threadCount = size;; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new CreateDestroyThread(evictor, i, size); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } - - // - // Verify all destroyed - // - for(i = 0; i < size; i++) - { - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } + const int threadCount = size;; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new CreateDestroyThread(evictor, i, size); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } + + // + // Verify all destroyed + // + for(i = 0; i < size; i++) + { + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } } // @@ -752,10 +752,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); } // @@ -763,30 +763,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // (really testing Ice here) // { - const int threadCount = size; - - ReadForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadForeverThread(servants); - threads[i]->start(); - } + const int threadCount = size; + + ReadForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadForeverThread(servants); + threads[i]->start(); + } - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivated); - } + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivated); + } - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -799,30 +799,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // Deactivate in the middle of adds // { - const int threadCount = size; - - AddForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new AddForeverThread(evictor, i); - threads[i]->start(); - } - - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivated); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size; + + AddForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new AddForeverThread(evictor, i); + threads[i]->start(); + } + + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivated); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } diff --git a/cpp/test/Freeze/evictor/Test.ice b/cpp/test/Freeze/evictor/Test.ice index 4ab855c984c..e51e4b39a18 100644 --- a/cpp/test/Freeze/evictor/Test.ice +++ b/cpp/test/Freeze/evictor/Test.ice @@ -61,7 +61,7 @@ interface RemoteEvictor idempotent void setSize(int size); Servant* createServant(string id, int value) - throws AlreadyRegisteredException, EvictorDeactivatedException; + throws AlreadyRegisteredException, EvictorDeactivatedException; idempotent Servant* getServant(string id); diff --git a/cpp/test/Freeze/evictor/TestI.cpp b/cpp/test/Freeze/evictor/TestI.cpp index 04e94256dcf..490d23083ac 100644 --- a/cpp/test/Freeze/evictor/TestI.cpp +++ b/cpp/test/Freeze/evictor/TestI.cpp @@ -20,16 +20,16 @@ class DelayedResponse : public Thread public: DelayedResponse(const Test::AMD_Servant_slowGetValuePtr& cb, int val) : - _cb(cb), - _val(val) + _cb(cb), + _val(val) { } virtual void run() { - ThreadControl::sleep(Time::milliSeconds(500)); - _cb->ice_response(_val); + ThreadControl::sleep(Time::milliSeconds(500)); + _cb->ice_response(_val); } private: @@ -75,7 +75,7 @@ Test::ServantI::slowGetValue(const Current&) const void Test::ServantI::slowGetValue_async(const AMD_Servant_slowGetValuePtr& cb, - const Current&) const + const Current&) const { IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); Monitor<Mutex>::Lock sync(*this); @@ -123,11 +123,11 @@ Test::ServantI::addFacet(const string& name, const string& data, const Current& try { - _evictor->addFacet(facet, current.id, name); + _evictor->addFacet(facet, current.id, name); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } } @@ -136,11 +136,11 @@ Test::ServantI::removeFacet(const string& name, const Current& current) const { try { - _evictor->removeFacet(current.id, name); + _evictor->removeFacet(current.id, name); } catch(const Ice::NotRegisteredException&) { - throw Test::NotRegisteredException(); + throw Test::NotRegisteredException(); } } @@ -170,11 +170,11 @@ Test::ServantI::release(const Current& current) { try { - _evictor->release(current.id); + _evictor->release(current.id); } catch(const Ice::NotRegisteredException&) { - throw NotRegisteredException(); + throw NotRegisteredException(); } } @@ -183,11 +183,11 @@ Test::ServantI::destroy(const Current& current) { try { - _evictor->remove(current.id); + _evictor->remove(current.id); } catch(const Ice::NotRegisteredException&) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -225,7 +225,7 @@ public: void init(const Test::RemoteEvictorIPtr& remoteEvictor, const Freeze::EvictorPtr& evictor) { _remoteEvictor = remoteEvictor; - _evictor = evictor; + _evictor = evictor; } virtual void @@ -243,7 +243,7 @@ private: Test::RemoteEvictorI::RemoteEvictorI(const ObjectAdapterPtr& adapter, const string& envName, - const string& category) : + const string& category) : _adapter(adapter), _category(category) { @@ -275,19 +275,19 @@ Test::RemoteEvictorI::createServant(const string& id, Int value, const Current&) ServantPtr servant = new ServantI(this, _evictor, value); try { - return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); + return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } catch(const Ice::ObjectAdapterDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } catch(const Freeze::EvictorDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } } @@ -327,7 +327,7 @@ Test::RemoteEvictorI::destroyAllServants(const string& facetName, const Current& Freeze::EvictorIteratorPtr p = _evictor->getIterator(facetName, batchSize); while(p->hasNext()) { - _evictor->remove(p->next()); + _evictor->remove(p->next()); } } @@ -344,7 +344,7 @@ Test::RemoteEvictorFactoryI::createEvictor(const string& name, const Current& cu { RemoteEvictorIPtr remoteEvictor = new RemoteEvictorI(_adapter, _envName, name); return RemoteEvictorPrx::uncheckedCast(_adapter->add(remoteEvictor, - _adapter->getCommunicator()->stringToIdentity(name))); + _adapter->getCommunicator()->stringToIdentity(name))); } void diff --git a/cpp/test/Freeze/evictor/TestI.h b/cpp/test/Freeze/evictor/TestI.h index e886473517c..458cf023702 100644 --- a/cpp/test/Freeze/evictor/TestI.h +++ b/cpp/test/Freeze/evictor/TestI.h @@ -41,7 +41,7 @@ public: virtual void slowGetValue_async(const AMD_Servant_slowGetValuePtr&, - const Ice::Current& = Ice::Current()) const; + const Ice::Current& = Ice::Current()) const; virtual void setValue(::Ice::Int, const Ice::Current& = Ice::Current()); diff --git a/cpp/test/Freeze/oldevictor/Client.cpp b/cpp/test/Freeze/oldevictor/Client.cpp index 41ee315faf2..cfafd704ef7 100644 --- a/cpp/test/Freeze/oldevictor/Client.cpp +++ b/cpp/test/Freeze/oldevictor/Client.cpp @@ -29,35 +29,35 @@ class ReadThread : public Thread public: ReadThread(vector<Test::ServantPrx>& servants) : - _servants(servants) + _servants(servants) { } virtual void run() { - int loops = 10; - while(loops-- > 0) - { - try - { - _servants[0]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - catch(...) - { - test(false); - } - - for(int i = 1; i < static_cast<int>(_servants.size()); ++i) - { - test(_servants[i]->getValue() == i); - } - } + int loops = 10; + while(loops-- > 0) + { + try + { + _servants[0]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + catch(...) + { + test(false); + } + + for(int i = 1; i < static_cast<int>(_servants.size()); ++i) + { + test(_servants[i]->getValue() == i); + } + } } private: @@ -71,72 +71,72 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; ReadForeverThread(vector<Test::ServantPrx>& servants) : - _servants(servants), - _state(StateRunning) + _servants(servants), + _state(StateRunning) { } virtual void run() { - for(;;) - { - try - { - for(int i = 0; i < static_cast<int>(_servants.size()); ++i) - { - if(getState() == StateDeactivated) - { - _servants[i]->slowGetValue(); - test(false); - } - else - { - test(_servants[i]->slowGetValue() == i); - } - } - } - catch(const Ice::SocketException&) - { - // - // Expected - // - test(validEx()); - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(...) - { - test(false); - return; - } - } + for(;;) + { + try + { + for(int i = 0; i < static_cast<int>(_servants.size()); ++i) + { + if(getState() == StateDeactivated) + { + _servants[i]->slowGetValue(); + test(false); + } + else + { + test(_servants[i]->slowGetValue() == i); + } + } + } + catch(const Ice::SocketException&) + { + // + // Expected + // + test(validEx()); + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; + test(false); + return; + } + catch(...) + { + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -152,99 +152,99 @@ public: enum State { StateRunning, StateDeactivating, StateDeactivated }; AddForeverThread(const Test::RemoteEvictorPrx& evictor, int prefix) : - _evictor(evictor), - _state(StateRunning) + _evictor(evictor), + _state(StateRunning) { - ostringstream ostr; - ostr << prefix; - _prefix = ostr.str(); + ostringstream ostr; + ostr << prefix; + _prefix = ostr.str(); } virtual void run() { - int index = 0; - - for(;;) - { - ostringstream ostr; - ostr << _prefix << "-" << index; - index++; - string id = ostr.str(); - try - { - if(getState() == StateDeactivated) - { - _evictor->createServant(id, 0); - test(false); - } - else - { - _evictor->createServant(id, 0); - } - } - catch(const Test::EvictorDeactivatedException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::ObjectNotExistException&) - { - test(validEx()); - // - // Expected - // - return; - } - catch(const Ice::LocalException& e) - { - cerr << "Caught unexpected : " << e << endl; - test(false); - return; - } - catch(const IceUtil::Exception& e) - { - cerr << "Caught IceUtil::Exception : " << e << endl; - cerr << "Index is " << index << endl; - test(false); - return; - } - catch(const std::exception& e) - { - cerr << "Caught std::exception : " << e.what() << endl; - test(false); - return; - } - catch(...) - { - cerr << "Caught unknown exception" << endl; + int index = 0; + + for(;;) + { + ostringstream ostr; + ostr << _prefix << "-" << index; + index++; + string id = ostr.str(); + try + { + if(getState() == StateDeactivated) + { + _evictor->createServant(id, 0); + test(false); + } + else + { + _evictor->createServant(id, 0); + } + } + catch(const Test::EvictorDeactivatedException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::ObjectNotExistException&) + { + test(validEx()); + // + // Expected + // + return; + } + catch(const Ice::LocalException& e) + { + cerr << "Caught unexpected : " << e << endl; test(false); - return; - } - } + return; + } + catch(const IceUtil::Exception& e) + { + cerr << "Caught IceUtil::Exception : " << e << endl; + cerr << "Index is " << index << endl; + test(false); + return; + } + catch(const std::exception& e) + { + cerr << "Caught std::exception : " << e.what() << endl; + test(false); + return; + } + catch(...) + { + cerr << "Caught unknown exception" << endl; + test(false); + return; + } + } } State getState() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state; } bool validEx() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - return _state == StateDeactivating || _state == StateDeactivated; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + return _state == StateDeactivating || _state == StateDeactivated; } void setState(State s) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); - _state = s; + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + _state = s; } private: @@ -259,96 +259,96 @@ class CreateDestroyThread : public Thread public: CreateDestroyThread(const Test::RemoteEvictorPrx& evictor, int id, int size) : - _evictor(evictor), - _size(size) + _evictor(evictor), + _size(size) { - ostringstream ostr; - ostr << id; - _id = ostr.str(); + ostringstream ostr; + ostr << id; + _id = ostr.str(); } virtual void run() { - try - { - int loops = 50; - while(loops-- > 0) - { - for(int i = 0; i < _size; i++) - { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - if(id == _id) - { - // - // Create when odd, destroy when even. - // - - if(loops % 2 == 0) - { - Test::ServantPrx servant = _evictor->getServant(id); - servant->destroy(); - - // - // Twice - // - try - { - servant->destroy(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } - else - { - Test::ServantPrx servant = _evictor->createServant(id, i); - - // - // Twice - // - try - { - servant = _evictor->createServant(id, 0); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - // Expected - } - } - } - else - { - // - // Just read/write the value - // - Test::ServantPrx servant = _evictor->getServant(id); - try - { - int val = servant->getValue(); - test(val == i || val == -i); - servant->setValue(-val); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected from time to time - } - } - } - } - } - catch(...) - { - // - // Unexpected! - // - test(false); - } + try + { + int loops = 50; + while(loops-- > 0) + { + for(int i = 0; i < _size; i++) + { + ostringstream ostr; + ostr << i; + string id = ostr.str(); + if(id == _id) + { + // + // Create when odd, destroy when even. + // + + if(loops % 2 == 0) + { + Test::ServantPrx servant = _evictor->getServant(id); + servant->destroy(); + + // + // Twice + // + try + { + servant->destroy(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } + else + { + Test::ServantPrx servant = _evictor->createServant(id, i); + + // + // Twice + // + try + { + servant = _evictor->createServant(id, 0); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + // Expected + } + } + } + else + { + // + // Just read/write the value + // + Test::ServantPrx servant = _evictor->getServant(id); + try + { + int val = servant->getValue(); + test(val == i || val == -i); + servant->setValue(-val); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected from time to time + } + } + } + } + } + catch(...) + { + // + // Unexpected! + // + test(false); + } } private: Test::RemoteEvictorPrx _evictor; @@ -379,32 +379,32 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) vector<Test::ServantPrx> servants; for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->ice_ping(); - - Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); - try - { - facet1->ice_ping(); - test(false); - } - catch(const Ice::FacetNotExistException&) - { - // Expected - } - - servants[i]->addFacet("facet1", "data"); - facet1->ice_ping(); - facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i); - facet1->addFacet("facet2", "moreData"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->ice_ping(); + + Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1"); + try + { + facet1->ice_ping(); + test(false); + } + catch(const Ice::FacetNotExistException&) + { + // Expected + } + + servants[i]->addFacet("facet1", "data"); + facet1->ice_ping(); + facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i); + facet1->addFacet("facet2", "moreData"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i); } // @@ -414,14 +414,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i); - test(facet1->getData() == "data"); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getData() == "moreData"); + test(servants[i]->getValue() == i); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i); + test(facet1->getData() == "data"); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getData() == "moreData"); } // @@ -429,13 +429,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->setValue(i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - facet1->setValue(10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - facet2->setValue(100 * i + 100); + servants[i]->setValue(i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + facet1->setValue(10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + facet2->setValue(100 * i + 100); } // @@ -445,13 +445,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 100); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1); - test(facet1->getValue() == 10 * i + 100); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); - test(facet2); - test(facet2->getValue() == 100 * i + 100); + test(servants[i]->getValue() == i + 100); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1); + test(facet1->getValue() == 10 * i + 100); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2"); + test(facet2); + test(facet2->getValue() == 100 * i + 100); } // // Test saving while busy @@ -459,24 +459,24 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Test::AMI_Servant_setValueAsyncPtr setCB = new AMI_Servant_setValueAsyncI; for(i = 0; i < size; i++) { - // - // Start a mutating operation so that the object is not idle. - // - servants[i]->setValueAsync_async(setCB, i + 300); - - test(servants[i]->getValue() == i + 100); - // - // This operation modifies the object state but is not saved - // because the setValueAsync operation is still pending. - // - servants[i]->setValue(i + 200); - test(servants[i]->getValue() == i + 200); + // + // Start a mutating operation so that the object is not idle. + // + servants[i]->setValueAsync_async(setCB, i + 300); + + test(servants[i]->getValue() == i + 100); + // + // This operation modifies the object state but is not saved + // because the setValueAsync operation is still pending. + // + servants[i]->setValue(i + 200); + test(servants[i]->getValue() == i + 200); - // - // Force the response to setValueAsync - // - servants[i]->releaseAsync(); - test(servants[i]->getValue() == i + 300); + // + // Force the response to setValueAsync + // + servants[i]->releaseAsync(); + test(servants[i]->getValue() == i + 300); } // @@ -484,14 +484,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->addFacet("facet1", "foobar"); - test(false); - } - catch(const Test::AlreadyRegisteredException&) - { - } + try + { + servants[i]->addFacet("facet1", "foobar"); + test(false); + } + catch(const Test::AlreadyRegisteredException&) + { + } } // @@ -499,8 +499,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // try { - servants[0]->removeFacet("facet3"); - test(false); + servants[0]->removeFacet("facet3"); + test(false); } catch(const Test::NotRegisteredException&) { @@ -512,8 +512,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->removeFacet("facet1"); - servants[i]->removeFacet("facet2"); + servants[i]->removeFacet("facet1"); + servants[i]->removeFacet("facet2"); } // @@ -521,10 +521,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); - Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); - test(facet2 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); + Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2"); + test(facet2 == 0); } evictor->setSize(0); @@ -532,10 +532,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(i = 0; i < size; i++) { - test(servants[i]->getValue() == i + 300); + test(servants[i]->getValue() == i + 300); - Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); - test(facet1 == 0); + Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1"); + test(facet1 == 0); } // @@ -543,26 +543,26 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->destroy(); - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - - try - { - servants[i]->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } + servants[i]->destroy(); + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + + try + { + servants[i]->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } } // @@ -571,11 +571,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); - servants[i]->setTransientValue(i); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); + servants[i]->setTransientValue(i); } // @@ -590,7 +590,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } // @@ -598,9 +598,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->keepInCache(); - servants[i]->keepInCache(); - servants[i]->setTransientValue(i); + servants[i]->keepInCache(); + servants[i]->keepInCache(); + servants[i]->setTransientValue(i); } evictor->saveNow(); evictor->setSize(0); @@ -612,7 +612,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -620,14 +620,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == i); + test(servants[i]->getTransientValue() == i); } // @@ -635,14 +635,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - servants[i]->release(); + servants[i]->release(); } evictor->saveNow(); evictor->setSize(0); evictor->setSize(size); for(i = 0; i < size; i++) { - test(servants[i]->getTransientValue() == -1); + test(servants[i]->getTransientValue() == -1); } @@ -651,15 +651,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // for(i = 0; i < size; i++) { - try - { - servants[i]->release(); - test(false); - } - catch(const Test::NotRegisteredException&) - { - // Expected - } + try + { + servants[i]->release(); + test(false); + } + catch(const Test::NotRegisteredException&) + { + // Expected + } } @@ -673,12 +673,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) evictor->setSize(size); for(i = 0; i < size; i++) {
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
- servants[i] = evictor->getServant(id); - test(servants[i]->getValue() == i); + servants[i] = evictor->getServant(id); + test(servants[i]->getValue() == i); } // @@ -689,19 +689,19 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants[0]->destroy(); { - const int threadCount = size * 2; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadThread(servants); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size * 2; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadThread(servants); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -715,35 +715,35 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // CreateDestroy threads // { - const int threadCount = size;; - - ThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new CreateDestroyThread(evictor, i, size); - threads[i]->start(); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } - - // - // Verify all destroyed - // - for(i = 0; i < size; i++) - { - try - { - servants[i]->getValue(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - // Expected - } - } + const int threadCount = size;; + + ThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new CreateDestroyThread(evictor, i, size); + threads[i]->start(); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } + + // + // Verify all destroyed + // + for(i = 0; i < size; i++) + { + try + { + servants[i]->getValue(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + // Expected + } + } } // @@ -752,10 +752,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) servants.clear(); for(i = 0; i < size; i++) { - ostringstream ostr; - ostr << i; - string id = ostr.str(); - servants.push_back(evictor->createServant(id, i)); + ostringstream ostr; + ostr << i; + string id = ostr.str(); + servants.push_back(evictor->createServant(id, i)); } // @@ -763,30 +763,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // (really testing Ice here) // { - const int threadCount = size; - - ReadForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new ReadForeverThread(servants); - threads[i]->start(); - } + const int threadCount = size; + + ReadForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new ReadForeverThread(servants); + threads[i]->start(); + } - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(ReadForeverThread::StateDeactivated); - } + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(ReadForeverThread::StateDeactivated); + } - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } // @@ -799,30 +799,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // Deactivate in the middle of adds // { - const int threadCount = size; - - AddForeverThreadPtr threads[threadCount]; - for(i = 0; i < threadCount; i++) - { - threads[i] = new AddForeverThread(evictor, i); - threads[i]->start(); - } - - ThreadControl::sleep(Time::milliSeconds(500)); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivating); - } - evictor->deactivate(); - for(i = 0; i < threadCount; i++) - { - threads[i]->setState(AddForeverThread::StateDeactivated); - } - - for(i = 0; i < threadCount; i++) - { - threads[i]->getThreadControl().join(); - } + const int threadCount = size; + + AddForeverThreadPtr threads[threadCount]; + for(i = 0; i < threadCount; i++) + { + threads[i] = new AddForeverThread(evictor, i); + threads[i]->start(); + } + + ThreadControl::sleep(Time::milliSeconds(500)); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivating); + } + evictor->deactivate(); + for(i = 0; i < threadCount; i++) + { + threads[i]->setState(AddForeverThread::StateDeactivated); + } + + for(i = 0; i < threadCount; i++) + { + threads[i]->getThreadControl().join(); + } } diff --git a/cpp/test/Freeze/oldevictor/Test.ice b/cpp/test/Freeze/oldevictor/Test.ice index f1ee08793eb..61610763814 100644 --- a/cpp/test/Freeze/oldevictor/Test.ice +++ b/cpp/test/Freeze/oldevictor/Test.ice @@ -61,7 +61,7 @@ interface RemoteEvictor void setSize(int size); Servant* createServant(string id, int value) - throws AlreadyRegisteredException, EvictorDeactivatedException; + throws AlreadyRegisteredException, EvictorDeactivatedException; Servant* getServant(string id); diff --git a/cpp/test/Freeze/oldevictor/TestI.cpp b/cpp/test/Freeze/oldevictor/TestI.cpp index 9b2850c9397..2e88f875e28 100644 --- a/cpp/test/Freeze/oldevictor/TestI.cpp +++ b/cpp/test/Freeze/oldevictor/TestI.cpp @@ -20,16 +20,16 @@ class DelayedResponse : public Thread public: DelayedResponse(const Test::AMD_Servant_slowGetValuePtr& cb, int val) : - _cb(cb), - _val(val) + _cb(cb), + _val(val) { } virtual void run() { - ThreadControl::sleep(Time::milliSeconds(500)); - _cb->ice_response(_val); + ThreadControl::sleep(Time::milliSeconds(500)); + _cb->ice_response(_val); } private: @@ -75,7 +75,7 @@ Test::ServantI::slowGetValue(const Current&) const void Test::ServantI::slowGetValue_async(const AMD_Servant_slowGetValuePtr& cb, - const Current&) const + const Current&) const { IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); Monitor<Mutex>::Lock sync(*this); @@ -122,11 +122,11 @@ Test::ServantI::addFacet(const string& name, const string& data, const Current& try { - _evictor->addFacet(facet, current.id, name); + _evictor->addFacet(facet, current.id, name); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } } @@ -135,11 +135,11 @@ Test::ServantI::removeFacet(const string& name, const Current& current) const { try { - _evictor->removeFacet(current.id, name); + _evictor->removeFacet(current.id, name); } catch(const Ice::NotRegisteredException&) { - throw Test::NotRegisteredException(); + throw Test::NotRegisteredException(); } } @@ -169,11 +169,11 @@ Test::ServantI::release(const Current& current) { try { - _evictor->release(current.id); + _evictor->release(current.id); } catch(const Ice::NotRegisteredException&) { - throw NotRegisteredException(); + throw NotRegisteredException(); } } @@ -182,11 +182,11 @@ Test::ServantI::destroy(const Current& current) { try { - _evictor->remove(current.id); + _evictor->remove(current.id); } catch(const Ice::NotRegisteredException&) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -224,7 +224,7 @@ public: void init(const Test::RemoteEvictorIPtr& remoteEvictor, const Freeze::EvictorPtr& evictor) { _remoteEvictor = remoteEvictor; - _evictor = evictor; + _evictor = evictor; } virtual void @@ -242,7 +242,7 @@ private: Test::RemoteEvictorI::RemoteEvictorI(const ObjectAdapterPtr& adapter, const string& envName, - const string& category) : + const string& category) : _adapter(adapter), _category(category) { @@ -274,19 +274,19 @@ Test::RemoteEvictorI::createServant(const string& id, Int value, const Current&) ServantPtr servant = new ServantI(this, _evictor, value); try { - return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); + return ServantPrx::uncheckedCast(_evictor->add(servant, ident)); } catch(const Ice::AlreadyRegisteredException&) { - throw Test::AlreadyRegisteredException(); + throw Test::AlreadyRegisteredException(); } catch(const Ice::ObjectAdapterDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } catch(const Freeze::EvictorDeactivatedException&) { - throw EvictorDeactivatedException(); + throw EvictorDeactivatedException(); } } @@ -326,7 +326,7 @@ Test::RemoteEvictorI::destroyAllServants(const string& facetName, const Current& Freeze::EvictorIteratorPtr p = _evictor->getIterator(facetName, batchSize); while(p->hasNext()) { - _evictor->remove(p->next()); + _evictor->remove(p->next()); } } @@ -343,7 +343,7 @@ Test::RemoteEvictorFactoryI::createEvictor(const string& name, const Current& cu { RemoteEvictorIPtr remoteEvictor = new RemoteEvictorI(_adapter, _envName, name); return RemoteEvictorPrx::uncheckedCast(_adapter->add(remoteEvictor, - _adapter->getCommunicator()->stringToIdentity(name))); + _adapter->getCommunicator()->stringToIdentity(name))); } void diff --git a/cpp/test/Freeze/oldevictor/TestI.h b/cpp/test/Freeze/oldevictor/TestI.h index 3f7ac3af396..cef09c3d6ad 100644 --- a/cpp/test/Freeze/oldevictor/TestI.h +++ b/cpp/test/Freeze/oldevictor/TestI.h @@ -41,7 +41,7 @@ public: virtual void slowGetValue_async(const AMD_Servant_slowGetValuePtr&, - const Ice::Current& = Ice::Current()) const; + const Ice::Current& = Ice::Current()) const; virtual void setValue(::Ice::Int, const Ice::Current& = Ice::Current()); diff --git a/cpp/test/FreezeScript/dbmap/run.py b/cpp/test/FreezeScript/dbmap/run.py index 362b3401e61..dcb1d9e6078 100755 --- a/cpp/test/FreezeScript/dbmap/run.py +++ b/cpp/test/FreezeScript/dbmap/run.py @@ -65,10 +65,10 @@ for oldfile in files: value = "int" command = transformdb + " --old " + os.path.join(directory, "fail", oldfile) + " --new " + \ - os.path.join(directory, "fail", newfile) + " -o tmp.xml --key string --value " + value + os.path.join(directory, "fail", newfile) + " -o tmp.xml --key string --value " + value if TestUtil.debug: - print command + print command stdin, stdout, stderr = os.popen3(command) lines1 = stderr.readlines() diff --git a/cpp/test/FreezeScript/evictor/makedb.cpp b/cpp/test/FreezeScript/evictor/makedb.cpp index 7adc199bb00..2a765c03322 100644 --- a/cpp/test/FreezeScript/evictor/makedb.cpp +++ b/cpp/test/FreezeScript/evictor/makedb.cpp @@ -74,7 +74,7 @@ run(const Ice::CommunicatorPtr& communicator, const string& envName, const strin for(int i = 0; i < 10; ++i) { - string facetName = "theFacet"; + string facetName = "theFacet"; Ice::Identity id; ostringstream ostr; diff --git a/cpp/test/Glacier2/attack/Client.cpp b/cpp/test/Glacier2/attack/Client.cpp index 0bea57e6931..113df36526c 100644 --- a/cpp/test/Glacier2/attack/Client.cpp +++ b/cpp/test/Glacier2/attack/Client.cpp @@ -36,7 +36,7 @@ main(int argc, char* argv[]) // proxies, even with regular retries disabled. // initData.properties->setProperty("Ice.RetryIntervals", "-1"); - + AttackClient app; return app.main(argc, argv, initData); } @@ -65,48 +65,48 @@ AttackClient::run(int argc, char* argv[]) string msg; for(int i = 1; i <= 10000; ++i) { - if(i % 100 == 0) - { - if(!msg.empty()) - { - cout << string(msg.size(), '\b'); - } - ostringstream s; - s << i; - msg = s.str(); - cout << msg << flush; - } - - Identity ident; - string::iterator p; - - ident.name.resize(1); // 1 + IceUtil::random() % 2); - for(p = ident.name.begin(); p != ident.name.end(); ++p) - { - *p = static_cast<char>('A' + IceUtil::random() % 26); - } - - ident.category.resize(IceUtil::random() % 2); - for(p = ident.category.begin(); p != ident.category.end(); ++p) - { - *p = static_cast<char>('a' + IceUtil::random() % 26); - } - - BackendPrx newBackend = BackendPrx::uncheckedCast(backendBase->ice_identity(ident)); - - set<BackendPrx>::const_iterator q = backends.find(newBackend); - - if(q == backends.end()) - { - backends.insert(newBackend); - backend = newBackend; - } - else - { - backend = *q; - } - - backend->ice_ping(); + if(i % 100 == 0) + { + if(!msg.empty()) + { + cout << string(msg.size(), '\b'); + } + ostringstream s; + s << i; + msg = s.str(); + cout << msg << flush; + } + + Identity ident; + string::iterator p; + + ident.name.resize(1); // 1 + IceUtil::random() % 2); + for(p = ident.name.begin(); p != ident.name.end(); ++p) + { + *p = static_cast<char>('A' + IceUtil::random() % 26); + } + + ident.category.resize(IceUtil::random() % 2); + for(p = ident.category.begin(); p != ident.category.end(); ++p) + { + *p = static_cast<char>('a' + IceUtil::random() % 26); + } + + BackendPrx newBackend = BackendPrx::uncheckedCast(backendBase->ice_identity(ident)); + + set<BackendPrx>::const_iterator q = backends.find(newBackend); + + if(q == backends.end()) + { + backends.insert(newBackend); + backend = newBackend; + } + else + { + backend = *q; + } + + backend->ice_ping(); } cout << string(msg.size(), '\b') << string(msg.size(), ' ') << string(msg.size(), '\b'); cout << "ok" << endl; @@ -120,12 +120,12 @@ AttackClient::run(int argc, char* argv[]) admin->shutdown(); try { - admin->ice_ping(); - test(false); + admin->ice_ping(); + test(false); } catch(const Ice::LocalException&) { - cout << "ok" << endl; + cout << "ok" << endl; } return EXIT_SUCCESS; diff --git a/cpp/test/Glacier2/attack/Server.cpp b/cpp/test/Glacier2/attack/Server.cpp index 1b5d8627065..87eb2268cb5 100644 --- a/cpp/test/Glacier2/attack/Server.cpp +++ b/cpp/test/Glacier2/attack/Server.cpp @@ -19,13 +19,13 @@ class ServantLocatorI : virtual public ServantLocator public: ServantLocatorI() : - _backend(new BackendI) + _backend(new BackendI) { } - + virtual ObjectPtr locate(const Current&, LocalObjectPtr&) { - return _backend; + return _backend; } virtual void finished(const Current&, const ObjectPtr&, const LocalObjectPtr&) diff --git a/cpp/test/Glacier2/dynamicFiltering/Client.cpp b/cpp/test/Glacier2/dynamicFiltering/Client.cpp index 8bb4deddf17..ee19c221a6e 100755 --- a/cpp/test/Glacier2/dynamicFiltering/Client.cpp +++ b/cpp/test/Glacier2/dynamicFiltering/Client.cpp @@ -36,7 +36,7 @@ main(int argc, char* argv[]) // initData.properties->setProperty("Ice.RetryIntervals", "-1"); initData.properties->setProperty("Ice.Warn.Connections", "0"); - + SessionControlClient app; return app.main(argc, argv, initData); } @@ -51,7 +51,7 @@ SessionControlClient::run(int argc, char* argv[]) cout << "accessing test controller... " << flush; Ice::CommunicatorPtr controlComm = Ice::initialize(argc, argv, initData); TestControllerPrx controller = TestControllerPrx::checkedCast( - controlComm->stringToProxy("testController:tcp -p 12013")); + controlComm->stringToProxy("testController:tcp -p 12013")); test(controller); TestToken currentState; TestToken newState; @@ -73,61 +73,61 @@ SessionControlClient::run(int argc, char* argv[]) bool printOk = false; while(currentState.code == Running) { - controller->step(currentSession, currentState, newState); - currentState = newState; - - if(currentState.code != Running) - { - cout << "ok" << endl; - break; - } - - // - // If we are running the first case for this configuration, print the configuration description. - // - if(currentState.caseIndex == 0) - { - if(printOk) - { - cout << "ok" << endl; - } - else - { - printOk = true; - } - cout << currentState.description << "... " << flush; - } - - if(currentState.expectedResult) - { - BackendPrx prx = BackendPrx::uncheckedCast(communicator()->stringToProxy(currentState.testReference)); - try - { - prx->check(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - test(false); - } - } - else - { - BackendPrx prx = BackendPrx::uncheckedCast(communicator()->stringToProxy(currentState.testReference)); - try - { - prx->check(); - test(false); - } - catch(const ObjectNotExistException&) - { - } - catch(const Exception& ex) - { - cerr << ex << endl; - test(false); - } - } + controller->step(currentSession, currentState, newState); + currentState = newState; + + if(currentState.code != Running) + { + cout << "ok" << endl; + break; + } + + // + // If we are running the first case for this configuration, print the configuration description. + // + if(currentState.caseIndex == 0) + { + if(printOk) + { + cout << "ok" << endl; + } + else + { + printOk = true; + } + cout << currentState.description << "... " << flush; + } + + if(currentState.expectedResult) + { + BackendPrx prx = BackendPrx::uncheckedCast(communicator()->stringToProxy(currentState.testReference)); + try + { + prx->check(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + test(false); + } + } + else + { + BackendPrx prx = BackendPrx::uncheckedCast(communicator()->stringToProxy(currentState.testReference)); + try + { + prx->check(); + test(false); + } + catch(const ObjectNotExistException&) + { + } + catch(const Exception& ex) + { + cerr << ex << endl; + test(false); + } + } } // @@ -135,7 +135,7 @@ SessionControlClient::run(int argc, char* argv[]) // try { - router->destroySession(); + router->destroySession(); } catch(const ConnectionLostException&) { @@ -148,16 +148,16 @@ SessionControlClient::run(int argc, char* argv[]) try { - // - // Shut down the test server. - // - currentSession = Test::TestSessionPrx::uncheckedCast(router->createSession("userid", "abc123")); - currentSession->shutdown(); + // + // Shut down the test server. + // + currentSession = Test::TestSessionPrx::uncheckedCast(router->createSession("userid", "abc123")); + currentSession->shutdown(); } catch(const Glacier2::CannotCreateSessionException& ex) { - cerr << ex.reason << endl; - throw ex; + cerr << ex.reason << endl; + throw ex; } // @@ -170,12 +170,12 @@ SessionControlClient::run(int argc, char* argv[]) admin->shutdown(); try { - admin->ice_ping(); - test(false); + admin->ice_ping(); + test(false); } catch(const Ice::LocalException&) { - cout << "ok" << endl; + cout << "ok" << endl; } return EXIT_SUCCESS; diff --git a/cpp/test/Glacier2/dynamicFiltering/Server.cpp b/cpp/test/Glacier2/dynamicFiltering/Server.cpp index 7c25807d0fe..c40fa198d0c 100755 --- a/cpp/test/Glacier2/dynamicFiltering/Server.cpp +++ b/cpp/test/Glacier2/dynamicFiltering/Server.cpp @@ -29,23 +29,23 @@ public: virtual void setAdapterDirectProxy_async(const AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb, const string&, - const ObjectPrx&, const Current&) + const ObjectPrx&, const Current&) { - cb->ice_response(); + cb->ice_response(); } virtual void setReplicatedAdapterDirectProxy_async(const AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr& cb, - const string&, const string&, const ObjectPrx&, const Current&) + const string&, const string&, const ObjectPrx&, const Current&) { - cb->ice_response(); + cb->ice_response(); } virtual void setServerProcessProxy_async(const AMD_LocatorRegistry_setServerProcessProxyPtr& cb, - const string&, const ProcessPrx&, const Current&) + const string&, const ProcessPrx&, const Current&) { - cb->ice_response(); + cb->ice_response(); } }; @@ -53,29 +53,29 @@ class ServerLocatorI : virtual public Locator { public: ServerLocatorI(BackendPtr backend, ObjectAdapterPtr adapter) : - _backend(backend), - _adapter(adapter) + _backend(backend), + _adapter(adapter) { - _registryPrx = LocatorRegistryPrx::uncheckedCast(adapter->add(new ServerLocatorRegistry, - _adapter->getCommunicator()->stringToIdentity("registry"))); + _registryPrx = LocatorRegistryPrx::uncheckedCast(adapter->add(new ServerLocatorRegistry, + _adapter->getCommunicator()->stringToIdentity("registry"))); } virtual void findObjectById_async(const AMD_Locator_findObjectByIdPtr& cb, const Identity& id, const Current&) const { - cb->ice_response(_adapter->createProxy(id)); + cb->ice_response(_adapter->createProxy(id)); } virtual void findAdapterById_async(const AMD_Locator_findAdapterByIdPtr& cb, const string& id, const Current& current) const { - cb->ice_response(_adapter->createDirectProxy(_adapter->getCommunicator()->stringToIdentity("dummy"))); + cb->ice_response(_adapter->createDirectProxy(_adapter->getCommunicator()->stringToIdentity("dummy"))); } virtual LocatorRegistryPrx getRegistry(const Current&) const { - return _registryPrx; + return _registryPrx; } private: @@ -89,13 +89,13 @@ class ServantLocatorI : virtual public ServantLocator public: ServantLocatorI(const BackendPtr& backend) : - _backend(backend) + _backend(backend) { } - + virtual ObjectPtr locate(const Current&, LocalObjectPtr&) { - return _backend; + return _backend; } virtual void finished(const Current&, const ObjectPtr&, const LocalObjectPtr&) diff --git a/cpp/test/Glacier2/dynamicFiltering/SessionI.cpp b/cpp/test/Glacier2/dynamicFiltering/SessionI.cpp index 3e3d70739a4..a17c975b53d 100755 --- a/cpp/test/Glacier2/dynamicFiltering/SessionI.cpp +++ b/cpp/test/Glacier2/dynamicFiltering/SessionI.cpp @@ -22,7 +22,7 @@ Glacier2::SessionPrx SessionManagerI::create(const string&, const Glacier2::SessionControlPrx& sessionControl, const Ice::Current& current) { Glacier2::SessionPrx newSession = Glacier2::SessionPrx::uncheckedCast( - current.adapter->addWithUUID(new SessionI(sessionControl, _controller))); + current.adapter->addWithUUID(new SessionI(sessionControl, _controller))); _controller->addSession(SessionTuple(newSession, sessionControl)); return newSession; } diff --git a/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp b/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp index c209c03356f..16b434716ab 100755 --- a/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp +++ b/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp @@ -57,101 +57,101 @@ TestControllerI::TestControllerI() void TestControllerI::step(const Glacier2::SessionPrx& currentSession, const TestToken& currentState, TestToken& newState, - const Ice::Current& current) + const Ice::Current& current) { switch(currentState.code) { - case Test::Finished: - { - assert("TestController::step() shouldn't have been called with a state of Finished" == 0); - break; - } - - case Test::Running: - { - TestConfiguration& config = _configurations[currentState.config]; - assert(!config.description.empty()); - - - bool found = false; - SessionTuple session; - for(vector<SessionTuple>::const_iterator i = _sessions.begin(); i != _sessions.end() && !found; ++i) - { - if(i->session == currentSession) - { - session = *i; - found = true; - } - } - - assert(found); - - // - // New sessions force configuration step. - // - bool reconfigure = !session.configured; - - // - // We start with the previous known state. - // - newState = currentState; - - ++newState.caseIndex; - if(!(newState.caseIndex < (long)config.cases.size())) - { - // - // We are out of test cases for this configuration. Move to - // the next configuration. - // - ++newState.config; - if(!(newState.config < (long)_configurations.size())) - { - newState.code = Test::Finished; - newState.expectedResult = false; - newState.description = "No more tests"; - newState.testReference = ""; - newState.config = -1; - newState.caseIndex = -1; - return; - } - - // - // New test configuration! - // - config = _configurations[newState.config]; - - newState.description = config.description; - newState.caseIndex = 0; - reconfigure = true; - } - newState.expectedResult = config.cases[newState.caseIndex].expectedResult; - newState.testReference = config.cases[newState.caseIndex].proxy; - - if(reconfigure) - { - Glacier2::StringSetPrx categories = session.sessionControl->categories(); - categories->add(config.categoryFiltersAccept); - - Glacier2::StringSetPrx adapterIds = session.sessionControl->adapterIds(); - adapterIds->add(config.adapterIdFiltersAccept); - - Glacier2::IdentitySetPrx ids = session.sessionControl->identities(); - ids->add(config.objectIdFiltersAccept); - session.configured = true; - } - break; - } - - default: - { - newState.code = Running; - newState.config = 0; - newState.caseIndex = 0; - newState.testReference = ""; - newState.description = "Initial running state"; - newState.expectedResult = false; - break; - } + case Test::Finished: + { + assert("TestController::step() shouldn't have been called with a state of Finished" == 0); + break; + } + + case Test::Running: + { + TestConfiguration& config = _configurations[currentState.config]; + assert(!config.description.empty()); + + + bool found = false; + SessionTuple session; + for(vector<SessionTuple>::const_iterator i = _sessions.begin(); i != _sessions.end() && !found; ++i) + { + if(i->session == currentSession) + { + session = *i; + found = true; + } + } + + assert(found); + + // + // New sessions force configuration step. + // + bool reconfigure = !session.configured; + + // + // We start with the previous known state. + // + newState = currentState; + + ++newState.caseIndex; + if(!(newState.caseIndex < (long)config.cases.size())) + { + // + // We are out of test cases for this configuration. Move to + // the next configuration. + // + ++newState.config; + if(!(newState.config < (long)_configurations.size())) + { + newState.code = Test::Finished; + newState.expectedResult = false; + newState.description = "No more tests"; + newState.testReference = ""; + newState.config = -1; + newState.caseIndex = -1; + return; + } + + // + // New test configuration! + // + config = _configurations[newState.config]; + + newState.description = config.description; + newState.caseIndex = 0; + reconfigure = true; + } + newState.expectedResult = config.cases[newState.caseIndex].expectedResult; + newState.testReference = config.cases[newState.caseIndex].proxy; + + if(reconfigure) + { + Glacier2::StringSetPrx categories = session.sessionControl->categories(); + categories->add(config.categoryFiltersAccept); + + Glacier2::StringSetPrx adapterIds = session.sessionControl->adapterIds(); + adapterIds->add(config.adapterIdFiltersAccept); + + Glacier2::IdentitySetPrx ids = session.sessionControl->identities(); + ids->add(config.objectIdFiltersAccept); + session.configured = true; + } + break; + } + + default: + { + newState.code = Running; + newState.config = 0; + newState.caseIndex = 0; + newState.testReference = ""; + newState.description = "Initial running state"; + newState.expectedResult = false; + break; + } } } @@ -172,10 +172,10 @@ TestControllerI::notifyDestroy(const Glacier2::SessionControlPrx& control) { for(vector<SessionTuple>::iterator i = _sessions.begin(); i != _sessions.end(); ++i) { - if(i->sessionControl == control) - { - _sessions.erase(i); - break; - } + if(i->sessionControl == control) + { + _sessions.erase(i); + break; + } } } diff --git a/cpp/test/Glacier2/dynamicFiltering/TestControllerI.h b/cpp/test/Glacier2/dynamicFiltering/TestControllerI.h index 59e3b51cf02..20b3efaadeb 100644 --- a/cpp/test/Glacier2/dynamicFiltering/TestControllerI.h +++ b/cpp/test/Glacier2/dynamicFiltering/TestControllerI.h @@ -25,22 +25,22 @@ struct SessionTuple SessionTuple() {} SessionTuple(Glacier2::SessionPrx s, Glacier2::SessionControlPrx control): - session(s), - sessionControl(control), - configured(false) + session(s), + sessionControl(control), + configured(false) {} SessionTuple& operator=(const SessionTuple& rhs) { - if(this == &rhs) - { - return *this; - } - - session = rhs.session; - sessionControl = rhs.sessionControl; - return *this; + if(this == &rhs) + { + return *this; + } + + session = rhs.session; + sessionControl = rhs.sessionControl; + return *this; } }; @@ -78,7 +78,7 @@ public: // Slice to C++ mapping. // void step(const Glacier2::SessionPrx& currentSession, const Test::TestToken& currentState, - Test::TestToken& newState, const Ice::Current&); + Test::TestToken& newState, const Ice::Current&); void shutdown(const Ice::Current&); diff --git a/cpp/test/Glacier2/dynamicFiltering/run.py b/cpp/test/Glacier2/dynamicFiltering/run.py index afa4600299e..a4c8dd1ebad 100755 --- a/cpp/test/Glacier2/dynamicFiltering/run.py +++ b/cpp/test/Glacier2/dynamicFiltering/run.py @@ -37,9 +37,9 @@ command = router + TestUtil.clientServerOptions + \ r' --Ice.OA.Glacier2.Client.Endpoints="default -p 12347 -t 10000"' + \ r' --Ice.OA.Glacier2.Admin.Endpoints="tcp -h 127.0.0.1 -p 12348 -t 10000"' + \ r' --Ice.OA.Glacier2.Server.Endpoints="default -p 12349 -t 10000"' + \ - r' --Glacier2.SessionManager="SessionManager:tcp -h 127.0.0.1 -p 12010 -t 10000"' + \ - r' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' + \ - r' --Ice.Default.Locator="locator:default -h 127.0.0.1 -p 12012 -t 10000"' + r' --Glacier2.SessionManager="SessionManager:tcp -h 127.0.0.1 -p 12010 -t 10000"' + \ + r' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' + \ + r' --Ice.Default.Locator="locator:default -h 127.0.0.1 -p 12012 -t 10000"' print "starting router...", starterPipe = os.popen(command + " 2>&1") diff --git a/cpp/test/Glacier2/router/Callback.ice b/cpp/test/Glacier2/router/Callback.ice index 73057f0ba53..4188edd551c 100644 --- a/cpp/test/Glacier2/router/Callback.ice +++ b/cpp/test/Glacier2/router/Callback.ice @@ -26,7 +26,7 @@ interface CallbackReceiver ["ami"] void callback(); ["ami"] void callbackEx() - throws CallbackException; + throws CallbackException; ["amd", "ami"] int concurrentCallback(int number); @@ -40,7 +40,7 @@ interface Callback ["amd"] void initiateCallback(CallbackReceiver* proxy); ["amd"] void initiateCallbackEx(CallbackReceiver* proxy) - throws CallbackException; + throws CallbackException; ["amd", "ami"] int initiateConcurrentCallback(int number, CallbackReceiver* proxy); diff --git a/cpp/test/Glacier2/router/CallbackI.cpp b/cpp/test/Glacier2/router/CallbackI.cpp index c3bc09db876..9c0a2e19062 100644 --- a/cpp/test/Glacier2/router/CallbackI.cpp +++ b/cpp/test/Glacier2/router/CallbackI.cpp @@ -20,20 +20,20 @@ class AMI_CallbackReceiver_callbackI : public AMI_CallbackReceiver_callback public: AMI_CallbackReceiver_callbackI(const AMD_Callback_initiateCallbackPtr cb) : - _cb(cb) + _cb(cb) { } virtual void ice_response() { - _cb->ice_response(); + _cb->ice_response(); } virtual void ice_exception(const Exception& e) { - _cb->ice_exception(e); + _cb->ice_exception(e); } private: @@ -46,20 +46,20 @@ class AMI_CallbackReceiver_callbackExI : public AMI_CallbackReceiver_callbackEx public: AMI_CallbackReceiver_callbackExI(const AMD_Callback_initiateCallbackExPtr cb) : - _cb(cb) + _cb(cb) { } virtual void ice_response() { - _cb->ice_response(); + _cb->ice_response(); } virtual void ice_exception(const Exception& e) { - _cb->ice_exception(e); + _cb->ice_exception(e); } private: @@ -72,20 +72,20 @@ class AMI_CallbackReceiver_concurrentCallbackI : public AMI_CallbackReceiver_con public: AMI_CallbackReceiver_concurrentCallbackI(const AMD_Callback_initiateConcurrentCallbackPtr cb) : - _cb(cb) + _cb(cb) { } virtual void ice_response(Int number) { - _cb->ice_response(number); + _cb->ice_response(number); } virtual void ice_exception(const Exception& e) { - _cb->ice_exception(e); + _cb->ice_exception(e); } private: @@ -98,20 +98,20 @@ class AMI_CallbackReceiver_waitCallbackI : public AMI_CallbackReceiver_waitCallb public: AMI_CallbackReceiver_waitCallbackI(const AMD_Callback_initiateWaitCallbackPtr cb) : - _cb(cb) + _cb(cb) { } virtual void ice_response() { - _cb->ice_response(); + _cb->ice_response(); } virtual void ice_exception(const Exception& e) { - _cb->ice_exception(e); + _cb->ice_exception(e); } private: @@ -124,20 +124,20 @@ class AMI_CallbackReceiver_callbackWithPayloadI : public AMI_CallbackReceiver_ca public: AMI_CallbackReceiver_callbackWithPayloadI(const AMD_Callback_initiateCallbackWithPayloadPtr cb) : - _cb(cb) + _cb(cb) { } virtual void ice_response() { - _cb->ice_response(); + _cb->ice_response(); } virtual void ice_exception(const Exception& e) { - _cb->ice_exception(e); + _cb->ice_exception(e); } private: @@ -174,8 +174,8 @@ CallbackReceiverI::callbackEx(const Current& current) void CallbackReceiverI::concurrentCallback_async(const AMD_CallbackReceiver_concurrentCallbackPtr& cb, - Int number, - const Current&) + Int number, + const Current&) { Lock sync(*this); @@ -190,19 +190,19 @@ void CallbackReceiverI::waitCallback(const Current&) { { - Lock sync(*this); - assert(!_waitCallback); - _waitCallback = true; - notifyAll(); + Lock sync(*this); + assert(!_waitCallback); + _waitCallback = true; + notifyAll(); } { - Lock sync(*this); - while(!_finishWaitCallback) - { - test(timedWait(IceUtil::Time::milliSeconds(10000))); - } - _finishWaitCallback = false; + Lock sync(*this); + while(!_finishWaitCallback) + { + test(timedWait(IceUtil::Time::milliSeconds(10000))); + } + _finishWaitCallback = false; } } @@ -222,10 +222,10 @@ CallbackReceiverI::callbackOK() while(!_callback) { - if(!timedWait(IceUtil::Time::milliSeconds(10000))) - { - return false; - } + if(!timedWait(IceUtil::Time::milliSeconds(10000))) + { + return false; + } } _callback = false; @@ -238,10 +238,10 @@ CallbackReceiverI::waitCallbackOK() Lock sync(*this); while(!_waitCallback) { - if(!timedWait(IceUtil::Time::milliSeconds(10000))) - { - return false; - } + if(!timedWait(IceUtil::Time::milliSeconds(10000))) + { + return false; + } } _waitCallback = false; @@ -255,10 +255,10 @@ CallbackReceiverI::callbackWithPayloadOK() while(!_callbackWithPayload) { - if(!timedWait(IceUtil::Time::milliSeconds(10000))) - { - return false; - } + if(!timedWait(IceUtil::Time::milliSeconds(10000))) + { + return false; + } } _callbackWithPayload = false; @@ -280,17 +280,17 @@ CallbackReceiverI::answerConcurrentCallbacks(unsigned int num) while(_callbacks.size() != num) { - if(!timedWait(IceUtil::Time::milliSeconds(10000))) - { - return false; - } + if(!timedWait(IceUtil::Time::milliSeconds(10000))) + { + return false; + } } for(vector<pair<AMD_CallbackReceiver_concurrentCallbackPtr, Int> >::const_iterator p = _callbacks.begin(); - p != _callbacks.end(); - ++p) + p != _callbacks.end(); + ++p) { - p->first->ice_response(p->second); + p->first->ice_response(p->second); } _callbacks.clear(); return true; @@ -302,55 +302,55 @@ CallbackI::CallbackI() void CallbackI::initiateCallback_async(const AMD_Callback_initiateCallbackPtr& cb, - const CallbackReceiverPrx& proxy, const Current& current) + const CallbackReceiverPrx& proxy, const Current& current) { if(proxy->ice_isTwoway()) { - proxy->callback_async(new AMI_CallbackReceiver_callbackI(cb), current.ctx); + proxy->callback_async(new AMI_CallbackReceiver_callbackI(cb), current.ctx); } else { - proxy->callback(current.ctx); - cb->ice_response(); + proxy->callback(current.ctx); + cb->ice_response(); } } void CallbackI::initiateCallbackEx_async(const AMD_Callback_initiateCallbackExPtr& cb, - const CallbackReceiverPrx& proxy, const Current& current) + const CallbackReceiverPrx& proxy, const Current& current) { if(proxy->ice_isTwoway()) { - proxy->callbackEx_async(new AMI_CallbackReceiver_callbackExI(cb), current.ctx); + proxy->callbackEx_async(new AMI_CallbackReceiver_callbackExI(cb), current.ctx); } else { - proxy->callbackEx(current.ctx); - cb->ice_response(); + proxy->callbackEx(current.ctx); + cb->ice_response(); } } void CallbackI::initiateConcurrentCallback_async(const AMD_Callback_initiateConcurrentCallbackPtr& cb, - Int number, - const CallbackReceiverPrx& proxy, - const Current& current) + Int number, + const CallbackReceiverPrx& proxy, + const Current& current) { proxy->concurrentCallback_async(new AMI_CallbackReceiver_concurrentCallbackI(cb), number, current.ctx); } void CallbackI::initiateWaitCallback_async(const AMD_Callback_initiateWaitCallbackPtr& cb, - const CallbackReceiverPrx& proxy, - const Current& current) + const CallbackReceiverPrx& proxy, + const Current& current) { proxy->waitCallback_async(new AMI_CallbackReceiver_waitCallbackI(cb)); } void CallbackI::initiateCallbackWithPayload_async(const AMD_Callback_initiateCallbackWithPayloadPtr& cb, - const CallbackReceiverPrx& proxy, - const Current& current) + const CallbackReceiverPrx& proxy, + const Current& current) { Ice::ByteSeq seq(1000 * 1024, 0); proxy->callbackWithPayload_async(new AMI_CallbackReceiver_callbackWithPayloadI(cb), seq); diff --git a/cpp/test/Glacier2/router/CallbackI.h b/cpp/test/Glacier2/router/CallbackI.h index 6e4a33f8565..9db011b4df4 100644 --- a/cpp/test/Glacier2/router/CallbackI.h +++ b/cpp/test/Glacier2/router/CallbackI.h @@ -24,8 +24,8 @@ public: virtual void callback(const Ice::Current&); virtual void callbackEx(const Ice::Current&); virtual void concurrentCallback_async(const ::Test::AMD_CallbackReceiver_concurrentCallbackPtr&, - Ice::Int, - const ::Ice::Current&); + Ice::Int, + const ::Ice::Current&); virtual void waitCallback(const ::Ice::Current&); virtual void callbackWithPayload(const Ice::ByteSeq&, const ::Ice::Current&); @@ -53,19 +53,19 @@ public: CallbackI(); virtual void initiateCallback_async(const ::Test::AMD_Callback_initiateCallbackPtr&, - const ::Test::CallbackReceiverPrx&, const Ice::Current&); + const ::Test::CallbackReceiverPrx&, const Ice::Current&); virtual void initiateCallbackEx_async(const ::Test::AMD_Callback_initiateCallbackExPtr&, - const ::Test::CallbackReceiverPrx&, const Ice::Current&); + const ::Test::CallbackReceiverPrx&, const Ice::Current&); virtual void initiateConcurrentCallback_async(const ::Test::AMD_Callback_initiateConcurrentCallbackPtr&, - Ice::Int, - const ::Test::CallbackReceiverPrx&, - const ::Ice::Current&); + Ice::Int, + const ::Test::CallbackReceiverPrx&, + const ::Ice::Current&); virtual void initiateWaitCallback_async(const ::Test::AMD_Callback_initiateWaitCallbackPtr&, - const ::Test::CallbackReceiverPrx&, - const ::Ice::Current&); + const ::Test::CallbackReceiverPrx&, + const ::Ice::Current&); virtual void initiateCallbackWithPayload_async(const ::Test::AMD_Callback_initiateCallbackWithPayloadPtr&, - const ::Test::CallbackReceiverPrx&, - const ::Ice::Current&); + const ::Test::CallbackReceiverPrx&, + const ::Ice::Current&); virtual void shutdown(const Ice::Current&); }; diff --git a/cpp/test/Glacier2/router/Client.cpp b/cpp/test/Glacier2/router/Client.cpp index a423212e8af..686752a79d1 100644 --- a/cpp/test/Glacier2/router/Client.cpp +++ b/cpp/test/Glacier2/router/Client.cpp @@ -21,49 +21,49 @@ using namespace Test; static Ice::InitializationData initData; class AMI_Callback_initiateConcurrentCallbackI : public AMI_Callback_initiateConcurrentCallback, - public IceUtil::Monitor<IceUtil::Mutex> + public IceUtil::Monitor<IceUtil::Mutex> { public: AMI_Callback_initiateConcurrentCallbackI() : - _haveResponse(false) + _haveResponse(false) { } virtual void ice_response(Int response) { - Lock sync(*this); - _haveResponse = true; - _response = response; - notify(); + Lock sync(*this); + _haveResponse = true; + _response = response; + notify(); } virtual void ice_exception(const Exception& e) { - Lock sync(*this); - _haveResponse = true; - _ex.reset(e.ice_clone()); - notify(); + Lock sync(*this); + _haveResponse = true; + _ex.reset(e.ice_clone()); + notify(); } int waitResponse() const { - Lock sync(*this); - while(!_haveResponse) - { - if(!timedWait(IceUtil::Time::milliSeconds(5000))) - { - throw TimeoutException(__FILE__, __LINE__); - } - } - if(_ex.get()) - { - _ex->ice_throw(); - } - return _response; + Lock sync(*this); + while(!_haveResponse) + { + if(!timedWait(IceUtil::Time::milliSeconds(5000))) + { + throw TimeoutException(__FILE__, __LINE__); + } + } + if(_ex.get()) + { + _ex->ice_throw(); + } + return _response; } private: @@ -85,92 +85,92 @@ public: virtual void run() { - CommunicatorPtr communicator = initialize(initData); - ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347 -t 10000"); - Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase); - communicator->setDefaultRouter(router); - - ostringstream os; - os << "userid-" << _id; - Glacier2::SessionPrx session = router->createSession(os.str(), "abc123"); - communicator->getProperties()->setProperty("Ice.PrintAdapterReady", ""); - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", router); - adapter->activate(); - - string category = router->getCategoryForClient(); - { - Lock sync(*this); - _callbackReceiver = new CallbackReceiverI; - notify(); - } - - Identity ident; - ident.name = "callbackReceiver"; - ident.category = category; - CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident)); - - ObjectPrx base = communicator->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); - base = base->ice_oneway(); - CallbackPrx callback = CallbackPrx::uncheckedCast(base); - - - // - // Block the CallbackReceiver in wait() to prevent the client from - // processing other incoming calls and wait to receive the callback. - // - callback->initiateWaitCallback(receiver); - test(_callbackReceiver->waitCallbackOK()); - - // - // Notify the main thread that the callback was received. - // - { - Lock sync(*this); - _callback = true; - notify(); - } - - // - // Callback the client with a large payload. This should cause - // the Glacier2 request queue thread to block trying to send the - // callback to the client because the client is currently blocked - // in CallbackReceiverI::waitCallback() and can't process more - // requests. - // - callback->initiateCallbackWithPayload(receiver); - test(_callbackReceiver->callbackWithPayloadOK()); - - try - { - router->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - catch(const Ice::LocalException&) - { - test(false); - } - communicator->destroy(); + CommunicatorPtr communicator = initialize(initData); + ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347 -t 10000"); + Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase); + communicator->setDefaultRouter(router); + + ostringstream os; + os << "userid-" << _id; + Glacier2::SessionPrx session = router->createSession(os.str(), "abc123"); + communicator->getProperties()->setProperty("Ice.PrintAdapterReady", ""); + ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", router); + adapter->activate(); + + string category = router->getCategoryForClient(); + { + Lock sync(*this); + _callbackReceiver = new CallbackReceiverI; + notify(); + } + + Identity ident; + ident.name = "callbackReceiver"; + ident.category = category; + CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident)); + + ObjectPrx base = communicator->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); + base = base->ice_oneway(); + CallbackPrx callback = CallbackPrx::uncheckedCast(base); + + + // + // Block the CallbackReceiver in wait() to prevent the client from + // processing other incoming calls and wait to receive the callback. + // + callback->initiateWaitCallback(receiver); + test(_callbackReceiver->waitCallbackOK()); + + // + // Notify the main thread that the callback was received. + // + { + Lock sync(*this); + _callback = true; + notify(); + } + + // + // Callback the client with a large payload. This should cause + // the Glacier2 request queue thread to block trying to send the + // callback to the client because the client is currently blocked + // in CallbackReceiverI::waitCallback() and can't process more + // requests. + // + callback->initiateCallbackWithPayload(receiver); + test(_callbackReceiver->callbackWithPayloadOK()); + + try + { + router->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Ice::LocalException&) + { + test(false); + } + communicator->destroy(); } void notifyWaitCallback() { - _callbackReceiver->notifyWaitCallback(); + _callbackReceiver->notifyWaitCallback(); } void waitForCallback() { - { - Lock sync(*this); - while(!_callback) - { - wait(); - } - } + { + Lock sync(*this); + while(!_callback) + { + wait(); + } + } } private: @@ -192,47 +192,47 @@ public: virtual void run() { - CommunicatorPtr communicator = initialize(initData); - ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347 -t 30000"); - _router = Glacier2::RouterPrx::checkedCast(routerBase); - communicator->setDefaultRouter(_router); - - ostringstream os; - os << "userid-" << _id; - Glacier2::SessionPrx session = _router->createSession(os.str(), "abc123"); - communicator->getProperties()->setProperty("Ice.PrintAdapterReady", ""); - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", _router); - adapter->activate(); - - string category = _router->getCategoryForClient(); - _callbackReceiver = new CallbackReceiverI; - Identity ident; - ident.name = "callbackReceiver"; - ident.category = category; - CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident)); - - ObjectPrx base = communicator->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); - base = base->ice_oneway(); - CallbackPrx callback = CallbackPrx::uncheckedCast(base); - - { - Lock sync(*this); - _initialized = true; - notifyAll(); - } - { - Lock sync(*this); - while(!_notified) - { - wait(); - } - } - - // - // Stress the router until the connection is closed. - // - stress(callback, receiver); - communicator->destroy(); + CommunicatorPtr communicator = initialize(initData); + ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347 -t 30000"); + _router = Glacier2::RouterPrx::checkedCast(routerBase); + communicator->setDefaultRouter(_router); + + ostringstream os; + os << "userid-" << _id; + Glacier2::SessionPrx session = _router->createSession(os.str(), "abc123"); + communicator->getProperties()->setProperty("Ice.PrintAdapterReady", ""); + ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", _router); + adapter->activate(); + + string category = _router->getCategoryForClient(); + _callbackReceiver = new CallbackReceiverI; + Identity ident; + ident.name = "callbackReceiver"; + ident.category = category; + CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident)); + + ObjectPrx base = communicator->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); + base = base->ice_oneway(); + CallbackPrx callback = CallbackPrx::uncheckedCast(base); + + { + Lock sync(*this); + _initialized = true; + notifyAll(); + } + { + Lock sync(*this); + while(!_notified) + { + wait(); + } + } + + // + // Stress the router until the connection is closed. + // + stress(callback, receiver); + communicator->destroy(); } virtual void stress(const CallbackPrx& callback, const CallbackReceiverPrx&) = 0; @@ -240,39 +240,39 @@ public: void notifyThread() { - { - Lock sync(*this); - while(!_initialized) - { - wait(); - } - } - { - Lock sync(*this); - _notified = true; - notify(); - } + { + Lock sync(*this); + while(!_initialized) + { + wait(); + } + } + { + Lock sync(*this); + _notified = true; + notify(); + } } void kill() { - try - { - _router->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - catch(const Ice::CommunicatorDestroyedException&) - { - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } + try + { + _router->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Ice::CommunicatorDestroyedException&) + { + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } } protected: @@ -296,28 +296,28 @@ public: virtual void stress(const CallbackPrx& callback, const CallbackReceiverPrx&) { - try - { - CallbackPrx cb = CallbackPrx::uncheckedCast(callback->ice_twoway()); - Context context; - context["_fwd"] = "t"; - while(true) - { - cb->ice_ping(context); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); - } - } - catch(const Ice::ConnectionLostException&) - { - } - catch(const Ice::CommunicatorDestroyedException&) - { - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } + try + { + CallbackPrx cb = CallbackPrx::uncheckedCast(callback->ice_twoway()); + Context context; + context["_fwd"] = "t"; + while(true) + { + cb->ice_ping(context); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); + } + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Ice::CommunicatorDestroyedException&) + { + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } } }; @@ -332,36 +332,36 @@ public: virtual void stress(const CallbackPrx& callback, const CallbackReceiverPrx& receiver) { - try - { - CallbackPrx cb = CallbackPrx::uncheckedCast(callback->ice_twoway()); - Context context; - context["_fwd"] = "t"; - while(true) - { - cb->initiateCallback(receiver, context); - test(_callbackReceiver->callbackOK()); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); - } - } - catch(const Ice::ConnectionLostException&) - { - // Session was destroyed. - } - catch(const Ice::ObjectNotExistException&) - { - // This might be raised by the CallbackI implementation if it can't invoke on the - // callback receiver because the session is being destroyed concurrently. - } - catch(const Ice::CommunicatorDestroyedException&) - { - // This might happen if the retry fails because the communicator is destroyed. - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } + try + { + CallbackPrx cb = CallbackPrx::uncheckedCast(callback->ice_twoway()); + Context context; + context["_fwd"] = "t"; + while(true) + { + cb->initiateCallback(receiver, context); + test(_callbackReceiver->callbackOK()); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); + } + } + catch(const Ice::ConnectionLostException&) + { + // Session was destroyed. + } + catch(const Ice::ObjectNotExistException&) + { + // This might be raised by the CallbackI implementation if it can't invoke on the + // callback receiver because the session is being destroyed concurrently. + } + catch(const Ice::CommunicatorDestroyedException&) + { + // This might happen if the retry fails because the communicator is destroyed. + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } } }; @@ -376,36 +376,36 @@ public: virtual void stress(const CallbackPrx& callback, const CallbackReceiverPrx& receiver) { - try - { - CallbackPrx cb = CallbackPrx::uncheckedCast(callback->ice_twoway()); - Context context; - context["_fwd"] = "t"; - while(true) - { - cb->initiateCallbackWithPayload(receiver, context); - test(_callbackReceiver->callbackWithPayloadOK()); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); - } - } - catch(const Ice::ConnectionLostException&) - { - // Session was destroyed. - } - catch(const Ice::ObjectNotExistException&) - { - // This might be raised by the CallbackI implementation if it can't invoke on the - // callback receiver because the session is being destroyed concurrently. - } - catch(const Ice::CommunicatorDestroyedException&) - { - // This might happen if the retry fails because the communicator is destroyed. - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } + try + { + CallbackPrx cb = CallbackPrx::uncheckedCast(callback->ice_twoway()); + Context context; + context["_fwd"] = "t"; + while(true) + { + cb->initiateCallbackWithPayload(receiver, context); + test(_callbackReceiver->callbackWithPayloadOK()); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + } + } + catch(const Ice::ConnectionLostException&) + { + // Session was destroyed. + } + catch(const Ice::ObjectNotExistException&) + { + // This might be raised by the CallbackI implementation if it can't invoke on the + // callback receiver because the session is being destroyed concurrently. + } + catch(const Ice::CommunicatorDestroyedException&) + { + // This might happen if the retry fails because the communicator is destroyed. + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } } }; @@ -437,132 +437,132 @@ CallbackClient::run(int argc, char* argv[]) ObjectPrx routerBase; { - cout << "testing stringToProxy for router... " << flush; - routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347 -t 10000"); - cout << "ok" << endl; + cout << "testing stringToProxy for router... " << flush; + routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347 -t 10000"); + cout << "ok" << endl; } Glacier2::RouterPrx router; { - cout << "testing checked cast for router... " << flush; - router = Glacier2::RouterPrx::checkedCast(routerBase); - test(router); - cout << "ok" << endl; + cout << "testing checked cast for router... " << flush; + router = Glacier2::RouterPrx::checkedCast(routerBase); + test(router); + cout << "ok" << endl; } { - cout << "installing router with communicator... " << flush; - communicator()->setDefaultRouter(router); - cout << "ok" << endl; + cout << "installing router with communicator... " << flush; + communicator()->setDefaultRouter(router); + cout << "ok" << endl; } { - cout << "getting the session timeout... " << flush; - Ice::Long timeout = router->getSessionTimeout(); - test(timeout == 30); - cout << "ok" << endl; + cout << "getting the session timeout... " << flush; + Ice::Long timeout = router->getSessionTimeout(); + test(timeout == 30); + cout << "ok" << endl; } ObjectPrx base; { - cout << "testing stringToProxy for server object... " << flush; - base = communicator()->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); - cout << "ok" << endl; + cout << "testing stringToProxy for server object... " << flush; + base = communicator()->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); + cout << "ok" << endl; } - + { - cout << "trying to ping server before session creation... " << flush; - try - { - base->ice_ping(); - test(false); - } - catch(const ConnectionLostException&) - { - cout << "ok" << endl; - } + cout << "trying to ping server before session creation... " << flush; + try + { + base->ice_ping(); + test(false); + } + catch(const ConnectionLostException&) + { + cout << "ok" << endl; + } } Glacier2::SessionPrx session; { - cout << "trying to create session with wrong password... " << flush; - try - { - session = router->createSession("userid", "xxx"); - test(false); - } - catch(const Glacier2::PermissionDeniedException&) - { - cout << "ok" << endl; - } + cout << "trying to create session with wrong password... " << flush; + try + { + session = router->createSession("userid", "xxx"); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + cout << "ok" << endl; + } } { - cout << "trying to destroy non-existing session... " << flush; - try - { - router->destroySession(); - test(false); - } - catch(const Glacier2::SessionNotExistException&) - { - cout << "ok" << endl; - } + cout << "trying to destroy non-existing session... " << flush; + try + { + router->destroySession(); + test(false); + } + catch(const Glacier2::SessionNotExistException&) + { + cout << "ok" << endl; + } } { - cout << "creating session with correct password... " << flush; - session = router->createSession("userid", "abc123"); - cout << "ok" << endl; + cout << "creating session with correct password... " << flush; + session = router->createSession("userid", "abc123"); + cout << "ok" << endl; } { - cout << "trying to create a second session... " << flush; - try - { - router->createSession("userid", "abc123"); - test(false); - } - catch(const Glacier2::CannotCreateSessionException&) - { - cout << "ok" << endl; - } + cout << "trying to create a second session... " << flush; + try + { + router->createSession("userid", "abc123"); + test(false); + } + catch(const Glacier2::CannotCreateSessionException&) + { + cout << "ok" << endl; + } } { - cout << "pinging server after session creation... " << flush; - base->ice_ping(); - cout << "ok" << endl; + cout << "pinging server after session creation... " << flush; + base->ice_ping(); + cout << "ok" << endl; } CallbackPrx twoway; { - cout << "testing checked cast for server object... " << flush; - twoway = CallbackPrx::checkedCast(base); - test(twoway); - cout << "ok" << endl; + cout << "testing checked cast for server object... " << flush; + twoway = CallbackPrx::checkedCast(base); + test(twoway); + cout << "ok" << endl; } ObjectAdapterPtr adapter; { - cout << "creating and activating callback receiver adapter with router... " << flush; - communicator()->getProperties()->setProperty("Ice.PrintAdapterReady", "0"); - adapter = communicator()->createObjectAdapterWithRouter("CallbackReceiverAdapter", router); - adapter->activate(); - cout << "ok" << endl; + cout << "creating and activating callback receiver adapter with router... " << flush; + communicator()->getProperties()->setProperty("Ice.PrintAdapterReady", "0"); + adapter = communicator()->createObjectAdapterWithRouter("CallbackReceiverAdapter", router); + adapter->activate(); + cout << "ok" << endl; } string category; { - cout << "getting category from router... " << flush; - category = router->getCategoryForClient(); - cout << "ok" << endl; + cout << "getting category from router... " << flush; + category = router->getCategoryForClient(); + cout << "ok" << endl; } CallbackReceiverI* callbackReceiverImpl; @@ -571,38 +571,38 @@ CallbackClient::run(int argc, char* argv[]) CallbackReceiverPrx fakeTwowayR; { - cout << "creating and adding callback receiver object... " << flush; - callbackReceiverImpl = new CallbackReceiverI; - callbackReceiver = callbackReceiverImpl; - Identity callbackReceiverIdent; - callbackReceiverIdent.name = "callbackReceiver"; - callbackReceiverIdent.category = category; - twowayR = CallbackReceiverPrx::uncheckedCast(adapter->add(callbackReceiver, callbackReceiverIdent)); - Identity fakeCallbackReceiverIdent; - fakeCallbackReceiverIdent.name = "callbackReceiver"; - fakeCallbackReceiverIdent.category = "dummy"; - fakeTwowayR = CallbackReceiverPrx::uncheckedCast(adapter->add(callbackReceiver, fakeCallbackReceiverIdent)); - cout << "ok" << endl; + cout << "creating and adding callback receiver object... " << flush; + callbackReceiverImpl = new CallbackReceiverI; + callbackReceiver = callbackReceiverImpl; + Identity callbackReceiverIdent; + callbackReceiverIdent.name = "callbackReceiver"; + callbackReceiverIdent.category = category; + twowayR = CallbackReceiverPrx::uncheckedCast(adapter->add(callbackReceiver, callbackReceiverIdent)); + Identity fakeCallbackReceiverIdent; + fakeCallbackReceiverIdent.name = "callbackReceiver"; + fakeCallbackReceiverIdent.category = "dummy"; + fakeTwowayR = CallbackReceiverPrx::uncheckedCast(adapter->add(callbackReceiver, fakeCallbackReceiverIdent)); + cout << "ok" << endl; } { - cout << "testing oneway callback... " << flush; - CallbackPrx oneway = CallbackPrx::uncheckedCast(twoway->ice_oneway()); - CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway()); - Context context; - context["_fwd"] = "o"; - oneway->initiateCallback(onewayR, context); - test(callbackReceiverImpl->callbackOK()); - cout << "ok" << endl; + cout << "testing oneway callback... " << flush; + CallbackPrx oneway = CallbackPrx::uncheckedCast(twoway->ice_oneway()); + CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway()); + Context context; + context["_fwd"] = "o"; + oneway->initiateCallback(onewayR, context); + test(callbackReceiverImpl->callbackOK()); + cout << "ok" << endl; } { - cout << "testing twoway callback... " << flush; - Context context; - context["_fwd"] = "t"; - twoway->initiateCallback(twowayR, context); - test(callbackReceiverImpl->callbackOK()); - cout << "ok" << endl; + cout << "testing twoway callback... " << flush; + Context context; + context["_fwd"] = "t"; + twoway->initiateCallback(twowayR, context); + test(callbackReceiverImpl->callbackOK()); + cout << "ok" << endl; } // @@ -612,292 +612,292 @@ CallbackClient::run(int argc, char* argv[]) // twoway requests (see bug 337 for more information). // { - cout << "testing concurrent twoway callback... " << flush; - Context context; - context["_fwd"] = "t"; - AMI_Callback_initiateConcurrentCallbackIPtr cb0 = new AMI_Callback_initiateConcurrentCallbackI(); - twoway->initiateConcurrentCallback_async(cb0, 0, twowayR, context); - AMI_Callback_initiateConcurrentCallbackIPtr cb1 = new AMI_Callback_initiateConcurrentCallbackI(); - twoway->initiateConcurrentCallback_async(cb1, 1, twowayR, context); - AMI_Callback_initiateConcurrentCallbackIPtr cb2 = new AMI_Callback_initiateConcurrentCallbackI(); - twoway->initiateConcurrentCallback_async(cb2, 2, twowayR, context); - test(callbackReceiverImpl->answerConcurrentCallbacks(3)); - test(cb0->waitResponse() == 0); - test(cb1->waitResponse() == 1); - test(cb2->waitResponse() == 2); - cout << "ok" << endl; - } - - { - cout << "ditto, but with user exception... " << flush; - Context context; - context["_fwd"] = "t"; - try - { - twoway->initiateCallbackEx(twowayR, context); - test(false); - } - catch(const CallbackException& ex) - { - test(ex.someValue == 3.14); - test(ex.someString == "3.14"); - } - test(callbackReceiverImpl->callbackOK()); - cout << "ok" << endl; - } - - { - cout << "trying twoway callback with fake category... " << flush; - Context context; - context["_fwd"] = "t"; - try - { - twoway->initiateCallback(fakeTwowayR, context); - test(false); - } - catch(const ObjectNotExistException&) - { - cout << "ok" << endl; - } - } - - { - cout << "testing whether other allowed category is accepted... " << flush; - Context context; - context["_fwd"] = "t"; - CallbackPrx otherCategoryTwoway = CallbackPrx::uncheckedCast( - twoway->ice_identity(communicator()->stringToIdentity("c2/callback"))); - otherCategoryTwoway->initiateCallback(twowayR, context); - test(callbackReceiverImpl->callbackOK()); - cout << "ok" << endl; - } - - { - cout << "testing whether disallowed category gets rejected... " << flush; - Context context; - context["_fwd"] = "t"; - try - { - CallbackPrx otherCategoryTwoway = CallbackPrx::uncheckedCast( - twoway->ice_identity(communicator()->stringToIdentity("c3/callback"))); - otherCategoryTwoway->initiateCallback(twowayR, context); - test(false); - } - catch(const ObjectNotExistException&) - { - cout << "ok" << endl; - } - } - - { - cout << "testing whether user-id as category is accepted... " << flush; - Context context; - context["_fwd"] = "t"; - CallbackPrx otherCategoryTwoway = CallbackPrx::uncheckedCast( - twoway->ice_identity(communicator()->stringToIdentity("_userid/callback"))); - otherCategoryTwoway->initiateCallback(twowayR, context); - test(callbackReceiverImpl->callbackOK()); - cout << "ok" << endl; - } - - { - cout << "testing buffered mode... " << flush; - - // - // Start 3 misbehaving clients. - // - const int nClients = 3; // Passwords need to be added to the password file if more clients are needed. - int i; - vector<MisbehavedClientPtr> clients; - for(i = 0; i < nClients; ++i) - { - clients.push_back(new MisbehavedClient(i)); - clients.back()->start(); - clients.back()->waitForCallback(); - } - - // - // Sleep for one second to make sure the router starts sending - // the callback with the payload to the clients. - // - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); - - // - // Initiate few callbacks with a large payload. Because of - // the buffered mode, this shouldn't block even though the - // misbehaved client are not answering their callback - // requests. - // - Context context; - context["_fwd"] = "t"; - twoway->initiateCallbackWithPayload(twowayR, context); - test(callbackReceiverImpl->callbackWithPayloadOK()); - twoway->initiateCallbackWithPayload(twowayR, context); - test(callbackReceiverImpl->callbackWithPayloadOK()); - twoway->initiateCallbackWithPayload(twowayR, context); - test(callbackReceiverImpl->callbackWithPayloadOK()); - twoway->initiateCallbackWithPayload(twowayR, context); - test(callbackReceiverImpl->callbackWithPayloadOK()); - - for(vector<MisbehavedClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) - { - (*p)->notifyWaitCallback(); - (*p)->getThreadControl().join(); - } - - cout << "ok" << endl; - } - - { - cout << "stress test... " << flush; - const int nClients = 3; // Passwords need to be added to the password file if more clients are needed. - int i; - vector<StressClientPtr> clients; - for(i = 0; i < nClients; ++i) - { - switch(IceUtil::random(3)) - { - case 0: - clients.push_back(new PingStressClient(i)); - break; - case 1: - clients.push_back(new CallbackStressClient(i)); - break; - case 2: - clients.push_back(new CallbackWithPayloadStressClient(i)); - break; - default: - assert(false); - break; - } - clients.back()->start(); - } - for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) - { - (*p)->notifyThread(); - } - - // - // Let the stress client run for a bit. - // - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(3)); - - // - // Send some callbacks. - // - Context context; - context["_fwd"] = "t"; - twoway->initiateCallback(twowayR); - test(callbackReceiverImpl->callbackOK()); - - // - // Kill the stress clients. - // - for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) - { - (*q)->kill(); - (*q)->getThreadControl().join(); - } - - - cout << "ok" << endl; - } - - { - cout << "testing server shutdown... " << flush; - twoway->shutdown(); - // No ping, otherwise the router prints a warning message if it's - // started with --Ice.Warn.Connections. - cout << "ok" << endl; - /* - try - { - base->ice_ping(); - test(false); - } - // If we use the glacier router, the exact exception reason gets - // lost. - catch(const UnknownLocalException&) - { - cout << "ok" << endl; - } - */ + cout << "testing concurrent twoway callback... " << flush; + Context context; + context["_fwd"] = "t"; + AMI_Callback_initiateConcurrentCallbackIPtr cb0 = new AMI_Callback_initiateConcurrentCallbackI(); + twoway->initiateConcurrentCallback_async(cb0, 0, twowayR, context); + AMI_Callback_initiateConcurrentCallbackIPtr cb1 = new AMI_Callback_initiateConcurrentCallbackI(); + twoway->initiateConcurrentCallback_async(cb1, 1, twowayR, context); + AMI_Callback_initiateConcurrentCallbackIPtr cb2 = new AMI_Callback_initiateConcurrentCallbackI(); + twoway->initiateConcurrentCallback_async(cb2, 2, twowayR, context); + test(callbackReceiverImpl->answerConcurrentCallbacks(3)); + test(cb0->waitResponse() == 0); + test(cb1->waitResponse() == 1); + test(cb2->waitResponse() == 2); + cout << "ok" << endl; + } + + { + cout << "ditto, but with user exception... " << flush; + Context context; + context["_fwd"] = "t"; + try + { + twoway->initiateCallbackEx(twowayR, context); + test(false); + } + catch(const CallbackException& ex) + { + test(ex.someValue == 3.14); + test(ex.someString == "3.14"); + } + test(callbackReceiverImpl->callbackOK()); + cout << "ok" << endl; + } + + { + cout << "trying twoway callback with fake category... " << flush; + Context context; + context["_fwd"] = "t"; + try + { + twoway->initiateCallback(fakeTwowayR, context); + test(false); + } + catch(const ObjectNotExistException&) + { + cout << "ok" << endl; + } + } + + { + cout << "testing whether other allowed category is accepted... " << flush; + Context context; + context["_fwd"] = "t"; + CallbackPrx otherCategoryTwoway = CallbackPrx::uncheckedCast( + twoway->ice_identity(communicator()->stringToIdentity("c2/callback"))); + otherCategoryTwoway->initiateCallback(twowayR, context); + test(callbackReceiverImpl->callbackOK()); + cout << "ok" << endl; + } + + { + cout << "testing whether disallowed category gets rejected... " << flush; + Context context; + context["_fwd"] = "t"; + try + { + CallbackPrx otherCategoryTwoway = CallbackPrx::uncheckedCast( + twoway->ice_identity(communicator()->stringToIdentity("c3/callback"))); + otherCategoryTwoway->initiateCallback(twowayR, context); + test(false); + } + catch(const ObjectNotExistException&) + { + cout << "ok" << endl; + } + } + + { + cout << "testing whether user-id as category is accepted... " << flush; + Context context; + context["_fwd"] = "t"; + CallbackPrx otherCategoryTwoway = CallbackPrx::uncheckedCast( + twoway->ice_identity(communicator()->stringToIdentity("_userid/callback"))); + otherCategoryTwoway->initiateCallback(twowayR, context); + test(callbackReceiverImpl->callbackOK()); + cout << "ok" << endl; + } + + { + cout << "testing buffered mode... " << flush; + + // + // Start 3 misbehaving clients. + // + const int nClients = 3; // Passwords need to be added to the password file if more clients are needed. + int i; + vector<MisbehavedClientPtr> clients; + for(i = 0; i < nClients; ++i) + { + clients.push_back(new MisbehavedClient(i)); + clients.back()->start(); + clients.back()->waitForCallback(); + } + + // + // Sleep for one second to make sure the router starts sending + // the callback with the payload to the clients. + // + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + + // + // Initiate few callbacks with a large payload. Because of + // the buffered mode, this shouldn't block even though the + // misbehaved client are not answering their callback + // requests. + // + Context context; + context["_fwd"] = "t"; + twoway->initiateCallbackWithPayload(twowayR, context); + test(callbackReceiverImpl->callbackWithPayloadOK()); + twoway->initiateCallbackWithPayload(twowayR, context); + test(callbackReceiverImpl->callbackWithPayloadOK()); + twoway->initiateCallbackWithPayload(twowayR, context); + test(callbackReceiverImpl->callbackWithPayloadOK()); + twoway->initiateCallbackWithPayload(twowayR, context); + test(callbackReceiverImpl->callbackWithPayloadOK()); + + for(vector<MisbehavedClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) + { + (*p)->notifyWaitCallback(); + (*p)->getThreadControl().join(); + } + + cout << "ok" << endl; + } + + { + cout << "stress test... " << flush; + const int nClients = 3; // Passwords need to be added to the password file if more clients are needed. + int i; + vector<StressClientPtr> clients; + for(i = 0; i < nClients; ++i) + { + switch(IceUtil::random(3)) + { + case 0: + clients.push_back(new PingStressClient(i)); + break; + case 1: + clients.push_back(new CallbackStressClient(i)); + break; + case 2: + clients.push_back(new CallbackWithPayloadStressClient(i)); + break; + default: + assert(false); + break; + } + clients.back()->start(); + } + for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) + { + (*p)->notifyThread(); + } + + // + // Let the stress client run for a bit. + // + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(3)); + + // + // Send some callbacks. + // + Context context; + context["_fwd"] = "t"; + twoway->initiateCallback(twowayR); + test(callbackReceiverImpl->callbackOK()); + + // + // Kill the stress clients. + // + for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) + { + (*q)->kill(); + (*q)->getThreadControl().join(); + } + + + cout << "ok" << endl; + } + + { + cout << "testing server shutdown... " << flush; + twoway->shutdown(); + // No ping, otherwise the router prints a warning message if it's + // started with --Ice.Warn.Connections. + cout << "ok" << endl; + /* + try + { + base->ice_ping(); + test(false); + } + // If we use the glacier router, the exact exception reason gets + // lost. + catch(const UnknownLocalException&) + { + cout << "ok" << endl; + } + */ } { - cout << "destroying session... " << flush; - try - { - router->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - catch(const Ice::LocalException&) - { - test(false); - } - cout << "ok" << endl; - } - - { - cout << "trying to ping server after session destruction... " << flush; - try - { - base->ice_ping(); - test(false); - } - catch(const ConnectionLostException&) - { - cout << "ok" << endl; - } + cout << "destroying session... " << flush; + try + { + router->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Ice::LocalException&) + { + test(false); + } + cout << "ok" << endl; + } + + { + cout << "trying to ping server after session destruction... " << flush; + try + { + base->ice_ping(); + test(false); + } + catch(const ConnectionLostException&) + { + cout << "ok" << endl; + } } if(argc >= 2 && strcmp(argv[1], "--shutdown") == 0) { - { - cout << "uninstalling router with communicator... " << flush; - communicator()->setDefaultRouter(0); - cout << "ok" << endl; - } + { + cout << "uninstalling router with communicator... " << flush; + communicator()->setDefaultRouter(0); + cout << "ok" << endl; + } - ObjectPrx adminBase; + ObjectPrx adminBase; - { - cout << "testing stringToProxy for admin object... " << flush; - adminBase = communicator()->stringToProxy("Glacier2/admin:tcp -h 127.0.0.1 -p 12348 -t 10000"); - cout << "ok" << endl; - } - + { + cout << "testing stringToProxy for admin object... " << flush; + adminBase = communicator()->stringToProxy("Glacier2/admin:tcp -h 127.0.0.1 -p 12348 -t 10000"); + cout << "ok" << endl; + } + /* - { - cout << "uninstalling router with admin object... " << flush; - adminBase->ice_router(0); - cout << "ok" << endl; - } + { + cout << "uninstalling router with admin object... " << flush; + adminBase->ice_router(0); + cout << "ok" << endl; + } */ - Glacier2::AdminPrx admin; - - { - cout << "testing checked cast for admin object... " << flush; - admin = Glacier2::AdminPrx::checkedCast(adminBase); - test(admin); - cout << "ok" << endl; - } - - cout << "testing Glacier2 shutdown... " << flush; - admin->shutdown(); - try - { - admin->ice_ping(); - test(false); - } - catch(const Ice::LocalException&) - { - cout << "ok" << endl; - } + Glacier2::AdminPrx admin; + + { + cout << "testing checked cast for admin object... " << flush; + admin = Glacier2::AdminPrx::checkedCast(adminBase); + test(admin); + cout << "ok" << endl; + } + + cout << "testing Glacier2 shutdown... " << flush; + admin->shutdown(); + try + { + admin->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + cout << "ok" << endl; + } } return EXIT_SUCCESS; diff --git a/cpp/test/Glacier2/sessionControl/Client.cpp b/cpp/test/Glacier2/sessionControl/Client.cpp index 35b7f03f58c..e80822b6731 100644 --- a/cpp/test/Glacier2/sessionControl/Client.cpp +++ b/cpp/test/Glacier2/sessionControl/Client.cpp @@ -36,7 +36,7 @@ main(int argc, char* argv[]) // initData.properties->setProperty("Ice.RetryIntervals", "-1"); initData.properties->setProperty("Ice.Warn.Connections", "0"); - + SessionControlClient app; return app.main(argc, argv, initData); } @@ -60,8 +60,8 @@ SessionControlClient::run(int argc, char* argv[]) cout << "testing destroy... " << flush; try { - session->destroyFromClient(); - test(false); + session->destroyFromClient(); + test(false); } catch(const Ice::ConnectionLostException&) { @@ -69,7 +69,7 @@ SessionControlClient::run(int argc, char* argv[]) try { session->ice_ping(); - test(false); + test(false); } catch(const Ice::ConnectionLostException&) { @@ -79,16 +79,16 @@ SessionControlClient::run(int argc, char* argv[]) cout << "testing create exceptions... " << flush; try { - router->createSession("rejectme", "abc123"); - test(false); + router->createSession("rejectme", "abc123"); + test(false); } catch(const Glacier2::CannotCreateSessionException&) { } try { - router->createSession("localexception", "abc123"); - test(false); + router->createSession("localexception", "abc123"); + test(false); } catch(const Glacier2::CannotCreateSessionException&) { @@ -105,12 +105,12 @@ SessionControlClient::run(int argc, char* argv[]) admin->shutdown(); try { - admin->ice_ping(); - test(false); + admin->ice_ping(); + test(false); } catch(const Ice::LocalException&) { - cout << "ok" << endl; + cout << "ok" << endl; } return EXIT_SUCCESS; diff --git a/cpp/test/Glacier2/sessionControl/SessionI.cpp b/cpp/test/Glacier2/sessionControl/SessionI.cpp index 9b88eed6126..b0d14cbb01b 100644 --- a/cpp/test/Glacier2/sessionControl/SessionI.cpp +++ b/cpp/test/Glacier2/sessionControl/SessionI.cpp @@ -25,13 +25,13 @@ public: void ice_response() { - _cb->ice_response(); + _cb->ice_response(); } void ice_exception(const IceUtil::Exception&) { - test(false); + test(false); } private: @@ -41,15 +41,15 @@ private: Glacier2::SessionPrx SessionManagerI::create(const string& userId, const Glacier2::SessionControlPrx& sessionControl, - const Ice::Current& current) + const Ice::Current& current) { if(userId == "rejectme") { - throw Glacier2::CannotCreateSessionException(""); + throw Glacier2::CannotCreateSessionException(""); } if(userId == "localexception") { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(new SessionI(sessionControl))); } diff --git a/cpp/test/Glacier2/sessionControl/run.py b/cpp/test/Glacier2/sessionControl/run.py index 36c3a117e1d..7cc29d5fc31 100755 --- a/cpp/test/Glacier2/sessionControl/run.py +++ b/cpp/test/Glacier2/sessionControl/run.py @@ -37,8 +37,8 @@ command = router + TestUtil.clientServerOptions + \ r' --Ice.OA.Glacier2.Client.Endpoints="default -p 12347 -t 10000"' + \ r' --Ice.OA.Glacier2.Admin.Endpoints="tcp -h 127.0.0.1 -p 12348 -t 10000"' \ r' --Ice.OA.Glacier2.Server.Endpoints="default -p 12349 -t 10000"' + \ - r' --Glacier2.SessionManager="SessionManager:tcp -h 127.0.0.1 -p 12010 -t 10000"' \ - r' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' + r' --Glacier2.SessionManager="SessionManager:tcp -h 127.0.0.1 -p 12010 -t 10000"' \ + r' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' print "starting router...", starterPipe = os.popen(command + " 2>&1") diff --git a/cpp/test/Glacier2/ssl/Client.cpp b/cpp/test/Glacier2/ssl/Client.cpp index 0daff0085b4..3c3e2f24b24 100755 --- a/cpp/test/Glacier2/ssl/Client.cpp +++ b/cpp/test/Glacier2/ssl/Client.cpp @@ -42,7 +42,7 @@ int CallbackClient::run(int argc, char* argv[]) { Glacier2::RouterPrx router = Glacier2::RouterPrx::uncheckedCast( - communicator()->stringToProxy("Glacier2/router:tcp -h 127.0.0.1 -p 12347 -t 10000")); + communicator()->stringToProxy("Glacier2/router:tcp -h 127.0.0.1 -p 12347 -t 10000")); communicator()->setDefaultRouter(router); // @@ -51,24 +51,24 @@ CallbackClient::run(int argc, char* argv[]) cout << "creating non-ssl session with tcp connection... "; try { - Glacier2::SessionPrx session = router->createSession("nossl", ""); - session->ice_ping(); - router->destroySession(); + Glacier2::SessionPrx session = router->createSession("nossl", ""); + session->ice_ping(); + router->destroySession(); } catch(const Ice::ConnectionLostException&) { } catch(const Glacier2::PermissionDeniedException&) { - test(false); + test(false); } cout << "ok" << endl; cout << "creating ssl session with tcp connection... "; try { - Glacier2::SessionPrx session = router->createSessionFromSecureConnection(); - test(false); + Glacier2::SessionPrx session = router->createSessionFromSecureConnection(); + test(false); } catch(const Glacier2::PermissionDeniedException&) { @@ -81,7 +81,7 @@ CallbackClient::run(int argc, char* argv[]) // communicator()->setDefaultRouter(Glacier2::RouterPrx()); router = Glacier2::RouterPrx::uncheckedCast( - communicator()->stringToProxy("Glacier2/router:ssl -h 127.0.0.1 -p 12348 -t 10000")); + communicator()->stringToProxy("Glacier2/router:ssl -h 127.0.0.1 -p 12348 -t 10000")); communicator()->setDefaultRouter(router); // @@ -90,38 +90,38 @@ CallbackClient::run(int argc, char* argv[]) cout << "creating non-ssl session with ssl connection... "; try { - Glacier2::SessionPrx session = router->createSession("nossl", ""); - session->ice_ping(); - router->destroySession(); + Glacier2::SessionPrx session = router->createSession("nossl", ""); + session->ice_ping(); + router->destroySession(); } catch(const Ice::ConnectionLostException&) { } catch(const Glacier2::PermissionDeniedException&) { - test(false); + test(false); } cout << "ok" << endl; cout << "creating ssl session with ssl connection... "; try { - Glacier2::SessionPrx session = router->createSessionFromSecureConnection(); - session->ice_ping(); - router->destroySession(); + Glacier2::SessionPrx session = router->createSessionFromSecureConnection(); + session->ice_ping(); + router->destroySession(); } catch(const Ice::ConnectionLostException&) { } catch(const Glacier2::PermissionDeniedException&) { - test(false); + test(false); } cout << "ok" << endl; communicator()->setDefaultRouter(0); Glacier2::AdminPrx admin = Glacier2::AdminPrx::checkedCast( - communicator()->stringToProxy("Glacier2/admin:tcp -h 127.0.0.1 -p 12349 -t 10000")); + communicator()->stringToProxy("Glacier2/admin:tcp -h 127.0.0.1 -p 12349 -t 10000")); admin->shutdown(); return EXIT_SUCCESS; diff --git a/cpp/test/Glacier2/ssl/Server.cpp b/cpp/test/Glacier2/ssl/Server.cpp index 1f4ba1db3f6..8221b47f966 100755 --- a/cpp/test/Glacier2/ssl/Server.cpp +++ b/cpp/test/Glacier2/ssl/Server.cpp @@ -22,15 +22,15 @@ public: virtual bool authorize(const Glacier2::SSLInfo& info, string&, const Ice::Current& current) const { - IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); - test(cert->getIssuerDN() == IceSSL::DistinguishedName( - "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.," - "L=Palm Beach Gardens,ST=Florida,C=US")); - test(cert->getSubjectDN() == IceSSL::DistinguishedName( - "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); - test(cert->checkValidity()); - - return true; + IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); + test(cert->getIssuerDN() == IceSSL::DistinguishedName( + "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.," + "L=Palm Beach Gardens,ST=Florida,C=US")); + test(cert->getSubjectDN() == IceSSL::DistinguishedName( + "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); + test(cert->checkValidity()); + + return true; } }; @@ -45,20 +45,20 @@ public: virtual void destroy(const Ice::Current& current) { - // - // If SSL, test that Glacier2.AddSSLContext is working. - // + // + // If SSL, test that Glacier2.AddSSLContext is working. + // if(_ssl) - { - Ice::Context::const_iterator p = current.ctx.find("SSL.Active"); - assert(p != current.ctx.end() && p->second == "1"); - } - - current.adapter->remove(current.id); - if(_shutdown) - { - current.adapter->getCommunicator()->shutdown(); - } + { + Ice::Context::const_iterator p = current.ctx.find("SSL.Active"); + assert(p != current.ctx.end() && p->second == "1"); + } + + current.adapter->remove(current.id); + if(_shutdown) + { + current.adapter->getCommunicator()->shutdown(); + } } private: const bool _shutdown; @@ -72,8 +72,8 @@ public: virtual Glacier2::SessionPrx create(const string& userId, const Glacier2::SessionControlPrx&, const Ice::Current& current) { - Glacier2::SessionPtr session = new SessionI(false, false); - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); + Glacier2::SessionPtr session = new SessionI(false, false); + return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); } }; @@ -84,26 +84,26 @@ public: virtual Glacier2::SessionPrx create(const Glacier2::SSLInfo& info, const Glacier2::SessionControlPrx&, const Ice::Current& current) { - test(info.remoteHost == "127.0.0.1"); - test(info.localHost == "127.0.0.1"); - test(info.localPort == 12348); - try - { - IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); - test(cert->getIssuerDN() == IceSSL::DistinguishedName( - "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.,L=Palm Beach Gardens," - "ST=Florida,C=US")); - test(cert->getSubjectDN() == IceSSL::DistinguishedName( - "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); - test(cert->checkValidity()); - } - catch(const IceSSL::CertificateReadException&) - { - test(false); - } - - Glacier2::SessionPtr session = new SessionI(true, true); - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); + test(info.remoteHost == "127.0.0.1"); + test(info.localHost == "127.0.0.1"); + test(info.localPort == 12348); + try + { + IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); + test(cert->getIssuerDN() == IceSSL::DistinguishedName( + "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.,L=Palm Beach Gardens," + "ST=Florida,C=US")); + test(cert->getSubjectDN() == IceSSL::DistinguishedName( + "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); + test(cert->checkValidity()); + } + catch(const IceSSL::CertificateReadException&) + { + test(false); + } + + Glacier2::SessionPtr session = new SessionI(true, true); + return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); } }; @@ -125,7 +125,7 @@ int SessionServer::run(int argc, char* argv[]) { Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints( - "SessionServer", "tcp -h 127.0.0.1 -p 12350 -t 10000"); + "SessionServer", "tcp -h 127.0.0.1 -p 12350 -t 10000"); adapter->add(new SSLPermissionsVerifierI, communicator()->stringToIdentity("sslverifier")); adapter->add(new SessionManagerI, communicator()->stringToIdentity("sessionmanager")); adapter->add(new SSLSessionManagerI, communicator()->stringToIdentity("sslsessionmanager")); diff --git a/cpp/test/Glacier2/ssl/run.py b/cpp/test/Glacier2/ssl/run.py index 607229590c2..627efff9342 100755 --- a/cpp/test/Glacier2/ssl/run.py +++ b/cpp/test/Glacier2/ssl/run.py @@ -43,7 +43,7 @@ command = router + TestUtil.clientServerOptions + \ r' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' + \ r' --Glacier2.SSLSessionManager="sslsessionmanager:tcp -h 127.0.0.1 -p 12350 -t 10000"' + \ r' --Glacier2.SSLPermissionsVerifier="sslverifier:tcp -h 127.0.0.1 -p 12350 -t 10000"' + \ - r" --Ice.Plugin.IceSSL=IceSSL:createIceSSL" + \ + r" --Ice.Plugin.IceSSL=IceSSL:createIceSSL" + \ r" --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ r' --IceSSL.CertFile=s_rsa1024_pub.pem' + \ r' --IceSSL.KeyFile=s_rsa1024_priv.pem' + \ @@ -57,7 +57,7 @@ print "ok" client = os.path.join(testdir, "client") command = client + TestUtil.clientOptions + \ - " --Ice.Plugin.IceSSL=IceSSL:createIceSSL" + \ + " --Ice.Plugin.IceSSL=IceSSL:createIceSSL" + \ " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ " --IceSSL.CertFile=c_rsa1024_pub.pem" + \ " --IceSSL.KeyFile=c_rsa1024_priv.pem" + \ diff --git a/cpp/test/Glacier2/staticFiltering/Client.cpp b/cpp/test/Glacier2/staticFiltering/Client.cpp index 4863e858857..d6990d801e5 100755 --- a/cpp/test/Glacier2/staticFiltering/Client.cpp +++ b/cpp/test/Glacier2/staticFiltering/Client.cpp @@ -38,7 +38,7 @@ main(int argc, char* argv[]) // proxies, even with regular retries disabled. // initData.properties->setProperty("Ice.RetryIntervals", "-1"); - + AttackClient app; return app.main(argc, argv, initData); } @@ -56,85 +56,85 @@ AttackClient::run(int argc, char* argv[]) PropertyDict badProxies = communicator()->getProperties()->getPropertiesForPrefix("Reject.Proxy."); for(p = badProxies.begin(); p != badProxies.end(); ++p) { - try - { - Glacier2::SessionPrx session = router->createSession("userid", "abc123"); - } - catch(const Glacier2::CannotCreateSessionException&) - { - test("Unable to create new session" == 0); - } - BackendPrx backend = BackendPrx::uncheckedCast(communicator()->stringToProxy(p->second)); - try - { - backend->ice_ping(); - cerr << "Test failed on : " << p->second << endl; - test("Expected exception" == 0); - } - catch(const ConnectionLostException&) - { - // - // This is ok. - // - } - catch(const CloseConnectionException&) - { - // - // This is also ok. - // - } - catch(const ObjectNotExistException&) - { - // - // This is ok for non-address filters. - // - try - { - router->destroySession(); - } - catch(...) - { - } - } - catch(const LocalException& e) - { - cerr << e << endl; - test("Unexpected local exception" == 0); - } + try + { + Glacier2::SessionPrx session = router->createSession("userid", "abc123"); + } + catch(const Glacier2::CannotCreateSessionException&) + { + test("Unable to create new session" == 0); + } + BackendPrx backend = BackendPrx::uncheckedCast(communicator()->stringToProxy(p->second)); + try + { + backend->ice_ping(); + cerr << "Test failed on : " << p->second << endl; + test("Expected exception" == 0); + } + catch(const ConnectionLostException&) + { + // + // This is ok. + // + } + catch(const CloseConnectionException&) + { + // + // This is also ok. + // + } + catch(const ObjectNotExistException&) + { + // + // This is ok for non-address filters. + // + try + { + router->destroySession(); + } + catch(...) + { + } + } + catch(const LocalException& e) + { + cerr << e << endl; + test("Unexpected local exception" == 0); + } } PropertyDict goodProxies = communicator()->getProperties()->getPropertiesForPrefix("Accept.Proxy."); for(p = goodProxies.begin(); p != goodProxies.end(); ++p) { - try - { - Glacier2::SessionPrx session = router->createSession("userid", "abc123"); - } - catch(const Glacier2::CannotCreateSessionException&) - { - test("Unable to create new session" == 0); - } - BackendPrx backend = BackendPrx::uncheckedCast(communicator()->stringToProxy(p->second)); - try - { - backend->ice_ping(); - } - catch(const LocalException& ex) - { - cerr << p->second << endl; - cerr << ex << endl; - test("Unexpected local exception" == 0); - } - try - { - router->destroySession(); - } - catch(const LocalException&) - { - // - // Expected. - // - } + try + { + Glacier2::SessionPrx session = router->createSession("userid", "abc123"); + } + catch(const Glacier2::CannotCreateSessionException&) + { + test("Unable to create new session" == 0); + } + BackendPrx backend = BackendPrx::uncheckedCast(communicator()->stringToProxy(p->second)); + try + { + backend->ice_ping(); + } + catch(const LocalException& ex) + { + cerr << p->second << endl; + cerr << ex << endl; + test("Unexpected local exception" == 0); + } + try + { + router->destroySession(); + } + catch(const LocalException&) + { + // + // Expected. + // + } } // @@ -144,28 +144,28 @@ AttackClient::run(int argc, char* argv[]) communicator()->setDefaultRouter(0); try { - BackendPrx backend = BackendPrx::checkedCast(communicator()->stringToProxy("dummy:tcp -p 12010 -t 10000")); - backend->shutdown(); + BackendPrx backend = BackendPrx::checkedCast(communicator()->stringToProxy("dummy:tcp -p 12010 -t 10000")); + backend->shutdown(); } catch(const Ice::LocalException&) { - test(false); + test(false); } try { - ObjectPrx adminBase = communicator()->stringToProxy("Glacier2/admin:tcp -h 127.0.0.1 -p 12348 -t 10000"); - Glacier2::AdminPrx admin = Glacier2::AdminPrx::checkedCast(adminBase); - test(admin); - admin->shutdown(); - try - { - admin->ice_ping(); - test(false); - } - catch(const Ice::LocalException&) - { - } + ObjectPrx adminBase = communicator()->stringToProxy("Glacier2/admin:tcp -h 127.0.0.1 -p 12348 -t 10000"); + Glacier2::AdminPrx admin = Glacier2::AdminPrx::checkedCast(adminBase); + test(admin); + admin->shutdown(); + try + { + admin->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } } catch(const Ice::LocalException&) { diff --git a/cpp/test/Glacier2/staticFiltering/Server.cpp b/cpp/test/Glacier2/staticFiltering/Server.cpp index 522747f23c9..e12ef11ac56 100644 --- a/cpp/test/Glacier2/staticFiltering/Server.cpp +++ b/cpp/test/Glacier2/staticFiltering/Server.cpp @@ -26,23 +26,23 @@ public: virtual void setAdapterDirectProxy_async(const AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb, const string&, - const ObjectPrx&, const Current&) + const ObjectPrx&, const Current&) { - cb->ice_response(); + cb->ice_response(); } virtual void setReplicatedAdapterDirectProxy_async(const AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr& cb, - const string&, const string&, const ObjectPrx&, const Current&) + const string&, const string&, const ObjectPrx&, const Current&) { - cb->ice_response(); + cb->ice_response(); } virtual void setServerProcessProxy_async(const AMD_LocatorRegistry_setServerProcessProxyPtr& cb, - const string&, const ProcessPrx&, const Current&) + const string&, const ProcessPrx&, const Current&) { - cb->ice_response(); + cb->ice_response(); } }; @@ -50,30 +50,30 @@ class ServerLocatorI : virtual public Locator { public: ServerLocatorI(const BackendPtr& backend, const ObjectAdapterPtr& adapter) : - _backend(backend), - _adapter(adapter), - _registryPrx( - LocatorRegistryPrx::uncheckedCast( - adapter->add(new ServerLocatorRegistry, _adapter->getCommunicator()->stringToIdentity("registry")))) + _backend(backend), + _adapter(adapter), + _registryPrx( + LocatorRegistryPrx::uncheckedCast( + adapter->add(new ServerLocatorRegistry, _adapter->getCommunicator()->stringToIdentity("registry")))) { } virtual void findObjectById_async(const AMD_Locator_findObjectByIdPtr& cb, const Identity& id, const Current&) const { - cb->ice_response(_adapter->createProxy(id)); + cb->ice_response(_adapter->createProxy(id)); } virtual void findAdapterById_async(const AMD_Locator_findAdapterByIdPtr& cb, const string& id, const Current& current) const { - cb->ice_response(_adapter->createDirectProxy(_adapter->getCommunicator()->stringToIdentity("dummy"))); + cb->ice_response(_adapter->createDirectProxy(_adapter->getCommunicator()->stringToIdentity("dummy"))); } virtual LocatorRegistryPrx getRegistry(const Current&) const { - return _registryPrx; + return _registryPrx; } private: @@ -87,13 +87,13 @@ class ServantLocatorI : virtual public ServantLocator public: ServantLocatorI(const BackendPtr& backend) : - _backend(backend) + _backend(backend) { } - + virtual ObjectPtr locate(const Current&, LocalObjectPtr&) { - return _backend; + return _backend; } virtual void finished(const Current&, const ObjectPtr&, const LocalObjectPtr&) @@ -127,8 +127,8 @@ int BackendServer::run(int argc, char* argv[]) { string endpoints = - communicator()->getProperties()->getPropertyWithDefault("Ice.OA.BackendAdapter.Endpoints", - "tcp -p 12010 -t 20000:ssl -p 12011 -t 20000"); + communicator()->getProperties()->getPropertyWithDefault("Ice.OA.BackendAdapter.Endpoints", + "tcp -p 12010 -t 20000:ssl -p 12011 -t 20000"); communicator()->getProperties()->setProperty("Ice.OA.BackendAdapter.Endpoints", endpoints); ObjectAdapterPtr adapter = communicator()->createObjectAdapter("BackendAdapter"); diff --git a/cpp/test/Glacier2/staticFiltering/run.py b/cpp/test/Glacier2/staticFiltering/run.py index bdf613b49ad..9cd9fba26d3 100755 --- a/cpp/test/Glacier2/staticFiltering/run.py +++ b/cpp/test/Glacier2/staticFiltering/run.py @@ -69,9 +69,9 @@ else: # the FQDN. # if fqdn == hostname: - hostname = hostname[:dot] + hostname = hostname[:dot] if domainname == "": - limitedTests = True + limitedTests = True try: testaddr = socket.gethostbyname(fqdn) testaddr = socket.gethostbyname(hostname) @@ -82,106 +82,106 @@ except: domainname = "" testcases = [ - ('testing category filter', - ('', '', '', 'foo "a cat with spaces"', '', ''), - [(True, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), - (True, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010')], []), - ('testing adapter id filter', - ('', '*', '', '', '', 'foo "an adapter with spaces"'), - [(False, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), - (False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'helloE @ bar'), - (True, 'helloF1 @ "an adapter with spaces"'), - (True, 'helloF @ foo')], []), - ('test identity filters', - ('', '', '', '', 'myident cata/fooa "a funny id/that might mess it up"', ''), - [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, 'myident:tcp -h 127.0.0.1 -p 12010'), - (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), - ('test mixing filters', - ('', '', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up" "a\\"nother"', - 'myadapter'), - [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), - (True, 'mycat/foo @ jimbo'), - (False, 'hiscatA @ jimbo'), - (True, 'hiscat @ myadapter'), - (True, 'a\"nother @ jimbo'), - (True, 'myident:tcp -h 127.0.0.1 -p 12010'), - (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), - ('test mixing filters (indirect only)', - ('', '*', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up"', 'myadapter'), - [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), - (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), - (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), - (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), - (False, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), - (False, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), - (True, 'mycat/foo @ jimbo'), - (False, 'hiscatA @ jimbo'), - (True, 'hiscat @ myadapter'), - (False, 'myident:tcp -h 127.0.0.1 -p 12010'), - (False, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), - (True, '"a funny id/that might mess it up" @ myadapter'), - (False, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), - ] + ('testing category filter', + ('', '', '', 'foo "a cat with spaces"', '', ''), + [(True, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), + (True, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010')], []), + ('testing adapter id filter', + ('', '*', '', '', '', 'foo "an adapter with spaces"'), + [(False, 'foo/helloA:tcp -h 127.0.0.1 -p 12010'), + (False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'helloE @ bar'), + (True, 'helloF1 @ "an adapter with spaces"'), + (True, 'helloF @ foo')], []), + ('test identity filters', + ('', '', '', '', 'myident cata/fooa "a funny id/that might mess it up"', ''), + [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, 'myident:tcp -h 127.0.0.1 -p 12010'), + (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), + ('test mixing filters', + ('', '', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up" "a\\"nother"', + 'myadapter'), + [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), + (True, 'mycat/foo @ jimbo'), + (False, 'hiscatA @ jimbo'), + (True, 'hiscat @ myadapter'), + (True, 'a\"nother @ jimbo'), + (True, 'myident:tcp -h 127.0.0.1 -p 12010'), + (True, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), + ('test mixing filters (indirect only)', + ('', '*', '', 'mycat "a sec cat"', 'myident cata/fooa "a funny id/that might mess it up"', 'myadapter'), + [(False, '"a cat with spaces/helloB":tcp -h 127.0.0.1 -p 12010'), + (False, 'nocat/helloC:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/helloD:tcp -h 127.0.0.1 -p 12010'), + (False, 'baz/myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/foo:tcp -h 127.0.0.1 -p 12010'), + (False, 'cat/fooa:tcp -h 127.0.0.1 -p 12010'), + (False, 'mycat/fooa:tcp -h 127.0.0.1 -p 12010'), + (False, '"a sec cat/fooa":tcp -h 127.0.0.1 -p 12010'), + (True, 'mycat/foo @ jimbo'), + (False, 'hiscatA @ jimbo'), + (True, 'hiscat @ myadapter'), + (False, 'myident:tcp -h 127.0.0.1 -p 12010'), + (False, 'cata/fooa:tcp -h 127.0.0.1 -p 12010'), + (True, '"a funny id/that might mess it up" @ myadapter'), + (False, '"a funny id/that might mess it up":tcp -h 127.0.0.1 -p 12010')], []), + ] if not limitedTests: testcases.extend([ - ('testing reject all', - (r'', r'*', r'', '', '', ''), - [(False, 'helloA:tcp -h %s -p 12010' % fqdn), - (False, 'helloB:tcp -h %s -p 12010' % hostname), - (False, 'helloC:tcp -h 127.0.0.1 -p 12010'), - (True, 'bar @ foo')], []), - ('testing loopback only rule', - (r'127.0.0.1 localhost', r'', r'', '', '', ''), - [(False, 'hello:tcp -h %s -p 12010' % fqdn), - (False, 'hello:tcp -h %s -p 12010' % hostname), - (False, '127.0.0.1:tcp -h %s -p 12010' % hostname), - (False, 'localhost:tcp -h %s -p 12010' % hostname), - (False, 'localhost/127.0.0.1:tcp -h %s -p 12010' % hostname), - (True, 'localhost:tcp -h 127.0.0.1 -p 12010'), - (True, 'localhost/127.0.0.1:tcp -h localhost -p 12010'), - (True, r'hello:tcp -h 127.0.0.1 -p 12010'), - (True, r'hello/somecat:tcp -h localhost -p 12010')], []), - ('testing domain filter rule (accept)', - ("*" + domainname, r'', r'', '', '', ''), - [(True, 'hello:tcp -h %s -p 12010' % fqdn), - (False, 'hello:tcp -h %s -p 12010' % hostname)], []), - ('testing domain filter rule (reject)', - (r'', "*" + domainname, r'', '', '', ''), - [(False, 'hello:tcp -h %s -p 12010' % fqdn), - (True, 'hello:tcp -h %s -p 12010' % hostname), - (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), - ('testing domain filter rule (mixed)', - ("127.0.0.1", fqdn, r'', '', '', ''), - [(False, 'hello:tcp -h %s -p 12010:tcp -h 127.0.0.1 -p 12010' % fqdn), - (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), - ('testing maximum proxy length rule', - (r'', r'', r'40', '', '', ''), - [(True, 'hello:tcp -h 127.0.0.1 -p 12010'), - (False, '012345678901234567890123456789012345678901234567890123456789:tcp -h 127.0.0.1 -p 12010')], []), - ]) + ('testing reject all', + (r'', r'*', r'', '', '', ''), + [(False, 'helloA:tcp -h %s -p 12010' % fqdn), + (False, 'helloB:tcp -h %s -p 12010' % hostname), + (False, 'helloC:tcp -h 127.0.0.1 -p 12010'), + (True, 'bar @ foo')], []), + ('testing loopback only rule', + (r'127.0.0.1 localhost', r'', r'', '', '', ''), + [(False, 'hello:tcp -h %s -p 12010' % fqdn), + (False, 'hello:tcp -h %s -p 12010' % hostname), + (False, '127.0.0.1:tcp -h %s -p 12010' % hostname), + (False, 'localhost:tcp -h %s -p 12010' % hostname), + (False, 'localhost/127.0.0.1:tcp -h %s -p 12010' % hostname), + (True, 'localhost:tcp -h 127.0.0.1 -p 12010'), + (True, 'localhost/127.0.0.1:tcp -h localhost -p 12010'), + (True, r'hello:tcp -h 127.0.0.1 -p 12010'), + (True, r'hello/somecat:tcp -h localhost -p 12010')], []), + ('testing domain filter rule (accept)', + ("*" + domainname, r'', r'', '', '', ''), + [(True, 'hello:tcp -h %s -p 12010' % fqdn), + (False, 'hello:tcp -h %s -p 12010' % hostname)], []), + ('testing domain filter rule (reject)', + (r'', "*" + domainname, r'', '', '', ''), + [(False, 'hello:tcp -h %s -p 12010' % fqdn), + (True, 'hello:tcp -h %s -p 12010' % hostname), + (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), + ('testing domain filter rule (mixed)', + ("127.0.0.1", fqdn, r'', '', '', ''), + [(False, 'hello:tcp -h %s -p 12010:tcp -h 127.0.0.1 -p 12010' % fqdn), + (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), + ('testing maximum proxy length rule', + (r'', r'', r'40', '', '', ''), + [(True, 'hello:tcp -h 127.0.0.1 -p 12010'), + (False, '012345678901234567890123456789012345678901234567890123456789:tcp -h 127.0.0.1 -p 12010')], []), + ]) if len(testcases) == 0: print "WARNING: You are running this test with SSL disabled and the network " @@ -214,20 +214,20 @@ for testcase in testcases: sys.stdout.write(description) for expect, proxy in attacks: - if expect: - attackcfg.write('Accept.Proxy.' + str(accepts) + '=') - accepts +=1 - else: - attackcfg.write('Reject.Proxy.' + str(rejects) + '=') - rejects +=1 - attackcfg.write(proxy + '\n') + if expect: + attackcfg.write('Accept.Proxy.' + str(accepts) + '=') + accepts +=1 + else: + attackcfg.write('Reject.Proxy.' + str(rejects) + '=') + rejects +=1 + attackcfg.write(proxy + '\n') attackcfg.close() pingProgress() hostArg = "" if limitedTests: - hostArg = " --Ice.Default.Host=127.0.0.1" + hostArg = " --Ice.Default.Host=127.0.0.1" # @@ -237,8 +237,8 @@ for testcase in testcases: # commonClientOptions = " --Ice.NullHandleAbort=1 --Ice.PrintProcessId=1" + hostArg commonServerOptions = r' --Ice.PrintProcessId --Ice.PrintAdapterReady --Ice.NullHandleAbort=1' + \ - r' --Ice.ServerIdleTime=600 --Ice.ThreadPool.Server.Size=2 --Ice.ThreadPool.Server.SizeMax=10' + \ - r' --Glacier2.RoutingTable.MaxSize=10 ' + hostArg + r' --Ice.ServerIdleTime=600 --Ice.ThreadPool.Server.Size=2 --Ice.ThreadPool.Server.SizeMax=10' + \ + r' --Glacier2.RoutingTable.MaxSize=10 ' + hostArg # # We cannot use the TestUtil options because they use localhost as the default host which doesn't really work for @@ -267,36 +267,36 @@ for testcase in testcases: # Regular expression syntax can easily confuse the command line. # if not len(acceptFilter) == 0: - routerConfig.write("Glacier2.Filter.Address.Accept=%s\n" % acceptFilter) + routerConfig.write("Glacier2.Filter.Address.Accept=%s\n" % acceptFilter) if not len(rejectFilter) == 0: - routerConfig.write("Glacier2.Filter.Address.Reject=%s\n" % rejectFilter) + routerConfig.write("Glacier2.Filter.Address.Reject=%s\n" % rejectFilter) if not len(maxEndpoints) == 0: - routerConfig.write("Glacier2.Filter.ProxySizeMax=%s\n" % maxEndpoints) + routerConfig.write("Glacier2.Filter.ProxySizeMax=%s\n" % maxEndpoints) if not len(categoryFilter) == 0: - routerConfig.write("Glacier2.Filter.Category.Accept=%s\n" % categoryFilter) + routerConfig.write("Glacier2.Filter.Category.Accept=%s\n" % categoryFilter) if not len(idFilter) == 0: - routerConfig.write("Glacier2.Filter.Identity.Accept=%s\n" % idFilter) + routerConfig.write("Glacier2.Filter.Identity.Accept=%s\n" % idFilter) if not len(adapterFilter) == 0: - routerConfig.write("Glacier2.Filter.AdapterId.Accept=%s\n" % adapterFilter) + routerConfig.write("Glacier2.Filter.AdapterId.Accept=%s\n" % adapterFilter) routerConfig.close() if TestUtil.debug: - print "(" + routerCmd + ")", + print "(" + routerCmd + ")", starterPipe = os.popen(routerCmd + " 2>&1") TestUtil.getServerPid(starterPipe) TestUtil.getAdapterReady(starterPipe) pingProgress() if TestUtil.protocol != "ssl": - serverConfig = file(os.path.join(testdir, "server.cfg"), "w") - serverOptions = ' --Ice.Config=' + os.path.join(testdir, "server.cfg") + " " + serverOptions - serverConfig.write("Ice.OA.BackendAdapter.Endpoints=tcp -p 12010 -t 20000\n") - serverConfig.close() + serverConfig = file(os.path.join(testdir, "server.cfg"), "w") + serverOptions = ' --Ice.Config=' + os.path.join(testdir, "server.cfg") + " " + serverOptions + serverConfig.write("Ice.OA.BackendAdapter.Endpoints=tcp -p 12010 -t 20000\n") + serverConfig.close() serverCmd = os.path.join(testdir, 'server') + serverOptions if TestUtil.debug: - print "(" + serverCmd + ")", + print "(" + serverCmd + ")", serverPipe = os.popen(serverCmd + " 2>&1") TestUtil.getServerPid(serverPipe) TestUtil.getAdapterReady(serverPipe) @@ -312,7 +312,7 @@ for testcase in testcases: clientCmd = os.path.join(testdir, 'client') + clientOptions + \ " --Ice.Config=" + os.path.join(testdir, 'attack.cfg') + " " if TestUtil.debug: - print "(" + clientCmd + ")", + print "(" + clientCmd + ")", clientPipe = os.popen(clientCmd + " 2>&1") TestUtil.ignorePid(clientPipe) @@ -320,9 +320,9 @@ for testcase in testcases: clientStatus = TestUtil.closePipe(clientPipe) if clientStatus: - TestUtil.killServers() + TestUtil.killServers() if clientStatus or TestUtil.serverStatus(): - sys.exit(1) + sys.exit(1) sys.exit(0) diff --git a/cpp/test/Ice/adapterDeactivation/AllTests.cpp b/cpp/test/Ice/adapterDeactivation/AllTests.cpp index e449ad33f54..4b39523946a 100644 --- a/cpp/test/Ice/adapterDeactivation/AllTests.cpp +++ b/cpp/test/Ice/adapterDeactivation/AllTests.cpp @@ -31,23 +31,23 @@ allTests(const CommunicatorPtr& communicator) { cout << "creating/destroying/recreating object adapter... " << flush; - ObjectAdapterPtr adapter = - communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999"); - try - { - communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9998"); - test(false); - } - catch(const AlreadyRegisteredException&) - { - } - adapter->destroy(); + ObjectAdapterPtr adapter = + communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999"); + try + { + communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9998"); + test(false); + } + catch(const AlreadyRegisteredException&) + { + } + adapter->destroy(); - // - // Use a different port than the first adapter to avoid an "address already in use" error. - // - adapter = communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9998"); - adapter->destroy(); + // + // Use a different port than the first adapter to avoid an "address already in use" error. + // + adapter = communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9998"); + adapter->destroy(); cout << "ok" << endl; } @@ -62,12 +62,12 @@ allTests(const CommunicatorPtr& communicator) cout << "testing whether server is gone... " << flush; try { - obj->ice_ping(); - test(false); + obj->ice_ping(); + test(false); } catch(const LocalException&) { - cout << "ok" << endl; + cout << "ok" << endl; } return obj; diff --git a/cpp/test/Ice/adapterDeactivation/ServantLocatorI.cpp b/cpp/test/Ice/adapterDeactivation/ServantLocatorI.cpp index 67e361ab6b5..2347ebac86e 100644 --- a/cpp/test/Ice/adapterDeactivation/ServantLocatorI.cpp +++ b/cpp/test/Ice/adapterDeactivation/ServantLocatorI.cpp @@ -40,7 +40,7 @@ ServantLocatorI::locate(const Ice::Current& current, Ice::LocalObjectPtr& cookie void ServantLocatorI::finished(const Ice::Current& current, const Ice::ObjectPtr& servant, - const Ice::LocalObjectPtr& cookie) + const Ice::LocalObjectPtr& cookie) { test(!_deactivated); diff --git a/cpp/test/Ice/adapterDeactivation/TestI.cpp b/cpp/test/Ice/adapterDeactivation/TestI.cpp index f43409c46f3..18bd51cb0ae 100644 --- a/cpp/test/Ice/adapterDeactivation/TestI.cpp +++ b/cpp/test/Ice/adapterDeactivation/TestI.cpp @@ -20,7 +20,7 @@ TestI::transient(const Current& current) CommunicatorPtr communicator = current.adapter->getCommunicator(); ObjectAdapterPtr adapter = - communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999"); + communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999"); adapter->activate(); adapter->destroy(); } diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp index 15502bfcfaf..5503d099c78 100644 --- a/cpp/test/Ice/binding/AllTests.cpp +++ b/cpp/test/Ice/binding/AllTests.cpp @@ -33,27 +33,27 @@ public: virtual void ice_response(const string& name) { - Lock sync(*this); - assert(!name.empty()); - _name = name; - notify(); + Lock sync(*this); + assert(!name.empty()); + _name = name; + notify(); } virtual void ice_exception(const Ice::Exception&) { - test(false); + test(false); } virtual string getResult() { - Lock sync(*this); - while(_name.empty()) - { - wait(); - } - return _name; + Lock sync(*this); + while(_name.empty()) + { + wait(); + } + return _name; } private: @@ -77,9 +77,9 @@ createTestIntfPrx(vector<RemoteObjectAdapterPrx>& adapters) TestIntfPrx test; for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) { - test = (*p)->getTestIntf(); - Ice::EndpointSeq edpts = test->ice_getEndpoints(); - endpoints.insert(endpoints.end(), edpts.begin(), edpts.end()); + test = (*p)->getTestIntf(); + Ice::EndpointSeq edpts = test->ice_getEndpoints(); + endpoints.insert(endpoints.end(), edpts.begin(), edpts.end()); } return TestIntfPrx::uncheckedCast(test->ice_endpoints(endpoints)); } @@ -89,7 +89,7 @@ deactivate(const RemoteCommunicatorPrx& com, vector<RemoteObjectAdapterPrx>& ada { for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) { - com->deactivateObjectAdapter(*p); + com->deactivateObjectAdapter(*p); } } @@ -103,600 +103,600 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing binding with single endpoint... " << flush; { - RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter", "default"); - - TestIntfPrx test1 = adapter->getTestIntf(); - TestIntfPrx test2 = adapter->getTestIntf(); - test(test1->ice_getConnection() == test2->ice_getConnection()); - - test1->ice_ping(); - test2->ice_ping(); - - com->deactivateObjectAdapter(adapter); - - TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1); - test(test3->ice_getConnection() == test1->ice_getConnection()); - test(test3->ice_getConnection() == test2->ice_getConnection()); - - try - { - test3->ice_ping(); - test(false); - } - catch(const Ice::ConnectionRefusedException&) - { - } + RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter", "default"); + + TestIntfPrx test1 = adapter->getTestIntf(); + TestIntfPrx test2 = adapter->getTestIntf(); + test(test1->ice_getConnection() == test2->ice_getConnection()); + + test1->ice_ping(); + test2->ice_ping(); + + com->deactivateObjectAdapter(adapter); + + TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1); + test(test3->ice_getConnection() == test1->ice_getConnection()); + test(test3->ice_getConnection() == test2->ice_getConnection()); + + try + { + test3->ice_ping(); + test(false); + } + catch(const Ice::ConnectionRefusedException&) + { + } } cout << "ok" << endl; cout << "testing binding with multiple endpoints... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter11", "default")); - adapters.push_back(com->createObjectAdapter("Adapter12", "default")); - adapters.push_back(com->createObjectAdapter("Adapter13", "default")); - - // - // Ensure that when a connection is opened it's reused for new - // proxies and that all endpoints are eventually tried. - // - set<string> names; - names.insert("Adapter11"); - names.insert("Adapter12"); - names.insert("Adapter13"); - while(!names.empty()) - { - vector<RemoteObjectAdapterPrx> adpts = adapters; - - TestIntfPrx test1 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test2 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test3 = createTestIntfPrx(adpts); - - test(test1->ice_getConnection() == test2->ice_getConnection()); - test(test2->ice_getConnection() == test3->ice_getConnection()); - - names.erase(test1->getAdapterName()); - test1->ice_getConnection()->close(false); - } - - // - // Ensure that the proxy correctly caches the connection (we - // always send the request over the same connection.) - // - { - for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) - { - (*p)->getTestIntf()->ice_ping(); - } - - TestIntfPrx test = createTestIntfPrx(adapters); - string name = test->getAdapterName(); - const int nRetry = 10; - int i; - for(i = 0; i < nRetry && test->getAdapterName() == name; i++); - test(i == nRetry); - - for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q) - { - (*q)->getTestIntf()->ice_getConnection()->close(false); - } - } - - // - // Deactivate an adapter and ensure that we can still - // establish the connection to the remaining adapters. - // - com->deactivateObjectAdapter(adapters[0]); - names.insert("Adapter12"); - names.insert("Adapter13"); - while(!names.empty()) - { - vector<RemoteObjectAdapterPrx> adpts = adapters; - - TestIntfPrx test1 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test2 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test3 = createTestIntfPrx(adpts); - - test(test1->ice_getConnection() == test2->ice_getConnection()); - test(test2->ice_getConnection() == test3->ice_getConnection()); - - names.erase(test1->getAdapterName()); - test1->ice_getConnection()->close(false); - } - - // - // Deactivate an adapter and ensure that we can still - // establish the connection to the remaining adapter. - // - com->deactivateObjectAdapter(adapters[2]); - TestIntfPrx test = createTestIntfPrx(adapters); - test(test->getAdapterName() == "Adapter12"); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter11", "default")); + adapters.push_back(com->createObjectAdapter("Adapter12", "default")); + adapters.push_back(com->createObjectAdapter("Adapter13", "default")); + + // + // Ensure that when a connection is opened it's reused for new + // proxies and that all endpoints are eventually tried. + // + set<string> names; + names.insert("Adapter11"); + names.insert("Adapter12"); + names.insert("Adapter13"); + while(!names.empty()) + { + vector<RemoteObjectAdapterPrx> adpts = adapters; + + TestIntfPrx test1 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test2 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test3 = createTestIntfPrx(adpts); + + test(test1->ice_getConnection() == test2->ice_getConnection()); + test(test2->ice_getConnection() == test3->ice_getConnection()); + + names.erase(test1->getAdapterName()); + test1->ice_getConnection()->close(false); + } + + // + // Ensure that the proxy correctly caches the connection (we + // always send the request over the same connection.) + // + { + for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) + { + (*p)->getTestIntf()->ice_ping(); + } + + TestIntfPrx test = createTestIntfPrx(adapters); + string name = test->getAdapterName(); + const int nRetry = 10; + int i; + for(i = 0; i < nRetry && test->getAdapterName() == name; i++); + test(i == nRetry); + + for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q) + { + (*q)->getTestIntf()->ice_getConnection()->close(false); + } + } + + // + // Deactivate an adapter and ensure that we can still + // establish the connection to the remaining adapters. + // + com->deactivateObjectAdapter(adapters[0]); + names.insert("Adapter12"); + names.insert("Adapter13"); + while(!names.empty()) + { + vector<RemoteObjectAdapterPrx> adpts = adapters; + + TestIntfPrx test1 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test2 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test3 = createTestIntfPrx(adpts); + + test(test1->ice_getConnection() == test2->ice_getConnection()); + test(test2->ice_getConnection() == test3->ice_getConnection()); + + names.erase(test1->getAdapterName()); + test1->ice_getConnection()->close(false); + } + + // + // Deactivate an adapter and ensure that we can still + // establish the connection to the remaining adapter. + // + com->deactivateObjectAdapter(adapters[2]); + TestIntfPrx test = createTestIntfPrx(adapters); + test(test->getAdapterName() == "Adapter12"); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing binding with multiple endpoints and AMI... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("AdapterAMI11", "default")); - adapters.push_back(com->createObjectAdapter("AdapterAMI12", "default")); - adapters.push_back(com->createObjectAdapter("AdapterAMI13", "default")); - - // - // Ensure that when a connection is opened it's reused for new - // proxies and that all endpoints are eventually tried. - // - set<string> names; - names.insert("AdapterAMI11"); - names.insert("AdapterAMI12"); - names.insert("AdapterAMI13"); - while(!names.empty()) - { - vector<RemoteObjectAdapterPrx> adpts = adapters; - - TestIntfPrx test1 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test2 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test3 = createTestIntfPrx(adpts); - - test(test1->ice_getConnection() == test2->ice_getConnection()); - test(test2->ice_getConnection() == test3->ice_getConnection()); - - names.erase(getAdapterNameWithAMI(test1)); - test1->ice_getConnection()->close(false); - } - - // - // Ensure that the proxy correctly caches the connection (we - // always send the request over the same connection.) - // - { - for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) - { - (*p)->getTestIntf()->ice_ping(); - } - - TestIntfPrx test = createTestIntfPrx(adapters); - string name = getAdapterNameWithAMI(test); - const int nRetry = 10; - int i; - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == name; i++); - test(i == nRetry); - - for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q) - { - (*q)->getTestIntf()->ice_getConnection()->close(false); - } - } - - // - // Deactivate an adapter and ensure that we can still - // establish the connection to the remaining adapters. - // - com->deactivateObjectAdapter(adapters[0]); - names.insert("AdapterAMI12"); - names.insert("AdapterAMI13"); - while(!names.empty()) - { - vector<RemoteObjectAdapterPrx> adpts = adapters; - - TestIntfPrx test1 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test2 = createTestIntfPrx(adpts); - random_shuffle(adpts.begin(), adpts.end(), rng); - TestIntfPrx test3 = createTestIntfPrx(adpts); - - test(test1->ice_getConnection() == test2->ice_getConnection()); - test(test2->ice_getConnection() == test3->ice_getConnection()); - - names.erase(test1->getAdapterName()); - test1->ice_getConnection()->close(false); - } - - // - // Deactivate an adapter and ensure that we can still - // establish the connection to the remaining adapter. - // - com->deactivateObjectAdapter(adapters[2]); - TestIntfPrx test = createTestIntfPrx(adapters); - test(test->getAdapterName() == "AdapterAMI12"); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("AdapterAMI11", "default")); + adapters.push_back(com->createObjectAdapter("AdapterAMI12", "default")); + adapters.push_back(com->createObjectAdapter("AdapterAMI13", "default")); + + // + // Ensure that when a connection is opened it's reused for new + // proxies and that all endpoints are eventually tried. + // + set<string> names; + names.insert("AdapterAMI11"); + names.insert("AdapterAMI12"); + names.insert("AdapterAMI13"); + while(!names.empty()) + { + vector<RemoteObjectAdapterPrx> adpts = adapters; + + TestIntfPrx test1 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test2 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test3 = createTestIntfPrx(adpts); + + test(test1->ice_getConnection() == test2->ice_getConnection()); + test(test2->ice_getConnection() == test3->ice_getConnection()); + + names.erase(getAdapterNameWithAMI(test1)); + test1->ice_getConnection()->close(false); + } + + // + // Ensure that the proxy correctly caches the connection (we + // always send the request over the same connection.) + // + { + for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) + { + (*p)->getTestIntf()->ice_ping(); + } + + TestIntfPrx test = createTestIntfPrx(adapters); + string name = getAdapterNameWithAMI(test); + const int nRetry = 10; + int i; + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == name; i++); + test(i == nRetry); + + for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q) + { + (*q)->getTestIntf()->ice_getConnection()->close(false); + } + } + + // + // Deactivate an adapter and ensure that we can still + // establish the connection to the remaining adapters. + // + com->deactivateObjectAdapter(adapters[0]); + names.insert("AdapterAMI12"); + names.insert("AdapterAMI13"); + while(!names.empty()) + { + vector<RemoteObjectAdapterPrx> adpts = adapters; + + TestIntfPrx test1 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test2 = createTestIntfPrx(adpts); + random_shuffle(adpts.begin(), adpts.end(), rng); + TestIntfPrx test3 = createTestIntfPrx(adpts); + + test(test1->ice_getConnection() == test2->ice_getConnection()); + test(test2->ice_getConnection() == test3->ice_getConnection()); + + names.erase(test1->getAdapterName()); + test1->ice_getConnection()->close(false); + } + + // + // Deactivate an adapter and ensure that we can still + // establish the connection to the remaining adapter. + // + com->deactivateObjectAdapter(adapters[2]); + TestIntfPrx test = createTestIntfPrx(adapters); + test(test->getAdapterName() == "AdapterAMI12"); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing random endpoint selection... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter21", "default")); - adapters.push_back(com->createObjectAdapter("Adapter22", "default")); - adapters.push_back(com->createObjectAdapter("Adapter23", "default")); - - TestIntfPrx test = createTestIntfPrx(adapters); - test(test->ice_getEndpointSelection() == Ice::Random); - - set<string> names; - names.insert("Adapter21"); - names.insert("Adapter22"); - names.insert("Adapter23"); - while(!names.empty()) - { - names.erase(test->getAdapterName()); - test->ice_getConnection()->close(false); - } - - test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Random)); - test(test->ice_getEndpointSelection() == Ice::Random); - - names.insert("Adapter21"); - names.insert("Adapter22"); - names.insert("Adapter23"); - while(!names.empty()) - { - names.erase(test->getAdapterName()); - test->ice_getConnection()->close(false); - } - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter21", "default")); + adapters.push_back(com->createObjectAdapter("Adapter22", "default")); + adapters.push_back(com->createObjectAdapter("Adapter23", "default")); + + TestIntfPrx test = createTestIntfPrx(adapters); + test(test->ice_getEndpointSelection() == Ice::Random); + + set<string> names; + names.insert("Adapter21"); + names.insert("Adapter22"); + names.insert("Adapter23"); + while(!names.empty()) + { + names.erase(test->getAdapterName()); + test->ice_getConnection()->close(false); + } + + test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Random)); + test(test->ice_getEndpointSelection() == Ice::Random); + + names.insert("Adapter21"); + names.insert("Adapter22"); + names.insert("Adapter23"); + while(!names.empty()) + { + names.erase(test->getAdapterName()); + test->ice_getConnection()->close(false); + } + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing ordered endpoint selection... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter31", "default")); - adapters.push_back(com->createObjectAdapter("Adapter32", "default")); - adapters.push_back(com->createObjectAdapter("Adapter33", "default")); - - TestIntfPrx test = createTestIntfPrx(adapters); - test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered)); - test(test->ice_getEndpointSelection() == Ice::Ordered); - const int nRetry = 5; - int i; - - // - // Ensure that endpoints are tried in order by deactiving the adapters - // one after the other. - // - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter31"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[0]); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter32"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[1]); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter33"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[2]); - - try - { - test->getAdapterName(); - } - catch(const Ice::ConnectionRefusedException&) - { - } - - Ice::EndpointSeq endpoints = test->ice_getEndpoints(); - - adapters.clear(); - - // - // Now, re-activate the adapters with the same endpoints in the opposite - // order. - // - adapters.push_back(com->createObjectAdapter("Adapter36", endpoints[2]->toString())); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter36"; i++); - test(i == nRetry); - test->ice_getConnection()->close(false); - adapters.push_back(com->createObjectAdapter("Adapter35", endpoints[1]->toString())); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++); - test(i == nRetry); - test->ice_getConnection()->close(false); - adapters.push_back(com->createObjectAdapter("Adapter34", endpoints[0]->toString())); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++); - test(i == nRetry); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter31", "default")); + adapters.push_back(com->createObjectAdapter("Adapter32", "default")); + adapters.push_back(com->createObjectAdapter("Adapter33", "default")); + + TestIntfPrx test = createTestIntfPrx(adapters); + test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered)); + test(test->ice_getEndpointSelection() == Ice::Ordered); + const int nRetry = 5; + int i; + + // + // Ensure that endpoints are tried in order by deactiving the adapters + // one after the other. + // + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter31"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[0]); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter32"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[1]); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter33"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[2]); + + try + { + test->getAdapterName(); + } + catch(const Ice::ConnectionRefusedException&) + { + } + + Ice::EndpointSeq endpoints = test->ice_getEndpoints(); + + adapters.clear(); + + // + // Now, re-activate the adapters with the same endpoints in the opposite + // order. + // + adapters.push_back(com->createObjectAdapter("Adapter36", endpoints[2]->toString())); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter36"; i++); + test(i == nRetry); + test->ice_getConnection()->close(false); + adapters.push_back(com->createObjectAdapter("Adapter35", endpoints[1]->toString())); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++); + test(i == nRetry); + test->ice_getConnection()->close(false); + adapters.push_back(com->createObjectAdapter("Adapter34", endpoints[0]->toString())); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++); + test(i == nRetry); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing per request binding with single endpoint... " << flush; { - RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter41", "default"); - - TestIntfPrx test1 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false)); - TestIntfPrx test2 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false)); - test(!test1->ice_isConnectionCached()); - test(!test2->ice_isConnectionCached()); - test(test1->ice_getConnection() == test2->ice_getConnection()); - - test1->ice_ping(); - - com->deactivateObjectAdapter(adapter); - - TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1); - try - { - test(test3->ice_getConnection() == test1->ice_getConnection()); - test(false); - } - catch(const Ice::ConnectionRefusedException&) - { - } + RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter41", "default"); + + TestIntfPrx test1 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false)); + TestIntfPrx test2 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false)); + test(!test1->ice_isConnectionCached()); + test(!test2->ice_isConnectionCached()); + test(test1->ice_getConnection() == test2->ice_getConnection()); + + test1->ice_ping(); + + com->deactivateObjectAdapter(adapter); + + TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1); + try + { + test(test3->ice_getConnection() == test1->ice_getConnection()); + test(false); + } + catch(const Ice::ConnectionRefusedException&) + { + } } cout << "ok" << endl; cout << "testing per request binding with multiple endpoints... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter51", "default")); - adapters.push_back(com->createObjectAdapter("Adapter52", "default")); - adapters.push_back(com->createObjectAdapter("Adapter53", "default")); - - TestIntfPrx test = TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters)->ice_connectionCached(false)); - test(!test->ice_isConnectionCached()); - - set<string> names; - names.insert("Adapter51"); - names.insert("Adapter52"); - names.insert("Adapter53"); - while(!names.empty()) - { - names.erase(test->getAdapterName()); - } - - com->deactivateObjectAdapter(adapters[0]); - - names.insert("Adapter52"); - names.insert("Adapter53"); - while(!names.empty()) - { - names.erase(test->getAdapterName()); - } - - com->deactivateObjectAdapter(adapters[2]); - - - test(test->getAdapterName() == "Adapter52"); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter51", "default")); + adapters.push_back(com->createObjectAdapter("Adapter52", "default")); + adapters.push_back(com->createObjectAdapter("Adapter53", "default")); + + TestIntfPrx test = TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters)->ice_connectionCached(false)); + test(!test->ice_isConnectionCached()); + + set<string> names; + names.insert("Adapter51"); + names.insert("Adapter52"); + names.insert("Adapter53"); + while(!names.empty()) + { + names.erase(test->getAdapterName()); + } + + com->deactivateObjectAdapter(adapters[0]); + + names.insert("Adapter52"); + names.insert("Adapter53"); + while(!names.empty()) + { + names.erase(test->getAdapterName()); + } + + com->deactivateObjectAdapter(adapters[2]); + + + test(test->getAdapterName() == "Adapter52"); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing per request binding with multiple endpoints and AMI... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("AdapterAMI51", "default")); - adapters.push_back(com->createObjectAdapter("AdapterAMI52", "default")); - adapters.push_back(com->createObjectAdapter("AdapterAMI53", "default")); - - TestIntfPrx test = TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters)->ice_connectionCached(false)); - test(!test->ice_isConnectionCached()); - - set<string> names; - names.insert("AdapterAMI51"); - names.insert("AdapterAMI52"); - names.insert("AdapterAMI53"); - while(!names.empty()) - { - names.erase(getAdapterNameWithAMI(test)); - } - - com->deactivateObjectAdapter(adapters[0]); - - names.insert("AdapterAMI52"); - names.insert("AdapterAMI53"); - while(!names.empty()) - { - names.erase(getAdapterNameWithAMI(test)); - } - - com->deactivateObjectAdapter(adapters[2]); - - test(test->getAdapterName() == "AdapterAMI52"); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("AdapterAMI51", "default")); + adapters.push_back(com->createObjectAdapter("AdapterAMI52", "default")); + adapters.push_back(com->createObjectAdapter("AdapterAMI53", "default")); + + TestIntfPrx test = TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters)->ice_connectionCached(false)); + test(!test->ice_isConnectionCached()); + + set<string> names; + names.insert("AdapterAMI51"); + names.insert("AdapterAMI52"); + names.insert("AdapterAMI53"); + while(!names.empty()) + { + names.erase(getAdapterNameWithAMI(test)); + } + + com->deactivateObjectAdapter(adapters[0]); + + names.insert("AdapterAMI52"); + names.insert("AdapterAMI53"); + while(!names.empty()) + { + names.erase(getAdapterNameWithAMI(test)); + } + + com->deactivateObjectAdapter(adapters[2]); + + test(test->getAdapterName() == "AdapterAMI52"); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing per request binding and ordered endpoint selection... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter61", "default")); - adapters.push_back(com->createObjectAdapter("Adapter62", "default")); - adapters.push_back(com->createObjectAdapter("Adapter63", "default")); - - TestIntfPrx test = createTestIntfPrx(adapters); - test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered)); - test(test->ice_getEndpointSelection() == Ice::Ordered); - test = TestIntfPrx::uncheckedCast(test->ice_connectionCached(false)); - test(!test->ice_isConnectionCached()); - const int nRetry = 5; - int i; - - // - // Ensure that endpoints are tried in order by deactiving the adapters - // one after the other. - // - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter61"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[0]); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter62"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[1]); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter63"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[2]); - - try - { - test->getAdapterName(); - } - catch(const Ice::ConnectionRefusedException&) - { - } - - Ice::EndpointSeq endpoints = test->ice_getEndpoints(); - - adapters.clear(); - - // - // Now, re-activate the adapters with the same endpoints in the opposite - // order. - // - adapters.push_back(com->createObjectAdapter("Adapter66", endpoints[2]->toString())); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter66"; i++); - test(i == nRetry); - adapters.push_back(com->createObjectAdapter("Adapter65", endpoints[1]->toString())); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter65"; i++); - test(i == nRetry); - adapters.push_back(com->createObjectAdapter("Adapter64", endpoints[0]->toString())); - for(i = 0; i < nRetry && test->getAdapterName() == "Adapter64"; i++); - test(i == nRetry); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter61", "default")); + adapters.push_back(com->createObjectAdapter("Adapter62", "default")); + adapters.push_back(com->createObjectAdapter("Adapter63", "default")); + + TestIntfPrx test = createTestIntfPrx(adapters); + test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered)); + test(test->ice_getEndpointSelection() == Ice::Ordered); + test = TestIntfPrx::uncheckedCast(test->ice_connectionCached(false)); + test(!test->ice_isConnectionCached()); + const int nRetry = 5; + int i; + + // + // Ensure that endpoints are tried in order by deactiving the adapters + // one after the other. + // + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter61"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[0]); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter62"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[1]); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter63"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[2]); + + try + { + test->getAdapterName(); + } + catch(const Ice::ConnectionRefusedException&) + { + } + + Ice::EndpointSeq endpoints = test->ice_getEndpoints(); + + adapters.clear(); + + // + // Now, re-activate the adapters with the same endpoints in the opposite + // order. + // + adapters.push_back(com->createObjectAdapter("Adapter66", endpoints[2]->toString())); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter66"; i++); + test(i == nRetry); + adapters.push_back(com->createObjectAdapter("Adapter65", endpoints[1]->toString())); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter65"; i++); + test(i == nRetry); + adapters.push_back(com->createObjectAdapter("Adapter64", endpoints[0]->toString())); + for(i = 0; i < nRetry && test->getAdapterName() == "Adapter64"; i++); + test(i == nRetry); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing per request binding and ordered endpoint selection and AMI... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("AdapterAMI61", "default")); - adapters.push_back(com->createObjectAdapter("AdapterAMI62", "default")); - adapters.push_back(com->createObjectAdapter("AdapterAMI63", "default")); - - TestIntfPrx test = createTestIntfPrx(adapters); - test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered)); - test(test->ice_getEndpointSelection() == Ice::Ordered); - test = TestIntfPrx::uncheckedCast(test->ice_connectionCached(false)); - test(!test->ice_isConnectionCached()); - const int nRetry = 5; - int i; - - // - // Ensure that endpoints are tried in order by deactiving the adapters - // one after the other. - // - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI61"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[0]); - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI62"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[1]); - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI63"; i++); - test(i == nRetry); - com->deactivateObjectAdapter(adapters[2]); - - try - { - test->getAdapterName(); - } - catch(const Ice::ConnectionRefusedException&) - { - } - - Ice::EndpointSeq endpoints = test->ice_getEndpoints(); - - adapters.clear(); - - // - // Now, re-activate the adapters with the same endpoints in the opposite - // order. - // - adapters.push_back(com->createObjectAdapter("AdapterAMI66", endpoints[2]->toString())); - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI66"; i++); - test(i == nRetry); - adapters.push_back(com->createObjectAdapter("AdapterAMI65", endpoints[1]->toString())); - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI65"; i++); - test(i == nRetry); - adapters.push_back(com->createObjectAdapter("AdapterAMI64", endpoints[0]->toString())); - for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI64"; i++); - test(i == nRetry); - - deactivate(com, adapters); + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("AdapterAMI61", "default")); + adapters.push_back(com->createObjectAdapter("AdapterAMI62", "default")); + adapters.push_back(com->createObjectAdapter("AdapterAMI63", "default")); + + TestIntfPrx test = createTestIntfPrx(adapters); + test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered)); + test(test->ice_getEndpointSelection() == Ice::Ordered); + test = TestIntfPrx::uncheckedCast(test->ice_connectionCached(false)); + test(!test->ice_isConnectionCached()); + const int nRetry = 5; + int i; + + // + // Ensure that endpoints are tried in order by deactiving the adapters + // one after the other. + // + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI61"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[0]); + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI62"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[1]); + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI63"; i++); + test(i == nRetry); + com->deactivateObjectAdapter(adapters[2]); + + try + { + test->getAdapterName(); + } + catch(const Ice::ConnectionRefusedException&) + { + } + + Ice::EndpointSeq endpoints = test->ice_getEndpoints(); + + adapters.clear(); + + // + // Now, re-activate the adapters with the same endpoints in the opposite + // order. + // + adapters.push_back(com->createObjectAdapter("AdapterAMI66", endpoints[2]->toString())); + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI66"; i++); + test(i == nRetry); + adapters.push_back(com->createObjectAdapter("AdapterAMI65", endpoints[1]->toString())); + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI65"; i++); + test(i == nRetry); + adapters.push_back(com->createObjectAdapter("AdapterAMI64", endpoints[0]->toString())); + for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI64"; i++); + test(i == nRetry); + + deactivate(com, adapters); } cout << "ok" << endl; cout << "testing endpoint mode filtering... " << flush; { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter71", "default")); - adapters.push_back(com->createObjectAdapter("Adapter72", "udp")); - - TestIntfPrx test = createTestIntfPrx(adapters); - test(test->getAdapterName() == "Adapter71"); - - TestIntfPrx testUDP = TestIntfPrx::uncheckedCast(test->ice_datagram()); - test(test->ice_getConnection() != testUDP->ice_getConnection()); - try - { - testUDP->getAdapterName(); - } - catch(const Ice::TwowayOnlyException&) - { - } + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter71", "default")); + adapters.push_back(com->createObjectAdapter("Adapter72", "udp")); + + TestIntfPrx test = createTestIntfPrx(adapters); + test(test->getAdapterName() == "Adapter71"); + + TestIntfPrx testUDP = TestIntfPrx::uncheckedCast(test->ice_datagram()); + test(test->ice_getConnection() != testUDP->ice_getConnection()); + try + { + testUDP->getAdapterName(); + } + catch(const Ice::TwowayOnlyException&) + { + } } cout << "ok" << endl; if(!communicator->getProperties()->getProperty("Ice.Plugin.IceSSL").empty()) { - cout << "testing unsecure vs. secure endpoints... " << flush; - { - vector<RemoteObjectAdapterPrx> adapters; - adapters.push_back(com->createObjectAdapter("Adapter81", "ssl")); - adapters.push_back(com->createObjectAdapter("Adapter82", "tcp")); - - TestIntfPrx test = createTestIntfPrx(adapters); - int i; - for(i = 0; i < 5; i++) - { - test(test->getAdapterName() == "Adapter82"); - test->ice_getConnection()->close(false); - } - - TestIntfPrx testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true)); - test(testSecure->ice_isSecure()); - testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(false)); - test(!testSecure->ice_isSecure()); - testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true)); - test(testSecure->ice_isSecure()); - test(test->ice_getConnection() != testSecure->ice_getConnection()); - - com->deactivateObjectAdapter(adapters[1]); - - for(i = 0; i < 5; i++) - { - test(test->getAdapterName() == "Adapter81"); - test->ice_getConnection()->close(false); - } - - com->createObjectAdapter("Adapter83", (test->ice_getEndpoints()[1])->toString()); // Reactive tcp OA. - - for(i = 0; i < 5; i++) - { - test(test->getAdapterName() == "Adapter83"); - test->ice_getConnection()->close(false); - } - - com->deactivateObjectAdapter(adapters[0]); - try - { - testSecure->ice_ping(); - test(false); - } - catch(const Ice::ConnectionRefusedException&) - { - } - - deactivate(com, adapters); - } - cout << "ok" << endl; + cout << "testing unsecure vs. secure endpoints... " << flush; + { + vector<RemoteObjectAdapterPrx> adapters; + adapters.push_back(com->createObjectAdapter("Adapter81", "ssl")); + adapters.push_back(com->createObjectAdapter("Adapter82", "tcp")); + + TestIntfPrx test = createTestIntfPrx(adapters); + int i; + for(i = 0; i < 5; i++) + { + test(test->getAdapterName() == "Adapter82"); + test->ice_getConnection()->close(false); + } + + TestIntfPrx testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true)); + test(testSecure->ice_isSecure()); + testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(false)); + test(!testSecure->ice_isSecure()); + testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true)); + test(testSecure->ice_isSecure()); + test(test->ice_getConnection() != testSecure->ice_getConnection()); + + com->deactivateObjectAdapter(adapters[1]); + + for(i = 0; i < 5; i++) + { + test(test->getAdapterName() == "Adapter81"); + test->ice_getConnection()->close(false); + } + + com->createObjectAdapter("Adapter83", (test->ice_getEndpoints()[1])->toString()); // Reactive tcp OA. + + for(i = 0; i < 5; i++) + { + test(test->getAdapterName() == "Adapter83"); + test->ice_getConnection()->close(false); + } + + com->deactivateObjectAdapter(adapters[0]); + try + { + testSecure->ice_ping(); + test(false); + } + catch(const Ice::ConnectionRefusedException&) + { + } + + deactivate(com, adapters); + } + cout << "ok" << endl; } com->shutdown(); diff --git a/cpp/test/Ice/binding/Client.cpp b/cpp/test/Ice/binding/Client.cpp index 0527d790712..a0f1ccc1976 100644 --- a/cpp/test/Ice/binding/Client.cpp +++ b/cpp/test/Ice/binding/Client.cpp @@ -29,26 +29,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/binding/Server.cpp b/cpp/test/Ice/binding/Server.cpp index 99d9b2beafd..ca6e34b3b7d 100644 --- a/cpp/test/Ice/binding/Server.cpp +++ b/cpp/test/Ice/binding/Server.cpp @@ -36,26 +36,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/binding/TestI.cpp b/cpp/test/Ice/binding/TestI.cpp index cbbad4a6e11..8407ebff887 100644 --- a/cpp/test/Ice/binding/TestI.cpp +++ b/cpp/test/Ice/binding/TestI.cpp @@ -41,7 +41,7 @@ RemoteCommunicatorI::shutdown(const Ice::Current& current) RemoteObjectAdapterI::RemoteObjectAdapterI(const Ice::ObjectAdapterPtr& adapter) : _adapter(adapter), _testIntf(TestIntfPrx::uncheckedCast(_adapter->add(new TestI(), - adapter->getCommunicator()->stringToIdentity("test")))) + adapter->getCommunicator()->stringToIdentity("test")))) { _adapter->activate(); } @@ -57,7 +57,7 @@ RemoteObjectAdapterI::deactivate(const Ice::Current&) { try { - _adapter->destroy(); + _adapter->destroy(); } catch(const ObjectAdapterDeactivatedException&) { diff --git a/cpp/test/Ice/binding/TestI.h b/cpp/test/Ice/binding/TestI.h index b17e3585bcc..569f6f24965 100644 --- a/cpp/test/Ice/binding/TestI.h +++ b/cpp/test/Ice/binding/TestI.h @@ -17,7 +17,7 @@ class RemoteCommunicatorI : public Test::RemoteCommunicator public: virtual Test::RemoteObjectAdapterPrx createObjectAdapter(const std::string&, const std::string&, - const Ice::Current&); + const Ice::Current&); virtual void deactivateObjectAdapter(const Test::RemoteObjectAdapterPrx&, const Ice::Current&); virtual void shutdown(const Ice::Current&); }; diff --git a/cpp/test/Ice/checksum/client/Client.cpp b/cpp/test/Ice/checksum/client/Client.cpp index e9d573432c0..792d51c0beb 100644 --- a/cpp/test/Ice/checksum/client/Client.cpp +++ b/cpp/test/Ice/checksum/client/Client.cpp @@ -30,26 +30,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/checksum/server/Server.cpp b/cpp/test/Ice/checksum/server/Server.cpp index 273c04de334..261564c6ca8 100644 --- a/cpp/test/Ice/checksum/server/Server.cpp +++ b/cpp/test/Ice/checksum/server/Server.cpp @@ -32,26 +32,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/custom/AllTests.cpp b/cpp/test/Ice/custom/AllTests.cpp index 535fe84ffba..e7e70631422 100644 --- a/cpp/test/Ice/custom/AllTests.cpp +++ b/cpp/test/Ice/custom/AllTests.cpp @@ -69,7 +69,7 @@ public: virtual void ice_response(const Test::BoolSeq& ret, const Test::BoolSeq& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -95,18 +95,18 @@ public: } virtual void ice_response(const pair<const Ice::Byte*, const Ice::Byte*>& ret, - const pair<const Ice::Byte*, const Ice::Byte*>& out) + const pair<const Ice::Byte*, const Ice::Byte*>& out) { test(_in.second - _in.first == out.second - out.first); test(_in.second - _in.first == ret.second - ret.first); - Ice::Byte* b = const_cast<Ice::Byte*>(_in.first); - Ice::Byte* r = const_cast<Ice::Byte*>(ret.first); - Ice::Byte* o = const_cast<Ice::Byte*>(out.first); - while(b != _in.second) - { - test(*r++ == *b); - test(*o++ == *b++); - } + Ice::Byte* b = const_cast<Ice::Byte*>(_in.first); + Ice::Byte* r = const_cast<Ice::Byte*>(ret.first); + Ice::Byte* o = const_cast<Ice::Byte*>(out.first); + while(b != _in.second) + { + test(*r++ == *b); + test(*o++ == *b++); + } called(); } @@ -134,7 +134,7 @@ public: virtual void ice_response(const Test::VariableList& ret, const Test::VariableList& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -162,7 +162,7 @@ public: virtual void ice_response(const Test::BoolSeq& ret, const Test::BoolSeq& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -188,18 +188,18 @@ public: } virtual void ice_response(const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& ret, - const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& out) + const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& out) { test(ice_distance(out.first, out.second) == static_cast<Ice::Int>(_in.size())); test(ice_distance(ret.first, ret.second) == static_cast<Ice::Int>(_in.size())); - Test::ByteList::const_iterator b; - Test::ByteList::const_iterator o = out.first; - Test::ByteList::const_iterator r = ret.first; - for(b = _in.begin(); b != _in.end(); ++b) - { - test(*b == *o++); - test(*b == *r++); - } + Test::ByteList::const_iterator b; + Test::ByteList::const_iterator o = out.first; + Test::ByteList::const_iterator r = ret.first; + for(b = _in.begin(); b != _in.end(); ++b) + { + test(*b == *o++); + test(*b == *r++); + } called(); } @@ -227,7 +227,7 @@ public: virtual void ice_response(const Test::VariableList& ret, const Test::VariableList& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -255,7 +255,7 @@ public: virtual void ice_response(const Test::BoolSeq& ret, const Test::BoolSeq& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -283,7 +283,7 @@ public: virtual void ice_response(const Test::ByteList& ret, const Test::ByteList& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -311,7 +311,7 @@ public: virtual void ice_response(const Test::VariableList& ret, const Test::VariableList& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -339,7 +339,7 @@ public: virtual void ice_response(const deque<bool>& ret, const deque<bool>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -367,7 +367,7 @@ public: virtual void ice_response(const list<bool>& ret, const list<bool>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -395,7 +395,7 @@ public: virtual void ice_response(const deque<Ice::Byte>& ret, const deque<Ice::Byte>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -423,7 +423,7 @@ public: virtual void ice_response(const list<Ice::Byte>& ret, const list<Ice::Byte>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -451,7 +451,7 @@ public: virtual void ice_response(const MyByteSeq& ret, const MyByteSeq& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -479,7 +479,7 @@ public: virtual void ice_response(const deque<string>& ret, const deque<string>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -507,7 +507,7 @@ public: virtual void ice_response(const list<string>& ret, const list<string>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -535,7 +535,7 @@ public: virtual void ice_response(const deque<Test::Fixed>& ret, const deque<Test::Fixed>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -563,7 +563,7 @@ public: virtual void ice_response(const list<Test::Fixed>& ret, const list<Test::Fixed>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -591,7 +591,7 @@ public: virtual void ice_response(const deque<Test::Variable>& ret, const deque<Test::Variable>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -619,7 +619,7 @@ public: virtual void ice_response(const list<Test::Variable>& ret, const list<Test::Variable>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -647,7 +647,7 @@ public: virtual void ice_response(const deque<Test::StringStringDict>& ret, const deque<Test::StringStringDict>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -675,7 +675,7 @@ public: virtual void ice_response(const list<Test::StringStringDict>& ret, const list<Test::StringStringDict>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -703,7 +703,7 @@ public: virtual void ice_response(const deque<Test::E>& ret, const deque<Test::E>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -731,7 +731,7 @@ public: virtual void ice_response(const list<Test::E>& ret, const list<Test::E>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -759,7 +759,7 @@ public: virtual void ice_response(const deque<Test::CPrx>& ret, const deque<Test::CPrx>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -787,7 +787,7 @@ public: virtual void ice_response(const list<Test::CPrx>& ret, const list<Test::CPrx>& out) { test(out == _in); - test(ret == _in); + test(ret == _in); called(); } @@ -814,13 +814,13 @@ public: virtual void ice_response(const deque<Test::CPtr>& ret, const deque<Test::CPtr>& out) { - test(out.size() == _in.size()); - test(ret.size() == _in.size()); - for(unsigned int i = 1; i < _in.size(); ++i) - { - test(out[i] == out[0]); - test(ret[i] == out[i]); - } + test(out.size() == _in.size()); + test(ret.size() == _in.size()); + for(unsigned int i = 1; i < _in.size(); ++i) + { + test(out[i] == out[0]); + test(ret[i] == out[i]); + } called(); } @@ -847,14 +847,14 @@ public: virtual void ice_response(const list<Test::CPtr>& ret, const list<Test::CPtr>& out) { - test(out.size() == _in.size()); - test(ret.size() == _in.size()); - list<Test::CPtr>::const_iterator p1; - list<Test::CPtr>::const_iterator p2; - for(p1 = out.begin(), p2 = ret.begin(); p1 != out.end(); ++p1, ++p2) - { - test(*p1 == *p2); - } + test(out.size() == _in.size()); + test(ret.size() == _in.size()); + list<Test::CPtr>::const_iterator p1; + list<Test::CPtr>::const_iterator p2; + for(p1 = out.begin(), p2 = ret.begin(); p1 != out.end(); ++p1, ++p2) + { + test(*p1 == *p2); + } called(); } @@ -875,17 +875,17 @@ class AMI_TestIntf_opClassStructI : public Test::AMI_TestIntf_opClassStruct, pub public: AMI_TestIntf_opClassStructI(const Test::ClassStructPtr& cs, const Test::ClassStructSeq& csseq1) : - _cs(cs), _csseq1(csseq1) + _cs(cs), _csseq1(csseq1) { } virtual void ice_response(const ::Test::ClassStructPtr& ret, - const ::Test::ClassStructPtr& cs1, - const ::Test::ClassStructSeq& seq) + const ::Test::ClassStructPtr& cs1, + const ::Test::ClassStructSeq& seq) { - test(ret == _cs); - test(cs1 == _cs); - test(seq == _csseq1); + test(ret == _cs); + test(cs1 == _cs); + test(seq == _csseq1); called(); } @@ -912,9 +912,9 @@ public: virtual void ice_response(const wstring& ret, const wstring& out) { - test(out == _in); - test(ret == _in); - called(); + test(out == _in); + test(ret == _in); + called(); } virtual void ice_exception(const ::Ice::Exception&) @@ -940,9 +940,9 @@ public: virtual void ice_response(const wstring& ret, const wstring& out) { - test(out == _in); - test(ret == _in); - called(); + test(out == _in); + test(ret == _in); + called(); } virtual void ice_exception(const ::Ice::Exception&) @@ -974,18 +974,18 @@ public: virtual void ice_exception(const ::Ice::Exception& ex) { try - { - ex.ice_throw(); - } - catch(const Test1::WstringException& e) - { - test(e.reason == _in); - called(); - } - catch(...) - { + { + ex.ice_throw(); + } + catch(const Test1::WstringException& e) + { + test(e.reason == _in); + called(); + } + catch(...) + { test(false); - } + } } private: @@ -1012,18 +1012,18 @@ public: virtual void ice_exception(const ::Ice::Exception& ex) { try - { - ex.ice_throw(); - } - catch(const Test2::WstringException& e) - { - test(e.reason == _in); - called(); - } - catch(...) - { + { + ex.ice_throw(); + } + catch(const Test2::WstringException& e) + { + test(e.reason == _in); + called(); + } + catch(...) + { test(false); - } + } } private: @@ -1038,7 +1038,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { cout << "testing stringToProxy... " << flush; string ref = communicator->getProperties()->getPropertyWithDefault( - "Custom.Proxy", "test:default -p 12010 -t 10000"); + "Custom.Proxy", "test:default -p 12010 -t 10000"); Ice::ObjectPrx base = communicator->stringToProxy(ref); test(base); cout << "ok" << endl; @@ -1053,487 +1053,487 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { Test::DoubleSeq in(5); - in[0] = 3.14; - in[1] = 1 / 3; - in[2] = 0.375; - in[3] = 4 / 3; - in[4] = -5.725; - Ice::Double inArray[5]; - for(int i = 0; i < 5; ++i) - { - inArray[i] = in[i]; - } - pair<const Ice::Double*, const Ice::Double*> inPair(inArray, inArray + 5); + in[0] = 3.14; + in[1] = 1 / 3; + in[2] = 0.375; + in[3] = 4 / 3; + in[4] = -5.725; + Ice::Double inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const Ice::Double*, const Ice::Double*> inPair(inArray, inArray + 5); - Test::DoubleSeq out; - Test::DoubleSeq ret = t->opDoubleArray(inPair, out); - test(out == in); - test(ret == in); + Test::DoubleSeq out; + Test::DoubleSeq ret = t->opDoubleArray(inPair, out); + test(out == in); + test(ret == in); } { Test::BoolSeq in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - bool inArray[5]; - for(int i = 0; i < 5; ++i) - { - inArray[i] = in[i]; - } - pair<const bool*, const bool*> inPair(inArray, inArray + 5); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + bool inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const bool*, const bool*> inPair(inArray, inArray + 5); - Test::BoolSeq out; - Test::BoolSeq ret = t->opBoolArray(inPair, out); - test(out == in); - test(ret == in); + Test::BoolSeq out; + Test::BoolSeq ret = t->opBoolArray(inPair, out); + test(out == in); + test(ret == in); } { Test::ByteList in; - Ice::Byte inArray[5]; - inArray[0] = '1'; - in.push_back(inArray[0]); - inArray[1] = '2'; - in.push_back(inArray[1]); - inArray[2] = '3'; - in.push_back(inArray[2]); - inArray[3] = '4'; - in.push_back(inArray[3]); - inArray[4] = '5'; - in.push_back(inArray[4]); - pair<const Ice::Byte*, const Ice::Byte*> inPair(inArray, inArray + 5); - - Test::ByteList out; - Test::ByteList ret = t->opByteArray(inPair, out); - test(out == in); - test(ret == in); + Ice::Byte inArray[5]; + inArray[0] = '1'; + in.push_back(inArray[0]); + inArray[1] = '2'; + in.push_back(inArray[1]); + inArray[2] = '3'; + in.push_back(inArray[2]); + inArray[3] = '4'; + in.push_back(inArray[3]); + inArray[4] = '5'; + in.push_back(inArray[4]); + pair<const Ice::Byte*, const Ice::Byte*> inPair(inArray, inArray + 5); + + Test::ByteList out; + Test::ByteList ret = t->opByteArray(inPair, out); + test(out == in); + test(ret == in); } { Test::VariableList in; - Test::Variable inArray[5]; - inArray[0].s = "These"; - in.push_back(inArray[0]); - inArray[1].s = "are"; - in.push_back(inArray[1]); - inArray[2].s = "five"; - in.push_back(inArray[2]); - inArray[3].s = "short"; - in.push_back(inArray[3]); - inArray[4].s = "strings."; - in.push_back(inArray[4]); - pair<const Test::Variable*, const Test::Variable*> inPair(inArray, inArray + 5); - - Test::VariableList out; - Test::VariableList ret = t->opVariableArray(inPair, out); - test(out == in); - test(ret == in); + Test::Variable inArray[5]; + inArray[0].s = "These"; + in.push_back(inArray[0]); + inArray[1].s = "are"; + in.push_back(inArray[1]); + inArray[2].s = "five"; + in.push_back(inArray[2]); + inArray[3].s = "short"; + in.push_back(inArray[3]); + inArray[4].s = "strings."; + in.push_back(inArray[4]); + pair<const Test::Variable*, const Test::Variable*> inPair(inArray, inArray + 5); + + Test::VariableList out; + Test::VariableList ret = t->opVariableArray(inPair, out); + test(out == in); + test(ret == in); } { Test::BoolSeq in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator> inPair(in.begin(), in.end()); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator> inPair(in.begin(), in.end()); - Test::BoolSeq out; - Test::BoolSeq ret = t->opBoolRange(inPair, out); - test(out == in); - test(ret == in); + Test::BoolSeq out; + Test::BoolSeq ret = t->opBoolRange(inPair, out); + test(out == in); + test(ret == in); } { Test::ByteList in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); - pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); - Test::ByteList out; - Test::ByteList ret = t->opByteRange(inPair, out); - test(out == in); - test(ret == in); + Test::ByteList out; + Test::ByteList ret = t->opByteRange(inPair, out); + test(out == in); + test(ret == in); } { Test::VariableList in; - Test::Variable v; - v.s = "These"; - in.push_back(v); - v.s = "are"; - in.push_back(v); - v.s = "five"; - in.push_back(v); - v.s = "short"; - in.push_back(v); - v.s = "strings."; - in.push_back(v); - pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator> inPair(in.begin(), in.end()); - - Test::VariableList out; - Test::VariableList ret = t->opVariableRange(inPair, out); - test(out == in); - test(ret == in); + Test::Variable v; + v.s = "These"; + in.push_back(v); + v.s = "are"; + in.push_back(v); + v.s = "five"; + in.push_back(v); + v.s = "short"; + in.push_back(v); + v.s = "strings."; + in.push_back(v); + pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator> inPair(in.begin(), in.end()); + + Test::VariableList out; + Test::VariableList ret = t->opVariableRange(inPair, out); + test(out == in); + test(ret == in); } { Test::BoolSeq in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - bool inArray[5]; - for(int i = 0; i < 5; ++i) - { - inArray[i] = in[i]; - } - pair<const bool*, const bool*> inPair(inArray, inArray + 5); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + bool inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const bool*, const bool*> inPair(inArray, inArray + 5); - Test::BoolSeq out; - Test::BoolSeq ret = t->opBoolRangeType(inPair, out); - test(out == in); - test(ret == in); + Test::BoolSeq out; + Test::BoolSeq ret = t->opBoolRangeType(inPair, out); + test(out == in); + test(ret == in); } { Test::ByteList in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); - pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); - Test::ByteList out; - Test::ByteList ret = t->opByteRangeType(inPair, out); - test(out == in); - test(ret == in); + Test::ByteList out; + Test::ByteList ret = t->opByteRangeType(inPair, out); + test(out == in); + test(ret == in); } { Test::VariableList in; - deque<Test::Variable> inSeq; - Test::Variable v; - v.s = "These"; - in.push_back(v); - inSeq.push_back(v); - v.s = "are"; - in.push_back(v); - inSeq.push_back(v); - v.s = "five"; - in.push_back(v); - inSeq.push_back(v); - v.s = "short"; - in.push_back(v); - inSeq.push_back(v); - v.s = "strings."; - in.push_back(v); - inSeq.push_back(v); - pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator> - inPair(inSeq.begin(), inSeq.end()); - - Test::VariableList out; - Test::VariableList ret = t->opVariableRangeType(inPair, out); - test(out == in); - test(ret == in); + deque<Test::Variable> inSeq; + Test::Variable v; + v.s = "These"; + in.push_back(v); + inSeq.push_back(v); + v.s = "are"; + in.push_back(v); + inSeq.push_back(v); + v.s = "five"; + in.push_back(v); + inSeq.push_back(v); + v.s = "short"; + in.push_back(v); + inSeq.push_back(v); + v.s = "strings."; + in.push_back(v); + inSeq.push_back(v); + pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator> + inPair(inSeq.begin(), inSeq.end()); + + Test::VariableList out; + Test::VariableList ret = t->opVariableRangeType(inPair, out); + test(out == in); + test(ret == in); } { deque<bool> in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; - deque<bool> out; - deque<bool> ret = t->opBoolSeq(in, out); - test(out == in); - test(ret == in); + deque<bool> out; + deque<bool> ret = t->opBoolSeq(in, out); + test(out == in); + test(ret == in); } { list<bool> in; - in.push_back(false); - in.push_back(true); - in.push_back(true); - in.push_back(false); - in.push_back(true); + in.push_back(false); + in.push_back(true); + in.push_back(true); + in.push_back(false); + in.push_back(true); - list<bool> out; - list<bool> ret = t->opBoolList(in, out); - test(out == in); - test(ret == in); + list<bool> out; + list<bool> ret = t->opBoolList(in, out); + test(out == in); + test(ret == in); } { deque< ::Ice::Byte> in(5); - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; + in[0] = '1'; + in[1] = '2'; + in[2] = '3'; + in[3] = '4'; + in[4] = '5'; - deque< ::Ice::Byte> out; - deque< ::Ice::Byte> ret = t->opByteSeq(in, out); - test(out == in); - test(ret == in); + deque< ::Ice::Byte> out; + deque< ::Ice::Byte> ret = t->opByteSeq(in, out); + test(out == in); + test(ret == in); } { list< ::Ice::Byte> in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); - list< ::Ice::Byte> out; - list< ::Ice::Byte> ret = t->opByteList(in, out); - test(out == in); - test(ret == in); + list< ::Ice::Byte> out; + list< ::Ice::Byte> ret = t->opByteList(in, out); + test(out == in); + test(ret == in); } { MyByteSeq in(5); - int i = 0; - for(MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) - { - *p = '1' + i++; - } + int i = 0; + for(MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) + { + *p = '1' + i++; + } - MyByteSeq out; - MyByteSeq ret = t->opMyByteSeq(in, out); - test(out == in); - test(ret == in); + MyByteSeq out; + MyByteSeq ret = t->opMyByteSeq(in, out); + test(out == in); + test(ret == in); } { deque<string> in(5); - in[0] = "These"; - in[1] = "are"; - in[2] = "five"; - in[3] = "short"; - in[4] = "strings."; + in[0] = "These"; + in[1] = "are"; + in[2] = "five"; + in[3] = "short"; + in[4] = "strings."; - deque<string> out; - deque<string> ret = t->opStringSeq(in, out); - test(out == in); - test(ret == in); + deque<string> out; + deque<string> ret = t->opStringSeq(in, out); + test(out == in); + test(ret == in); } { list<string> in; - in.push_back("These"); - in.push_back("are"); - in.push_back("five"); - in.push_back("short"); - in.push_back("strings."); + in.push_back("These"); + in.push_back("are"); + in.push_back("five"); + in.push_back("short"); + in.push_back("strings."); - list<string> out; - list<string> ret = t->opStringList(in, out); - test(out == in); - test(ret == in); + list<string> out; + list<string> ret = t->opStringList(in, out); + test(out == in); + test(ret == in); } { deque<Test::Fixed> in(5); - in[0].s = 1; - in[1].s = 2; - in[2].s = 3; - in[3].s = 4; - in[4].s = 5; + in[0].s = 1; + in[1].s = 2; + in[2].s = 3; + in[3].s = 4; + in[4].s = 5; - deque<Test::Fixed> out; - deque<Test::Fixed> ret = t->opFixedSeq(in, out); - test(out == in); - test(ret == in); + deque<Test::Fixed> out; + deque<Test::Fixed> ret = t->opFixedSeq(in, out); + test(out == in); + test(ret == in); } { list<Test::Fixed> in(5); - short num = 1; - for(list<Test::Fixed>::iterator p = in.begin(); p != in.end(); ++p) - { - (*p).s = num++; - } + short num = 1; + for(list<Test::Fixed>::iterator p = in.begin(); p != in.end(); ++p) + { + (*p).s = num++; + } - list<Test::Fixed> out; - list<Test::Fixed> ret = t->opFixedList(in, out); - test(out == in); - test(ret == in); + list<Test::Fixed> out; + list<Test::Fixed> ret = t->opFixedList(in, out); + test(out == in); + test(ret == in); } { deque<Test::Variable> in(5); - in[0].s = "These"; - in[1].s = "are"; - in[2].s = "five"; - in[3].s = "short"; - in[4].s = "strings."; + in[0].s = "These"; + in[1].s = "are"; + in[2].s = "five"; + in[3].s = "short"; + in[4].s = "strings."; - deque<Test::Variable> out; - deque<Test::Variable> ret = t->opVariableSeq(in, out); - test(out == in); - test(ret == in); + deque<Test::Variable> out; + deque<Test::Variable> ret = t->opVariableSeq(in, out); + test(out == in); + test(ret == in); } { list<Test::Variable> in; - Test::Variable v; - v.s = "These"; - in.push_back(v); - v.s = "are"; - in.push_back(v); - v.s = "five"; - in.push_back(v); - v.s = "short"; - in.push_back(v); - v.s = "strings."; - in.push_back(v); + Test::Variable v; + v.s = "These"; + in.push_back(v); + v.s = "are"; + in.push_back(v); + v.s = "five"; + in.push_back(v); + v.s = "short"; + in.push_back(v); + v.s = "strings."; + in.push_back(v); - list<Test::Variable> out; - list<Test::Variable> ret = t->opVariableList(in, out); - test(out == in); - test(ret == in); + list<Test::Variable> out; + list<Test::Variable> ret = t->opVariableList(in, out); + test(out == in); + test(ret == in); } { deque<Test::StringStringDict> in(5); - in[0]["A"] = "a"; - in[1]["B"] = "b"; - in[2]["C"] = "c"; - in[3]["D"] = "d"; - in[4]["E"] = "e"; + in[0]["A"] = "a"; + in[1]["B"] = "b"; + in[2]["C"] = "c"; + in[3]["D"] = "d"; + in[4]["E"] = "e"; - deque<Test::StringStringDict> out; - deque<Test::StringStringDict> ret = t->opStringStringDictSeq(in, out); - test(out == in); - test(ret == in); + deque<Test::StringStringDict> out; + deque<Test::StringStringDict> ret = t->opStringStringDictSeq(in, out); + test(out == in); + test(ret == in); } { list<Test::StringStringDict> in; - Test::StringStringDict ssd; - ssd["A"] = "a"; - in.push_back(ssd); - ssd["B"] = "b"; - in.push_back(ssd); - ssd["C"] = "c"; - in.push_back(ssd); - ssd["D"] = "d"; - in.push_back(ssd); - ssd["E"] = "e"; - in.push_back(ssd); + Test::StringStringDict ssd; + ssd["A"] = "a"; + in.push_back(ssd); + ssd["B"] = "b"; + in.push_back(ssd); + ssd["C"] = "c"; + in.push_back(ssd); + ssd["D"] = "d"; + in.push_back(ssd); + ssd["E"] = "e"; + in.push_back(ssd); - list<Test::StringStringDict> out; - list<Test::StringStringDict> ret = t->opStringStringDictList(in, out); - test(out == in); - test(ret == in); + list<Test::StringStringDict> out; + list<Test::StringStringDict> ret = t->opStringStringDictList(in, out); + test(out == in); + test(ret == in); } { deque<Test::E> in(5); - in[0] = Test::E1; - in[1] = Test::E2; - in[2] = Test::E3; - in[3] = Test::E1; - in[4] = Test::E3; + in[0] = Test::E1; + in[1] = Test::E2; + in[2] = Test::E3; + in[3] = Test::E1; + in[4] = Test::E3; - deque<Test::E> out; - deque<Test::E> ret = t->opESeq(in, out); - test(out == in); - test(ret == in); + deque<Test::E> out; + deque<Test::E> ret = t->opESeq(in, out); + test(out == in); + test(ret == in); } { list<Test::E> in; - in.push_back(Test::E1); - in.push_back(Test::E2); - in.push_back(Test::E3); - in.push_back(Test::E1); - in.push_back(Test::E3); + in.push_back(Test::E1); + in.push_back(Test::E2); + in.push_back(Test::E3); + in.push_back(Test::E1); + in.push_back(Test::E3); - list<Test::E> out; - list<Test::E> ret = t->opEList(in, out); - test(out == in); - test(ret == in); + list<Test::E> out; + list<Test::E> ret = t->opEList(in, out); + test(out == in); + test(ret == in); } { deque<Test::CPrx> in(5); - in[0] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000")); - in[1] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001")); - in[2] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002")); - in[3] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003")); - in[4] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004")); + in[0] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000")); + in[1] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001")); + in[2] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002")); + in[3] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003")); + in[4] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004")); - deque<Test::CPrx> out; - deque<Test::CPrx> ret = t->opCPrxSeq(in, out); - test(out == in); - test(ret == in); + deque<Test::CPrx> out; + deque<Test::CPrx> ret = t->opCPrxSeq(in, out); + test(out == in); + test(ret == in); } { list<Test::CPrx> in; - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004"))); - list<Test::CPrx> out; - list<Test::CPrx> ret = t->opCPrxList(in, out); - test(out == in); - test(ret == in); + list<Test::CPrx> out; + list<Test::CPrx> ret = t->opCPrxList(in, out); + test(out == in); + test(ret == in); } { deque<Test::CPtr> in(5); - in[0] = new Test::C(); - in[1] = in[0]; - in[2] = in[0]; - in[3] = in[0]; - in[4] = in[0]; - - deque<Test::CPtr> out; - deque<Test::CPtr> ret = t->opCSeq(in, out); - test(out.size() == in.size()); - test(ret.size() == in.size()); - for(unsigned int i = 1; i < in.size(); ++i) - { - test(out[i] == out[0]); - test(ret[i] == out[i]); - } + in[0] = new Test::C(); + in[1] = in[0]; + in[2] = in[0]; + in[3] = in[0]; + in[4] = in[0]; + + deque<Test::CPtr> out; + deque<Test::CPtr> ret = t->opCSeq(in, out); + test(out.size() == in.size()); + test(ret.size() == in.size()); + for(unsigned int i = 1; i < in.size(); ++i) + { + test(out[i] == out[0]); + test(ret[i] == out[i]); + } } { list<Test::CPtr> in; - in.push_back(new Test::C()); - in.push_back(new Test::C()); - in.push_back(new Test::C()); - in.push_back(new Test::C()); - in.push_back(new Test::C()); - - list<Test::CPtr> out; - list<Test::CPtr> ret = t->opCList(in, out); - test(out.size() == in.size()); - test(ret.size() == in.size()); - list<Test::CPtr>::const_iterator p1; - list<Test::CPtr>::const_iterator p2; - for(p1 = out.begin(), p2 = ret.begin(); p1 != out.end(); ++p1, ++p2) - { - test(*p1 == *p2); - } + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + + list<Test::CPtr> out; + list<Test::CPtr> ret = t->opCList(in, out); + test(out.size() == in.size()); + test(ret.size() == in.size()); + list<Test::CPtr>::const_iterator p1; + list<Test::CPtr>::const_iterator p2; + for(p1 = out.begin(), p2 = ret.begin(); p1 != out.end(); ++p1, ++p2) + { + test(*p1 == *p2); + } } cout << "ok" << endl; @@ -1544,422 +1544,422 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { Test::BoolSeq in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - bool inArray[5]; - for(int i = 0; i < 5; ++i) - { - inArray[i] = in[i]; - } - pair<const bool*, const bool*> inPair(inArray, inArray + 5); - - AMI_TestIntf_opBoolArrayIPtr cb = new AMI_TestIntf_opBoolArrayI(in); - t->opBoolArray_async(cb, inPair); - test(cb->check()); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + bool inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const bool*, const bool*> inPair(inArray, inArray + 5); + + AMI_TestIntf_opBoolArrayIPtr cb = new AMI_TestIntf_opBoolArrayI(in); + t->opBoolArray_async(cb, inPair); + test(cb->check()); } { - Ice::Byte in[5]; - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; - pair<const Ice::Byte*, const Ice::Byte*> inPair(in, in + 5); - - AMI_TestIntf_opByteArrayIPtr cb = new AMI_TestIntf_opByteArrayI(inPair); - t->opByteArray_async(cb, inPair); - test(cb->check()); + Ice::Byte in[5]; + in[0] = '1'; + in[1] = '2'; + in[2] = '3'; + in[3] = '4'; + in[4] = '5'; + pair<const Ice::Byte*, const Ice::Byte*> inPair(in, in + 5); + + AMI_TestIntf_opByteArrayIPtr cb = new AMI_TestIntf_opByteArrayI(inPair); + t->opByteArray_async(cb, inPair); + test(cb->check()); } { Test::VariableList in; - Test::Variable inArray[5]; - inArray[0].s = "These"; - in.push_back(inArray[0]); - inArray[1].s = "are"; - in.push_back(inArray[1]); - inArray[2].s = "five"; - in.push_back(inArray[2]); - inArray[3].s = "short"; - in.push_back(inArray[3]); - inArray[4].s = "strings."; - in.push_back(inArray[4]); - pair<const Test::Variable*, const Test::Variable*> inPair(inArray, inArray + 5); - - AMI_TestIntf_opVariableArrayIPtr cb = new AMI_TestIntf_opVariableArrayI(in); - t->opVariableArray_async(cb, inPair); - test(cb->check()); + Test::Variable inArray[5]; + inArray[0].s = "These"; + in.push_back(inArray[0]); + inArray[1].s = "are"; + in.push_back(inArray[1]); + inArray[2].s = "five"; + in.push_back(inArray[2]); + inArray[3].s = "short"; + in.push_back(inArray[3]); + inArray[4].s = "strings."; + in.push_back(inArray[4]); + pair<const Test::Variable*, const Test::Variable*> inPair(inArray, inArray + 5); + + AMI_TestIntf_opVariableArrayIPtr cb = new AMI_TestIntf_opVariableArrayI(in); + t->opVariableArray_async(cb, inPair); + test(cb->check()); } { Test::BoolSeq in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator> inPair(in.begin(), in.end()); - - AMI_TestIntf_opBoolRangeIPtr cb = new AMI_TestIntf_opBoolRangeI(in); - t->opBoolRange_async(cb, inPair); - test(cb->check()); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator> inPair(in.begin(), in.end()); + + AMI_TestIntf_opBoolRangeIPtr cb = new AMI_TestIntf_opBoolRangeI(in); + t->opBoolRange_async(cb, inPair); + test(cb->check()); } { Test::ByteList in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); - pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); - - AMI_TestIntf_opByteRangeIPtr cb = new AMI_TestIntf_opByteRangeI(in); - t->opByteRange_async(cb, inPair); - test(cb->check()); + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); + + AMI_TestIntf_opByteRangeIPtr cb = new AMI_TestIntf_opByteRangeI(in); + t->opByteRange_async(cb, inPair); + test(cb->check()); } { Test::VariableList in; - Test::Variable v; - v.s = "These"; - in.push_back(v); - v.s = "are"; - in.push_back(v); - v.s = "five"; - in.push_back(v); - v.s = "short"; - in.push_back(v); - v.s = "strings."; - in.push_back(v); - pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator> inPair(in.begin(), in.end()); - - AMI_TestIntf_opVariableRangeIPtr cb = new AMI_TestIntf_opVariableRangeI(in); - t->opVariableRange_async(cb, inPair); - test(cb->check()); + Test::Variable v; + v.s = "These"; + in.push_back(v); + v.s = "are"; + in.push_back(v); + v.s = "five"; + in.push_back(v); + v.s = "short"; + in.push_back(v); + v.s = "strings."; + in.push_back(v); + pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator> inPair(in.begin(), in.end()); + + AMI_TestIntf_opVariableRangeIPtr cb = new AMI_TestIntf_opVariableRangeI(in); + t->opVariableRange_async(cb, inPair); + test(cb->check()); } { Test::BoolSeq in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - bool inArray[5]; - for(int i = 0; i < 5; ++i) - { - inArray[i] = in[i]; - } - pair<const bool*, const bool*> inPair(inArray, inArray + 5); - - AMI_TestIntf_opBoolRangeTypeIPtr cb = new AMI_TestIntf_opBoolRangeTypeI(in); - t->opBoolRangeType_async(cb, inPair); - test(cb->check()); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + bool inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const bool*, const bool*> inPair(inArray, inArray + 5); + + AMI_TestIntf_opBoolRangeTypeIPtr cb = new AMI_TestIntf_opBoolRangeTypeI(in); + t->opBoolRangeType_async(cb, inPair); + test(cb->check()); } { Test::ByteList in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); - pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); - - AMI_TestIntf_opByteRangeTypeIPtr cb = new AMI_TestIntf_opByteRangeTypeI(in); - t->opByteRangeType_async(cb, inPair); - test(cb->check()); + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); + + AMI_TestIntf_opByteRangeTypeIPtr cb = new AMI_TestIntf_opByteRangeTypeI(in); + t->opByteRangeType_async(cb, inPair); + test(cb->check()); } { Test::VariableList in; - deque<Test::Variable> inSeq; - Test::Variable v; - v.s = "These"; - in.push_back(v); - inSeq.push_back(v); - v.s = "are"; - in.push_back(v); - inSeq.push_back(v); - v.s = "five"; - in.push_back(v); - inSeq.push_back(v); - v.s = "short"; - in.push_back(v); - inSeq.push_back(v); - v.s = "strings."; - in.push_back(v); - inSeq.push_back(v); - pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator> - inPair(inSeq.begin(), inSeq.end()); - - AMI_TestIntf_opVariableRangeTypeIPtr cb = new AMI_TestIntf_opVariableRangeTypeI(in); - t->opVariableRangeType_async(cb, inPair); - test(cb->check()); + deque<Test::Variable> inSeq; + Test::Variable v; + v.s = "These"; + in.push_back(v); + inSeq.push_back(v); + v.s = "are"; + in.push_back(v); + inSeq.push_back(v); + v.s = "five"; + in.push_back(v); + inSeq.push_back(v); + v.s = "short"; + in.push_back(v); + inSeq.push_back(v); + v.s = "strings."; + in.push_back(v); + inSeq.push_back(v); + pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator> + inPair(inSeq.begin(), inSeq.end()); + + AMI_TestIntf_opVariableRangeTypeIPtr cb = new AMI_TestIntf_opVariableRangeTypeI(in); + t->opVariableRangeType_async(cb, inPair); + test(cb->check()); } { deque<bool> in(5); - in[0] = false; - in[1] = true; - in[2] = true; - in[3] = false; - in[4] = true; - - AMI_TestIntf_opBoolSeqIPtr cb = new AMI_TestIntf_opBoolSeqI(in); - t->opBoolSeq_async(cb, in); - test(cb->check()); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + + AMI_TestIntf_opBoolSeqIPtr cb = new AMI_TestIntf_opBoolSeqI(in); + t->opBoolSeq_async(cb, in); + test(cb->check()); } { list<bool> in; - in.push_back(false); - in.push_back(true); - in.push_back(true); - in.push_back(false); - in.push_back(true); - - AMI_TestIntf_opBoolListIPtr cb = new AMI_TestIntf_opBoolListI(in); - t->opBoolList_async(cb, in); - test(cb->check()); + in.push_back(false); + in.push_back(true); + in.push_back(true); + in.push_back(false); + in.push_back(true); + + AMI_TestIntf_opBoolListIPtr cb = new AMI_TestIntf_opBoolListI(in); + t->opBoolList_async(cb, in); + test(cb->check()); } { deque< ::Ice::Byte> in(5); - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; - - AMI_TestIntf_opByteSeqIPtr cb = new AMI_TestIntf_opByteSeqI(in); - t->opByteSeq_async(cb, in); - test(cb->check()); + in[0] = '1'; + in[1] = '2'; + in[2] = '3'; + in[3] = '4'; + in[4] = '5'; + + AMI_TestIntf_opByteSeqIPtr cb = new AMI_TestIntf_opByteSeqI(in); + t->opByteSeq_async(cb, in); + test(cb->check()); } { list< ::Ice::Byte> in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); - - AMI_TestIntf_opByteListIPtr cb = new AMI_TestIntf_opByteListI(in); - t->opByteList_async(cb, in); - test(cb->check()); + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + + AMI_TestIntf_opByteListIPtr cb = new AMI_TestIntf_opByteListI(in); + t->opByteList_async(cb, in); + test(cb->check()); } { MyByteSeq in(5); - int i = 0; - for(MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) - { - *p = '1' + i++; - } - - AMI_TestIntf_opMyByteSeqIPtr cb = new AMI_TestIntf_opMyByteSeqI(in); - t->opMyByteSeq_async(cb, in); - test(cb->check()); + int i = 0; + for(MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) + { + *p = '1' + i++; + } + + AMI_TestIntf_opMyByteSeqIPtr cb = new AMI_TestIntf_opMyByteSeqI(in); + t->opMyByteSeq_async(cb, in); + test(cb->check()); } { deque<string> in(5); - in[0] = "These"; - in[1] = "are"; - in[2] = "five"; - in[3] = "short"; - in[4] = "strings."; - - AMI_TestIntf_opStringSeqIPtr cb = new AMI_TestIntf_opStringSeqI(in); - t->opStringSeq_async(cb, in); - test(cb->check()); + in[0] = "These"; + in[1] = "are"; + in[2] = "five"; + in[3] = "short"; + in[4] = "strings."; + + AMI_TestIntf_opStringSeqIPtr cb = new AMI_TestIntf_opStringSeqI(in); + t->opStringSeq_async(cb, in); + test(cb->check()); } { list<string> in; - in.push_back("These"); - in.push_back("are"); - in.push_back("five"); - in.push_back("short"); - in.push_back("strings."); - - AMI_TestIntf_opStringListIPtr cb = new AMI_TestIntf_opStringListI(in); - t->opStringList_async(cb, in); - test(cb->check()); + in.push_back("These"); + in.push_back("are"); + in.push_back("five"); + in.push_back("short"); + in.push_back("strings."); + + AMI_TestIntf_opStringListIPtr cb = new AMI_TestIntf_opStringListI(in); + t->opStringList_async(cb, in); + test(cb->check()); } { deque<Test::Fixed> in(5); - in[0].s = 1; - in[1].s = 2; - in[2].s = 3; - in[3].s = 4; - in[4].s = 5; - - AMI_TestIntf_opFixedSeqIPtr cb = new AMI_TestIntf_opFixedSeqI(in); - t->opFixedSeq_async(cb, in); - test(cb->check()); + in[0].s = 1; + in[1].s = 2; + in[2].s = 3; + in[3].s = 4; + in[4].s = 5; + + AMI_TestIntf_opFixedSeqIPtr cb = new AMI_TestIntf_opFixedSeqI(in); + t->opFixedSeq_async(cb, in); + test(cb->check()); } { list<Test::Fixed> in(5); - short num = 1; - for(list<Test::Fixed>::iterator p = in.begin(); p != in.end(); ++p) - { - (*p).s = num++; - } - - AMI_TestIntf_opFixedListIPtr cb = new AMI_TestIntf_opFixedListI(in); - t->opFixedList_async(cb, in); - test(cb->check()); + short num = 1; + for(list<Test::Fixed>::iterator p = in.begin(); p != in.end(); ++p) + { + (*p).s = num++; + } + + AMI_TestIntf_opFixedListIPtr cb = new AMI_TestIntf_opFixedListI(in); + t->opFixedList_async(cb, in); + test(cb->check()); } { deque<Test::Variable> in(5); - in[0].s = "These"; - in[1].s = "are"; - in[2].s = "five"; - in[3].s = "short"; - in[4].s = "strings."; - - AMI_TestIntf_opVariableSeqIPtr cb = new AMI_TestIntf_opVariableSeqI(in); - t->opVariableSeq_async(cb, in); - test(cb->check()); + in[0].s = "These"; + in[1].s = "are"; + in[2].s = "five"; + in[3].s = "short"; + in[4].s = "strings."; + + AMI_TestIntf_opVariableSeqIPtr cb = new AMI_TestIntf_opVariableSeqI(in); + t->opVariableSeq_async(cb, in); + test(cb->check()); } { list<Test::Variable> in; - Test::Variable v; - v.s = "These"; - in.push_back(v); - v.s = "are"; - in.push_back(v); - v.s = "five"; - in.push_back(v); - v.s = "short"; - in.push_back(v); - v.s = "strings."; - in.push_back(v); - - AMI_TestIntf_opVariableListIPtr cb = new AMI_TestIntf_opVariableListI(in); - t->opVariableList_async(cb, in); - test(cb->check()); + Test::Variable v; + v.s = "These"; + in.push_back(v); + v.s = "are"; + in.push_back(v); + v.s = "five"; + in.push_back(v); + v.s = "short"; + in.push_back(v); + v.s = "strings."; + in.push_back(v); + + AMI_TestIntf_opVariableListIPtr cb = new AMI_TestIntf_opVariableListI(in); + t->opVariableList_async(cb, in); + test(cb->check()); } { deque<Test::StringStringDict> in(5); - in[0]["A"] = "a"; - in[1]["B"] = "b"; - in[2]["C"] = "c"; - in[3]["D"] = "d"; - in[4]["E"] = "e"; - - AMI_TestIntf_opStringStringDictSeqIPtr cb = new AMI_TestIntf_opStringStringDictSeqI(in); - t->opStringStringDictSeq_async(cb, in); - test(cb->check()); + in[0]["A"] = "a"; + in[1]["B"] = "b"; + in[2]["C"] = "c"; + in[3]["D"] = "d"; + in[4]["E"] = "e"; + + AMI_TestIntf_opStringStringDictSeqIPtr cb = new AMI_TestIntf_opStringStringDictSeqI(in); + t->opStringStringDictSeq_async(cb, in); + test(cb->check()); } { list<Test::StringStringDict> in; - Test::StringStringDict ssd; - ssd["A"] = "a"; - in.push_back(ssd); - ssd["B"] = "b"; - in.push_back(ssd); - ssd["C"] = "c"; - in.push_back(ssd); - ssd["D"] = "d"; - in.push_back(ssd); - ssd["E"] = "e"; - in.push_back(ssd); - - AMI_TestIntf_opStringStringDictListIPtr cb = new AMI_TestIntf_opStringStringDictListI(in); - t->opStringStringDictList_async(cb, in); - test(cb->check()); + Test::StringStringDict ssd; + ssd["A"] = "a"; + in.push_back(ssd); + ssd["B"] = "b"; + in.push_back(ssd); + ssd["C"] = "c"; + in.push_back(ssd); + ssd["D"] = "d"; + in.push_back(ssd); + ssd["E"] = "e"; + in.push_back(ssd); + + AMI_TestIntf_opStringStringDictListIPtr cb = new AMI_TestIntf_opStringStringDictListI(in); + t->opStringStringDictList_async(cb, in); + test(cb->check()); } { deque<Test::E> in(5); - in[0] = Test::E1; - in[1] = Test::E2; - in[2] = Test::E3; - in[3] = Test::E1; - in[4] = Test::E3; - - AMI_TestIntf_opESeqIPtr cb = new AMI_TestIntf_opESeqI(in); - t->opESeq_async(cb, in); - test(cb->check()); + in[0] = Test::E1; + in[1] = Test::E2; + in[2] = Test::E3; + in[3] = Test::E1; + in[4] = Test::E3; + + AMI_TestIntf_opESeqIPtr cb = new AMI_TestIntf_opESeqI(in); + t->opESeq_async(cb, in); + test(cb->check()); } { list<Test::E> in; - in.push_back(Test::E1); - in.push_back(Test::E2); - in.push_back(Test::E3); - in.push_back(Test::E1); - in.push_back(Test::E3); - - AMI_TestIntf_opEListIPtr cb = new AMI_TestIntf_opEListI(in); - t->opEList_async(cb, in); - test(cb->check()); + in.push_back(Test::E1); + in.push_back(Test::E2); + in.push_back(Test::E3); + in.push_back(Test::E1); + in.push_back(Test::E3); + + AMI_TestIntf_opEListIPtr cb = new AMI_TestIntf_opEListI(in); + t->opEList_async(cb, in); + test(cb->check()); } { deque<Test::CPrx> in(5); - in[0] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000")); - in[1] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001")); - in[2] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002")); - in[3] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003")); - in[4] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004")); - - AMI_TestIntf_opCPrxSeqIPtr cb = new AMI_TestIntf_opCPrxSeqI(in); - t->opCPrxSeq_async(cb, in); - test(cb->check()); + in[0] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000")); + in[1] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001")); + in[2] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002")); + in[3] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003")); + in[4] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004")); + + AMI_TestIntf_opCPrxSeqIPtr cb = new AMI_TestIntf_opCPrxSeqI(in); + t->opCPrxSeq_async(cb, in); + test(cb->check()); } { list<Test::CPrx> in; - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003"))); - in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004"))); - - AMI_TestIntf_opCPrxListIPtr cb = new AMI_TestIntf_opCPrxListI(in); - t->opCPrxList_async(cb, in); - test(cb->check()); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004"))); + + AMI_TestIntf_opCPrxListIPtr cb = new AMI_TestIntf_opCPrxListI(in); + t->opCPrxList_async(cb, in); + test(cb->check()); } { deque<Test::CPtr> in(5); - in[0] = new Test::C(); - in[1] = in[0]; - in[2] = in[0]; - in[3] = in[0]; - in[4] = in[0]; - - AMI_TestIntf_opCSeqIPtr cb = new AMI_TestIntf_opCSeqI(in); - t->opCSeq_async(cb, in); - test(cb->check()); + in[0] = new Test::C(); + in[1] = in[0]; + in[2] = in[0]; + in[3] = in[0]; + in[4] = in[0]; + + AMI_TestIntf_opCSeqIPtr cb = new AMI_TestIntf_opCSeqI(in); + t->opCSeq_async(cb, in); + test(cb->check()); } { list<Test::CPtr> in; - in.push_back(new Test::C()); - in.push_back(new Test::C()); - in.push_back(new Test::C()); - in.push_back(new Test::C()); - in.push_back(new Test::C()); - - AMI_TestIntf_opCListIPtr cb = new AMI_TestIntf_opCListI(in); - t->opCList_async(cb, in); - test(cb->check()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + + AMI_TestIntf_opCListIPtr cb = new AMI_TestIntf_opCListI(in); + t->opCList_async(cb, in); + test(cb->check()); } cout << "ok" << endl; @@ -1987,10 +1987,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { cout << "testing class mapped structs with AMI... " << flush; - AMI_TestIntf_opClassStructIPtr cb = new AMI_TestIntf_opClassStructI(cs, csseq1); - t->opClassStruct_async(cb, cs, csseq1); - test(cb->check()); - cout << "ok" << endl; + AMI_TestIntf_opClassStructIPtr cb = new AMI_TestIntf_opClassStructI(cs, csseq1); + t->opClassStruct_async(cb, cs, csseq1); + test(cb->check()); + cout << "ok" << endl; } cout << "testing wstring... " << flush; @@ -2008,14 +2008,14 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) wdict2 = wdict1; ref = communicator->getProperties()->getPropertyWithDefault( - "Custom.WstringProxy1", "wstring1:default -p 12010 -t 10000"); + "Custom.WstringProxy1", "wstring1:default -p 12010 -t 10000"); base = communicator->stringToProxy(ref); test(base); Test1::WstringClassPrx wsc1 = Test1::WstringClassPrx::checkedCast(base); test(t); ref = communicator->getProperties()->getPropertyWithDefault( - "Custom.WstringProxy2", "wstring2:default -p 12010 -t 10000"); + "Custom.WstringProxy2", "wstring2:default -p 12010 -t 10000"); base = communicator->stringToProxy(ref); test(base); Test2::WstringClassPrx wsc2 = Test2::WstringClassPrx::checkedCast(base); @@ -2029,9 +2029,9 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - AMI_Test1_opStringIPtr cb = new AMI_Test1_opStringI(wstr); - wsc1->opString_async(cb, wstr); - test(cb->check()); + AMI_Test1_opStringIPtr cb = new AMI_Test1_opStringI(wstr); + wsc1->opString_async(cb, wstr); + test(cb->check()); } ret = wsc2->opString(wstr, out); @@ -2040,9 +2040,9 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - AMI_Test2_opStringIPtr cb = new AMI_Test2_opStringI(wstr); - wsc2->opString_async(cb, wstr); - test(cb->check()); + AMI_Test2_opStringIPtr cb = new AMI_Test2_opStringI(wstr); + wsc2->opString_async(cb, wstr); + test(cb->check()); } Test1::WstringStruct wss1; @@ -2070,9 +2070,9 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - AMI_Test1_throwExceptIPtr cb = new AMI_Test1_throwExceptI(wstr); - wsc1->throwExcept_async(cb, wstr); - test(cb->check()); + AMI_Test1_throwExceptIPtr cb = new AMI_Test1_throwExceptI(wstr); + wsc1->throwExcept_async(cb, wstr); + test(cb->check()); } try @@ -2086,9 +2086,9 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - AMI_Test2_throwExceptIPtr cb = new AMI_Test2_throwExceptI(wstr); - wsc2->throwExcept_async(cb, wstr); - test(cb->check()); + AMI_Test2_throwExceptIPtr cb = new AMI_Test2_throwExceptI(wstr); + wsc2->throwExcept_async(cb, wstr); + test(cb->check()); } cout << "ok" << endl; diff --git a/cpp/test/Ice/custom/Client.cpp b/cpp/test/Ice/custom/Client.cpp index 14e524cc20e..6241f91a320 100644 --- a/cpp/test/Ice/custom/Client.cpp +++ b/cpp/test/Ice/custom/Client.cpp @@ -33,8 +33,8 @@ main(int argc, char** argv) try { Ice::InitializationData initData; - initData.stringConverter = new Test::StringConverterI(); - initData.wstringConverter = new Test::WstringConverterI(); + initData.stringConverter = new Test::StringConverterI(); + initData.wstringConverter = new Test::WstringConverterI(); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } diff --git a/cpp/test/Ice/custom/Collocated.cpp b/cpp/test/Ice/custom/Collocated.cpp index fea1ce2681a..b7da06a2c82 100644 --- a/cpp/test/Ice/custom/Collocated.cpp +++ b/cpp/test/Ice/custom/Collocated.cpp @@ -38,11 +38,11 @@ main(int argc, char** argv) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); - initData.stringConverter = new Test::StringConverterI(); - initData.wstringConverter = new Test::WstringConverterI(); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); + initData.stringConverter = new Test::StringConverterI(); + initData.wstringConverter = new Test::WstringConverterI(); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } diff --git a/cpp/test/Ice/custom/MyByteSeq.cpp b/cpp/test/Ice/custom/MyByteSeq.cpp index de8306692cc..0fcdf2b4f74 100644 --- a/cpp/test/Ice/custom/MyByteSeq.cpp +++ b/cpp/test/Ice/custom/MyByteSeq.cpp @@ -31,7 +31,7 @@ MyByteSeq::MyByteSeq(const MyByteSeq& seq) if(_size != 0) { _data = (Ice::Byte*)malloc(_size); - memcpy(_data, seq._data, _size); + memcpy(_data, seq._data, _size); } else { @@ -82,13 +82,13 @@ MyByteSeq::operator=(const MyByteSeq& rhs) if(_data != 0) { free(_data); - _data = 0; + _data = 0; } _size = rhs._size; if(_size != 0) { _data = (Ice::Byte*)malloc(_size); - memcpy(_data, rhs._data, _size); + memcpy(_data, rhs._data, _size); } } diff --git a/cpp/test/Ice/custom/Server.cpp b/cpp/test/Ice/custom/Server.cpp index 0e3925e6c08..15ef0f01bf9 100644 --- a/cpp/test/Ice/custom/Server.cpp +++ b/cpp/test/Ice/custom/Server.cpp @@ -37,11 +37,11 @@ main(int argc, char** argv) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); - initData.stringConverter = new Test::StringConverterI(); - initData.wstringConverter = new Test::WstringConverterI(); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); + initData.stringConverter = new Test::StringConverterI(); + initData.wstringConverter = new Test::WstringConverterI(); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } diff --git a/cpp/test/Ice/custom/ServerAMD.cpp b/cpp/test/Ice/custom/ServerAMD.cpp index 92c0fad867c..d4ccd779899 100644 --- a/cpp/test/Ice/custom/ServerAMD.cpp +++ b/cpp/test/Ice/custom/ServerAMD.cpp @@ -37,12 +37,12 @@ main(int argc, char** argv) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - - initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); - initData.stringConverter = new Test::StringConverterI(); - initData.wstringConverter = new Test::WstringConverterI(); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + + initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); + initData.stringConverter = new Test::StringConverterI(); + initData.wstringConverter = new Test::WstringConverterI(); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } diff --git a/cpp/test/Ice/custom/StringConverterI.cpp b/cpp/test/Ice/custom/StringConverterI.cpp index f3798ad5db5..626a3626476 100644 --- a/cpp/test/Ice/custom/StringConverterI.cpp +++ b/cpp/test/Ice/custom/StringConverterI.cpp @@ -30,7 +30,7 @@ Test::StringConverterI::toUTF8(const char* sourceStart, const char* sourceEnd, I void Test::StringConverterI::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, - string& target) const + string& target) const { size_t size = static_cast<size_t>(sourceEnd - sourceStart); target.resize(size); @@ -63,7 +63,7 @@ Test::WstringConverterI::toUTF8(const wchar_t* sourceStart, const wchar_t* sourc void Test::WstringConverterI::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, - wstring& target) const + wstring& target) const { size_t size = static_cast<size_t>(sourceEnd - sourceStart); string s; diff --git a/cpp/test/Ice/custom/StringConverterI.h b/cpp/test/Ice/custom/StringConverterI.h index 6d555358398..9a2d63cfd9b 100644 --- a/cpp/test/Ice/custom/StringConverterI.h +++ b/cpp/test/Ice/custom/StringConverterI.h @@ -26,7 +26,7 @@ public: virtual Ice::Byte* toUTF8(const char*, const char*, Ice::UTF8Buffer&) const; virtual void fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, - std::string& target) const; + std::string& target) const; }; class WstringConverterI : public Ice::WstringConverter @@ -35,7 +35,7 @@ public: virtual Ice::Byte* toUTF8(const wchar_t*, const wchar_t*, Ice::UTF8Buffer&) const; virtual void fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, - std::wstring& target) const; + std::wstring& target) const; }; diff --git a/cpp/test/Ice/custom/Test.ice b/cpp/test/Ice/custom/Test.ice index baa8cceb1e3..ec21d2d7802 100644 --- a/cpp/test/Ice/custom/Test.ice +++ b/cpp/test/Ice/custom/Test.ice @@ -139,7 +139,7 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq opByteSeq(["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq inSeq, - out ["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq outSeq); + out ["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq outSeq); ByteList opByteList(ByteList inSeq, out ByteList outSeq); @@ -148,7 +148,7 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque<std::string>"] StringSeq opStringSeq(["cpp:type:std::deque<std::string>"] StringSeq inSeq, - out ["cpp:type:std::deque<std::string>"] StringSeq outSeq); + out ["cpp:type:std::deque<std::string>"] StringSeq outSeq); StringList opStringList(StringList inSeq, out StringList outSeq); @@ -160,13 +160,13 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque< ::Test::Variable>"] VariableSeq opVariableSeq(["cpp:type:std::deque< ::Test::Variable>"] VariableSeq inSeq, - out ["cpp:type:std::deque< ::Test::Variable>"] VariableSeq outSeq); + out ["cpp:type:std::deque< ::Test::Variable>"] VariableSeq outSeq); VariableList opVariableList(VariableList inSeq, out VariableList outSeq); ["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq opStringStringDictSeq(["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq inSeq, - out ["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq outSeq); + out ["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq outSeq); StringStringDictList opStringStringDictList(StringStringDictList inSeq, out StringStringDictList outSeq); @@ -177,7 +177,7 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq opCPrxSeq(["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq inSeq, - out ["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq outSeq); + out ["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq outSeq); CPrxList opCPrxList(CPrxList inSeq, out CPrxList outSeq); diff --git a/cpp/test/Ice/custom/TestAMD.ice b/cpp/test/Ice/custom/TestAMD.ice index 736131296fe..b0c8383855b 100644 --- a/cpp/test/Ice/custom/TestAMD.ice +++ b/cpp/test/Ice/custom/TestAMD.ice @@ -139,7 +139,7 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq opByteSeq(["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq inSeq, - out ["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq outSeq); + out ["cpp:type:std::deque< ::Ice::Byte>"] ByteSeq outSeq); ByteList opByteList(ByteList inSeq, out ByteList outSeq); @@ -148,7 +148,7 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque<std::string>"] StringSeq opStringSeq(["cpp:type:std::deque<std::string>"] StringSeq inSeq, - out ["cpp:type:std::deque<std::string>"] StringSeq outSeq); + out ["cpp:type:std::deque<std::string>"] StringSeq outSeq); StringList opStringList(StringList inSeq, out StringList outSeq); @@ -160,13 +160,13 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque< ::Test::Variable>"] VariableSeq opVariableSeq(["cpp:type:std::deque< ::Test::Variable>"] VariableSeq inSeq, - out ["cpp:type:std::deque< ::Test::Variable>"] VariableSeq outSeq); + out ["cpp:type:std::deque< ::Test::Variable>"] VariableSeq outSeq); VariableList opVariableList(VariableList inSeq, out VariableList outSeq); ["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq opStringStringDictSeq(["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq inSeq, - out ["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq outSeq); + out ["cpp:type:std::deque< ::Test::StringStringDict>"] StringStringDictSeq outSeq); StringStringDictList opStringStringDictList(StringStringDictList inSeq, out StringStringDictList outSeq); @@ -177,7 +177,7 @@ sequence<ClassStruct> ClassStructSeq; ["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq opCPrxSeq(["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq inSeq, - out ["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq outSeq); + out ["cpp:type:std::deque< ::Test::CPrx>"] CPrxSeq outSeq); CPrxList opCPrxList(CPrxList inSeq, out CPrxList outSeq); diff --git a/cpp/test/Ice/custom/TestAMDI.cpp b/cpp/test/Ice/custom/TestAMDI.cpp index b7c4cd26c79..e323194c210 100644 --- a/cpp/test/Ice/custom/TestAMDI.cpp +++ b/cpp/test/Ice/custom/TestAMDI.cpp @@ -17,8 +17,8 @@ TestIntfI::TestIntfI(const Ice::CommunicatorPtr& communicator) void TestIntfI::opDoubleArray_async(const Test::AMD_TestIntf_opDoubleArrayPtr& opDoubleArrayCB, - const std::pair<const Ice::Double*, const Ice::Double*>& inSeq, - const Ice::Current& current) + const std::pair<const Ice::Double*, const Ice::Double*>& inSeq, + const Ice::Current& current) { Test::DoubleSeq outSeq(inSeq.first, inSeq.second); opDoubleArrayCB->ice_response(outSeq, outSeq); @@ -26,8 +26,8 @@ TestIntfI::opDoubleArray_async(const Test::AMD_TestIntf_opDoubleArrayPtr& opDoub void TestIntfI::opBoolArray_async(const Test::AMD_TestIntf_opBoolArrayPtr& opBoolArrayCB, - const std::pair<const bool*, const bool*>& inSeq, - const Ice::Current& current) + const std::pair<const bool*, const bool*>& inSeq, + const Ice::Current& current) { Test::BoolSeq outSeq(inSeq.first, inSeq.second); opBoolArrayCB->ice_response(outSeq, outSeq); @@ -35,16 +35,16 @@ TestIntfI::opBoolArray_async(const Test::AMD_TestIntf_opBoolArrayPtr& opBoolArra void TestIntfI::opByteArray_async(const Test::AMD_TestIntf_opByteArrayPtr& opByteArrayCB, - const std::pair<const Ice::Byte*, const Ice::Byte*>& inSeq, - const Ice::Current& current) + const std::pair<const Ice::Byte*, const Ice::Byte*>& inSeq, + const Ice::Current& current) { opByteArrayCB->ice_response(inSeq, inSeq); } void TestIntfI::opVariableArray_async(const Test::AMD_TestIntf_opVariableArrayPtr& opVariableArrayCB, - const std::pair<const Test::Variable*, const Test::Variable*>& inSeq, - const Ice::Current& current) + const std::pair<const Test::Variable*, const Test::Variable*>& inSeq, + const Ice::Current& current) { Test::VariableList outSeq(inSeq.first, inSeq.second); opVariableArrayCB->ice_response(outSeq, outSeq); @@ -52,8 +52,8 @@ TestIntfI::opVariableArray_async(const Test::AMD_TestIntf_opVariableArrayPtr& op void TestIntfI::opBoolRange_async(const Test::AMD_TestIntf_opBoolRangePtr& opBoolRangeCB, - const std::pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>& inSeq, - const Ice::Current& current) + const std::pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>& inSeq, + const Ice::Current& current) { Test::BoolSeq outSeq(inSeq.first, inSeq.second); opBoolRangeCB->ice_response(outSeq, outSeq); @@ -61,17 +61,17 @@ TestIntfI::opBoolRange_async(const Test::AMD_TestIntf_opBoolRangePtr& opBoolRang void TestIntfI::opByteRange_async(const Test::AMD_TestIntf_opByteRangePtr& opByteRangeCB, - const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& inSeq, - const Ice::Current& current) + const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& inSeq, + const Ice::Current& current) { opByteRangeCB->ice_response(inSeq, inSeq); } void TestIntfI::opVariableRange_async(const Test::AMD_TestIntf_opVariableRangePtr& opVariableRangeCB, - const std::pair<Test::VariableList::const_iterator, - Test::VariableList::const_iterator>& inSeq, - const Ice::Current& current) + const std::pair<Test::VariableList::const_iterator, + Test::VariableList::const_iterator>& inSeq, + const Ice::Current& current) { Test::VariableList outSeq(inSeq.first, inSeq.second); opVariableRangeCB->ice_response(outSeq, outSeq); @@ -79,8 +79,8 @@ TestIntfI::opVariableRange_async(const Test::AMD_TestIntf_opVariableRangePtr& op void TestIntfI::opBoolRangeType_async(const Test::AMD_TestIntf_opBoolRangeTypePtr& opBoolRangeTypeCB, - const std::pair<const bool*, const bool*>& inSeq, - const Ice::Current& current) + const std::pair<const bool*, const bool*>& inSeq, + const Ice::Current& current) { Test::BoolSeq outSeq(inSeq.first, inSeq.second); opBoolRangeTypeCB->ice_response(outSeq, outSeq); @@ -88,8 +88,8 @@ TestIntfI::opBoolRangeType_async(const Test::AMD_TestIntf_opBoolRangeTypePtr& op void TestIntfI::opByteRangeType_async(const Test::AMD_TestIntf_opByteRangeTypePtr& opByteRangeTypeCB, - const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& inSeq, - const Ice::Current& current) + const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& inSeq, + const Ice::Current& current) { Test::ByteList outSeq(inSeq.first, inSeq.second); opByteRangeTypeCB->ice_response(outSeq, outSeq); @@ -97,22 +97,22 @@ TestIntfI::opByteRangeType_async(const Test::AMD_TestIntf_opByteRangeTypePtr& op void TestIntfI::opVariableRangeType_async(const Test::AMD_TestIntf_opVariableRangeTypePtr& opVariableRangeTypeCB, - const std::pair<std::deque<Test::Variable>::const_iterator, - std::deque<Test::Variable>::const_iterator>& inSeq, - const Ice::Current& current) + const std::pair<std::deque<Test::Variable>::const_iterator, + std::deque<Test::Variable>::const_iterator>& inSeq, + const Ice::Current& current) { Test::VariableList outSeq; for(std::deque<Test::Variable>::const_iterator p = inSeq.first; p != inSeq.second; ++p) { - outSeq.push_back(*p); + outSeq.push_back(*p); } opVariableRangeTypeCB->ice_response(outSeq, outSeq); } void TestIntfI::opBoolSeq_async(const Test::AMD_TestIntf_opBoolSeqPtr& opBoolSeqCB, - const std::deque<bool>& inSeq, - const Ice::Current& current) + const std::deque<bool>& inSeq, + const Ice::Current& current) { std::deque<bool> outSeq(inSeq); opBoolSeqCB->ice_response(outSeq, outSeq); @@ -120,8 +120,8 @@ TestIntfI::opBoolSeq_async(const Test::AMD_TestIntf_opBoolSeqPtr& opBoolSeqCB, void TestIntfI::opBoolList_async(const Test::AMD_TestIntf_opBoolListPtr& opBoolListCB, - const Test::BoolList& inSeq, - const Ice::Current& current) + const Test::BoolList& inSeq, + const Ice::Current& current) { Test::BoolList outSeq(inSeq); opBoolListCB->ice_response(outSeq, outSeq); @@ -129,8 +129,8 @@ TestIntfI::opBoolList_async(const Test::AMD_TestIntf_opBoolListPtr& opBoolListCB void TestIntfI::opByteSeq_async(const Test::AMD_TestIntf_opByteSeqPtr& opByteSeqCB, - const std::deque<Ice::Byte>& inSeq, - const Ice::Current& current) + const std::deque<Ice::Byte>& inSeq, + const Ice::Current& current) { std::deque<Ice::Byte> outSeq(inSeq); opByteSeqCB->ice_response(outSeq, outSeq); @@ -138,8 +138,8 @@ TestIntfI::opByteSeq_async(const Test::AMD_TestIntf_opByteSeqPtr& opByteSeqCB, void TestIntfI::opByteList_async(const Test::AMD_TestIntf_opByteListPtr& opByteListCB, - const Test::ByteList& inSeq, - const Ice::Current& current) + const Test::ByteList& inSeq, + const Ice::Current& current) { Test::ByteList outSeq(inSeq); opByteListCB->ice_response(outSeq, outSeq); @@ -147,8 +147,8 @@ TestIntfI::opByteList_async(const Test::AMD_TestIntf_opByteListPtr& opByteListCB void TestIntfI::opMyByteSeq_async(const Test::AMD_TestIntf_opMyByteSeqPtr& opMyByteSeqCB, - const MyByteSeq& inSeq, - const Ice::Current& current) + const MyByteSeq& inSeq, + const Ice::Current& current) { MyByteSeq outSeq(inSeq); opMyByteSeqCB->ice_response(outSeq, outSeq); @@ -156,8 +156,8 @@ TestIntfI::opMyByteSeq_async(const Test::AMD_TestIntf_opMyByteSeqPtr& opMyByteSe void TestIntfI::opStringSeq_async(const Test::AMD_TestIntf_opStringSeqPtr& opStringSeqCB, - const std::deque<std::string>& inSeq, - const Ice::Current& current) + const std::deque<std::string>& inSeq, + const Ice::Current& current) { std::deque<std::string> outSeq(inSeq); opStringSeqCB->ice_response(outSeq, outSeq); @@ -165,8 +165,8 @@ TestIntfI::opStringSeq_async(const Test::AMD_TestIntf_opStringSeqPtr& opStringSe void TestIntfI::opStringList_async(const Test::AMD_TestIntf_opStringListPtr& opStringListCB, - const Test::StringList& inSeq, - const Ice::Current& current) + const Test::StringList& inSeq, + const Ice::Current& current) { Test::StringList outSeq(inSeq); opStringListCB->ice_response(outSeq, outSeq); @@ -174,8 +174,8 @@ TestIntfI::opStringList_async(const Test::AMD_TestIntf_opStringListPtr& opString void TestIntfI::opFixedSeq_async(const Test::AMD_TestIntf_opFixedSeqPtr& opFixedSeqCB, - const std::deque<Test::Fixed>& inSeq, - const Ice::Current& current) + const std::deque<Test::Fixed>& inSeq, + const Ice::Current& current) { std::deque<Test::Fixed> outSeq(inSeq); opFixedSeqCB->ice_response(outSeq, outSeq); @@ -183,8 +183,8 @@ TestIntfI::opFixedSeq_async(const Test::AMD_TestIntf_opFixedSeqPtr& opFixedSeqCB void TestIntfI::opFixedList_async(const Test::AMD_TestIntf_opFixedListPtr& opFixedListCB, - const Test::FixedList& inSeq, - const Ice::Current& current) + const Test::FixedList& inSeq, + const Ice::Current& current) { Test::FixedList outSeq(inSeq); opFixedListCB->ice_response(outSeq, outSeq); @@ -192,8 +192,8 @@ TestIntfI::opFixedList_async(const Test::AMD_TestIntf_opFixedListPtr& opFixedLis void TestIntfI::opVariableSeq_async(const Test::AMD_TestIntf_opVariableSeqPtr& opVariableSeqCB, - const std::deque<Test::Variable>& inSeq, - const Ice::Current& current) + const std::deque<Test::Variable>& inSeq, + const Ice::Current& current) { std::deque<Test::Variable> outSeq(inSeq); opVariableSeqCB->ice_response(outSeq, outSeq); @@ -201,8 +201,8 @@ TestIntfI::opVariableSeq_async(const Test::AMD_TestIntf_opVariableSeqPtr& opVari void TestIntfI::opVariableList_async(const Test::AMD_TestIntf_opVariableListPtr& opVariableListCB, - const Test::VariableList& inSeq, - const Ice::Current& current) + const Test::VariableList& inSeq, + const Ice::Current& current) { Test::VariableList outSeq(inSeq); opVariableListCB->ice_response(outSeq, outSeq); @@ -210,8 +210,8 @@ TestIntfI::opVariableList_async(const Test::AMD_TestIntf_opVariableListPtr& opVa void TestIntfI::opStringStringDictSeq_async(const Test::AMD_TestIntf_opStringStringDictSeqPtr& opStringStringDictSeqCB, - const std::deque<Test::StringStringDict>& inSeq, - const Ice::Current& current) + const std::deque<Test::StringStringDict>& inSeq, + const Ice::Current& current) { std::deque<Test::StringStringDict> outSeq(inSeq); opStringStringDictSeqCB->ice_response(outSeq, outSeq); @@ -219,8 +219,8 @@ TestIntfI::opStringStringDictSeq_async(const Test::AMD_TestIntf_opStringStringDi void TestIntfI::opStringStringDictList_async(const Test::AMD_TestIntf_opStringStringDictListPtr& opStringStringDictListCB, - const Test::StringStringDictList& inSeq, - const Ice::Current& current) + const Test::StringStringDictList& inSeq, + const Ice::Current& current) { Test::StringStringDictList outSeq(inSeq); opStringStringDictListCB->ice_response(outSeq, outSeq); @@ -228,8 +228,8 @@ TestIntfI::opStringStringDictList_async(const Test::AMD_TestIntf_opStringStringD void TestIntfI::opESeq_async(const Test::AMD_TestIntf_opESeqPtr& opESeqCB, - const std::deque<Test::E>& inSeq, - const Ice::Current& current) + const std::deque<Test::E>& inSeq, + const Ice::Current& current) { std::deque<Test::E> outSeq(inSeq); opESeqCB->ice_response(outSeq, outSeq); @@ -237,8 +237,8 @@ TestIntfI::opESeq_async(const Test::AMD_TestIntf_opESeqPtr& opESeqCB, void TestIntfI::opEList_async(const Test::AMD_TestIntf_opEListPtr& opEListCB, - const Test::EList& inSeq, - const Ice::Current& current) + const Test::EList& inSeq, + const Ice::Current& current) { Test::EList outSeq(inSeq); opEListCB->ice_response(outSeq, outSeq); @@ -246,8 +246,8 @@ TestIntfI::opEList_async(const Test::AMD_TestIntf_opEListPtr& opEListCB, void TestIntfI::opCPrxSeq_async(const Test::AMD_TestIntf_opCPrxSeqPtr& opCPrxSeqCB, - const std::deque<Test::CPrx>& inSeq, - const Ice::Current& current) + const std::deque<Test::CPrx>& inSeq, + const Ice::Current& current) { std::deque<Test::CPrx> outSeq(inSeq); opCPrxSeqCB->ice_response(outSeq, outSeq); @@ -255,8 +255,8 @@ TestIntfI::opCPrxSeq_async(const Test::AMD_TestIntf_opCPrxSeqPtr& opCPrxSeqCB, void TestIntfI::opCPrxList_async(const Test::AMD_TestIntf_opCPrxListPtr& opCPrxListCB, - const Test::CPrxList& inSeq, - const Ice::Current& current) + const Test::CPrxList& inSeq, + const Ice::Current& current) { Test::CPrxList outSeq(inSeq); opCPrxListCB->ice_response(outSeq, outSeq); @@ -264,8 +264,8 @@ TestIntfI::opCPrxList_async(const Test::AMD_TestIntf_opCPrxListPtr& opCPrxListCB void TestIntfI::opCSeq_async(const Test::AMD_TestIntf_opCSeqPtr& opCSeqCB, - const std::deque<Test::CPtr>& inSeq, - const Ice::Current& current) + const std::deque<Test::CPtr>& inSeq, + const Ice::Current& current) { std::deque<Test::CPtr> outSeq(inSeq); opCSeqCB->ice_response(outSeq, outSeq); @@ -273,8 +273,8 @@ TestIntfI::opCSeq_async(const Test::AMD_TestIntf_opCSeqPtr& opCSeqCB, void TestIntfI::opCList_async(const Test::AMD_TestIntf_opCListPtr& opCListCB, - const Test::CList& inSeq, - const Ice::Current& current) + const Test::CList& inSeq, + const Ice::Current& current) { Test::CList outSeq(inSeq); opCListCB->ice_response(outSeq, outSeq); @@ -282,16 +282,16 @@ TestIntfI::opCList_async(const Test::AMD_TestIntf_opCListPtr& opCListCB, void TestIntfI::opClassStruct_async(const ::Test::AMD_TestIntf_opClassStructPtr& cb, - const ::Test::ClassStructPtr& inS, - const ::Test::ClassStructSeq& inSeq, - const ::Ice::Current&) + const ::Test::ClassStructPtr& inS, + const ::Test::ClassStructSeq& inSeq, + const ::Ice::Current&) { cb->ice_response(inS, inS, inSeq); } void TestIntfI::shutdown_async(const Test::AMD_TestIntf_shutdownPtr& shutdownCB, - const Ice::Current& current) + const Ice::Current& current) { _communicator->shutdown(); shutdownCB->ice_response(); diff --git a/cpp/test/Ice/custom/TestAMDI.h b/cpp/test/Ice/custom/TestAMDI.h index 634d7f64ce8..04133eb2e50 100644 --- a/cpp/test/Ice/custom/TestAMDI.h +++ b/cpp/test/Ice/custom/TestAMDI.h @@ -19,130 +19,130 @@ public: TestIntfI(const Ice::CommunicatorPtr&); virtual void opDoubleArray_async(const Test::AMD_TestIntf_opDoubleArrayPtr&, - const std::pair<const Ice::Double*, const Ice::Double*>&, - const Ice::Current&); + const std::pair<const Ice::Double*, const Ice::Double*>&, + const Ice::Current&); virtual void opBoolArray_async(const Test::AMD_TestIntf_opBoolArrayPtr&, - const std::pair<const bool*, const bool*>&, - const Ice::Current&); + const std::pair<const bool*, const bool*>&, + const Ice::Current&); virtual void opByteArray_async(const Test::AMD_TestIntf_opByteArrayPtr&, - const std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, - const Ice::Current&); + const std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, + const Ice::Current&); virtual void opVariableArray_async(const Test::AMD_TestIntf_opVariableArrayPtr&, - const std::pair<const Test::Variable*, const Test::Variable*>&, - const Ice::Current&); + const std::pair<const Test::Variable*, const Test::Variable*>&, + const Ice::Current&); virtual void opBoolRange_async(const Test::AMD_TestIntf_opBoolRangePtr&, - const std::pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>&, - const Ice::Current&); + const std::pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>&, + const Ice::Current&); virtual void opByteRange_async(const Test::AMD_TestIntf_opByteRangePtr&, - const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>&, - const Ice::Current&); + const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>&, + const Ice::Current&); virtual void opVariableRange_async(const Test::AMD_TestIntf_opVariableRangePtr&, - const std::pair<Test::VariableList::const_iterator, - Test::VariableList::const_iterator>&, - const Ice::Current&); + const std::pair<Test::VariableList::const_iterator, + Test::VariableList::const_iterator>&, + const Ice::Current&); virtual void opBoolRangeType_async(const Test::AMD_TestIntf_opBoolRangeTypePtr&, - const std::pair<const bool*, const bool*>&, - const Ice::Current&); + const std::pair<const bool*, const bool*>&, + const Ice::Current&); virtual void opByteRangeType_async(const Test::AMD_TestIntf_opByteRangeTypePtr&, - const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>&, - const Ice::Current&); + const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>&, + const Ice::Current&); virtual void opVariableRangeType_async(const Test::AMD_TestIntf_opVariableRangeTypePtr&, - const std::pair<std::deque<Test::Variable>::const_iterator, - std::deque<Test::Variable>::const_iterator>&, - const Ice::Current&); + const std::pair<std::deque<Test::Variable>::const_iterator, + std::deque<Test::Variable>::const_iterator>&, + const Ice::Current&); virtual void opBoolSeq_async(const Test::AMD_TestIntf_opBoolSeqPtr&, - const std::deque<bool>&, - const Ice::Current&); + const std::deque<bool>&, + const Ice::Current&); virtual void opBoolList_async(const Test::AMD_TestIntf_opBoolListPtr&, - const Test::BoolList&, - const Ice::Current&); + const Test::BoolList&, + const Ice::Current&); virtual void opByteSeq_async(const Test::AMD_TestIntf_opByteSeqPtr&, - const std::deque<Ice::Byte>&, - const Ice::Current&); + const std::deque<Ice::Byte>&, + const Ice::Current&); virtual void opByteList_async(const Test::AMD_TestIntf_opByteListPtr&, - const Test::ByteList&, - const Ice::Current&); + const Test::ByteList&, + const Ice::Current&); virtual void opMyByteSeq_async(const Test::AMD_TestIntf_opMyByteSeqPtr&, - const MyByteSeq&, - const Ice::Current&); + const MyByteSeq&, + const Ice::Current&); virtual void opStringSeq_async(const Test::AMD_TestIntf_opStringSeqPtr&, - const std::deque<std::string>&, - const Ice::Current&); + const std::deque<std::string>&, + const Ice::Current&); virtual void opStringList_async(const Test::AMD_TestIntf_opStringListPtr&, - const Test::StringList&, - const Ice::Current&); + const Test::StringList&, + const Ice::Current&); virtual void opFixedSeq_async(const Test::AMD_TestIntf_opFixedSeqPtr&, - const std::deque<Test::Fixed>&, - const Ice::Current&); + const std::deque<Test::Fixed>&, + const Ice::Current&); virtual void opFixedList_async(const Test::AMD_TestIntf_opFixedListPtr&, - const Test::FixedList&, - const Ice::Current&); + const Test::FixedList&, + const Ice::Current&); virtual void opVariableSeq_async(const Test::AMD_TestIntf_opVariableSeqPtr&, - const std::deque<Test::Variable>&, - const Ice::Current&); + const std::deque<Test::Variable>&, + const Ice::Current&); virtual void opVariableList_async(const Test::AMD_TestIntf_opVariableListPtr&, - const Test::VariableList&, - const Ice::Current&); + const Test::VariableList&, + const Ice::Current&); virtual void opStringStringDictSeq_async(const Test::AMD_TestIntf_opStringStringDictSeqPtr&, - const std::deque<Test::StringStringDict>&, - const Ice::Current&); + const std::deque<Test::StringStringDict>&, + const Ice::Current&); virtual void opStringStringDictList_async(const Test::AMD_TestIntf_opStringStringDictListPtr&, - const Test::StringStringDictList&, - const Ice::Current&); + const Test::StringStringDictList&, + const Ice::Current&); virtual void opESeq_async(const Test::AMD_TestIntf_opESeqPtr&, - const std::deque<Test::E>&, - const Ice::Current&); + const std::deque<Test::E>&, + const Ice::Current&); virtual void opEList_async(const Test::AMD_TestIntf_opEListPtr&, - const Test::EList&, - const Ice::Current&); + const Test::EList&, + const Ice::Current&); virtual void opCPrxSeq_async(const Test::AMD_TestIntf_opCPrxSeqPtr&, - const std::deque<Test::CPrx>&, - const Ice::Current&); + const std::deque<Test::CPrx>&, + const Ice::Current&); virtual void opCPrxList_async(const Test::AMD_TestIntf_opCPrxListPtr&, - const Test::CPrxList&, - const Ice::Current&); + const Test::CPrxList&, + const Ice::Current&); virtual void opCSeq_async(const Test::AMD_TestIntf_opCSeqPtr&, - const std::deque<Test::CPtr>&, - const Ice::Current&); + const std::deque<Test::CPtr>&, + const Ice::Current&); virtual void opCList_async(const Test::AMD_TestIntf_opCListPtr&, - const Test::CList&, - const Ice::Current&); + const Test::CList&, + const Ice::Current&); virtual void opClassStruct_async(const ::Test::AMD_TestIntf_opClassStructPtr&, - const ::Test::ClassStructPtr&, - const ::Test::ClassStructSeq&, - const ::Ice::Current&); + const ::Test::ClassStructPtr&, + const ::Test::ClassStructSeq&, + const ::Ice::Current&); virtual void shutdown_async(const Test::AMD_TestIntf_shutdownPtr&, - const Ice::Current&); + const Ice::Current&); private: diff --git a/cpp/test/Ice/custom/TestI.cpp b/cpp/test/Ice/custom/TestI.cpp index e25e467d09a..df9e4f055da 100644 --- a/cpp/test/Ice/custom/TestI.cpp +++ b/cpp/test/Ice/custom/TestI.cpp @@ -17,8 +17,8 @@ TestIntfI::TestIntfI(const Ice::CommunicatorPtr& communicator) Test::DoubleSeq TestIntfI::opDoubleArray(const std::pair<const Ice::Double*, const Ice::Double*>& inSeq, - Test::DoubleSeq& outSeq, - const Ice::Current& current) + Test::DoubleSeq& outSeq, + const Ice::Current& current) { Test::DoubleSeq(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -26,8 +26,8 @@ TestIntfI::opDoubleArray(const std::pair<const Ice::Double*, const Ice::Double*> Test::BoolSeq TestIntfI::opBoolArray(const std::pair<const bool*, const bool*>& inSeq, - Test::BoolSeq& outSeq, - const Ice::Current& current) + Test::BoolSeq& outSeq, + const Ice::Current& current) { Test::BoolSeq(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -35,8 +35,8 @@ TestIntfI::opBoolArray(const std::pair<const bool*, const bool*>& inSeq, Test::ByteList TestIntfI::opByteArray(const std::pair<const Ice::Byte*, const Ice::Byte*>& inSeq, - Test::ByteList& outSeq, - const Ice::Current& current) + Test::ByteList& outSeq, + const Ice::Current& current) { Test::ByteList(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -44,8 +44,8 @@ TestIntfI::opByteArray(const std::pair<const Ice::Byte*, const Ice::Byte*>& inSe Test::VariableList TestIntfI::opVariableArray(const std::pair<const Test::Variable*, const Test::Variable*>& inSeq, - Test::VariableList& outSeq, - const Ice::Current& current) + Test::VariableList& outSeq, + const Ice::Current& current) { Test::VariableList(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -53,8 +53,8 @@ TestIntfI::opVariableArray(const std::pair<const Test::Variable*, const Test::Va Test::BoolSeq TestIntfI::opBoolRange(const std::pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>& inSeq, - Test::BoolSeq& outSeq, - const Ice::Current&) + Test::BoolSeq& outSeq, + const Ice::Current&) { Test::BoolSeq(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -62,8 +62,8 @@ TestIntfI::opBoolRange(const std::pair<Test::BoolSeq::const_iterator, Test::Bool Test::ByteList TestIntfI::opByteRange(const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& inSeq, - Test::ByteList& outSeq, - const Ice::Current&) + Test::ByteList& outSeq, + const Ice::Current&) { Test::ByteList(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -71,9 +71,9 @@ TestIntfI::opByteRange(const std::pair<Test::ByteList::const_iterator, Test::Byt Test::VariableList TestIntfI::opVariableRange( - const std::pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator>& inSeq, - Test::VariableList& outSeq, - const Ice::Current&) + const std::pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator>& inSeq, + Test::VariableList& outSeq, + const Ice::Current&) { Test::VariableList(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -81,8 +81,8 @@ TestIntfI::opVariableRange( Test::BoolSeq TestIntfI::opBoolRangeType(const std::pair<const bool*, const bool*>& inSeq, - Test::BoolSeq& outSeq, - const Ice::Current&) + Test::BoolSeq& outSeq, + const Ice::Current&) { Test::BoolSeq(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -90,8 +90,8 @@ TestIntfI::opBoolRangeType(const std::pair<const bool*, const bool*>& inSeq, Test::ByteList TestIntfI::opByteRangeType(const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& inSeq, - Test::ByteList& outSeq, - const Ice::Current&) + Test::ByteList& outSeq, + const Ice::Current&) { Test::ByteList(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -99,21 +99,21 @@ TestIntfI::opByteRangeType(const std::pair<Test::ByteList::const_iterator, Test: Test::VariableList TestIntfI::opVariableRangeType( - const std::pair<std::deque<Test::Variable>::const_iterator, std::deque<Test::Variable>::const_iterator>& inSeq, - Test::VariableList& outSeq, - const Ice::Current&) + const std::pair<std::deque<Test::Variable>::const_iterator, std::deque<Test::Variable>::const_iterator>& inSeq, + Test::VariableList& outSeq, + const Ice::Current&) { for(std::deque<Test::Variable>::const_iterator p = inSeq.first; p != inSeq.second; ++p) { - outSeq.push_back(*p); + outSeq.push_back(*p); } return outSeq; } std::deque<bool> TestIntfI::opBoolSeq(const std::deque<bool>& inSeq, - std::deque<bool>& outSeq, - const Ice::Current& current) + std::deque<bool>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -121,8 +121,8 @@ TestIntfI::opBoolSeq(const std::deque<bool>& inSeq, std::list<bool> TestIntfI::opBoolList(const std::list<bool>& inSeq, - std::list<bool>& outSeq, - const Ice::Current& current) + std::list<bool>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -130,8 +130,8 @@ TestIntfI::opBoolList(const std::list<bool>& inSeq, std::deque< ::Ice::Byte> TestIntfI::opByteSeq(const std::deque< ::Ice::Byte>& inSeq, - std::deque< ::Ice::Byte>& outSeq, - const Ice::Current& current) + std::deque< ::Ice::Byte>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -139,8 +139,8 @@ TestIntfI::opByteSeq(const std::deque< ::Ice::Byte>& inSeq, std::list< ::Ice::Byte> TestIntfI::opByteList(const std::list< ::Ice::Byte>& inSeq, - std::list< ::Ice::Byte>& outSeq, - const Ice::Current& current) + std::list< ::Ice::Byte>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -148,8 +148,8 @@ TestIntfI::opByteList(const std::list< ::Ice::Byte>& inSeq, MyByteSeq TestIntfI::opMyByteSeq(const MyByteSeq& inSeq, - MyByteSeq& outSeq, - const Ice::Current& current) + MyByteSeq& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -157,8 +157,8 @@ TestIntfI::opMyByteSeq(const MyByteSeq& inSeq, std::deque< ::std::string> TestIntfI::opStringSeq(const std::deque< ::std::string>& inSeq, - std::deque< ::std::string>& outSeq, - const Ice::Current& current) + std::deque< ::std::string>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -166,8 +166,8 @@ TestIntfI::opStringSeq(const std::deque< ::std::string>& inSeq, std::list< ::std::string> TestIntfI::opStringList(const std::list< ::std::string>& inSeq, - std::list< ::std::string>& outSeq, - const Ice::Current& current) + std::list< ::std::string>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -175,8 +175,8 @@ TestIntfI::opStringList(const std::list< ::std::string>& inSeq, std::deque< ::Test::Fixed> TestIntfI::opFixedSeq(const std::deque< ::Test::Fixed>& inSeq, - std::deque< ::Test::Fixed>& outSeq, - const Ice::Current& current) + std::deque< ::Test::Fixed>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -184,8 +184,8 @@ TestIntfI::opFixedSeq(const std::deque< ::Test::Fixed>& inSeq, std::list< ::Test::Fixed> TestIntfI::opFixedList(const std::list< ::Test::Fixed>& inSeq, - std::list< ::Test::Fixed>& outSeq, - const Ice::Current& current) + std::list< ::Test::Fixed>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -193,8 +193,8 @@ TestIntfI::opFixedList(const std::list< ::Test::Fixed>& inSeq, std::deque< ::Test::Variable> TestIntfI::opVariableSeq(const std::deque< ::Test::Variable>& inSeq, - std::deque< ::Test::Variable>& outSeq, - const Ice::Current& current) + std::deque< ::Test::Variable>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -202,8 +202,8 @@ TestIntfI::opVariableSeq(const std::deque< ::Test::Variable>& inSeq, std::list< ::Test::Variable> TestIntfI::opVariableList(const std::list< ::Test::Variable>& inSeq, - std::list< ::Test::Variable>& outSeq, - const Ice::Current& current) + std::list< ::Test::Variable>& outSeq, + const Ice::Current& current) { outSeq = inSeq; return inSeq; @@ -283,10 +283,10 @@ TestIntfI::opCList(const std::list< ::Test::CPtr>& inSeq, ::Test::ClassStructPtr TestIntfI::opClassStruct(const ::Test::ClassStructPtr& inS, - const ::Test::ClassStructSeq& inSeq, - ::Test::ClassStructPtr& out, - ::Test::ClassStructSeq& outSeq, - const Ice::Current&) + const ::Test::ClassStructSeq& inSeq, + ::Test::ClassStructPtr& out, + ::Test::ClassStructSeq& outSeq, + const Ice::Current&) { outSeq = inSeq; out = inS; diff --git a/cpp/test/Ice/custom/TestI.h b/cpp/test/Ice/custom/TestI.h index c8800c755e4..c0aaa4b4416 100644 --- a/cpp/test/Ice/custom/TestI.h +++ b/cpp/test/Ice/custom/TestI.h @@ -19,92 +19,92 @@ public: TestIntfI(const Ice::CommunicatorPtr&); virtual Test::DoubleSeq opDoubleArray(const std::pair<const Ice::Double*, const Ice::Double*>&, - Test::DoubleSeq&, - const Ice::Current&); + Test::DoubleSeq&, + const Ice::Current&); virtual Test::BoolSeq opBoolArray(const std::pair<const bool*, const bool*>&, - Test::BoolSeq&, - const Ice::Current&); + Test::BoolSeq&, + const Ice::Current&); virtual Test::ByteList opByteArray(const std::pair<const Ice::Byte*, const Ice::Byte*>&, - Test::ByteList&, - const Ice::Current&); + Test::ByteList&, + const Ice::Current&); virtual Test::VariableList opVariableArray(const std::pair<const Test::Variable*, const Test::Variable*>&, - Test::VariableList&, - const Ice::Current&); + Test::VariableList&, + const Ice::Current&); virtual Test::BoolSeq opBoolRange(const std::pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>&, - Test::BoolSeq&, - const Ice::Current&); + Test::BoolSeq&, + const Ice::Current&); virtual Test::ByteList opByteRange(const std::pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>&, - Test::ByteList&, - const Ice::Current&); + Test::ByteList&, + const Ice::Current&); virtual Test::VariableList opVariableRange(const std::pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator>&, - Test::VariableList&, - const Ice::Current&); + Test::VariableList&, + const Ice::Current&); virtual Test::BoolSeq opBoolRangeType(const std::pair<const bool*, const bool*>&, - Test::BoolSeq&, - const Ice::Current&); + Test::BoolSeq&, + const Ice::Current&); virtual Test::ByteList opByteRangeType(const std::pair<Test::ByteList::const_iterator, - Test::ByteList::const_iterator>&, - Test::ByteList&, - const Ice::Current&); + Test::ByteList::const_iterator>&, + Test::ByteList&, + const Ice::Current&); virtual Test::VariableList opVariableRangeType(const std::pair<std::deque<Test::Variable>::const_iterator, - std::deque<Test::Variable>::const_iterator>&, - Test::VariableList&, - const Ice::Current&); + std::deque<Test::Variable>::const_iterator>&, + Test::VariableList&, + const Ice::Current&); virtual std::deque<bool> opBoolSeq(const std::deque<bool>&, - std::deque<bool>&, - const Ice::Current&); + std::deque<bool>&, + const Ice::Current&); virtual std::list<bool> opBoolList(const std::list<bool>&, - std::list<bool>&, - const Ice::Current&); + std::list<bool>&, + const Ice::Current&); virtual std::deque< ::Ice::Byte> opByteSeq(const std::deque< ::Ice::Byte>&, - std::deque< ::Ice::Byte>&, - const Ice::Current&); + std::deque< ::Ice::Byte>&, + const Ice::Current&); virtual std::list< ::Ice::Byte> opByteList(const std::list< ::Ice::Byte>&, - std::list< ::Ice::Byte>&, - const Ice::Current&); + std::list< ::Ice::Byte>&, + const Ice::Current&); virtual MyByteSeq opMyByteSeq(const MyByteSeq&, - MyByteSeq&, - const Ice::Current&); + MyByteSeq&, + const Ice::Current&); virtual std::deque< ::std::string> opStringSeq(const std::deque< ::std::string>&, - std::deque< ::std::string>&, - const Ice::Current&); + std::deque< ::std::string>&, + const Ice::Current&); virtual std::list< ::std::string> opStringList(const std::list< ::std::string>&, - std::list< ::std::string>&, - const Ice::Current&); + std::list< ::std::string>&, + const Ice::Current&); virtual std::deque< ::Test::Fixed> opFixedSeq(const std::deque< ::Test::Fixed>&, - std::deque< ::Test::Fixed>&, - const Ice::Current&); + std::deque< ::Test::Fixed>&, + const Ice::Current&); virtual std::list< ::Test::Fixed> opFixedList(const std::list< ::Test::Fixed>&, - std::list< ::Test::Fixed>&, - const Ice::Current&); + std::list< ::Test::Fixed>&, + const Ice::Current&); virtual std::deque< ::Test::Variable> opVariableSeq(const std::deque< ::Test::Variable>&, - std::deque< ::Test::Variable>&, - const Ice::Current&); + std::deque< ::Test::Variable>&, + const Ice::Current&); virtual std::list< ::Test::Variable> opVariableList(const std::list< ::Test::Variable>&, - std::list< ::Test::Variable>&, - const Ice::Current&); + std::list< ::Test::Variable>&, + const Ice::Current&); virtual std::deque< ::Test::StringStringDict> opStringStringDictSeq(const std::deque< ::Test::StringStringDict>&, std::deque< ::Test::StringStringDict>&, @@ -139,10 +139,10 @@ public: const Ice::Current&); virtual ::Test::ClassStructPtr opClassStruct(const ::Test::ClassStructPtr&, - const ::Test::ClassStructSeq&, - ::Test::ClassStructPtr& out, - ::Test::ClassStructSeq& outSeq, - const Ice::Current&); + const ::Test::ClassStructSeq&, + ::Test::ClassStructPtr& out, + ::Test::ClassStructSeq& outSeq, + const Ice::Current&); virtual void shutdown(const Ice::Current&); diff --git a/cpp/test/Ice/custom/WstringAMDI.cpp b/cpp/test/Ice/custom/WstringAMDI.cpp index 9e827b7e870..1663c138aea 100644 --- a/cpp/test/Ice/custom/WstringAMDI.cpp +++ b/cpp/test/Ice/custom/WstringAMDI.cpp @@ -11,24 +11,24 @@ void Test1::WstringClassI::opString_async(const ::Test1::AMD_WstringClass_opStringPtr& opStringCB, - const ::std::wstring& s1, - const Ice::Current& current) + const ::std::wstring& s1, + const Ice::Current& current) { opStringCB->ice_response(s1, s1); } void Test1::WstringClassI::opStruct_async(const ::Test1::AMD_WstringClass_opStructPtr& opStructCB, - const ::Test1::WstringStruct& s1, - const Ice::Current& current) + const ::Test1::WstringStruct& s1, + const Ice::Current& current) { opStructCB->ice_response(s1, s1); } void Test1::WstringClassI::throwExcept_async(const ::Test1::AMD_WstringClass_throwExceptPtr& throwExceptCB, - const ::std::wstring& reason, - const Ice::Current& current) + const ::std::wstring& reason, + const Ice::Current& current) { Test1::WstringException ex; ex.reason = reason; @@ -37,24 +37,24 @@ Test1::WstringClassI::throwExcept_async(const ::Test1::AMD_WstringClass_throwExc void Test2::WstringClassI::opString_async(const ::Test2::AMD_WstringClass_opStringPtr& opStringCB, - const ::std::wstring& s1, - const Ice::Current& current) + const ::std::wstring& s1, + const Ice::Current& current) { opStringCB->ice_response(s1, s1); } void Test2::WstringClassI::opStruct_async(const ::Test2::AMD_WstringClass_opStructPtr& opStructCB, - const ::Test2::WstringStruct& s1, - const Ice::Current& current) + const ::Test2::WstringStruct& s1, + const Ice::Current& current) { opStructCB->ice_response(s1, s1); } void Test2::WstringClassI::throwExcept_async(const ::Test2::AMD_WstringClass_throwExceptPtr& throwExceptCB, - const ::std::wstring& reason, - const Ice::Current& current) + const ::std::wstring& reason, + const Ice::Current& current) { Test2::WstringException ex; ex.reason = reason; diff --git a/cpp/test/Ice/custom/WstringAMDI.h b/cpp/test/Ice/custom/WstringAMDI.h index 2f5058c1f6a..a2eadd58cf4 100644 --- a/cpp/test/Ice/custom/WstringAMDI.h +++ b/cpp/test/Ice/custom/WstringAMDI.h @@ -20,16 +20,16 @@ class WstringClassI : virtual public WstringClass public: virtual void opString_async(const ::Test1::AMD_WstringClass_opStringPtr&, - const ::std::wstring&, - const Ice::Current&); + const ::std::wstring&, + const Ice::Current&); virtual void opStruct_async(const ::Test1::AMD_WstringClass_opStructPtr&, - const ::Test1::WstringStruct&, - const Ice::Current&); + const ::Test1::WstringStruct&, + const Ice::Current&); virtual void throwExcept_async(const ::Test1::AMD_WstringClass_throwExceptPtr&, - const ::std::wstring&, - const Ice::Current&); + const ::std::wstring&, + const Ice::Current&); }; } @@ -42,16 +42,16 @@ class WstringClassI : virtual public WstringClass public: virtual void opString_async(const ::Test2::AMD_WstringClass_opStringPtr&, - const ::std::wstring&, - const Ice::Current&); + const ::std::wstring&, + const Ice::Current&); virtual void opStruct_async(const ::Test2::AMD_WstringClass_opStructPtr&, - const ::Test2::WstringStruct&, - const Ice::Current&); + const ::Test2::WstringStruct&, + const Ice::Current&); virtual void throwExcept_async(const ::Test2::AMD_WstringClass_throwExceptPtr&, - const ::std::wstring&, - const Ice::Current&); + const ::std::wstring&, + const Ice::Current&); }; } diff --git a/cpp/test/Ice/custom/WstringI.cpp b/cpp/test/Ice/custom/WstringI.cpp index 75681f1f195..58af4234727 100644 --- a/cpp/test/Ice/custom/WstringI.cpp +++ b/cpp/test/Ice/custom/WstringI.cpp @@ -11,8 +11,8 @@ ::std::wstring Test1::WstringClassI::opString(const ::std::wstring& s1, - ::std::wstring& s2, - const Ice::Current& current) + ::std::wstring& s2, + const Ice::Current& current) { s2 = s1; return s1; @@ -20,8 +20,8 @@ Test1::WstringClassI::opString(const ::std::wstring& s1, ::Test1::WstringStruct Test1::WstringClassI::opStruct(const ::Test1::WstringStruct& s1, - ::Test1::WstringStruct& s2, - const Ice::Current& current) + ::Test1::WstringStruct& s2, + const Ice::Current& current) { s2 = s1; return s1; @@ -29,7 +29,7 @@ Test1::WstringClassI::opStruct(const ::Test1::WstringStruct& s1, void Test1::WstringClassI::throwExcept(const ::std::wstring& reason, - const Ice::Current& current) + const Ice::Current& current) { Test1::WstringException ex; ex.reason = reason; @@ -38,8 +38,8 @@ Test1::WstringClassI::throwExcept(const ::std::wstring& reason, ::std::wstring Test2::WstringClassI::opString(const ::std::wstring& s1, - ::std::wstring& s2, - const Ice::Current& current) + ::std::wstring& s2, + const Ice::Current& current) { s2 = s1; return s1; @@ -47,8 +47,8 @@ Test2::WstringClassI::opString(const ::std::wstring& s1, ::Test2::WstringStruct Test2::WstringClassI::opStruct(const ::Test2::WstringStruct& s1, - ::Test2::WstringStruct& s2, - const Ice::Current& current) + ::Test2::WstringStruct& s2, + const Ice::Current& current) { s2 = s1; return s1; @@ -56,7 +56,7 @@ Test2::WstringClassI::opStruct(const ::Test2::WstringStruct& s1, void Test2::WstringClassI::throwExcept(const ::std::wstring& reason, - const Ice::Current& current) + const Ice::Current& current) { Test2::WstringException ex; ex.reason = reason; diff --git a/cpp/test/Ice/custom/WstringI.h b/cpp/test/Ice/custom/WstringI.h index e785a8ed33f..87fa6397e38 100644 --- a/cpp/test/Ice/custom/WstringI.h +++ b/cpp/test/Ice/custom/WstringI.h @@ -20,15 +20,15 @@ class WstringClassI : virtual public WstringClass public: virtual ::std::wstring opString(const ::std::wstring&, - ::std::wstring&, - const Ice::Current&); + ::std::wstring&, + const Ice::Current&); virtual ::Test1::WstringStruct opStruct(const ::Test1::WstringStruct&, - ::Test1::WstringStruct&, - const Ice::Current&); + ::Test1::WstringStruct&, + const Ice::Current&); virtual void throwExcept(const ::std::wstring&, - const Ice::Current&); + const Ice::Current&); }; } @@ -41,15 +41,15 @@ class WstringClassI : virtual public WstringClass public: virtual ::std::wstring opString(const ::std::wstring&, - ::std::wstring&, - const Ice::Current&); + ::std::wstring&, + const Ice::Current&); virtual ::Test2::WstringStruct opStruct(const ::Test2::WstringStruct&, - ::Test2::WstringStruct&, - const Ice::Current&); + ::Test2::WstringStruct&, + const Ice::Current&); virtual void throwExcept(const ::std::wstring&, - const Ice::Current&); + const Ice::Current&); }; } diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index ef140647a36..95009807260 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -39,7 +39,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -49,26 +49,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -82,24 +82,24 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const A& ex) - { - test(ex.aMem == 1); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const A& ex) + { + test(ex.aMem == 1); + } + catch(...) + { + test(false); + } + called(); } }; @@ -116,25 +116,25 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::ObjectNotExistException& ex) - { - Ice::Identity id = _communicator->stringToIdentity("does not exist"); - test(ex.id == id); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::ObjectNotExistException& ex) + { + Ice::Identity id = _communicator->stringToIdentity("does not exist"); + test(ex.id == id); + } + catch(...) + { + test(false); + } + called(); } private: @@ -150,24 +150,24 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::FacetNotExistException& ex) - { - test(ex.facet == "no such facet"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::FacetNotExistException& ex) + { + test(ex.facet == "no such facet"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -179,28 +179,28 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const A& ex) - { - test(ex.aMem == 1); - } - catch(const D& ex) - { - test(ex.dMem == -1); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const A& ex) + { + test(ex.aMem == 1); + } + catch(const D& ex) + { + test(ex.dMem == -1); + } + catch(...) + { + test(false); + } + called(); } }; @@ -212,25 +212,25 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const B& ex) - { - test(ex.aMem == 1); - test(ex.bMem == 2); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const B& ex) + { + test(ex.aMem == 1); + test(ex.bMem == 2); + } + catch(...) + { + test(false); + } + called(); } }; @@ -242,26 +242,26 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const C& ex) - { - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const C& ex) + { + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); + } + catch(...) + { + test(false); + } + called(); } }; @@ -273,25 +273,25 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const B& ex) - { - test(ex.aMem == 1); - test(ex.bMem == 2); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const B& ex) + { + test(ex.aMem == 1); + test(ex.bMem == 2); + } + catch(...) + { + test(false); + } + called(); } }; @@ -303,26 +303,26 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const C& ex) - { - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const C& ex) + { + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); + } + catch(...) + { + test(false); + } + called(); } }; @@ -334,26 +334,26 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const C& ex) - { - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const C& ex) + { + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); + } + catch(...) + { + test(false); + } + called(); } }; @@ -366,31 +366,31 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Mod::A& ex) - { - test(ex.aMem == 1); - test(ex.a2Mem == 2); - } + try + { + exc.ice_throw(); + } + catch(const Mod::A& ex) + { + test(ex.aMem == 1); + test(ex.a2Mem == 2); + } catch(const Ice::OperationNotExistException&) { // // This operation is not supported in Java. // } - catch(...) - { - test(false); - } - called(); + catch(...) + { + test(false); + } + called(); } }; @@ -404,23 +404,23 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::UnknownUserException&) - { - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::UnknownUserException&) + { + } + catch(...) + { + test(false); + } + called(); } }; @@ -432,23 +432,23 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::UnknownUserException&) - { - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::UnknownUserException&) + { + } + catch(...) + { + test(false); + } + called(); } }; @@ -460,23 +460,23 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::UnknownUserException&) - { - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::UnknownUserException&) + { + } + catch(...) + { + test(false); + } + called(); } }; @@ -488,23 +488,23 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::UnknownLocalException&) - { - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::UnknownLocalException&) + { + } + catch(...) + { + test(false); + } + called(); } }; @@ -516,23 +516,23 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::UnknownException&) - { - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::UnknownException&) + { + } + catch(...) + { + test(false); + } + called(); } }; @@ -544,24 +544,24 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Ice::OperationNotExistException& ex) - { - test(ex.operation == "noSuchOperation"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Ice::OperationNotExistException& ex) + { + test(ex.operation == "noSuchOperation"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -572,107 +572,107 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { cout << "testing object adapter registration exceptions... " << flush; { - Ice::ObjectAdapterPtr first; + Ice::ObjectAdapterPtr first; + try + { + first = communicator->createObjectAdapter("TestAdapter0"); + test(false); + } + catch(const Ice::InitializationException&) + { + // Expected + } + + communicator->getProperties()->setProperty("Ice.OA.TestAdapter0.Endpoints", "default"); + first = communicator->createObjectAdapter("TestAdapter0"); + try + { + Ice::ObjectAdapterPtr second = communicator->createObjectAdapter("TestAdapter0"); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + // Expected + } + try - { - first = communicator->createObjectAdapter("TestAdapter0"); - test(false); - } - catch(const Ice::InitializationException&) - { - // Expected - } - - communicator->getProperties()->setProperty("Ice.OA.TestAdapter0.Endpoints", "default"); - first = communicator->createObjectAdapter("TestAdapter0"); - try - { - Ice::ObjectAdapterPtr second = communicator->createObjectAdapter("TestAdapter0"); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - // Expected - } - - try - { - Ice::ObjectAdapterPtr second = - communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011 -t 10000"); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - // Expected. - } - // - // Properties must remain unaffected if an exception occurs. - // - test(communicator->getProperties()->getProperty("Ice.OA.TestAdapter0.Endpoints") == "default"); - first->deactivate(); + { + Ice::ObjectAdapterPtr second = + communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011 -t 10000"); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + // Expected. + } + // + // Properties must remain unaffected if an exception occurs. + // + test(communicator->getProperties()->getProperty("Ice.OA.TestAdapter0.Endpoints") == "default"); + first->deactivate(); } cout << "ok" << endl; cout << "testing servant registration exceptions... " << flush; { - communicator->getProperties()->setProperty("Ice.OA.TestAdapter1.Endpoints", "default"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter1"); - Ice::ObjectPtr obj = new EmptyI; - adapter->add(obj, communicator->stringToIdentity("x")); - try - { - adapter->add(obj, communicator->stringToIdentity("x")); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - } - - adapter->remove(communicator->stringToIdentity("x")); - try - { - adapter->remove(communicator->stringToIdentity("x")); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - - adapter->deactivate(); + communicator->getProperties()->setProperty("Ice.OA.TestAdapter1.Endpoints", "default"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter1"); + Ice::ObjectPtr obj = new EmptyI; + adapter->add(obj, communicator->stringToIdentity("x")); + try + { + adapter->add(obj, communicator->stringToIdentity("x")); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + } + + adapter->remove(communicator->stringToIdentity("x")); + try + { + adapter->remove(communicator->stringToIdentity("x")); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + + adapter->deactivate(); } cout << "ok" << endl; cout << "testing servant locator registrations exceptions... " << flush; { - communicator->getProperties()->setProperty("Ice.OA.TestAdapter2.Endpoints", "default"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2"); - Ice::ServantLocatorPtr loc = new ServantLocatorI; - adapter->addServantLocator(loc, "x"); - try - { - adapter->addServantLocator(loc, "x"); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - } - - adapter->deactivate(); + communicator->getProperties()->setProperty("Ice.OA.TestAdapter2.Endpoints", "default"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2"); + Ice::ServantLocatorPtr loc = new ServantLocatorI; + adapter->addServantLocator(loc, "x"); + try + { + adapter->addServantLocator(loc, "x"); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + } + + adapter->deactivate(); } cout << "ok" << endl; cout << "testing object factory registration exception... " << flush; { - Ice::ObjectFactoryPtr of = new ObjectFactoryI; - communicator->addObjectFactory(of, "x"); - try - { - communicator->addObjectFactory(of, "x"); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - } + Ice::ObjectFactoryPtr of = new ObjectFactoryI; + communicator->addObjectFactory(of, "x"); + try + { + communicator->addObjectFactory(of, "x"); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + } } cout << "ok" << endl; @@ -692,80 +692,80 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) try { - thrower->throwAasA(1); - test(false); + thrower->throwAasA(1); + test(false); } catch(const A& ex) { - test(ex.aMem == 1); + test(ex.aMem == 1); } catch(const Ice::Exception& ex) { - cout << ex << endl; - test(false); + cout << ex << endl; + test(false); } catch(...) { - test(false); + test(false); } try { - thrower->throwAorDasAorD(1); - test(false); + thrower->throwAorDasAorD(1); + test(false); } catch(const A& ex) { - test(ex.aMem == 1); + test(ex.aMem == 1); } catch(...) { - test(false); + test(false); } try { - thrower->throwAorDasAorD(-1); - test(false); + thrower->throwAorDasAorD(-1); + test(false); } catch(const D& ex) { - test(ex.dMem == -1); + test(ex.dMem == -1); } catch(...) { - test(false); + test(false); } try { - thrower->throwBasB(1, 2); - test(false); + thrower->throwBasB(1, 2); + test(false); } catch(const B& ex) { - test(ex.aMem == 1); - test(ex.bMem == 2); + test(ex.aMem == 1); + test(ex.bMem == 2); } catch(...) { - test(false); + test(false); } try { - thrower->throwCasC(1, 2, 3); - test(false); + thrower->throwCasC(1, 2, 3); + test(false); } catch(const C& ex) { - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); } catch(...) { - test(false); + test(false); } #if (!defined(_MSC_VER) || _MSC_VER >= 1300) @@ -774,23 +774,23 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // try { - thrower->throwModA(1, 2); - test(false); + thrower->throwModA(1, 2); + test(false); } catch(const Mod::A& ex) { - test(ex.aMem == 1); - test(ex.a2Mem == 2); + test(ex.aMem == 1); + test(ex.a2Mem == 2); } catch(const Ice::OperationNotExistException&) { - // + // // This operation is not supported in Java. // } catch(...) { - test(false); + test(false); } #endif @@ -800,31 +800,31 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) try { - thrower->throwBasB(1, 2); - test(false); + thrower->throwBasB(1, 2); + test(false); } catch(const A& ex) { - test(ex.aMem == 1); + test(ex.aMem == 1); } catch(...) { - test(false); + test(false); } try { - thrower->throwCasC(1, 2, 3); - test(false); + thrower->throwCasC(1, 2, 3); + test(false); } catch(const B& ex) { - test(ex.aMem == 1); - test(ex.bMem == 2); + test(ex.aMem == 1); + test(ex.bMem == 2); } catch(...) { - test(false); + test(false); } #if (!defined(_MSC_VER) || _MSC_VER >= 1300) @@ -833,167 +833,167 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // try { - thrower->throwModA(1, 2); - test(false); + thrower->throwModA(1, 2); + test(false); } catch(const A& ex) { - test(ex.aMem == 1); + test(ex.aMem == 1); } catch(const Ice::OperationNotExistException&) { - // + // // This operation is not supported in Java. // } catch(...) { - test(false); + test(false); } #endif cout << "ok" << endl; cout << "catching derived types... " << flush; - + try { - thrower->throwBasA(1, 2); - test(false); + thrower->throwBasA(1, 2); + test(false); } catch(const B& ex) { - test(ex.aMem == 1); - test(ex.bMem == 2); + test(ex.aMem == 1); + test(ex.bMem == 2); } catch(...) { - test(false); + test(false); } try { - thrower->throwCasA(1, 2, 3); - test(false); + thrower->throwCasA(1, 2, 3); + test(false); } catch(const C& ex) { - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); } catch(...) { - test(false); + test(false); } try { - thrower->throwCasB(1, 2, 3); - test(false); + thrower->throwCasB(1, 2, 3); + test(false); } catch(const C& ex) { - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); } catch(...) { - test(false); + test(false); } cout << "ok" << endl; if(thrower->supportsUndeclaredExceptions()) { - cout << "catching unknown user exception... " << flush; - - try - { - thrower->throwUndeclaredA(1); - test(false); - } - catch(const A& ex) - { - // - // We get the original exception with collocation - // optimization. - // - test(collocated); - test(ex.aMem == 1); - } - catch(const Ice::UnknownUserException&) - { - // - // We get an unknown user exception without collocation - // optimization. - // - test(!collocated); - } - catch(...) - { - test(false); - } - - try - { - thrower->throwUndeclaredB(1, 2); - test(false); - } - catch(const B& ex) - { - // - // We get the original exception with collocation - // optimization. - // - test(collocated); - test(ex.aMem == 1); - test(ex.bMem == 2); - } - catch(const Ice::UnknownUserException&) - { - // - // We get an unknown user exception without collocation - // optimization. - // - test(!collocated); - } - catch(...) - { - test(false); - } - - try - { - thrower->throwUndeclaredC(1, 2, 3); - test(false); - } - catch(const C& ex) - { - // - // We get the original exception with collocation - // optimization. - // - test(collocated); - test(ex.aMem == 1); - test(ex.bMem == 2); - test(ex.cMem == 3); - } - catch(const Ice::UnknownUserException&) - { - // - // We get an unknown user exception without - // collocation optimization. - // - test(!collocated); - } - catch(...) - { - test(false); - } - - cout << "ok" << endl; + cout << "catching unknown user exception... " << flush; + + try + { + thrower->throwUndeclaredA(1); + test(false); + } + catch(const A& ex) + { + // + // We get the original exception with collocation + // optimization. + // + test(collocated); + test(ex.aMem == 1); + } + catch(const Ice::UnknownUserException&) + { + // + // We get an unknown user exception without collocation + // optimization. + // + test(!collocated); + } + catch(...) + { + test(false); + } + + try + { + thrower->throwUndeclaredB(1, 2); + test(false); + } + catch(const B& ex) + { + // + // We get the original exception with collocation + // optimization. + // + test(collocated); + test(ex.aMem == 1); + test(ex.bMem == 2); + } + catch(const Ice::UnknownUserException&) + { + // + // We get an unknown user exception without collocation + // optimization. + // + test(!collocated); + } + catch(...) + { + test(false); + } + + try + { + thrower->throwUndeclaredC(1, 2, 3); + test(false); + } + catch(const C& ex) + { + // + // We get the original exception with collocation + // optimization. + // + test(collocated); + test(ex.aMem == 1); + test(ex.bMem == 2); + test(ex.cMem == 3); + } + catch(const Ice::UnknownUserException&) + { + // + // We get an unknown user exception without + // collocation optimization. + // + test(!collocated); + } + catch(...) + { + test(false); + } + + cout << "ok" << endl; } cout << "catching object not exist exception... " << flush; @@ -1001,18 +1001,18 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Ice::Identity id = communicator->stringToIdentity("does not exist"); try { - ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower->ice_identity(id)); - thrower2->throwAasA(1); -// thrower2->ice_ping(); - test(false); + ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower->ice_identity(id)); + thrower2->throwAasA(1); +// thrower2->ice_ping(); + test(false); } catch(const Ice::ObjectNotExistException& ex) { - test(ex.id == id); + test(ex.id == id); } catch(...) { - test(false); + test(false); } cout << "ok" << endl; @@ -1021,20 +1021,20 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) try { - ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet"); - try - { - thrower2->ice_ping(); - test(false); - } - catch(const Ice::FacetNotExistException& ex) - { - test(ex.facet == "no such facet"); - } + ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet"); + try + { + thrower2->ice_ping(); + test(false); + } + catch(const Ice::FacetNotExistException& ex) + { + test(ex.facet == "no such facet"); + } } catch(...) { - test(false); + test(false); } cout << "ok" << endl; @@ -1043,17 +1043,17 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) try { - WrongOperationPrx thrower2 = WrongOperationPrx::uncheckedCast(thrower); - thrower2->noSuchOperation(); - test(false); + WrongOperationPrx thrower2 = WrongOperationPrx::uncheckedCast(thrower); + thrower2->noSuchOperation(); + test(false); } catch(const Ice::OperationNotExistException& ex) { - test(ex.operation == "noSuchOperation"); + test(ex.operation == "noSuchOperation"); } catch(...) { - test(false); + test(false); } cout << "ok" << endl; @@ -1062,28 +1062,28 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) try { - thrower->throwLocalException(); - test(false); + thrower->throwLocalException(); + test(false); } catch(const Ice::TimeoutException&) { - // - // We get the original exception with collocation - // optimization. - // - test(collocated); + // + // We get the original exception with collocation + // optimization. + // + test(collocated); } catch(const Ice::UnknownLocalException&) { - // - // We get an unknown local exception without collocation - // optimization. - // - test(!collocated); + // + // We get an unknown local exception without collocation + // optimization. + // + test(!collocated); } catch(...) { - test(false); + test(false); } cout << "ok" << endl; @@ -1092,180 +1092,180 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) try { - thrower->throwNonIceException(); - test(false); + thrower->throwNonIceException(); + test(false); } catch(const Ice::UnknownException&) { - // - // We get an unknown exception without collocation - // optimization. - // - assert(!collocated); + // + // We get an unknown exception without collocation + // optimization. + // + assert(!collocated); } catch(...) { - // - // We get the original exception with collocation - // optimization. - // - assert(collocated); + // + // We get the original exception with collocation + // optimization. + // + assert(collocated); } cout << "ok" << endl; if(!collocated) { - cout << "catching exact types with AMI... " << flush; - - { - AMI_Thrower_throwAasAIPtr cb = new AMI_Thrower_throwAasAI; - thrower->throwAasA_async(cb, 1); - test(cb->check()); - // Let's check if we can reuse the same callback object for another call. - thrower->throwAasA_async(cb, 1); - test(cb->check()); - } - - { - AMI_Thrower_throwAorDasAorDIPtr cb = new AMI_Thrower_throwAorDasAorDI; - thrower->throwAorDasAorD_async(cb, 1); - test(cb->check()); - } - - { - AMI_Thrower_throwAorDasAorDIPtr cb = new AMI_Thrower_throwAorDasAorDI; - thrower->throwAorDasAorD_async(cb, -1); - test(cb->check()); - } - - { - AMI_Thrower_throwBasBIPtr cb = new AMI_Thrower_throwBasBI; - thrower->throwBasB_async(cb, 1, 2); - test(cb->check()); - } - - { - AMI_Thrower_throwCasCIPtr cb = new AMI_Thrower_throwCasCI; - thrower->throwCasC_async(cb, 1, 2, 3); - test(cb->check()); - // Let's check if we can reuse the same callback object for another call. - thrower->throwCasC_async(cb, 1, 2, 3); - test(cb->check()); - } - + cout << "catching exact types with AMI... " << flush; + + { + AMI_Thrower_throwAasAIPtr cb = new AMI_Thrower_throwAasAI; + thrower->throwAasA_async(cb, 1); + test(cb->check()); + // Let's check if we can reuse the same callback object for another call. + thrower->throwAasA_async(cb, 1); + test(cb->check()); + } + + { + AMI_Thrower_throwAorDasAorDIPtr cb = new AMI_Thrower_throwAorDasAorDI; + thrower->throwAorDasAorD_async(cb, 1); + test(cb->check()); + } + + { + AMI_Thrower_throwAorDasAorDIPtr cb = new AMI_Thrower_throwAorDasAorDI; + thrower->throwAorDasAorD_async(cb, -1); + test(cb->check()); + } + + { + AMI_Thrower_throwBasBIPtr cb = new AMI_Thrower_throwBasBI; + thrower->throwBasB_async(cb, 1, 2); + test(cb->check()); + } + + { + AMI_Thrower_throwCasCIPtr cb = new AMI_Thrower_throwCasCI; + thrower->throwCasC_async(cb, 1, 2, 3); + test(cb->check()); + // Let's check if we can reuse the same callback object for another call. + thrower->throwCasC_async(cb, 1, 2, 3); + test(cb->check()); + } + #if (!defined(_MSC_VER) || _MSC_VER >= 1300) // // With VC6 SP5, there is no way to call ::A::__write from ::Mod::A // - { - AMI_Thrower_throwModAIPtr cb = new AMI_Thrower_throwModAI; - thrower->throwModA_async(cb, 1, 2); - test(cb->check()); - } + { + AMI_Thrower_throwModAIPtr cb = new AMI_Thrower_throwModAI; + thrower->throwModA_async(cb, 1, 2); + test(cb->check()); + } #endif - cout << "ok" << endl; - - cout << "catching derived types... " << flush; - - { - AMI_Thrower_throwBasAIPtr cb = new AMI_Thrower_throwBasAI; - thrower->throwBasA_async(cb, 1, 2); - test(cb->check()); - } - - { - AMI_Thrower_throwCasAIPtr cb = new AMI_Thrower_throwCasAI; - thrower->throwCasA_async(cb, 1, 2, 3); - test(cb->check()); - } - - { - AMI_Thrower_throwCasBIPtr cb = new AMI_Thrower_throwCasBI; - thrower->throwCasB_async(cb, 1, 2, 3); - test(cb->check()); - } - - cout << "ok" << endl; - - if(thrower->supportsUndeclaredExceptions()) - { - cout << "catching unknown user exception with AMI... " << flush; - - { - AMI_Thrower_throwUndeclaredAIPtr cb = new AMI_Thrower_throwUndeclaredAI; - thrower->throwUndeclaredA_async(cb, 1); - test(cb->check()); - } - - { - AMI_Thrower_throwUndeclaredBIPtr cb = new AMI_Thrower_throwUndeclaredBI; - thrower->throwUndeclaredB_async(cb, 1, 2); - test(cb->check()); - } - - { - AMI_Thrower_throwUndeclaredCIPtr cb = new AMI_Thrower_throwUndeclaredCI; - thrower->throwUndeclaredC_async(cb, 1, 2, 3); - test(cb->check()); - } - - cout << "ok" << endl; - } - - cout << "catching object not exist exception with AMI... " << flush; - - { - id = communicator->stringToIdentity("does not exist"); - ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower->ice_identity(id)); - AMI_Thrower_throwAasAObjectNotExistIPtr cb = new AMI_Thrower_throwAasAObjectNotExistI(communicator); - thrower2->throwAasA_async(cb, 1); - test(cb->check()); - } - - cout << "ok" << endl; - - cout << "catching facet not exist exception with AMI... " << flush; - - ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet"); - { - AMI_Thrower_throwAasAFacetNotExistIPtr cb = new AMI_Thrower_throwAasAFacetNotExistI; - thrower2->throwAasA_async(cb, 1); - test(cb->check()); - } - - cout << "ok" << endl; - - cout << "catching operation not exist exception with AMI... " << flush; - - { - AMI_WrongOperation_noSuchOperationIPtr cb = new AMI_WrongOperation_noSuchOperationI; - WrongOperationPrx thrower4 = WrongOperationPrx::uncheckedCast(thrower); - thrower4->noSuchOperation_async(cb); - test(cb->check()); - } - - cout << "ok" << endl; + cout << "ok" << endl; + + cout << "catching derived types... " << flush; + + { + AMI_Thrower_throwBasAIPtr cb = new AMI_Thrower_throwBasAI; + thrower->throwBasA_async(cb, 1, 2); + test(cb->check()); + } + + { + AMI_Thrower_throwCasAIPtr cb = new AMI_Thrower_throwCasAI; + thrower->throwCasA_async(cb, 1, 2, 3); + test(cb->check()); + } + + { + AMI_Thrower_throwCasBIPtr cb = new AMI_Thrower_throwCasBI; + thrower->throwCasB_async(cb, 1, 2, 3); + test(cb->check()); + } + + cout << "ok" << endl; + + if(thrower->supportsUndeclaredExceptions()) + { + cout << "catching unknown user exception with AMI... " << flush; + + { + AMI_Thrower_throwUndeclaredAIPtr cb = new AMI_Thrower_throwUndeclaredAI; + thrower->throwUndeclaredA_async(cb, 1); + test(cb->check()); + } + + { + AMI_Thrower_throwUndeclaredBIPtr cb = new AMI_Thrower_throwUndeclaredBI; + thrower->throwUndeclaredB_async(cb, 1, 2); + test(cb->check()); + } + + { + AMI_Thrower_throwUndeclaredCIPtr cb = new AMI_Thrower_throwUndeclaredCI; + thrower->throwUndeclaredC_async(cb, 1, 2, 3); + test(cb->check()); + } + + cout << "ok" << endl; + } + + cout << "catching object not exist exception with AMI... " << flush; + + { + id = communicator->stringToIdentity("does not exist"); + ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower->ice_identity(id)); + AMI_Thrower_throwAasAObjectNotExistIPtr cb = new AMI_Thrower_throwAasAObjectNotExistI(communicator); + thrower2->throwAasA_async(cb, 1); + test(cb->check()); + } + + cout << "ok" << endl; + + cout << "catching facet not exist exception with AMI... " << flush; + + ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet"); + { + AMI_Thrower_throwAasAFacetNotExistIPtr cb = new AMI_Thrower_throwAasAFacetNotExistI; + thrower2->throwAasA_async(cb, 1); + test(cb->check()); + } + + cout << "ok" << endl; + + cout << "catching operation not exist exception with AMI... " << flush; + + { + AMI_WrongOperation_noSuchOperationIPtr cb = new AMI_WrongOperation_noSuchOperationI; + WrongOperationPrx thrower4 = WrongOperationPrx::uncheckedCast(thrower); + thrower4->noSuchOperation_async(cb); + test(cb->check()); + } + + cout << "ok" << endl; - cout << "catching unknown local exception with AMI... " << flush; - - { - AMI_Thrower_throwLocalExceptionIPtr cb = new AMI_Thrower_throwLocalExceptionI; - thrower->throwLocalException_async(cb); - test(cb->check()); - } - - cout << "ok" << endl; - - cout << "catching unknown non-Ice exception with AMI... " << flush; - - AMI_Thrower_throwNonIceExceptionIPtr cb = new AMI_Thrower_throwNonIceExceptionI; - thrower->throwNonIceException_async(cb); - test(cb->check()); - - cout << "ok" << endl; - + cout << "catching unknown local exception with AMI... " << flush; + + { + AMI_Thrower_throwLocalExceptionIPtr cb = new AMI_Thrower_throwLocalExceptionI; + thrower->throwLocalException_async(cb); + test(cb->check()); + } + + cout << "ok" << endl; + + cout << "catching unknown non-Ice exception with AMI... " << flush; + + AMI_Thrower_throwNonIceExceptionIPtr cb = new AMI_Thrower_throwNonIceExceptionI; + thrower->throwNonIceException_async(cb); + test(cb->check()); + + cout << "ok" << endl; + } return thrower; diff --git a/cpp/test/Ice/exceptions/Client.cpp b/cpp/test/Ice/exceptions/Client.cpp index ddffc3942bc..684fb41d824 100644 --- a/cpp/test/Ice/exceptions/Client.cpp +++ b/cpp/test/Ice/exceptions/Client.cpp @@ -31,26 +31,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/exceptions/Collocated.cpp b/cpp/test/Ice/exceptions/Collocated.cpp index 7f609905298..19b9b0eff09 100644 --- a/cpp/test/Ice/exceptions/Collocated.cpp +++ b/cpp/test/Ice/exceptions/Collocated.cpp @@ -35,26 +35,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/exceptions/Server.cpp b/cpp/test/Ice/exceptions/Server.cpp index 566d3d98fc6..a21d497727d 100644 --- a/cpp/test/Ice/exceptions/Server.cpp +++ b/cpp/test/Ice/exceptions/Server.cpp @@ -34,26 +34,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/exceptions/ServerAMD.cpp b/cpp/test/Ice/exceptions/ServerAMD.cpp index 6e1985d2025..cb58072e087 100644 --- a/cpp/test/Ice/exceptions/ServerAMD.cpp +++ b/cpp/test/Ice/exceptions/ServerAMD.cpp @@ -34,26 +34,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/exceptions/Test.ice b/cpp/test/Ice/exceptions/Test.ice index 0844993df14..296d76f7005 100644 --- a/cpp/test/Ice/exceptions/Test.ice +++ b/cpp/test/Ice/exceptions/Test.ice @@ -43,7 +43,7 @@ module Mod { exception A extends ::Test::A { - int a2Mem; + int a2Mem; }; }; diff --git a/cpp/test/Ice/exceptions/TestAMD.ice b/cpp/test/Ice/exceptions/TestAMD.ice index a3efb41c18e..9c0eb3ad93b 100644 --- a/cpp/test/Ice/exceptions/TestAMD.ice +++ b/cpp/test/Ice/exceptions/TestAMD.ice @@ -39,7 +39,7 @@ module Mod { exception A extends ::Test::A { - int a2Mem; + int a2Mem; }; }; diff --git a/cpp/test/Ice/exceptions/TestAMDI.cpp b/cpp/test/Ice/exceptions/TestAMDI.cpp index 34aef3df1c0..8d2924f270f 100644 --- a/cpp/test/Ice/exceptions/TestAMDI.cpp +++ b/cpp/test/Ice/exceptions/TestAMDI.cpp @@ -19,7 +19,7 @@ ThrowerI::ThrowerI(const Ice::ObjectAdapterPtr& adapter) : void ThrowerI::shutdown_async(const AMD_Thrower_shutdownPtr& cb, - const Ice::Current&) + const Ice::Current&) { _adapter->getCommunicator()->shutdown(); cb->ice_response(); @@ -27,21 +27,21 @@ ThrowerI::shutdown_async(const AMD_Thrower_shutdownPtr& cb, void ThrowerI::supportsUndeclaredExceptions_async(const AMD_Thrower_supportsUndeclaredExceptionsPtr& cb, - const Ice::Current&) + const Ice::Current&) { cb->ice_response(true); } void ThrowerI::supportsAssertException_async(const AMD_Thrower_supportsAssertExceptionPtr& cb, - const Ice::Current&) + const Ice::Current&) { cb->ice_response(false); } void ThrowerI::throwAasA_async(const AMD_Thrower_throwAasAPtr& cb, - Ice::Int a, const Ice::Current&) + Ice::Int a, const Ice::Current&) { A ex; ex.aMem = a; @@ -50,25 +50,25 @@ ThrowerI::throwAasA_async(const AMD_Thrower_throwAasAPtr& cb, void ThrowerI::throwAorDasAorD_async(const AMD_Thrower_throwAorDasAorDPtr& cb, - Ice::Int a, const Ice::Current&) + Ice::Int a, const Ice::Current&) { if(a > 0) { - A ex; - ex.aMem = a; - cb->ice_exception(ex); + A ex; + ex.aMem = a; + cb->ice_exception(ex); } else { - D ex; - ex.dMem = a; - cb->ice_exception(ex); + D ex; + ex.dMem = a; + cb->ice_exception(ex); } } void ThrowerI::throwBasA_async(const AMD_Thrower_throwBasAPtr& cb, - Ice::Int a, Ice::Int b, const Ice::Current& current) + Ice::Int a, Ice::Int b, const Ice::Current& current) { B ex; ex.aMem = a; @@ -79,7 +79,7 @@ ThrowerI::throwBasA_async(const AMD_Thrower_throwBasAPtr& cb, void ThrowerI::throwCasA_async(const AMD_Thrower_throwCasAPtr& cb, - Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current& current) + Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current& current) { C ex; ex.aMem = a; @@ -90,7 +90,7 @@ ThrowerI::throwCasA_async(const AMD_Thrower_throwCasAPtr& cb, void ThrowerI::throwBasB_async(const AMD_Thrower_throwBasBPtr& cb, - Ice::Int a, Ice::Int b, const Ice::Current&) + Ice::Int a, Ice::Int b, const Ice::Current&) { B ex; ex.aMem = a; @@ -101,7 +101,7 @@ ThrowerI::throwBasB_async(const AMD_Thrower_throwBasBPtr& cb, void ThrowerI::throwCasB_async(const AMD_Thrower_throwCasBPtr& cb, - Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current& current) + Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current& current) { C ex; ex.aMem = a; @@ -112,7 +112,7 @@ ThrowerI::throwCasB_async(const AMD_Thrower_throwCasBPtr& cb, void ThrowerI::throwCasC_async(const AMD_Thrower_throwCasCPtr& cb, - Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current&) + Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current&) { C ex; ex.aMem = a; @@ -123,7 +123,7 @@ ThrowerI::throwCasC_async(const AMD_Thrower_throwCasCPtr& cb, void ThrowerI::throwModA_async(const AMD_Thrower_throwModAPtr& cb, - Ice::Int a, Ice::Int a2, const Ice::Current&) + Ice::Int a, Ice::Int a2, const Ice::Current&) { Mod::A ex; ex.aMem = a; @@ -134,7 +134,7 @@ ThrowerI::throwModA_async(const AMD_Thrower_throwModAPtr& cb, void ThrowerI::throwUndeclaredA_async(const AMD_Thrower_throwUndeclaredAPtr& cb, - Ice::Int a, const Ice::Current&) + Ice::Int a, const Ice::Current&) { A ex; ex.aMem = a; @@ -143,7 +143,7 @@ ThrowerI::throwUndeclaredA_async(const AMD_Thrower_throwUndeclaredAPtr& cb, void ThrowerI::throwUndeclaredB_async(const AMD_Thrower_throwUndeclaredBPtr& cb, - Ice::Int a, Ice::Int b, const Ice::Current&) + Ice::Int a, Ice::Int b, const Ice::Current&) { B ex; ex.aMem = a; @@ -154,7 +154,7 @@ ThrowerI::throwUndeclaredB_async(const AMD_Thrower_throwUndeclaredBPtr& cb, void ThrowerI::throwUndeclaredC_async(const AMD_Thrower_throwUndeclaredCPtr& cb, - Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current&) + Ice::Int a, Ice::Int b, Ice::Int c, const Ice::Current&) { C ex; ex.aMem = a; @@ -165,21 +165,21 @@ ThrowerI::throwUndeclaredC_async(const AMD_Thrower_throwUndeclaredCPtr& cb, void ThrowerI::throwLocalException_async(const AMD_Thrower_throwLocalExceptionPtr& cb, - const Ice::Current&) + const Ice::Current&) { cb->ice_exception(Ice::TimeoutException(__FILE__, __LINE__)); } void ThrowerI::throwNonIceException_async(const AMD_Thrower_throwNonIceExceptionPtr&, - const Ice::Current&) + const Ice::Current&) { throw int(12345); } void ThrowerI::throwAssertException_async(const AMD_Thrower_throwAssertExceptionPtr&, - const Ice::Current&) + const Ice::Current&) { assert(false); // Not supported in C++. } diff --git a/cpp/test/Ice/exceptions/TestAMDI.h b/cpp/test/Ice/exceptions/TestAMDI.h index 3b16b849d12..bdd7971b5fa 100644 --- a/cpp/test/Ice/exceptions/TestAMDI.h +++ b/cpp/test/Ice/exceptions/TestAMDI.h @@ -19,42 +19,42 @@ public: ThrowerI(const Ice::ObjectAdapterPtr&); virtual void shutdown_async(const Test::AMD_Thrower_shutdownPtr&, - const Ice::Current&); + const Ice::Current&); virtual void supportsUndeclaredExceptions_async(const Test::AMD_Thrower_supportsUndeclaredExceptionsPtr&, - const Ice::Current&); + const Ice::Current&); virtual void supportsAssertException_async(const Test::AMD_Thrower_supportsAssertExceptionPtr&, - const Ice::Current&); + const Ice::Current&); virtual void throwAasA_async(const Test::AMD_Thrower_throwAasAPtr&, - Ice::Int, const Ice::Current&); + Ice::Int, const Ice::Current&); virtual void throwAorDasAorD_async(const Test::AMD_Thrower_throwAorDasAorDPtr&, - Ice::Int, const Ice::Current&); + Ice::Int, const Ice::Current&); virtual void throwBasA_async(const Test::AMD_Thrower_throwBasAPtr&, - Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, const Ice::Current&); virtual void throwCasA_async(const Test::AMD_Thrower_throwCasAPtr&, - Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); virtual void throwBasB_async(const Test::AMD_Thrower_throwBasBPtr&, - Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, const Ice::Current&); virtual void throwCasB_async(const Test::AMD_Thrower_throwCasBPtr&, - Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); virtual void throwCasC_async(const Test::AMD_Thrower_throwCasCPtr&, - Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); virtual void throwModA_async(const Test::AMD_Thrower_throwModAPtr&, - Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, const Ice::Current&); virtual void throwUndeclaredA_async(const Test::AMD_Thrower_throwUndeclaredAPtr&, - Ice::Int, const Ice::Current&); + Ice::Int, const Ice::Current&); virtual void throwUndeclaredB_async(const Test::AMD_Thrower_throwUndeclaredBPtr&, - Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, const Ice::Current&); virtual void throwUndeclaredC_async(const Test::AMD_Thrower_throwUndeclaredCPtr&, - Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); + Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); virtual void throwLocalException_async(const Test::AMD_Thrower_throwLocalExceptionPtr&, - const Ice::Current&); + const Ice::Current&); virtual void throwNonIceException_async(const Test::AMD_Thrower_throwNonIceExceptionPtr&, - const Ice::Current&); + const Ice::Current&); virtual void throwAssertException_async(const Test::AMD_Thrower_throwAssertExceptionPtr&, - const Ice::Current&); + const Ice::Current&); private: diff --git a/cpp/test/Ice/exceptions/TestI.cpp b/cpp/test/Ice/exceptions/TestI.cpp index 2b95046467f..05a1e1d7863 100644 --- a/cpp/test/Ice/exceptions/TestI.cpp +++ b/cpp/test/Ice/exceptions/TestI.cpp @@ -48,15 +48,15 @@ ThrowerI::throwAorDasAorD(Ice::Int a, const Ice::Current&) { if(a > 0) { - A ex; - ex.aMem = a; - throw ex; + A ex; + ex.aMem = a; + throw ex; } else { - D ex; - ex.dMem = a; - throw ex; + D ex; + ex.dMem = a; + throw ex; } } diff --git a/cpp/test/Ice/facets/AllTests.cpp b/cpp/test/Ice/facets/AllTests.cpp index 4122e0cc203..34090065ae0 100644 --- a/cpp/test/Ice/facets/AllTests.cpp +++ b/cpp/test/Ice/facets/AllTests.cpp @@ -29,8 +29,8 @@ allTests(const Ice::CommunicatorPtr& communicator) adapter->addFacet(obj, communicator->stringToIdentity("d"), "facetABCD"); try { - adapter->addFacet(obj, communicator->stringToIdentity("d"), "facetABCD"); - test(false); + adapter->addFacet(obj, communicator->stringToIdentity("d"), "facetABCD"); + test(false); } catch(Ice::AlreadyRegisteredException&) { @@ -38,8 +38,8 @@ allTests(const Ice::CommunicatorPtr& communicator) adapter->removeFacet(communicator->stringToIdentity("d"), "facetABCD"); try { - adapter->removeFacet(communicator->stringToIdentity("d"), "facetABCD"); - test(false); + adapter->removeFacet(communicator->stringToIdentity("d"), "facetABCD"); + test(false); } catch(Ice::NotRegisteredException&) { @@ -61,8 +61,8 @@ allTests(const Ice::CommunicatorPtr& communicator) test(fm["f2"] == obj2); try { - adapter->removeAllFacets(communicator->stringToIdentity("id1")); - test(false); + adapter->removeAllFacets(communicator->stringToIdentity("id1")); + test(false); } catch(Ice::NotRegisteredException&) { diff --git a/cpp/test/Ice/facets/Client.cpp b/cpp/test/Ice/facets/Client.cpp index 4932992110d..769e96f91e7 100644 --- a/cpp/test/Ice/facets/Client.cpp +++ b/cpp/test/Ice/facets/Client.cpp @@ -31,26 +31,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/facets/Collocated.cpp b/cpp/test/Ice/facets/Collocated.cpp index 77ceb993408..f1f5a14040a 100644 --- a/cpp/test/Ice/facets/Collocated.cpp +++ b/cpp/test/Ice/facets/Collocated.cpp @@ -40,26 +40,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/facets/Server.cpp b/cpp/test/Ice/facets/Server.cpp index cb4850bf414..34c8d3a10c7 100644 --- a/cpp/test/Ice/facets/Server.cpp +++ b/cpp/test/Ice/facets/Server.cpp @@ -39,26 +39,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/faultTolerance/AllTests.cpp b/cpp/test/Ice/faultTolerance/AllTests.cpp index abaf9d2ccd1..f450b1d5798 100644 --- a/cpp/test/Ice/faultTolerance/AllTests.cpp +++ b/cpp/test/Ice/faultTolerance/AllTests.cpp @@ -19,7 +19,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -29,26 +29,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(30))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(30))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -62,18 +62,18 @@ public: virtual void ice_response(Ice::Int pid) { - _pid = pid; - called(); + _pid = pid; + called(); } virtual void ice_exception(const Ice::Exception& ex) { - test(false); + test(false); } Ice::Int pid() const { - return _pid; + return _pid; } private: @@ -89,12 +89,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const Ice::Exception&) { - test(false); + test(false); } }; @@ -106,27 +106,27 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& ex) { - try - { - ex.ice_throw(); - } - catch(const Ice::ConnectionLostException&) - { - } - catch(const Ice::ConnectFailedException&) - { - } - catch(Ice::Exception& ex) - { - cout << ex << endl; - test(false); - } - called(); + try + { + ex.ice_throw(); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Ice::ConnectFailedException&) + { + } + catch(Ice::Exception& ex) + { + cout << ex << endl; + test(false); + } + called(); } }; @@ -136,27 +136,27 @@ class AMI_Test_idempotentAbortI : public AMI_TestIntf_idempotentAbort, public Ca { virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& ex) { - try - { - ex.ice_throw(); - } - catch(const Ice::ConnectionLostException&) - { - } - catch(const Ice::ConnectFailedException&) - { - } - catch(Ice::Exception& ex) - { - cout << ex << endl; - test(false); - } - called(); + try + { + ex.ice_throw(); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Ice::ConnectFailedException&) + { + } + catch(Ice::Exception& ex) + { + cout << ex << endl; + test(false); + } + called(); } }; @@ -170,7 +170,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const vector<int>& ports) ref << "test"; for(vector<int>::const_iterator p = ports.begin(); p != ports.end(); ++p) { - ref << ":default -t 60000 -p " << *p; + ref << ":default -t 60000 -p " << *p; } Ice::ObjectPrx base = communicator->stringToProxy(ref.str()); test(base); @@ -186,121 +186,121 @@ allTests(const Ice::CommunicatorPtr& communicator, const vector<int>& ports) bool ami = false; for(unsigned int i = 1, j = 0; i <= ports.size(); ++i, ++j) { - if(j > 3) - { - j = 0; - ami = !ami; - } - - if(!ami) - { - cout << "testing server #" << i << "... " << flush; - int pid = obj->pid(); - test(pid != oldPid); - cout << "ok" << endl; - oldPid = pid; - } - else - { - cout << "testing server #" << i << " with AMI... " << flush; - AMI_Test_pidIPtr cb = new AMI_Test_pidI(); - obj->pid_async(cb); - test(cb->check()); - int pid = cb->pid(); - test(pid != oldPid); - cout << "ok" << endl; - oldPid = pid; - } - - if(j == 0) - { - if(!ami) - { - cout << "shutting down server #" << i << "... " << flush; - obj->shutdown(); - cout << "ok" << endl; - } - else - { - cout << "shutting down server #" << i << " with AMI... " << flush; - AMI_Test_shutdownIPtr cb = new AMI_Test_shutdownI; - obj->shutdown_async(cb); - test(cb->check()); - cout << "ok" << endl; - } - } - else if(j == 1 || i + 1 > ports.size()) - { - if(!ami) - { - cout << "aborting server #" << i << "... " << flush; - try - { - obj->abort(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - cout << "ok" << endl; - } - catch(const Ice::ConnectFailedException&) - { - cout << "ok" << endl; - } - } - else - { - cout << "aborting server #" << i << " with AMI... " << flush; - AMI_Test_abortIPtr cb = new AMI_Test_abortI; - obj->abort_async(cb); - test(cb->check()); - cout << "ok" << endl; - } - } - else if(j == 2 || j == 3) - { - if(!ami) - { - cout << "aborting server #" << i << " and #" << i + 1 << " with idempotent call... " << flush; - try - { - obj->idempotentAbort(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - cout << "ok" << endl; - } - catch(const Ice::ConnectFailedException&) - { - cout << "ok" << endl; - } - } - else - { - cout << "aborting server #" << i << " and #" << i + 1 << " with idempotent AMI call... " << flush; - AMI_Test_idempotentAbortIPtr cb = new AMI_Test_idempotentAbortI; - obj->idempotentAbort_async(cb); - test(cb->check()); - cout << "ok" << endl; - } - - ++i; - } - else - { - assert(false); - } + if(j > 3) + { + j = 0; + ami = !ami; + } + + if(!ami) + { + cout << "testing server #" << i << "... " << flush; + int pid = obj->pid(); + test(pid != oldPid); + cout << "ok" << endl; + oldPid = pid; + } + else + { + cout << "testing server #" << i << " with AMI... " << flush; + AMI_Test_pidIPtr cb = new AMI_Test_pidI(); + obj->pid_async(cb); + test(cb->check()); + int pid = cb->pid(); + test(pid != oldPid); + cout << "ok" << endl; + oldPid = pid; + } + + if(j == 0) + { + if(!ami) + { + cout << "shutting down server #" << i << "... " << flush; + obj->shutdown(); + cout << "ok" << endl; + } + else + { + cout << "shutting down server #" << i << " with AMI... " << flush; + AMI_Test_shutdownIPtr cb = new AMI_Test_shutdownI; + obj->shutdown_async(cb); + test(cb->check()); + cout << "ok" << endl; + } + } + else if(j == 1 || i + 1 > ports.size()) + { + if(!ami) + { + cout << "aborting server #" << i << "... " << flush; + try + { + obj->abort(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + cout << "ok" << endl; + } + catch(const Ice::ConnectFailedException&) + { + cout << "ok" << endl; + } + } + else + { + cout << "aborting server #" << i << " with AMI... " << flush; + AMI_Test_abortIPtr cb = new AMI_Test_abortI; + obj->abort_async(cb); + test(cb->check()); + cout << "ok" << endl; + } + } + else if(j == 2 || j == 3) + { + if(!ami) + { + cout << "aborting server #" << i << " and #" << i + 1 << " with idempotent call... " << flush; + try + { + obj->idempotentAbort(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + cout << "ok" << endl; + } + catch(const Ice::ConnectFailedException&) + { + cout << "ok" << endl; + } + } + else + { + cout << "aborting server #" << i << " and #" << i + 1 << " with idempotent AMI call... " << flush; + AMI_Test_idempotentAbortIPtr cb = new AMI_Test_idempotentAbortI; + obj->idempotentAbort_async(cb); + test(cb->check()); + cout << "ok" << endl; + } + + ++i; + } + else + { + assert(false); + } } cout << "testing whether all servers are gone... " << flush; try { - obj->ice_ping(); - test(false); + obj->ice_ping(); + test(false); } catch(const Ice::LocalException&) { - cout << "ok" << endl; + cout << "ok" << endl; } } diff --git a/cpp/test/Ice/faultTolerance/Client.cpp b/cpp/test/Ice/faultTolerance/Client.cpp index 26332a7b4db..c7a9561d4ae 100644 --- a/cpp/test/Ice/faultTolerance/Client.cpp +++ b/cpp/test/Ice/faultTolerance/Client.cpp @@ -25,32 +25,32 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) vector<int> ports; for(int i = 1; i < argc; ++i) { - if(argv[i][0] == '-') - { - cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } + if(argv[i][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } - ports.push_back(atoi(argv[i])); + ports.push_back(atoi(argv[i])); } if(ports.empty()) { - cerr << argv[0] << ": no ports specified" << endl; - usage(argv[0]); - return EXIT_FAILURE; + cerr << argv[0] << ": no ports specified" << endl; + usage(argv[0]); + return EXIT_FAILURE; } try { - void allTests(const Ice::CommunicatorPtr&, const vector<int>&); - allTests(communicator, ports); + void allTests(const Ice::CommunicatorPtr&, const vector<int>&); + allTests(communicator, ports); } catch(const Ice::Exception& ex) { - cout << ex << endl; - test(false); + cout << ex << endl; + test(false); } return EXIT_SUCCESS; @@ -64,34 +64,34 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); - // - // This test aborts servers, so we don't want warnings. - // - initData.properties->setProperty("Ice.Warn.Connections", "0"); + // + // This test aborts servers, so we don't want warnings. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/faultTolerance/Server.cpp b/cpp/test/Ice/faultTolerance/Server.cpp index 90618e949d7..089190cee08 100644 --- a/cpp/test/Ice/faultTolerance/Server.cpp +++ b/cpp/test/Ice/faultTolerance/Server.cpp @@ -24,28 +24,28 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) int port = 0; for(int i = 1; i < argc; ++i) { - if(argv[i][0] == '-') - { - cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } + if(argv[i][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } - if(port > 0) - { - cerr << argv[0] << ": only one port can be specified" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } + if(port > 0) + { + cerr << argv[0] << ": only one port can be specified" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } - port = atoi(argv[i]); + port = atoi(argv[i]); } if(port <= 0) { - cerr << argv[0] << ": no port specified" << endl; - usage(argv[0]); - return EXIT_FAILURE; + cerr << argv[0] << ": no port specified" << endl; + usage(argv[0]); + return EXIT_FAILURE; } ostringstream endpts; @@ -68,34 +68,34 @@ main(int argc, char* argv[]) try { // - // In this test, we need a longer server idle time, otherwise - // our test servers may time out before they are used in the - // test. - // - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.ServerIdleTime", "120"); // Two minutes. + // In this test, we need a longer server idle time, otherwise + // our test servers may time out before they are used in the + // test. + // + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.ServerIdleTime", "120"); // Two minutes. - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/gc/Client.cpp b/cpp/test/Ice/gc/Client.cpp index 0e0f6fae130..86d599a91fb 100644 --- a/cpp/test/Ice/gc/Client.cpp +++ b/cpp/test/Ice/gc/Client.cpp @@ -45,12 +45,12 @@ struct N : public C { N() { - incNum(); + incNum(); } ~N() { - decNum(); + decNum(); } }; @@ -60,12 +60,12 @@ struct N2 : public C2 { N2() { - incNum(); + incNum(); } ~N2() { - decNum(); + decNum(); } }; @@ -75,12 +75,12 @@ struct NN : public Node { NN() { - incNum(); + incNum(); } ~NN() { - decNum(); + decNum(); } }; @@ -90,12 +90,12 @@ struct NL : public Leaf { NL() { - incNum(); + incNum(); } ~NL() { - decNum(); + decNum(); } }; @@ -107,138 +107,138 @@ public: GarbageProducer() { - _stop = false; + _stop = false; } virtual void run() { - ::IceUtil::ThreadControl t = getThreadControl(); - - while(true) - { - { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - if(_stop) - { - return; - } - } - - t.yield(); - - { - NPtr n = new N; - n->left = n; - } - - { - NPtr n = new N; - n->left = n; - n->right = n; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->right = n2; - n2->right = n1; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->right = n1; - n2->right = n2; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->right = n2; - n2->right = n3; - n3->right = n1; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->right = n3; - n2->right = n1; - n3->right = n2; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - n1->left = n2; - n2->left = n1; - n2->right = n3; - n3->left = n4; - } - - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - NPtr n5 = new N; - NPtr n6 = new N; - n1->left = n2; - n2->left = n1; - n2->right = n3; - n3->left = n4; - n4->right = n5; - n5->right = n6; - n6->right = n5; - } - } + ::IceUtil::ThreadControl t = getThreadControl(); + + while(true) + { + { + ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + if(_stop) + { + return; + } + } + + t.yield(); + + { + NPtr n = new N; + n->left = n; + } + + { + NPtr n = new N; + n->left = n; + n->right = n; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + n1->right = n2; + n2->right = n1; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + n1->right = n1; + n2->right = n2; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + n1->left = n2; + n2->left = n3; + n3->left = n1; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + n1->left = n2; + n2->left = n3; + n3->left = n1; + n1->right = n2; + n2->right = n3; + n3->right = n1; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + n1->left = n2; + n2->left = n3; + n3->left = n1; + n1->right = n3; + n2->right = n1; + n3->right = n2; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + NPtr n4 = new N; + n1->left = n2; + n2->left = n1; + n2->right = n3; + n3->left = n4; + } + + { + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + NPtr n4 = new N; + NPtr n5 = new N; + NPtr n6 = new N; + n1->left = n2; + n2->left = n1; + n2->right = n3; + n3->left = n4; + n4->right = n5; + n5->right = n6; + n6->right = n5; + } + } } void stop() { - { - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - _stop = true; - notify(); - } - getThreadControl().join(); + { + ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + _stop = true; + notify(); + } + getThreadControl().join(); } void randomWait() { - ::IceUtil::Time waitTime = ::IceUtil::Time::milliSeconds(10 + rand() % 50); - ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - timedWait(waitTime); + ::IceUtil::Time waitTime = ::IceUtil::Time::milliSeconds(10 + rand() % 50); + ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); + timedWait(waitTime); } private: @@ -258,10 +258,10 @@ MyApplication::run(int argc, char* argv[]) { cout << "testing single instance... " << flush; { - NPtr n = new N; - test(getNum() == 1); - Ice::collectGarbage(); - test(getNum() == 1); + NPtr n = new N; + test(getNum() == 1); + Ice::collectGarbage(); + test(getNum() == 1); } test(getNum() == 0); Ice::collectGarbage(); @@ -270,11 +270,11 @@ MyApplication::run(int argc, char* argv[]) cout << "testing single instance cycle... " << flush; { - NPtr n = new N; - n->left = n; - test(getNum() == 1); - Ice::collectGarbage(); - test(getNum() == 1); + NPtr n = new N; + n->left = n; + test(getNum() == 1); + Ice::collectGarbage(); + test(getNum() == 1); } test(getNum() == 1); Ice::collectGarbage(); @@ -283,12 +283,12 @@ MyApplication::run(int argc, char* argv[]) cout << "testing single instance cycle with double pointers... " << flush; { - NPtr n = new N; - n->left = n; - n->right = n; - test(getNum() == 1); - Ice::collectGarbage(); - test(getNum() == 1); + NPtr n = new N; + n->left = n; + n->right = n; + test(getNum() == 1); + Ice::collectGarbage(); + test(getNum() == 1); } test(getNum() == 1); Ice::collectGarbage(); @@ -297,13 +297,13 @@ MyApplication::run(int argc, char* argv[]) cout << "testing double instance cycle... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } test(getNum() == 2); Ice::collectGarbage(); @@ -312,15 +312,15 @@ MyApplication::run(int argc, char* argv[]) cout << "testing double instance cycle with double pointers... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->right = n2; - n2->right = n1; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + n1->right = n2; + n2->right = n1; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } test(getNum() == 2); Ice::collectGarbage(); @@ -329,15 +329,15 @@ MyApplication::run(int argc, char* argv[]) cout << "testing double instance cycle with looped pointers... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->right = n1; - n2->right = n2; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + n1->right = n1; + n2->right = n2; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } test(getNum() == 2); Ice::collectGarbage(); @@ -346,15 +346,15 @@ MyApplication::run(int argc, char* argv[]) cout << "testing triple instance cycle... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - test(getNum() == 3); - Ice::collectGarbage(); - test(getNum() == 3); + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + n1->left = n2; + n2->left = n3; + n3->left = n1; + test(getNum() == 3); + Ice::collectGarbage(); + test(getNum() == 3); } test(getNum() == 3); Ice::collectGarbage(); @@ -363,18 +363,18 @@ MyApplication::run(int argc, char* argv[]) cout << "testing triple instance cycle with double pointers... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->right = n2; - n2->right = n3; - n3->right = n1; - test(getNum() == 3); - Ice::collectGarbage(); - test(getNum() == 3); + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + n1->left = n2; + n2->left = n3; + n3->left = n1; + n1->right = n2; + n2->right = n3; + n3->right = n1; + test(getNum() == 3); + Ice::collectGarbage(); + test(getNum() == 3); } test(getNum() == 3); Ice::collectGarbage(); @@ -383,18 +383,18 @@ MyApplication::run(int argc, char* argv[]) cout << "testing triple instance cycle with opposing pointers... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->right = n3; - n2->right = n1; - n3->right = n2; - test(getNum() == 3); - Ice::collectGarbage(); - test(getNum() == 3); + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + n1->left = n2; + n2->left = n3; + n3->left = n1; + n1->right = n3; + n2->right = n1; + n3->right = n2; + test(getNum() == 3); + Ice::collectGarbage(); + test(getNum() == 3); } test(getNum() == 3); Ice::collectGarbage(); @@ -404,18 +404,18 @@ MyApplication::run(int argc, char* argv[]) cout << "testing cycle with trailing instances... " << flush; NPtr n; { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - n1->left = n2; - n2->left = n1; - n2->right = n3; - n3->left = n4; - n = n3; - test(getNum() == 4); - Ice::collectGarbage(); - test(getNum() == 4); + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + NPtr n4 = new N; + n1->left = n2; + n2->left = n1; + n2->right = n3; + n3->left = n4; + n = n3; + test(getNum() == 4); + Ice::collectGarbage(); + test(getNum() == 4); } test(getNum() == 4); Ice::collectGarbage(); @@ -428,23 +428,23 @@ MyApplication::run(int argc, char* argv[]) cout << "testing cycle with trailing instances and trailing cycle... " << flush; { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - NPtr n5 = new N; - NPtr n6 = new N; - n1->left = n2; - n2->left = n1; - n2->right = n3; - n3->left = n4; - n4->right = n5; - n5->right = n6; - n6->right = n5; - n = n4; - test(getNum() == 6); - Ice::collectGarbage(); - test(getNum() == 6); + NPtr n1 = new N; + NPtr n2 = new N; + NPtr n3 = new N; + NPtr n4 = new N; + NPtr n5 = new N; + NPtr n6 = new N; + n1->left = n2; + n2->left = n1; + n2->right = n3; + n3->left = n4; + n4->right = n5; + n5->right = n6; + n6->right = n5; + n = n4; + test(getNum() == 6); + Ice::collectGarbage(); + test(getNum() == 6); } test(getNum() == 6); Ice::collectGarbage(); @@ -457,14 +457,14 @@ MyApplication::run(int argc, char* argv[]) cout << "testing sequence element cycle... " << flush; { - CSeq cs; - cs.push_back(new N); - cs.push_back(new N); - cs[0]->left = cs[1]; - cs[1]->left = cs[0]; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + CSeq cs; + cs.push_back(new N); + cs.push_back(new N); + cs[0]->left = cs[1]; + cs[1]->left = cs[0]; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } Ice::collectGarbage(); test(getNum() == 0); @@ -472,16 +472,16 @@ MyApplication::run(int argc, char* argv[]) cout << "testing dictionary element cycle... " << flush; { - CDict cd; - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - cd[0] = n1; - cd[1] = n2; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + CDict cd; + NPtr n1 = new N; + NPtr n2 = new N; + n1->left = n2; + n2->left = n1; + cd[0] = n1; + cd[1] = n2; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } Ice::collectGarbage(); test(getNum() == 0); @@ -489,18 +489,18 @@ MyApplication::run(int argc, char* argv[]) cout << "testing sequence of struct cycle... " << flush; { - SSeq ss; - S s; + SSeq ss; + S s; - ss.push_back(s); - ss.push_back(s); - ss[0].theC = new N; - ss[1].theC = new N; - ss[0].theC->left = ss[1].theC; - ss[1].theC->left = ss[0].theC; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + ss.push_back(s); + ss.push_back(s); + ss[0].theC = new N; + ss[1].theC = new N; + ss[0].theC->left = ss[1].theC; + ss[1].theC->left = ss[0].theC; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } Ice::collectGarbage(); test(getNum() == 0); @@ -508,18 +508,18 @@ MyApplication::run(int argc, char* argv[]) cout << "testing sequence of struct of dictionary cycle... " << flush; { - N2Ptr n2 = new N2; - S2 s2; + N2Ptr n2 = new N2; + S2 s2; - n2->theS2Seq.push_back(s2); - n2->theS2Seq.push_back(s2); - n2->theS2Seq[0].theC2Dict[0] = n2; - n2->theS2Seq[0].theC2Dict[1] = n2; - n2->theS2Seq[1].theC2Dict[0] = n2; - n2->theS2Seq[1].theC2Dict[1] = n2; - test(getNum() == 1); - Ice::collectGarbage(); - test(getNum() == 1); + n2->theS2Seq.push_back(s2); + n2->theS2Seq.push_back(s2); + n2->theS2Seq[0].theC2Dict[0] = n2; + n2->theS2Seq[0].theC2Dict[1] = n2; + n2->theS2Seq[1].theC2Dict[0] = n2; + n2->theS2Seq[1].theC2Dict[1] = n2; + test(getNum() == 1); + Ice::collectGarbage(); + test(getNum() == 1); } Ice::collectGarbage(); test(getNum() == 0); @@ -529,61 +529,61 @@ MyApplication::run(int argc, char* argv[]) { NNPtr nn = new NN; - nn->l = new NL; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + nn->l = new NL; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } Ice::collectGarbage(); test(getNum() == 0); { NLPtr p; - { - NNPtr nn = new NN; - p = new NL; - nn->l = p; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); - } - Ice::collectGarbage(); - test(getNum() == 1); + { + NNPtr nn = new NN; + p = new NL; + nn->l = p; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); + } + Ice::collectGarbage(); + test(getNum() == 1); } test(getNum() == 0); { - NNPtr nn = new NN; - NLPtr nl = new NL; - nn->l = nl; - nn->n = nn; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + NNPtr nn = new NN; + NLPtr nl = new NL; + nn->l = nl; + nn->n = nn; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } test(getNum() == 2); Ice::collectGarbage(); test(getNum() == 0); { - NNPtr nn1 = new NN; - NNPtr nn2 = new NN; - NLPtr nl = new NL; - nn1->l = nl; - nn1->n = nn2; - nn2->l = nl; - nn2->n = nn1; - test(getNum() == 3); - Ice::collectGarbage(); - test(getNum() == 3); + NNPtr nn1 = new NN; + NNPtr nn2 = new NN; + NLPtr nl = new NL; + nn1->l = nl; + nn1->n = nn2; + nn2->l = nl; + nn2->n = nn1; + test(getNum() == 3); + Ice::collectGarbage(); + test(getNum() == 3); } test(getNum() == 3); Ice::collectGarbage(); test(getNum() == 0); { - NLPtr nl = new NL; - test(getNum() == 1); + NLPtr nl = new NL; + test(getNum() == 1); } test(getNum() == 0); Ice::collectGarbage(); @@ -591,10 +591,10 @@ MyApplication::run(int argc, char* argv[]) { NNPtr nn1 = new NN; - nn1->n = new NN; - test(getNum() == 2); - Ice::collectGarbage(); - test(getNum() == 2); + nn1->n = new NN; + test(getNum() == 2); + Ice::collectGarbage(); + test(getNum() == 2); } test(getNum() == 0); Ice::collectGarbage(); @@ -619,12 +619,12 @@ MyApplication::run(int argc, char* argv[]) for(int i = 0; i < 50; ++i) { - if(interrupted()) - { - break; - } - garbageThread->randomWait(); - Ice::collectGarbage(); + if(interrupted()) + { + break; + } + garbageThread->randomWait(); + Ice::collectGarbage(); } garbageThread->stop(); @@ -632,13 +632,13 @@ MyApplication::run(int argc, char* argv[]) Ice::collectGarbage(); if(!interrupted()) { - test(getNum() == 0); - cout << "ok" << endl; - return EXIT_SUCCESS; + test(getNum() == 0); + cout << "ok" << endl; + return EXIT_SUCCESS; } else { - return 130; // SIGINT + 128 + return 130; // SIGINT + 128 } } diff --git a/cpp/test/Ice/gc/Test.ice b/cpp/test/Ice/gc/Test.ice index e2451aa5ceb..bc367837722 100644 --- a/cpp/test/Ice/gc/Test.ice +++ b/cpp/test/Ice/gc/Test.ice @@ -64,31 +64,31 @@ class Node // Sequence of structs defined above. -sequence<C2Dict> C2DictSeq; // Sequence of dictionary. +sequence<C2Dict> C2DictSeq; // Sequence of dictionary. -sequence<CSeq> CSeqSeq; // Sequence of sequence. +sequence<CSeq> CSeqSeq; // Sequence of sequence. // Struct containing classes defined above. -struct A // Struct containing sequence. +struct A // Struct containing sequence. { SSeq theSSeq; }; // Struct containing dictionary defined above. -struct B // Struct containing struct. +struct B // Struct containing struct. { S theS; }; // Dictionary of classes defined above. -dictionary<int, CSeq> CSeqDict; // Dictionary containing sequence. +dictionary<int, CSeq> CSeqDict; // Dictionary containing sequence. -dictionary<int, S> SDict; // Dictionary containing struct. +dictionary<int, S> SDict; // Dictionary containing struct. -dictionary<int, CDict> CDictDict; // Dictionary containing dictionary. +dictionary<int, CDict> CDictDict; // Dictionary containing dictionary. class CTest { @@ -114,18 +114,18 @@ module AAA dictionary<int, B> BDict; struct BStruct { - B bMem; + B bMem; }; class C { - Object obj1; - Object obj2; + Object obj1; + Object obj2; B b1; B b2; BSeq x; - BDict y; - BStruct z; + BDict y; + BStruct z; }; }; @@ -135,18 +135,18 @@ module AAA dictionary<int, C> CDict; struct CStruct { - C cMem; + C cMem; }; class B { - Object obj1; - Object obj2; - C c1; - C c2; + Object obj1; + Object obj2; + C c1; + C c2; CSeq x; - CDict y; - CStruct z; + CDict y; + CStruct z; }; }; @@ -167,24 +167,24 @@ module DDD { interface I { - void op(); + void op(); }; class C { - void op(); + void op(); }; class C2; class U { - I myI; - I* myIstar; - C myC; - C* myCstar; - C2 myC2; - C2* myC2star; + I myI; + I* myIstar; + C myC; + C* myCstar; + C2 myC2; + C2* myC2star; }; class C2 diff --git a/cpp/test/Ice/hold/AllTests.cpp b/cpp/test/Ice/hold/AllTests.cpp index 656afd3f066..929fdcf53b8 100644 --- a/cpp/test/Ice/hold/AllTests.cpp +++ b/cpp/test/Ice/hold/AllTests.cpp @@ -32,7 +32,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "changing state between active and hold rapidly... " << flush; for(int i = 0; i < 100; ++i) { - hold->putOnHold(0); + hold->putOnHold(0); } cout << "ok" << endl; diff --git a/cpp/test/Ice/hold/Client.cpp b/cpp/test/Ice/hold/Client.cpp index aaa0e585955..0162051684d 100644 --- a/cpp/test/Ice/hold/Client.cpp +++ b/cpp/test/Ice/hold/Client.cpp @@ -30,26 +30,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/hold/Server.cpp b/cpp/test/Ice/hold/Server.cpp index 1b4c0a5784e..ba0dfe8fbba 100644 --- a/cpp/test/Ice/hold/Server.cpp +++ b/cpp/test/Ice/hold/Server.cpp @@ -32,26 +32,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/hold/TestI.cpp b/cpp/test/Ice/hold/TestI.cpp index bd5200168e5..63015a458f9 100644 --- a/cpp/test/Ice/hold/TestI.cpp +++ b/cpp/test/Ice/hold/TestI.cpp @@ -15,12 +15,12 @@ HoldI::putOnHold(Ice::Int seconds, const Ice::Current& current) { if(seconds <= 0) { - current.adapter->hold(); - current.adapter->activate(); + current.adapter->hold(); + current.adapter->activate(); } else { - assert(false); // TODO + assert(false); // TODO } } diff --git a/cpp/test/Ice/inheritance/Client.cpp b/cpp/test/Ice/inheritance/Client.cpp index 5e73131b1c9..cd9f5e04e0e 100644 --- a/cpp/test/Ice/inheritance/Client.cpp +++ b/cpp/test/Ice/inheritance/Client.cpp @@ -31,26 +31,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/inheritance/Collocated.cpp b/cpp/test/Ice/inheritance/Collocated.cpp index da1f7d58fe7..215c3a5e3b6 100644 --- a/cpp/test/Ice/inheritance/Collocated.cpp +++ b/cpp/test/Ice/inheritance/Collocated.cpp @@ -35,26 +35,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/inheritance/Server.cpp b/cpp/test/Ice/inheritance/Server.cpp index 20635c31e8f..a28e1fa33a8 100644 --- a/cpp/test/Ice/inheritance/Server.cpp +++ b/cpp/test/Ice/inheritance/Server.cpp @@ -32,26 +32,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/inheritance/TestI.h b/cpp/test/Ice/inheritance/TestI.h index 90cbb433848..72918965061 100644 --- a/cpp/test/Ice/inheritance/TestI.h +++ b/cpp/test/Ice/inheritance/TestI.h @@ -74,7 +74,7 @@ class IB1I : virtual public Test::MB::IB1, virtual public IAI { public: - virtual Test::MB::IB1Prx ib1op(const Test::MB::IB1Prx&, const Ice::Current&); + virtual Test::MB::IB1Prx ib1op(const Test::MB::IB1Prx&, const Ice::Current&); }; class IB2I : virtual public Test::MB::IB2, virtual public IAI diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index 8250e3c8701..c5993bb19fe 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -23,7 +23,7 @@ public: virtual void sayHello(const Ice::Current& foo) { - // Do nothing, this is just a dummy servant. + // Do nothing, this is just a dummy servant. } }; @@ -101,13 +101,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) manager->startServer(); try { - obj2 = TestIntfPrx::checkedCast(base2); - obj2->ice_ping(); + obj2 = TestIntfPrx::checkedCast(base2); + obj2->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; @@ -116,13 +116,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) manager->startServer(); try { - obj6 = TestIntfPrx::checkedCast(base6); - obj6->ice_ping(); + obj6 = TestIntfPrx::checkedCast(base6); + obj6->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; @@ -131,123 +131,123 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) manager->startServer(); try { - obj3 = TestIntfPrx::checkedCast(base3); - obj3->ice_ping(); + obj3 = TestIntfPrx::checkedCast(base3); + obj3->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } try { - obj2 = TestIntfPrx::checkedCast(base2); - obj2->ice_ping(); + obj2 = TestIntfPrx::checkedCast(base2); + obj2->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } obj->shutdown(); manager->startServer(); try { - obj2 = TestIntfPrx::checkedCast(base2); - obj2->ice_ping(); + obj2 = TestIntfPrx::checkedCast(base2); + obj2->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } try { - obj3 = TestIntfPrx::checkedCast(base3); - obj3->ice_ping(); + obj3 = TestIntfPrx::checkedCast(base3); + obj3->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } obj->shutdown(); manager->startServer(); try { - obj2 = TestIntfPrx::checkedCast(base2); - obj2->ice_ping(); + obj2 = TestIntfPrx::checkedCast(base2); + obj2->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } obj->shutdown(); manager->startServer(); try { - obj3 = TestIntfPrx::checkedCast(base3); - obj3->ice_ping(); + obj3 = TestIntfPrx::checkedCast(base3); + obj3->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } obj->shutdown(); manager->startServer(); try { - obj2 = TestIntfPrx::checkedCast(base2); - obj2->ice_ping(); + obj2 = TestIntfPrx::checkedCast(base2); + obj2->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } obj->shutdown(); manager->startServer(); try { - obj5 = TestIntfPrx::checkedCast(base5); - obj5->ice_ping(); + obj5 = TestIntfPrx::checkedCast(base5); + obj5->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing proxy with unknown identity... " << flush; try { - base = communicator->stringToProxy("unknown/unknown"); - base->ice_ping(); - test(false); + base = communicator->stringToProxy("unknown/unknown"); + base->ice_ping(); + test(false); } catch (const Ice::NotRegisteredException& ex) { - test(ex.kindOfObject == "object"); - test(ex.id == "unknown/unknown"); + test(ex.kindOfObject == "object"); + test(ex.id == "unknown/unknown"); } cout << "ok" << endl; cout << "testing proxy with unknown adapter... " << flush; try { - base = communicator->stringToProxy("test @ TestAdapterUnknown"); - base->ice_ping(); - test(false); + base = communicator->stringToProxy("test @ TestAdapterUnknown"); + base->ice_ping(); + test(false); } catch (const Ice::NotRegisteredException& ex) { - test(ex.kindOfObject == "object adapter"); - test(ex.id == "TestAdapterUnknown"); + test(ex.kindOfObject == "object adapter"); + test(ex.id == "TestAdapterUnknown"); } cout << "ok" << endl; @@ -319,24 +319,24 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) cout << "testing whether server is gone... " << flush; try { - obj2->ice_ping(); - test(false); + obj2->ice_ping(); + test(false); } catch(const Ice::LocalException&) { } try { - obj3->ice_ping(); - test(false); + obj3->ice_ping(); + test(false); } catch(const Ice::LocalException&) { } try { - obj5->ice_ping(); - test(false); + obj5->ice_ping(); + test(false); } catch(const Ice::LocalException&) { @@ -362,9 +362,9 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) try { - HelloPrx helloPrx = HelloPrx::checkedCast(communicator->stringToProxy(communicator->identityToString(id))); - Ice::ConnectionPtr connection = helloPrx->ice_getConnection(); - test(false); + HelloPrx helloPrx = HelloPrx::checkedCast(communicator->stringToProxy(communicator->identityToString(id))); + Ice::ConnectionPtr connection = helloPrx->ice_getConnection(); + test(false); } catch(const Ice::CollocationOptimizationException&) { diff --git a/cpp/test/Ice/location/Client.cpp b/cpp/test/Ice/location/Client.cpp index aa5e1d2d4cc..410164bb3fd 100644 --- a/cpp/test/Ice/location/Client.cpp +++ b/cpp/test/Ice/location/Client.cpp @@ -30,28 +30,28 @@ main(int argc, char* argv[]) try { Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.Default.Locator", "locator:default -p 12010"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Default.Locator", "locator:default -p 12010"); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/location/Server.cpp b/cpp/test/Ice/location/Server.cpp index e76326f9e0d..e327819beb1 100644 --- a/cpp/test/Ice/location/Server.cpp +++ b/cpp/test/Ice/location/Server.cpp @@ -39,7 +39,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, adapter->add(object, communicator->stringToIdentity("ServerManager")); Ice::LocatorRegistryPrx registryPrx = - Ice::LocatorRegistryPrx::uncheckedCast(adapter->add(registry, communicator->stringToIdentity("registry"))); + Ice::LocatorRegistryPrx::uncheckedCast(adapter->add(registry, communicator->stringToIdentity("registry"))); Ice::LocatorPtr locator = new ServerLocator(registry, registryPrx); adapter->add(locator, communicator->stringToIdentity("locator")); @@ -58,30 +58,30 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - communicator = Ice::initialize(argc, argv, initData); - assert(initData.properties != communicator->getProperties()); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + communicator = Ice::initialize(argc, argv, initData); + assert(initData.properties != communicator->getProperties()); - status = run(argc, argv, communicator, initData); + status = run(argc, argv, communicator, initData); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/location/ServerLocator.cpp b/cpp/test/Ice/location/ServerLocator.cpp index c6fe03a8c1e..b6eb03caba3 100644 --- a/cpp/test/Ice/location/ServerLocator.cpp +++ b/cpp/test/Ice/location/ServerLocator.cpp @@ -19,8 +19,8 @@ ServerLocatorRegistry::ServerLocatorRegistry() void ServerLocatorRegistry::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb, - const std::string& adapter, const ::Ice::ObjectPrx& object, - const ::Ice::Current&) + const std::string& adapter, const ::Ice::ObjectPrx& object, + const ::Ice::Current&) { _adapters[adapter] = object; cb->ice_response(); @@ -39,7 +39,7 @@ ServerLocatorRegistry::setReplicatedAdapterDirectProxy_async( void ServerLocatorRegistry::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb, - const ::std::string&, const Ice::ProcessPrx&, const ::Ice::Current&) + const ::std::string&, const Ice::ProcessPrx&, const ::Ice::Current&) { cb->ice_response(); } @@ -56,7 +56,7 @@ ServerLocatorRegistry::getAdapter(const ::std::string& adapter) const ::std::map< string, ::Ice::ObjectPrx>::const_iterator p = _adapters.find(adapter); if(_adapters.find(adapter) == _adapters.end()) { - throw Ice::AdapterNotFoundException(); + throw Ice::AdapterNotFoundException(); } return p->second; } @@ -67,7 +67,7 @@ ServerLocatorRegistry::getObject(const ::Ice::Identity& id) const ::std::map< ::Ice::Identity, ::Ice::ObjectPrx>::const_iterator p = _objects.find(id); if(p == _objects.end()) { - throw Ice::ObjectNotFoundException(); + throw Ice::ObjectNotFoundException(); } return p->second; @@ -88,7 +88,7 @@ ServerLocator::ServerLocator(const ServerLocatorRegistryPtr& registry, const ::I void ServerLocator::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& response, const Ice::Identity& id, - const Ice::Current& current) const + const Ice::Current& current) const { ++const_cast<int&>(_requestCount); response->ice_response(_registry->getObject(id)); @@ -96,7 +96,7 @@ ServerLocator::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& re void ServerLocator::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& response, const string& id, - const Ice::Current& current) const + const Ice::Current& current) const { ++const_cast<int&>(_requestCount); response->ice_response(_registry->getAdapter(id)); diff --git a/cpp/test/Ice/location/ServerLocator.h b/cpp/test/Ice/location/ServerLocator.h index 7b2a7131cd9..73da5c18e8d 100644 --- a/cpp/test/Ice/location/ServerLocator.h +++ b/cpp/test/Ice/location/ServerLocator.h @@ -21,12 +21,12 @@ public: ServerLocatorRegistry(); virtual void setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr&, - const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); + const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); virtual void setReplicatedAdapterDirectProxy_async( - const Ice::AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr&, - const std::string&, const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); + const Ice::AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr&, + const std::string&, const ::std::string&, const ::Ice::ObjectPrx&, const ::Ice::Current&); virtual void setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr&, - const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&); + const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&); void addObject(const ::Ice::ObjectPrx&, const ::Ice::Current&); // @@ -51,10 +51,10 @@ public: ServerLocator(const ::ServerLocatorRegistryPtr&, const ::Ice::LocatorRegistryPrx&); virtual void findObjectById_async(const ::Ice::AMD_Locator_findObjectByIdPtr&, const ::Ice::Identity&, - const ::Ice::Current&) const; + const ::Ice::Current&) const; virtual void findAdapterById_async(const ::Ice::AMD_Locator_findAdapterByIdPtr&, const ::std::string&, - const ::Ice::Current&) const; + const ::Ice::Current&) const; virtual ::Ice::LocatorRegistryPrx getRegistry(const ::Ice::Current&) const; diff --git a/cpp/test/Ice/location/TestI.cpp b/cpp/test/Ice/location/TestI.cpp index 1eb60dea2bf..d5f22b48672 100644 --- a/cpp/test/Ice/location/TestI.cpp +++ b/cpp/test/Ice/location/TestI.cpp @@ -14,8 +14,8 @@ using namespace Test; ServerManagerI::ServerManagerI(const Ice::ObjectAdapterPtr& adapter, - const ServerLocatorRegistryPtr& registry, - const Ice::InitializationData& initData) : + const ServerLocatorRegistryPtr& registry, + const Ice::InitializationData& initData) : _adapter(adapter), _registry(registry), _initData(initData) { _initData.properties->setProperty("Ice.OA.TestAdapter.Endpoints", "default"); @@ -33,8 +33,8 @@ ServerManagerI::startServer(const Ice::Current& current) { for(::std::vector<Ice::CommunicatorPtr>::const_iterator i = _communicators.begin(); i != _communicators.end(); ++i) { - (*i)->waitForShutdown(); - (*i)->destroy(); + (*i)->waitForShutdown(); + (*i)->destroy(); } _communicators.clear(); @@ -70,15 +70,15 @@ ServerManagerI::shutdown(const Ice::Current&) { for(::std::vector<Ice::CommunicatorPtr>::const_iterator i = _communicators.begin(); i != _communicators.end(); ++i) { - (*i)->destroy(); + (*i)->destroy(); } _adapter->getCommunicator()->shutdown(); } TestI::TestI(const Ice::ObjectAdapterPtr& adapter, - const Ice::ObjectAdapterPtr& adapter2, - const ServerLocatorRegistryPtr& registry) : + const Ice::ObjectAdapterPtr& adapter2, + const ServerLocatorRegistryPtr& registry) : _adapter1(adapter), _adapter2(adapter2), _registry(registry) { _registry->addObject(_adapter1->add(new HelloI(), _adapter1->getCommunicator()->stringToIdentity("hello"))); @@ -94,7 +94,7 @@ HelloPrx TestI::getHello(const Ice::Current&) { return HelloPrx::uncheckedCast(_adapter1->createIndirectProxy( - _adapter1->getCommunicator()->stringToIdentity("hello"))); + _adapter1->getCommunicator()->stringToIdentity("hello"))); } HelloPrx @@ -109,11 +109,11 @@ TestI::migrateHello(const Ice::Current&) const Ice::Identity id = _adapter1->getCommunicator()->stringToIdentity("hello"); try { - _registry->addObject(_adapter2->add(_adapter1->remove(id), id)); + _registry->addObject(_adapter2->add(_adapter1->remove(id), id)); } catch(Ice::NotRegisteredException&) { - _registry->addObject(_adapter1->add(_adapter2->remove(id), id)); + _registry->addObject(_adapter1->add(_adapter2->remove(id), id)); } } diff --git a/cpp/test/Ice/location/TestI.h b/cpp/test/Ice/location/TestI.h index ac03b3970ce..c94a16d5452 100644 --- a/cpp/test/Ice/location/TestI.h +++ b/cpp/test/Ice/location/TestI.h @@ -19,7 +19,7 @@ class ServerManagerI : public Test::ServerManager public: ServerManagerI(const Ice::ObjectAdapterPtr&, const ServerLocatorRegistryPtr&, - const Ice::InitializationData&); + const Ice::InitializationData&); virtual void startServer(const Ice::Current&); virtual void shutdown(const Ice::Current&); diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp index 7144ee7e861..91161ac04c2 100644 --- a/cpp/test/Ice/objects/AllTests.cpp +++ b/cpp/test/Ice/objects/AllTests.cpp @@ -140,32 +140,32 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - cout << "testing UnexpectedObjectException... " << flush; - ref = "uoet:default -p 12010 -t 10000"; - base = communicator->stringToProxy(ref); - test(base); - UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrx::uncheckedCast(base); - test(uoet); - try - { - uoet->op(); - test(false); - } - catch(const Ice::UnexpectedObjectException& ex) - { - test(ex.type == "::Test::AlsoEmpty"); - test(ex.expectedType == "::Test::Empty"); - } - catch(const Ice::Exception& ex) - { - cout << ex << endl; - test(false); - } - catch(...) - { - test(false); - } - cout << "ok" << endl; + cout << "testing UnexpectedObjectException... " << flush; + ref = "uoet:default -p 12010 -t 10000"; + base = communicator->stringToProxy(ref); + test(base); + UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrx::uncheckedCast(base); + test(uoet); + try + { + uoet->op(); + test(false); + } + catch(const Ice::UnexpectedObjectException& ex) + { + test(ex.type == "::Test::AlsoEmpty"); + test(ex.expectedType == "::Test::Empty"); + } + catch(const Ice::Exception& ex) + { + cout << ex << endl; + test(false); + } + catch(...) + { + test(false); + } + cout << "ok" << endl; } return initial; diff --git a/cpp/test/Ice/objects/Client.cpp b/cpp/test/Ice/objects/Client.cpp index 3c057524e36..3e7f3fcfa13 100644 --- a/cpp/test/Ice/objects/Client.cpp +++ b/cpp/test/Ice/objects/Client.cpp @@ -20,25 +20,25 @@ public: virtual Ice::ObjectPtr create(const string& type) { - if(type == "::Test::B") - { - return new BI; - } - else if(type == "::Test::C") - { - return new CI; - } - else if(type == "::Test::D") - { - return new DI; - } - assert(false); // Should never be reached - return 0; + if(type == "::Test::B") + { + return new BI; + } + else if(type == "::Test::C") + { + return new CI; + } + else if(type == "::Test::D") + { + return new DI; + } + assert(false); // Should never be reached + return 0; } virtual void destroy() { - // Nothing to do + // Nothing to do } }; @@ -64,26 +64,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/objects/Collocated.cpp b/cpp/test/Ice/objects/Collocated.cpp index a61ce056025..ed26a370e30 100644 --- a/cpp/test/Ice/objects/Collocated.cpp +++ b/cpp/test/Ice/objects/Collocated.cpp @@ -35,26 +35,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/objects/Server.cpp b/cpp/test/Ice/objects/Server.cpp index c5b7d672501..25379cd3be7 100644 --- a/cpp/test/Ice/objects/Server.cpp +++ b/cpp/test/Ice/objects/Server.cpp @@ -35,26 +35,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp index 9f141b6a63a..4beaa5477fc 100644 --- a/cpp/test/Ice/objects/TestI.cpp +++ b/cpp/test/Ice/objects/TestI.cpp @@ -162,7 +162,7 @@ InitialI::getAll(BPtr& b1, BPtr& b2, CPtr& c, DPtr& d, const Ice::Current&) bool UnexpectedObjectExceptionTestI::ice_invoke(const std::vector<Ice::Byte>&, std::vector<Ice::Byte>& outParams, - const Ice::Current& current) + const Ice::Current& current) { Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); Ice::OutputStreamPtr out = Ice::createOutputStream(communicator); diff --git a/cpp/test/Ice/operations/AllTests.cpp b/cpp/test/Ice/operations/AllTests.cpp index 7f592a449fd..15df53511d6 100644 --- a/cpp/test/Ice/operations/AllTests.cpp +++ b/cpp/test/Ice/operations/AllTests.cpp @@ -202,17 +202,17 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - cout << "testing timeout... " << flush; - Test::MyClassPrx clTimeout = Test::MyClassPrx::uncheckedCast(cl->ice_timeout(500)); - try - { - clTimeout->opSleep(2000); - test(false); - } - catch(const Ice::TimeoutException&) - { - } - cout << "ok" << endl; + cout << "testing timeout... " << flush; + Test::MyClassPrx clTimeout = Test::MyClassPrx::uncheckedCast(cl->ice_timeout(500)); + try + { + clTimeout->opSleep(2000); + test(false); + } + catch(const Ice::TimeoutException&) + { + } + cout << "ok" << endl; } cout << "testing twoway operations... " << flush; @@ -224,17 +224,17 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) if(!collocated) { - cout << "testing twoway operations with AMI... " << flush; - void twowaysAMI(const Ice::CommunicatorPtr&, const Test::MyClassPrx&); - twowaysAMI(communicator, cl); - twowaysAMI(communicator, derived); - cout << "ok" << endl; - - cout << "testing batch oneway operations... " << flush; - void batchOneways(const Test::MyClassPrx&); - batchOneways(cl); - batchOneways(derived); - cout << "ok" << endl; + cout << "testing twoway operations with AMI... " << flush; + void twowaysAMI(const Ice::CommunicatorPtr&, const Test::MyClassPrx&); + twowaysAMI(communicator, cl); + twowaysAMI(communicator, derived); + cout << "ok" << endl; + + cout << "testing batch oneway operations... " << flush; + void batchOneways(const Test::MyClassPrx&); + batchOneways(cl); + batchOneways(derived); + cout << "ok" << endl; } return cl; diff --git a/cpp/test/Ice/operations/BatchOneways.cpp b/cpp/test/Ice/operations/BatchOneways.cpp index 0556e8bb722..d0394e5cd51 100644 --- a/cpp/test/Ice/operations/BatchOneways.cpp +++ b/cpp/test/Ice/operations/BatchOneways.cpp @@ -22,32 +22,32 @@ batchOneways(const Test::MyClassPrx& p) try { - p->opByteSOneway(bs1); - test(true); + p->opByteSOneway(bs1); + test(true); } catch(const Ice::MemoryLimitException&) { - test(false); + test(false); } try { - p->opByteSOneway(bs2); - test(true); + p->opByteSOneway(bs2); + test(true); } catch(const Ice::MemoryLimitException&) { - test(false); + test(false); } try { - p->opByteSOneway(bs3); - test(false); + p->opByteSOneway(bs3); + test(false); } catch(const Ice::MemoryLimitException&) { - test(true); + test(true); } Test::MyClassPrx batch = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway()); @@ -56,15 +56,15 @@ batchOneways(const Test::MyClassPrx& p) for(i = 0 ; i < 30 ; ++i) { - try - { - batch->opByteSOneway(bs1); - test(true); - } - catch(const Ice::MemoryLimitException&) - { - test(false); - } + try + { + batch->opByteSOneway(bs1); + test(true); + } + catch(const Ice::MemoryLimitException&) + { + test(false); + } } batch->ice_getConnection()->flushBatchRequests(); diff --git a/cpp/test/Ice/operations/Client.cpp b/cpp/test/Ice/operations/Client.cpp index 7e7cceb914d..b421a629cf5 100644 --- a/cpp/test/Ice/operations/Client.cpp +++ b/cpp/test/Ice/operations/Client.cpp @@ -25,12 +25,12 @@ run(int argc, char* argv[], myClass->shutdown(); try { - myClass->opVoid(); - test(false); + myClass->opVoid(); + test(false); } catch(const Ice::LocalException&) { - cout << "ok" << endl; + cout << "ok" << endl; } return EXIT_SUCCESS; @@ -44,47 +44,47 @@ main(int argc, char* argv[]) try { - // - // In this test, we need at least two threads in the - // client side thread pool for nested AMI. - // - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2"); - initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); + // + // In this test, we need at least two threads in the + // client side thread pool for nested AMI. + // + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2"); + initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); - // - // We must set MessageSizeMax to an explicit values, because - // we run tests to check whether Ice.MemoryLimitException is - // raised as expected. - // - initData.properties->setProperty("Ice.MessageSizeMax", "100"); + // + // We must set MessageSizeMax to an explicit values, because + // we run tests to check whether Ice.MemoryLimitException is + // raised as expected. + // + initData.properties->setProperty("Ice.MessageSizeMax", "100"); - // - // We don't want connection warnings because of the timeout test. - // - initData.properties->setProperty("Ice.Warn.Connections", "0"); + // + // We don't want connection warnings because of the timeout test. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator, initData); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator, initData); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/operations/Collocated.cpp b/cpp/test/Ice/operations/Collocated.cpp index dda296e4cae..784cee66f14 100644 --- a/cpp/test/Ice/operations/Collocated.cpp +++ b/cpp/test/Ice/operations/Collocated.cpp @@ -37,28 +37,28 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator, initData); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator, initData); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/operations/Server.cpp b/cpp/test/Ice/operations/Server.cpp index 9e4e511dad9..85979d7424f 100644 --- a/cpp/test/Ice/operations/Server.cpp +++ b/cpp/test/Ice/operations/Server.cpp @@ -34,30 +34,30 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.Warn.Connections", "0"); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/operations/ServerAMD.cpp b/cpp/test/Ice/operations/ServerAMD.cpp index 251d5068424..0cac6d02a18 100644 --- a/cpp/test/Ice/operations/ServerAMD.cpp +++ b/cpp/test/Ice/operations/ServerAMD.cpp @@ -34,30 +34,30 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice index d655feb0599..043060a5d93 100644 --- a/cpp/test/Ice/operations/Test.ice +++ b/cpp/test/Ice/operations/Test.ice @@ -75,75 +75,75 @@ dictionary<string, MyEnum> StringMyEnumD; void opSleep(int duration); byte opByte(byte p1, byte p2, - out byte p3); + out byte p3); bool opBool(bool p1, bool p2, - out bool p3); + out bool p3); long opShortIntLong(short p1, int p2, long p3, - out short p4, out int p5, out long p6); + out short p4, out int p5, out long p6); double opFloatDouble(float p1, double p2, - out float p3, out double p4); + out float p3, out double p4); string opString(string p1, string p2, - out string p3); + out string p3); MyEnum opMyEnum(MyEnum p1, out MyEnum p2); MyClass* opMyClass(MyClass* p1, out MyClass* p2, out MyClass* p3); Structure opStruct(Structure p1, Structure p2, - out Structure p3); + out Structure p3); ByteS opByteS(ByteS p1, ByteS p2, - out ByteS p3); + out ByteS p3); BoolS opBoolS(BoolS p1, BoolS p2, - out BoolS p3); + out BoolS p3); LongS opShortIntLongS(Test::ShortS p1, IntS p2, LongS p3, - out ::Test::ShortS p4, out IntS p5, out LongS p6); + out ::Test::ShortS p4, out IntS p5, out LongS p6); DoubleS opFloatDoubleS(FloatS p1, DoubleS p2, - out FloatS p3, out DoubleS p4); + out FloatS p3, out DoubleS p4); StringS opStringS(StringS p1, StringS p2, - out StringS p3); + out StringS p3); ByteSS opByteSS(ByteSS p1, ByteSS p2, - out ByteSS p3); + out ByteSS p3); BoolSS opBoolSS(BoolSS p1, BoolSS p2, - out BoolSS p3); + out BoolSS p3); LongSS opShortIntLongSS(ShortSS p1, IntSS p2, LongSS p3, - out ShortSS p4, out IntSS p5, out LongSS p6); + out ShortSS p4, out IntSS p5, out LongSS p6); DoubleSS opFloatDoubleSS(FloatSS p1, DoubleSS p2, - out FloatSS p3, out DoubleSS p4); + out FloatSS p3, out DoubleSS p4); StringSS opStringSS(StringSS p1, StringSS p2, - out StringSS p3); + out StringSS p3); StringSSS opStringSSS(StringSSS p1, StringSSS p2, - out StringSSS p3); + out StringSSS p3); ByteBoolD opByteBoolD(ByteBoolD p1, ByteBoolD p2, - out ByteBoolD p3); + out ByteBoolD p3); ShortIntD opShortIntD(ShortIntD p1, ShortIntD p2, - out ShortIntD p3); + out ShortIntD p3); LongFloatD opLongFloatD(LongFloatD p1, LongFloatD p2, - out LongFloatD p3); + out LongFloatD p3); StringStringD opStringStringD(StringStringD p1, StringStringD p2, - out StringStringD p3); + out StringStringD p3); StringMyEnumD opStringMyEnumD(StringMyEnumD p1, StringMyEnumD p2, - out StringMyEnumD p3); + out StringMyEnumD p3); IntS opIntS(IntS s); diff --git a/cpp/test/Ice/operations/TestAMD.ice b/cpp/test/Ice/operations/TestAMD.ice index 1d58252d323..9bdc8c6fe3b 100644 --- a/cpp/test/Ice/operations/TestAMD.ice +++ b/cpp/test/Ice/operations/TestAMD.ice @@ -75,75 +75,75 @@ dictionary<string, MyEnum> StringMyEnumD; void opSleep(int duration); byte opByte(byte p1, byte p2, - out byte p3); + out byte p3); bool opBool(bool p1, bool p2, - out bool p3); + out bool p3); long opShortIntLong(short p1, int p2, long p3, - out short p4, out int p5, out long p6); + out short p4, out int p5, out long p6); double opFloatDouble(float p1, double p2, - out float p3, out double p4); + out float p3, out double p4); string opString(string p1, string p2, - out string p3); + out string p3); MyEnum opMyEnum(MyEnum p1, out MyEnum p2); MyClass* opMyClass(MyClass* p1, out MyClass* p2, out MyClass* p3); Structure opStruct(Structure p1, Structure p2, - out Structure p3); + out Structure p3); ByteS opByteS(ByteS p1, ByteS p2, - out ByteS p3); + out ByteS p3); BoolS opBoolS(BoolS p1, BoolS p2, - out BoolS p3); + out BoolS p3); LongS opShortIntLongS(Test::ShortS p1, IntS p2, LongS p3, - out ::Test::ShortS p4, out IntS p5, out LongS p6); + out ::Test::ShortS p4, out IntS p5, out LongS p6); DoubleS opFloatDoubleS(FloatS p1, DoubleS p2, - out FloatS p3, out DoubleS p4); + out FloatS p3, out DoubleS p4); StringS opStringS(StringS p1, StringS p2, - out StringS p3); + out StringS p3); ByteSS opByteSS(ByteSS p1, ByteSS p2, - out ByteSS p3); + out ByteSS p3); BoolSS opBoolSS(BoolSS p1, BoolSS p2, - out BoolSS p3); + out BoolSS p3); LongSS opShortIntLongSS(ShortSS p1, IntSS p2, LongSS p3, - out ShortSS p4, out IntSS p5, out LongSS p6); + out ShortSS p4, out IntSS p5, out LongSS p6); DoubleSS opFloatDoubleSS(FloatSS p1, DoubleSS p2, - out FloatSS p3, out DoubleSS p4); + out FloatSS p3, out DoubleSS p4); StringSS opStringSS(StringSS p1, StringSS p2, - out StringSS p3); + out StringSS p3); StringSSS opStringSSS(StringSSS p1, StringSSS p2, - out StringSSS p3); + out StringSSS p3); ByteBoolD opByteBoolD(ByteBoolD p1, ByteBoolD p2, - out ByteBoolD p3); + out ByteBoolD p3); ShortIntD opShortIntD(ShortIntD p1, ShortIntD p2, - out ShortIntD p3); + out ShortIntD p3); LongFloatD opLongFloatD(LongFloatD p1, LongFloatD p2, - out LongFloatD p3); + out LongFloatD p3); StringStringD opStringStringD(StringStringD p1, StringStringD p2, - out StringStringD p3); + out StringStringD p3); StringMyEnumD opStringMyEnumD(StringMyEnumD p1, StringMyEnumD p2, - out StringMyEnumD p3); + out StringMyEnumD p3); IntS opIntS(IntS s); diff --git a/cpp/test/Ice/operations/TestAMDI.cpp b/cpp/test/Ice/operations/TestAMDI.cpp index 48cb26beeed..028993f910a 100644 --- a/cpp/test/Ice/operations/TestAMDI.cpp +++ b/cpp/test/Ice/operations/TestAMDI.cpp @@ -20,13 +20,13 @@ class Thread_opVoid : public IceUtil::Thread public: Thread_opVoid(const Test::AMD_MyClass_opVoidPtr& cb) : - _cb(cb) + _cb(cb) { } virtual void run() { - _cb->ice_response(); + _cb->ice_response(); } private: @@ -45,8 +45,8 @@ MyDerivedClassI::shutdown_async(const Test::AMD_MyClass_shutdownPtr& cb, const I { if(_opVoidThread) { - _opVoidThread->getThreadControl().join(); - _opVoidThread = 0; + _opVoidThread->getThreadControl().join(); + _opVoidThread = 0; } _adapter->getCommunicator()->shutdown(); @@ -58,8 +58,8 @@ MyDerivedClassI::opVoid_async(const Test::AMD_MyClass_opVoidPtr& cb, const Ice:: { if(_opVoidThread) { - _opVoidThread->getThreadControl().join(); - _opVoidThread = 0; + _opVoidThread->getThreadControl().join(); + _opVoidThread = 0; } _opVoidThread = new Thread_opVoid(cb); @@ -68,8 +68,8 @@ MyDerivedClassI::opVoid_async(const Test::AMD_MyClass_opVoidPtr& cb, const Ice:: void MyDerivedClassI::opSleep_async(const Test::AMD_MyClass_opSleepPtr& cb, - int duration, - const Ice::Current&) + int duration, + const Ice::Current&) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(duration)); cb->ice_response(); @@ -77,74 +77,74 @@ MyDerivedClassI::opSleep_async(const Test::AMD_MyClass_opSleepPtr& cb, void MyDerivedClassI::opByte_async(const Test::AMD_MyClass_opBytePtr& cb, - Ice::Byte p1, - Ice::Byte p2, - const Ice::Current&) + Ice::Byte p1, + Ice::Byte p2, + const Ice::Current&) { cb->ice_response(p1, p1 ^ p2); } void MyDerivedClassI::opBool_async(const Test::AMD_MyClass_opBoolPtr& cb, - bool p1, - bool p2, - const Ice::Current&) + bool p1, + bool p2, + const Ice::Current&) { cb->ice_response(p2, p1); } void MyDerivedClassI::opShortIntLong_async(const Test::AMD_MyClass_opShortIntLongPtr& cb, - Ice::Short p1, - Ice::Int p2, - Ice::Long p3, - const Ice::Current&) + Ice::Short p1, + Ice::Int p2, + Ice::Long p3, + const Ice::Current&) { cb->ice_response(p3, p1, p2, p3); } void MyDerivedClassI::opFloatDouble_async(const Test::AMD_MyClass_opFloatDoublePtr& cb, - Ice::Float p1, - Ice::Double p2, - const Ice::Current&) + Ice::Float p1, + Ice::Double p2, + const Ice::Current&) { cb->ice_response(p2, p1, p2); } void MyDerivedClassI::opString_async(const Test::AMD_MyClass_opStringPtr& cb, - const std::string& p1, - const std::string& p2, - const Ice::Current&) + const std::string& p1, + const std::string& p2, + const Ice::Current&) { cb->ice_response(p1 + " " + p2, p2 + " " + p1); } void MyDerivedClassI::opMyEnum_async(const Test::AMD_MyClass_opMyEnumPtr& cb, - Test::MyEnum p1, - const Ice::Current&) + Test::MyEnum p1, + const Ice::Current&) { cb->ice_response(Test::enum3, p1); } void MyDerivedClassI::opMyClass_async(const Test::AMD_MyClass_opMyClassPtr& cb, - const Test::MyClassPrx& p1, - const Ice::Current&) + const Test::MyClassPrx& p1, + const Ice::Current&) { Test::MyClassPrx p2 = p1; Test::MyClassPrx p3 = Test::MyClassPrx::uncheckedCast(_adapter->createProxy( - _adapter->getCommunicator()->stringToIdentity("noSuchIdentity"))); + _adapter->getCommunicator()->stringToIdentity("noSuchIdentity"))); cb->ice_response(Test::MyClassPrx::uncheckedCast(_adapter->createProxy(_identity)), p2, p3); } void MyDerivedClassI::opStruct_async(const Test::AMD_MyClass_opStructPtr& cb, - const Test::Structure& p1, - const Test::Structure& p2, - const Ice::Current&) + const Test::Structure& p1, + const Test::Structure& p2, + const Ice::Current&) { Test::Structure p3 = p1; p3.s.s = "a new string"; @@ -153,9 +153,9 @@ MyDerivedClassI::opStruct_async(const Test::AMD_MyClass_opStructPtr& cb, void MyDerivedClassI::opByteS_async(const Test::AMD_MyClass_opByteSPtr& cb, - const Test::ByteS& p1, - const Test::ByteS& p2, - const Ice::Current&) + const Test::ByteS& p1, + const Test::ByteS& p2, + const Ice::Current&) { Test::ByteS p3; p3.resize(p1.size()); @@ -167,9 +167,9 @@ MyDerivedClassI::opByteS_async(const Test::AMD_MyClass_opByteSPtr& cb, void MyDerivedClassI::opBoolS_async(const Test::AMD_MyClass_opBoolSPtr& cb, - const Test::BoolS& p1, - const Test::BoolS& p2, - const Ice::Current&) + const Test::BoolS& p1, + const Test::BoolS& p2, + const Ice::Current&) { Test::BoolS p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -181,10 +181,10 @@ MyDerivedClassI::opBoolS_async(const Test::AMD_MyClass_opBoolSPtr& cb, void MyDerivedClassI::opShortIntLongS_async(const Test::AMD_MyClass_opShortIntLongSPtr& cb, - const Test::ShortS& p1, - const Test::IntS& p2, - const Test::LongS& p3, - const Ice::Current&) + const Test::ShortS& p1, + const Test::IntS& p2, + const Test::LongS& p3, + const Ice::Current&) { Test::ShortS p4 = p1; Test::IntS p5; @@ -197,9 +197,9 @@ MyDerivedClassI::opShortIntLongS_async(const Test::AMD_MyClass_opShortIntLongSPt void MyDerivedClassI::opFloatDoubleS_async(const Test::AMD_MyClass_opFloatDoubleSPtr& cb, - const Test::FloatS& p1, - const Test::DoubleS& p2, - const Ice::Current&) + const Test::FloatS& p1, + const Test::DoubleS& p2, + const Ice::Current&) { Test::FloatS p3 = p1; Test::DoubleS p4; @@ -212,9 +212,9 @@ MyDerivedClassI::opFloatDoubleS_async(const Test::AMD_MyClass_opFloatDoubleSPtr& void MyDerivedClassI::opStringS_async(const Test::AMD_MyClass_opStringSPtr& cb, - const Test::StringS& p1, - const Test::StringS& p2, - const Ice::Current&) + const Test::StringS& p1, + const Test::StringS& p2, + const Ice::Current&) { Test::StringS p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -226,9 +226,9 @@ MyDerivedClassI::opStringS_async(const Test::AMD_MyClass_opStringSPtr& cb, void MyDerivedClassI::opByteSS_async(const Test::AMD_MyClass_opByteSSPtr& cb, - const Test::ByteSS& p1, - const Test::ByteSS& p2, - const Ice::Current&) + const Test::ByteSS& p1, + const Test::ByteSS& p2, + const Ice::Current&) { Test::ByteSS p3; p3.resize(p1.size()); @@ -240,9 +240,9 @@ MyDerivedClassI::opByteSS_async(const Test::AMD_MyClass_opByteSSPtr& cb, void MyDerivedClassI::opBoolSS_async(const Test::AMD_MyClass_opBoolSSPtr& cb, - const Test::BoolSS& p1, - const Test::BoolSS& p2, - const Ice::Current&) + const Test::BoolSS& p1, + const Test::BoolSS& p2, + const Ice::Current&) { Test::BoolSS p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -254,10 +254,10 @@ MyDerivedClassI::opBoolSS_async(const Test::AMD_MyClass_opBoolSSPtr& cb, void MyDerivedClassI::opShortIntLongSS_async(const Test::AMD_MyClass_opShortIntLongSSPtr& cb, - const Test::ShortSS& p1, - const Test::IntSS& p2, - const Test::LongSS& p3, - const Ice::Current&) + const Test::ShortSS& p1, + const Test::IntSS& p2, + const Test::LongSS& p3, + const Ice::Current&) { Test::ShortSS p4 = p1; Test::IntSS p5; @@ -270,9 +270,9 @@ MyDerivedClassI::opShortIntLongSS_async(const Test::AMD_MyClass_opShortIntLongSS void MyDerivedClassI::opFloatDoubleSS_async(const Test::AMD_MyClass_opFloatDoubleSSPtr& cb, - const Test::FloatSS& p1, - const Test::DoubleSS& p2, - const Ice::Current&) + const Test::FloatSS& p1, + const Test::DoubleSS& p2, + const Ice::Current&) { Test::FloatSS p3 = p1; Test::DoubleSS p4; @@ -285,9 +285,9 @@ MyDerivedClassI::opFloatDoubleSS_async(const Test::AMD_MyClass_opFloatDoubleSSPt void MyDerivedClassI::opStringSS_async(const Test::AMD_MyClass_opStringSSPtr& cb, - const Test::StringSS& p1, - const Test::StringSS& p2, - const Ice::Current&) + const Test::StringSS& p1, + const Test::StringSS& p2, + const Ice::Current&) { Test::StringSS p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -299,9 +299,9 @@ MyDerivedClassI::opStringSS_async(const Test::AMD_MyClass_opStringSSPtr& cb, void MyDerivedClassI::opStringSSS_async(const Test::AMD_MyClass_opStringSSSPtr& cb, - const Test::StringSSS& p1, - const Test::StringSSS& p2, - const Ice::Current&) + const Test::StringSSS& p1, + const Test::StringSSS& p2, + const Ice::Current&) { Test::StringSSS p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -313,9 +313,9 @@ MyDerivedClassI::opStringSSS_async(const Test::AMD_MyClass_opStringSSSPtr& cb, void MyDerivedClassI::opByteBoolD_async(const Test::AMD_MyClass_opByteBoolDPtr& cb, - const Test::ByteBoolD& p1, - const Test::ByteBoolD& p2, - const Ice::Current&) + const Test::ByteBoolD& p1, + const Test::ByteBoolD& p2, + const Ice::Current&) { Test::ByteBoolD p3 = p1; Test::ByteBoolD r = p1; @@ -325,9 +325,9 @@ MyDerivedClassI::opByteBoolD_async(const Test::AMD_MyClass_opByteBoolDPtr& cb, void MyDerivedClassI::opShortIntD_async(const Test::AMD_MyClass_opShortIntDPtr& cb, - const Test::ShortIntD& p1, - const Test::ShortIntD& p2, - const Ice::Current&) + const Test::ShortIntD& p1, + const Test::ShortIntD& p2, + const Ice::Current&) { Test::ShortIntD p3 = p1; Test::ShortIntD r = p1; @@ -337,9 +337,9 @@ MyDerivedClassI::opShortIntD_async(const Test::AMD_MyClass_opShortIntDPtr& cb, void MyDerivedClassI::opLongFloatD_async(const Test::AMD_MyClass_opLongFloatDPtr& cb, - const Test::LongFloatD& p1, - const Test::LongFloatD& p2, - const Ice::Current&) + const Test::LongFloatD& p1, + const Test::LongFloatD& p2, + const Ice::Current&) { Test::LongFloatD p3 = p1; Test::LongFloatD r = p1; @@ -349,9 +349,9 @@ MyDerivedClassI::opLongFloatD_async(const Test::AMD_MyClass_opLongFloatDPtr& cb, void MyDerivedClassI::opStringStringD_async(const Test::AMD_MyClass_opStringStringDPtr& cb, - const Test::StringStringD& p1, - const Test::StringStringD& p2, - const Ice::Current&) + const Test::StringStringD& p1, + const Test::StringStringD& p2, + const Ice::Current&) { Test::StringStringD p3 = p1; Test::StringStringD r = p1; @@ -361,9 +361,9 @@ MyDerivedClassI::opStringStringD_async(const Test::AMD_MyClass_opStringStringDPt void MyDerivedClassI::opStringMyEnumD_async(const Test::AMD_MyClass_opStringMyEnumDPtr& cb, - const Test::StringMyEnumD& p1, - const Test::StringMyEnumD& p2, - const Ice::Current&) + const Test::StringMyEnumD& p1, + const Test::StringMyEnumD& p2, + const Ice::Current&) { Test::StringMyEnumD p3 = p1; Test::StringMyEnumD r = p1; @@ -381,7 +381,7 @@ MyDerivedClassI::opIntS_async(const Test::AMD_MyClass_opIntSPtr& cb, const Test: void MyDerivedClassI::opByteSOneway_async(const Test::AMD_MyClass_opByteSOnewayPtr& cb, const Test::ByteS& s, - const Ice::Current&) + const Ice::Current&) { cb->ice_response(); } @@ -395,7 +395,7 @@ MyDerivedClassI::opContext_async(const Test::AMD_MyClass_opContextPtr& cb, const void MyDerivedClassI::opDoubleMarshaling_async(const Test::AMD_MyClass_opDoubleMarshalingPtr& cb, - Ice::Double p1, const Test::DoubleS& p2, const Ice::Current&) + Ice::Double p1, const Test::DoubleS& p2, const Ice::Current&) { Ice::Double d = 1278312346.0 / 13.0; test(p1 == d); diff --git a/cpp/test/Ice/operations/TestAMDI.h b/cpp/test/Ice/operations/TestAMDI.h index 19c3313bfdb..87098048a1e 100644 --- a/cpp/test/Ice/operations/TestAMDI.h +++ b/cpp/test/Ice/operations/TestAMDI.h @@ -20,123 +20,123 @@ public: MyDerivedClassI(const Ice::ObjectAdapterPtr&, const Ice::Identity&); virtual void shutdown_async(const Test::AMD_MyClass_shutdownPtr&, - const Ice::Current&); + const Ice::Current&); virtual void opVoid_async(const Test::AMD_MyClass_opVoidPtr&, - const Ice::Current&); + const Ice::Current&); virtual void opSleep_async(const Test::AMD_MyClass_opSleepPtr&, - int, - const Ice::Current&); + int, + const Ice::Current&); virtual void opByte_async(const Test::AMD_MyClass_opBytePtr&, - Ice::Byte, Ice::Byte, - const Ice::Current&); + Ice::Byte, Ice::Byte, + const Ice::Current&); virtual void opBool_async(const Test::AMD_MyClass_opBoolPtr&, - bool, bool, - const Ice::Current&); + bool, bool, + const Ice::Current&); virtual void opShortIntLong_async(const Test::AMD_MyClass_opShortIntLongPtr&, - Ice::Short, Ice::Int, Ice::Long, - const Ice::Current&); + Ice::Short, Ice::Int, Ice::Long, + const Ice::Current&); virtual void opFloatDouble_async(const Test::AMD_MyClass_opFloatDoublePtr&, - Ice::Float, Ice::Double, - const Ice::Current&); + Ice::Float, Ice::Double, + const Ice::Current&); virtual void opString_async(const Test::AMD_MyClass_opStringPtr&, - const std::string&, const std::string&, - const Ice::Current&); + const std::string&, const std::string&, + const Ice::Current&); virtual void opMyEnum_async(const Test::AMD_MyClass_opMyEnumPtr&, - Test::MyEnum, - const Ice::Current&); + Test::MyEnum, + const Ice::Current&); virtual void opMyClass_async(const Test::AMD_MyClass_opMyClassPtr&, - const Test::MyClassPrx&, - const Ice::Current&); + const Test::MyClassPrx&, + const Ice::Current&); virtual void opStruct_async(const Test::AMD_MyClass_opStructPtr&, - const Test::Structure&, const Test::Structure&, - const Ice::Current&); + const Test::Structure&, const Test::Structure&, + const Ice::Current&); virtual void opByteS_async(const Test::AMD_MyClass_opByteSPtr&, - const Test::ByteS&, const Test::ByteS&, - const Ice::Current&); + const Test::ByteS&, const Test::ByteS&, + const Ice::Current&); virtual void opBoolS_async(const Test::AMD_MyClass_opBoolSPtr&, - const Test::BoolS&, const Test::BoolS&, - const Ice::Current&); + const Test::BoolS&, const Test::BoolS&, + const Ice::Current&); virtual void opShortIntLongS_async(const Test::AMD_MyClass_opShortIntLongSPtr&, - const Test::ShortS&, const Test::IntS&, const Test::LongS&, - const Ice::Current&); + const Test::ShortS&, const Test::IntS&, const Test::LongS&, + const Ice::Current&); virtual void opFloatDoubleS_async(const Test::AMD_MyClass_opFloatDoubleSPtr&, - const Test::FloatS&, const Test::DoubleS&, - const Ice::Current&); + const Test::FloatS&, const Test::DoubleS&, + const Ice::Current&); virtual void opStringS_async(const Test::AMD_MyClass_opStringSPtr&, - const Test::StringS&, const Test::StringS&, - const Ice::Current&); + const Test::StringS&, const Test::StringS&, + const Ice::Current&); virtual void opByteSS_async(const Test::AMD_MyClass_opByteSSPtr&, - const Test::ByteSS&, const Test::ByteSS&, - const Ice::Current&); + const Test::ByteSS&, const Test::ByteSS&, + const Ice::Current&); virtual void opBoolSS_async(const Test::AMD_MyClass_opBoolSSPtr&, - const Test::BoolSS&, const Test::BoolSS&, - const Ice::Current&); + const Test::BoolSS&, const Test::BoolSS&, + const Ice::Current&); virtual void opShortIntLongSS_async(const Test::AMD_MyClass_opShortIntLongSSPtr&, - const Test::ShortSS&, const Test::IntSS&, const Test::LongSS&, - const Ice::Current&); + const Test::ShortSS&, const Test::IntSS&, const Test::LongSS&, + const Ice::Current&); virtual void opFloatDoubleSS_async(const Test::AMD_MyClass_opFloatDoubleSSPtr&, - const Test::FloatSS&, const Test::DoubleSS&, - const Ice::Current&); + const Test::FloatSS&, const Test::DoubleSS&, + const Ice::Current&); virtual void opStringSS_async(const Test::AMD_MyClass_opStringSSPtr&, - const Test::StringSS&, const Test::StringSS&, - const Ice::Current&); + const Test::StringSS&, const Test::StringSS&, + const Ice::Current&); virtual void opStringSSS_async(const Test::AMD_MyClass_opStringSSSPtr&, - const Test::StringSSS&, const Test::StringSSS&, - const Ice::Current&); + const Test::StringSSS&, const Test::StringSSS&, + const Ice::Current&); virtual void opByteBoolD_async(const Test::AMD_MyClass_opByteBoolDPtr&, - const Test::ByteBoolD&, const Test::ByteBoolD&, - const Ice::Current&); + const Test::ByteBoolD&, const Test::ByteBoolD&, + const Ice::Current&); virtual void opShortIntD_async(const Test::AMD_MyClass_opShortIntDPtr&, - const Test::ShortIntD&, const Test::ShortIntD&, - const Ice::Current&); + const Test::ShortIntD&, const Test::ShortIntD&, + const Ice::Current&); virtual void opLongFloatD_async(const Test::AMD_MyClass_opLongFloatDPtr&, - const Test::LongFloatD&, const Test::LongFloatD&, - const Ice::Current&); + const Test::LongFloatD&, const Test::LongFloatD&, + const Ice::Current&); virtual void opStringStringD_async(const Test::AMD_MyClass_opStringStringDPtr&, - const Test::StringStringD&, const Test::StringStringD&, - const Ice::Current&); + const Test::StringStringD&, const Test::StringStringD&, + const Ice::Current&); virtual void opStringMyEnumD_async(const Test::AMD_MyClass_opStringMyEnumDPtr&, - const Test::StringMyEnumD&, const Test::StringMyEnumD&, - const Ice::Current&); + const Test::StringMyEnumD&, const Test::StringMyEnumD&, + const Ice::Current&); virtual void opIntS_async(const Test::AMD_MyClass_opIntSPtr&, const Test::IntS&, const Ice::Current&); virtual void opByteSOneway_async(const Test::AMD_MyClass_opByteSOnewayPtr&, const Test::ByteS&, - const Ice::Current&); + const Ice::Current&); virtual void opContext_async(const Test::AMD_MyClass_opContextPtr&, const Ice::Current&); virtual void opDoubleMarshaling_async(const Test::AMD_MyClass_opDoubleMarshalingPtr&, - Ice::Double, const Test::DoubleS&, const Ice::Current&); + Ice::Double, const Test::DoubleS&, const Ice::Current&); virtual void opDerived_async(const Test::AMD_MyDerivedClass_opDerivedPtr&, - const Ice::Current&); + const Ice::Current&); private: diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp index 77b275b5ae7..e6415f93a87 100644 --- a/cpp/test/Ice/operations/TestI.cpp +++ b/cpp/test/Ice/operations/TestI.cpp @@ -41,9 +41,9 @@ MyDerivedClassI::opSleep(int duration, const Ice::Current&) Ice::Byte MyDerivedClassI::opByte(Ice::Byte p1, - Ice::Byte p2, - Ice::Byte& p3, - const Ice::Current&) + Ice::Byte p2, + Ice::Byte& p3, + const Ice::Current&) { p3 = p1 ^ p2; return p1; @@ -51,9 +51,9 @@ MyDerivedClassI::opByte(Ice::Byte p1, bool MyDerivedClassI::opBool(bool p1, - bool p2, - bool& p3, - const Ice::Current&) + bool p2, + bool& p3, + const Ice::Current&) { p3 = p1; return p2; @@ -61,12 +61,12 @@ MyDerivedClassI::opBool(bool p1, Ice::Long MyDerivedClassI::opShortIntLong(Ice::Short p1, - Ice::Int p2, - Ice::Long p3, - Ice::Short& p4, - Ice::Int& p5, - Ice::Long& p6, - const Ice::Current&) + Ice::Int p2, + Ice::Long p3, + Ice::Short& p4, + Ice::Int& p5, + Ice::Long& p6, + const Ice::Current&) { p4 = p1; p5 = p2; @@ -76,10 +76,10 @@ MyDerivedClassI::opShortIntLong(Ice::Short p1, Ice::Double MyDerivedClassI::opFloatDouble(Ice::Float p1, - Ice::Double p2, - Ice::Float& p3, - Ice::Double& p4, - const Ice::Current&) + Ice::Double p2, + Ice::Float& p3, + Ice::Double& p4, + const Ice::Current&) { p3 = p1; p4 = p2; @@ -88,9 +88,9 @@ MyDerivedClassI::opFloatDouble(Ice::Float p1, std::string MyDerivedClassI::opString(const std::string& p1, - const std::string& p2, - std::string& p3, - const Ice::Current&) + const std::string& p2, + std::string& p3, + const Ice::Current&) { p3 = p2 + " " + p1; return p1 + " " + p2; @@ -98,8 +98,8 @@ MyDerivedClassI::opString(const std::string& p1, Test::MyEnum MyDerivedClassI::opMyEnum(Test::MyEnum p1, - Test::MyEnum& p2, - const Ice::Current&) + Test::MyEnum& p2, + const Ice::Current&) { p2 = p1; return Test::enum3; @@ -107,21 +107,21 @@ MyDerivedClassI::opMyEnum(Test::MyEnum p1, Test::MyClassPrx MyDerivedClassI::opMyClass(const Test::MyClassPrx& p1, - Test::MyClassPrx& p2, - Test::MyClassPrx& p3, - const Ice::Current&) + Test::MyClassPrx& p2, + Test::MyClassPrx& p3, + const Ice::Current&) { p2 = p1; p3 = Test::MyClassPrx::uncheckedCast(_adapter->createProxy( - _adapter->getCommunicator()->stringToIdentity("noSuchIdentity"))); + _adapter->getCommunicator()->stringToIdentity("noSuchIdentity"))); return Test::MyClassPrx::uncheckedCast(_adapter->createProxy(_identity)); } Test::Structure MyDerivedClassI::opStruct(const Test::Structure& p1, - const ::Test::Structure& p2, - ::Test::Structure& p3, - const Ice::Current&) + const ::Test::Structure& p2, + ::Test::Structure& p3, + const Ice::Current&) { p3 = p1; p3.s.s = "a new string"; @@ -130,9 +130,9 @@ MyDerivedClassI::opStruct(const Test::Structure& p1, Test::ByteS MyDerivedClassI::opByteS(const Test::ByteS& p1, - const Test::ByteS& p2, - Test::ByteS& p3, - const Ice::Current&) + const Test::ByteS& p2, + Test::ByteS& p3, + const Ice::Current&) { p3.resize(p1.size()); std::reverse_copy(p1.begin(), p1.end(), p3.begin()); @@ -143,9 +143,9 @@ MyDerivedClassI::opByteS(const Test::ByteS& p1, Test::BoolS MyDerivedClassI::opBoolS(const Test::BoolS& p1, - const Test::BoolS& p2, - Test::BoolS& p3, - const Ice::Current&) + const Test::BoolS& p2, + Test::BoolS& p3, + const Ice::Current&) { p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -157,12 +157,12 @@ MyDerivedClassI::opBoolS(const Test::BoolS& p1, Test::LongS MyDerivedClassI::opShortIntLongS(const Test::ShortS& p1, - const Test::IntS& p2, - const Test::LongS& p3, - Test::ShortS& p4, - Test::IntS& p5, - Test::LongS& p6, - const Ice::Current&) + const Test::IntS& p2, + const Test::LongS& p3, + Test::ShortS& p4, + Test::IntS& p5, + Test::LongS& p6, + const Ice::Current&) { p4 = p1; p5.resize(p2.size()); @@ -174,10 +174,10 @@ MyDerivedClassI::opShortIntLongS(const Test::ShortS& p1, Test::DoubleS MyDerivedClassI::opFloatDoubleS(const Test::FloatS& p1, - const Test::DoubleS& p2, - Test::FloatS& p3, - Test::DoubleS& p4, - const Ice::Current&) + const Test::DoubleS& p2, + Test::FloatS& p3, + Test::DoubleS& p4, + const Ice::Current&) { p3 = p1; p4.resize(p2.size()); @@ -189,9 +189,9 @@ MyDerivedClassI::opFloatDoubleS(const Test::FloatS& p1, Test::StringS MyDerivedClassI::opStringS(const Test::StringS& p1, - const Test::StringS& p2, - Test::StringS& p3, - const Ice::Current&) + const Test::StringS& p2, + Test::StringS& p3, + const Ice::Current&) { p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -203,9 +203,9 @@ MyDerivedClassI::opStringS(const Test::StringS& p1, Test::ByteSS MyDerivedClassI::opByteSS(const Test::ByteSS& p1, - const Test::ByteSS& p2, - Test::ByteSS& p3, - const Ice::Current&) + const Test::ByteSS& p2, + Test::ByteSS& p3, + const Ice::Current&) { p3.resize(p1.size()); std::reverse_copy(p1.begin(), p1.end(), p3.begin()); @@ -216,9 +216,9 @@ MyDerivedClassI::opByteSS(const Test::ByteSS& p1, Test::BoolSS MyDerivedClassI::opBoolSS(const Test::BoolSS& p1, - const Test::BoolSS& p2, - Test::BoolSS& p3, - const Ice::Current&) + const Test::BoolSS& p2, + Test::BoolSS& p3, + const Ice::Current&) { p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -230,12 +230,12 @@ MyDerivedClassI::opBoolSS(const Test::BoolSS& p1, Test::LongSS MyDerivedClassI::opShortIntLongSS(const Test::ShortSS& p1, - const Test::IntSS& p2, - const Test::LongSS& p3, - Test::ShortSS& p4, - Test::IntSS& p5, - Test::LongSS& p6, - const Ice::Current&) + const Test::IntSS& p2, + const Test::LongSS& p3, + Test::ShortSS& p4, + Test::IntSS& p5, + Test::LongSS& p6, + const Ice::Current&) { p4 = p1; p5.resize(p2.size()); @@ -247,10 +247,10 @@ MyDerivedClassI::opShortIntLongSS(const Test::ShortSS& p1, Test::DoubleSS MyDerivedClassI::opFloatDoubleSS(const Test::FloatSS& p1, - const Test::DoubleSS& p2, - Test::FloatSS& p3, - Test::DoubleSS& p4, - const Ice::Current&) + const Test::DoubleSS& p2, + Test::FloatSS& p3, + Test::DoubleSS& p4, + const Ice::Current&) { p3 = p1; p4.resize(p2.size()); @@ -262,9 +262,9 @@ MyDerivedClassI::opFloatDoubleSS(const Test::FloatSS& p1, Test::StringSS MyDerivedClassI::opStringSS(const Test::StringSS& p1, - const Test::StringSS& p2, - Test::StringSS& p3, - const Ice::Current&) + const Test::StringSS& p2, + Test::StringSS& p3, + const Ice::Current&) { p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -276,9 +276,9 @@ MyDerivedClassI::opStringSS(const Test::StringSS& p1, Test::StringSSS MyDerivedClassI::opStringSSS(const Test::StringSSS& p1, - const Test::StringSSS& p2, - Test::StringSSS& p3, - const ::Ice::Current&) + const Test::StringSSS& p2, + Test::StringSSS& p3, + const ::Ice::Current&) { p3 = p1; std::copy(p2.begin(), p2.end(), std::back_inserter(p3)); @@ -290,9 +290,9 @@ MyDerivedClassI::opStringSSS(const Test::StringSSS& p1, Test::ByteBoolD MyDerivedClassI::opByteBoolD(const Test::ByteBoolD& p1, - const Test::ByteBoolD& p2, - Test::ByteBoolD& p3, - const Ice::Current&) + const Test::ByteBoolD& p2, + Test::ByteBoolD& p3, + const Ice::Current&) { p3 = p1; Test::ByteBoolD r = p1; @@ -302,9 +302,9 @@ MyDerivedClassI::opByteBoolD(const Test::ByteBoolD& p1, Test::ShortIntD MyDerivedClassI::opShortIntD(const Test::ShortIntD& p1, - const Test::ShortIntD& p2, - Test::ShortIntD& p3, - const Ice::Current&) + const Test::ShortIntD& p2, + Test::ShortIntD& p3, + const Ice::Current&) { p3 = p1; Test::ShortIntD r = p1; @@ -314,9 +314,9 @@ MyDerivedClassI::opShortIntD(const Test::ShortIntD& p1, Test::LongFloatD MyDerivedClassI::opLongFloatD(const Test::LongFloatD& p1, - const Test::LongFloatD& p2, - Test::LongFloatD& p3, - const Ice::Current&) + const Test::LongFloatD& p2, + Test::LongFloatD& p3, + const Ice::Current&) { p3 = p1; Test::LongFloatD r = p1; @@ -326,9 +326,9 @@ MyDerivedClassI::opLongFloatD(const Test::LongFloatD& p1, Test::StringStringD MyDerivedClassI::opStringStringD(const Test::StringStringD& p1, - const Test::StringStringD& p2, - Test::StringStringD& p3, - const Ice::Current&) + const Test::StringStringD& p2, + Test::StringStringD& p3, + const Ice::Current&) { p3 = p1; Test::StringStringD r = p1; @@ -338,9 +338,9 @@ MyDerivedClassI::opStringStringD(const Test::StringStringD& p1, Test::StringMyEnumD MyDerivedClassI::opStringMyEnumD(const Test::StringMyEnumD& p1, - const Test::StringMyEnumD& p2, - Test::StringMyEnumD& p3, - const Ice::Current&) + const Test::StringMyEnumD& p2, + Test::StringMyEnumD& p3, + const Ice::Current&) { p3 = p1; Test::StringMyEnumD r = p1; diff --git a/cpp/test/Ice/operations/TestI.h b/cpp/test/Ice/operations/TestI.h index 5a396df41e9..d5f8be15477 100644 --- a/cpp/test/Ice/operations/TestI.h +++ b/cpp/test/Ice/operations/TestI.h @@ -25,128 +25,128 @@ public: virtual void opSleep(int, const Ice::Current&); virtual Ice::Byte opByte(Ice::Byte, - Ice::Byte, - Ice::Byte&, - const Ice::Current&); + Ice::Byte, + Ice::Byte&, + const Ice::Current&); virtual bool opBool(bool, - bool, - bool&, - const Ice::Current&); + bool, + bool&, + const Ice::Current&); virtual Ice::Long opShortIntLong(Ice::Short, - Ice::Int, - Ice::Long, - Ice::Short&, - Ice::Int&, - Ice::Long&, - const Ice::Current&); + Ice::Int, + Ice::Long, + Ice::Short&, + Ice::Int&, + Ice::Long&, + const Ice::Current&); virtual Ice::Double opFloatDouble(Ice::Float, - Ice::Double, - Ice::Float&, - Ice::Double&, - const Ice::Current&); + Ice::Double, + Ice::Float&, + Ice::Double&, + const Ice::Current&); virtual std::string opString(const std::string&, - const std::string&, - std::string&, - const Ice::Current&); + const std::string&, + std::string&, + const Ice::Current&); virtual Test::MyEnum opMyEnum(Test::MyEnum, - Test::MyEnum&, - const Ice::Current&); + Test::MyEnum&, + const Ice::Current&); virtual Test::MyClassPrx opMyClass(const Test::MyClassPrx&, - Test::MyClassPrx&, Test::MyClassPrx&, - const Ice::Current&); + Test::MyClassPrx&, Test::MyClassPrx&, + const Ice::Current&); virtual Test::Structure opStruct(const Test::Structure&, const Test::Structure&, - Test::Structure&, - const Ice::Current&); + Test::Structure&, + const Ice::Current&); virtual Test::ByteS opByteS(const Test::ByteS&, - const Test::ByteS&, - Test::ByteS&, - const Ice::Current&); + const Test::ByteS&, + Test::ByteS&, + const Ice::Current&); virtual Test::BoolS opBoolS(const Test::BoolS&, - const Test::BoolS&, - Test::BoolS&, - const Ice::Current&); + const Test::BoolS&, + Test::BoolS&, + const Ice::Current&); virtual Test::LongS opShortIntLongS(const Test::ShortS&, - const Test::IntS&, - const Test::LongS&, - Test::ShortS&, - Test::IntS&, - Test::LongS&, - const Ice::Current&); + const Test::IntS&, + const Test::LongS&, + Test::ShortS&, + Test::IntS&, + Test::LongS&, + const Ice::Current&); virtual Test::DoubleS opFloatDoubleS(const Test::FloatS&, - const Test::DoubleS&, - Test::FloatS&, - Test::DoubleS&, - const Ice::Current&); + const Test::DoubleS&, + Test::FloatS&, + Test::DoubleS&, + const Ice::Current&); virtual Test::StringS opStringS(const Test::StringS&, - const Test::StringS&, - Test::StringS&, - const Ice::Current&); + const Test::StringS&, + Test::StringS&, + const Ice::Current&); virtual Test::ByteSS opByteSS(const Test::ByteSS&, - const Test::ByteSS&, - Test::ByteSS&, - const Ice::Current&); + const Test::ByteSS&, + Test::ByteSS&, + const Ice::Current&); virtual Test::BoolSS opBoolSS(const Test::BoolSS&, - const Test::BoolSS&, - Test::BoolSS&, - const Ice::Current&); + const Test::BoolSS&, + Test::BoolSS&, + const Ice::Current&); virtual Test::LongSS opShortIntLongSS(const Test::ShortSS&, - const Test::IntSS&, - const Test::LongSS&, - Test::ShortSS&, - Test::IntSS&, - Test::LongSS&, - const Ice::Current&); + const Test::IntSS&, + const Test::LongSS&, + Test::ShortSS&, + Test::IntSS&, + Test::LongSS&, + const Ice::Current&); virtual Test::DoubleSS opFloatDoubleSS(const Test::FloatSS&, - const Test::DoubleSS&, - Test::FloatSS&, - Test::DoubleSS&, - const Ice::Current&); + const Test::DoubleSS&, + Test::FloatSS&, + Test::DoubleSS&, + const Ice::Current&); virtual Test::StringSS opStringSS(const Test::StringSS&, - const Test::StringSS&, - Test::StringSS&, - const Ice::Current&); + const Test::StringSS&, + Test::StringSS&, + const Ice::Current&); virtual Test::StringSSS opStringSSS(const Test::StringSSS&, - const Test::StringSSS&, - Test::StringSSS&, - const ::Ice::Current&); + const Test::StringSSS&, + Test::StringSSS&, + const ::Ice::Current&); virtual Test::ByteBoolD opByteBoolD(const Test::ByteBoolD&, const Test::ByteBoolD&, - Test::ByteBoolD&, - const Ice::Current&); + Test::ByteBoolD&, + const Ice::Current&); virtual Test::ShortIntD opShortIntD(const Test::ShortIntD&, const Test::ShortIntD&, - Test::ShortIntD&, - const Ice::Current&); + Test::ShortIntD&, + const Ice::Current&); virtual Test::LongFloatD opLongFloatD(const Test::LongFloatD&, const Test::LongFloatD&, - Test::LongFloatD&, - const Ice::Current&); + Test::LongFloatD&, + const Ice::Current&); virtual Test::StringStringD opStringStringD(const Test::StringStringD&, const Test::StringStringD&, - Test::StringStringD&, - const Ice::Current&); + Test::StringStringD&, + const Ice::Current&); virtual Test::StringMyEnumD opStringMyEnumD(const Test::StringMyEnumD&, const Test::StringMyEnumD&, - Test::StringMyEnumD&, - const Ice::Current&); + Test::StringMyEnumD&, + const Ice::Current&); virtual Test::IntS opIntS(const Test::IntS&, const Ice::Current&); diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index 107e198a5d6..27f7133b622 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -28,723 +28,723 @@ void twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) { { - p->opVoid(); + p->opVoid(); } { - Ice::Byte b; - Ice::Byte r; + Ice::Byte b; + Ice::Byte r; - r = p->opByte(Ice::Byte(0xff), Ice::Byte(0x0f), b); - test(b == Ice::Byte(0xf0)); - test(r == Ice::Byte(0xff)); + r = p->opByte(Ice::Byte(0xff), Ice::Byte(0x0f), b); + test(b == Ice::Byte(0xf0)); + test(r == Ice::Byte(0xff)); } { - bool b; - bool r; + bool b; + bool r; - r = p->opBool(true, false, b); - test(b); - test(!r); + r = p->opBool(true, false, b); + test(b); + test(!r); } { - Ice::Short s; - Ice::Int i; - Ice::Long l; - Ice::Long r; - - r = p->opShortIntLong(10, 11, 12, s, i, l); - test(s == 10); - test(i == 11); - test(l == 12); - test(r == 12); - - r = p->opShortIntLong(numeric_limits<Ice::Short>::min(), numeric_limits<Ice::Int>::min(), - numeric_limits<Ice::Long>::min(), s, i, l); - test(s == numeric_limits<Ice::Short>::min()); - test(i == numeric_limits<Ice::Int>::min()); - test(l == numeric_limits<Ice::Long>::min()); - test(r == numeric_limits<Ice::Long>::min()); - - r = p->opShortIntLong(numeric_limits<Ice::Short>::max(), numeric_limits<Ice::Int>::max(), - numeric_limits<Ice::Long>::max(), s, i, l); - test(s == numeric_limits<Ice::Short>::max()); - test(i == numeric_limits<Ice::Int>::max()); - test(l == numeric_limits<Ice::Long>::max()); - test(r == numeric_limits<Ice::Long>::max()); + Ice::Short s; + Ice::Int i; + Ice::Long l; + Ice::Long r; + + r = p->opShortIntLong(10, 11, 12, s, i, l); + test(s == 10); + test(i == 11); + test(l == 12); + test(r == 12); + + r = p->opShortIntLong(numeric_limits<Ice::Short>::min(), numeric_limits<Ice::Int>::min(), + numeric_limits<Ice::Long>::min(), s, i, l); + test(s == numeric_limits<Ice::Short>::min()); + test(i == numeric_limits<Ice::Int>::min()); + test(l == numeric_limits<Ice::Long>::min()); + test(r == numeric_limits<Ice::Long>::min()); + + r = p->opShortIntLong(numeric_limits<Ice::Short>::max(), numeric_limits<Ice::Int>::max(), + numeric_limits<Ice::Long>::max(), s, i, l); + test(s == numeric_limits<Ice::Short>::max()); + test(i == numeric_limits<Ice::Int>::max()); + test(l == numeric_limits<Ice::Long>::max()); + test(r == numeric_limits<Ice::Long>::max()); } { - Ice::Float f; - Ice::Double d; - Ice::Double r; - - r = p->opFloatDouble(Ice::Float(3.14), Ice::Double(1.1E10), f, d); - test(f == Ice::Float(3.14)); - test(d == Ice::Double(1.1E10)); - test(r == Ice::Double(1.1E10)); - - r = p->opFloatDouble(numeric_limits<Ice::Float>::min(), numeric_limits<Ice::Double>::min(), f, d); - test(f == numeric_limits<Ice::Float>::min()); - test(d == numeric_limits<Ice::Double>::min()); - test(r == numeric_limits<Ice::Double>::min()); - - r = p->opFloatDouble(numeric_limits<Ice::Float>::max(), numeric_limits<Ice::Double>::max(), f, d); - test(f == numeric_limits<Ice::Float>::max()); - test(d == numeric_limits<Ice::Double>::max()); - test(r == numeric_limits<Ice::Double>::max()); + Ice::Float f; + Ice::Double d; + Ice::Double r; + + r = p->opFloatDouble(Ice::Float(3.14), Ice::Double(1.1E10), f, d); + test(f == Ice::Float(3.14)); + test(d == Ice::Double(1.1E10)); + test(r == Ice::Double(1.1E10)); + + r = p->opFloatDouble(numeric_limits<Ice::Float>::min(), numeric_limits<Ice::Double>::min(), f, d); + test(f == numeric_limits<Ice::Float>::min()); + test(d == numeric_limits<Ice::Double>::min()); + test(r == numeric_limits<Ice::Double>::min()); + + r = p->opFloatDouble(numeric_limits<Ice::Float>::max(), numeric_limits<Ice::Double>::max(), f, d); + test(f == numeric_limits<Ice::Float>::max()); + test(d == numeric_limits<Ice::Double>::max()); + test(r == numeric_limits<Ice::Double>::max()); } { - string s; - string r; + string s; + string r; - r = p->opString("hello", "world", s); - test(s == "world hello"); - test(r == "hello world"); + r = p->opString("hello", "world", s); + test(s == "world hello"); + test(r == "hello world"); } { - Test::MyEnum e; - Test::MyEnum r; - - r = p->opMyEnum(Test::enum2, e); - test(e == Test::enum2); - test(r == Test::enum3); + Test::MyEnum e; + Test::MyEnum r; + + r = p->opMyEnum(Test::enum2, e); + test(e == Test::enum2); + test(r == Test::enum3); } { - Test::MyClassPrx c1; - Test::MyClassPrx c2; - Test::MyClassPrx r; - - r = p->opMyClass(p, c1, c2); - test(Ice::proxyIdentityAndFacetEqual(c1, p)); - test(!Ice::proxyIdentityAndFacetEqual(c2, p)); - test(Ice::proxyIdentityAndFacetEqual(r, p)); - test(c1->ice_getIdentity() == communicator->stringToIdentity("test")); - test(c2->ice_getIdentity() == communicator->stringToIdentity("noSuchIdentity")); - test(r->ice_getIdentity() == communicator->stringToIdentity("test")); - r->opVoid(); - c1->opVoid(); - try - { - c2->opVoid(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - r = p->opMyClass(0, c1, c2); - test(c1 == 0); - test(c2 != 0); - test(Ice::proxyIdentityAndFacetEqual(r, p)); - r->opVoid(); + Test::MyClassPrx c1; + Test::MyClassPrx c2; + Test::MyClassPrx r; + + r = p->opMyClass(p, c1, c2); + test(Ice::proxyIdentityAndFacetEqual(c1, p)); + test(!Ice::proxyIdentityAndFacetEqual(c2, p)); + test(Ice::proxyIdentityAndFacetEqual(r, p)); + test(c1->ice_getIdentity() == communicator->stringToIdentity("test")); + test(c2->ice_getIdentity() == communicator->stringToIdentity("noSuchIdentity")); + test(r->ice_getIdentity() == communicator->stringToIdentity("test")); + r->opVoid(); + c1->opVoid(); + try + { + c2->opVoid(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + r = p->opMyClass(0, c1, c2); + test(c1 == 0); + test(c2 != 0); + test(Ice::proxyIdentityAndFacetEqual(r, p)); + r->opVoid(); } { - Test::Structure si1; - si1.p = p; - si1.e = Test::enum3; - si1.s.s = "abc"; - Test::Structure si2; - si2.p = 0; - si2.e = Test::enum2; - si2.s.s = "def"; - - Test::Structure so; - Test::Structure rso = p->opStruct(si1, si2, so); - test(rso.p == 0); - test(rso.e == Test::enum2); - test(rso.s.s == "def"); - test(so.p == p); - test(so.e == Test::enum3); - test(so.s.s == "a new string"); - so.p->opVoid(); + Test::Structure si1; + si1.p = p; + si1.e = Test::enum3; + si1.s.s = "abc"; + Test::Structure si2; + si2.p = 0; + si2.e = Test::enum2; + si2.s.s = "def"; + + Test::Structure so; + Test::Structure rso = p->opStruct(si1, si2, so); + test(rso.p == 0); + test(rso.e == Test::enum2); + test(rso.s.s == "def"); + test(so.p == p); + test(so.e == Test::enum3); + test(so.s.s == "a new string"); + so.p->opVoid(); } { - Test::ByteS bsi1; - Test::ByteS bsi2; - - bsi1.push_back(Ice::Byte(0x01)); - bsi1.push_back(Ice::Byte(0x11)); - bsi1.push_back(Ice::Byte(0x12)); - bsi1.push_back(Ice::Byte(0x22)); - - bsi2.push_back(Ice::Byte(0xf1)); - bsi2.push_back(Ice::Byte(0xf2)); - bsi2.push_back(Ice::Byte(0xf3)); - bsi2.push_back(Ice::Byte(0xf4)); - - Test::ByteS bso; - Test::ByteS rso; - - rso = p->opByteS(bsi1, bsi2, bso); - test(bso.size() == 4); - test(bso[0] == Ice::Byte(0x22)); - test(bso[1] == Ice::Byte(0x12)); - test(bso[2] == Ice::Byte(0x11)); - test(bso[3] == Ice::Byte(0x01)); - test(rso.size() == 8); - test(rso[0] == Ice::Byte(0x01)); - test(rso[1] == Ice::Byte(0x11)); - test(rso[2] == Ice::Byte(0x12)); - test(rso[3] == Ice::Byte(0x22)); - test(rso[4] == Ice::Byte(0xf1)); - test(rso[5] == Ice::Byte(0xf2)); - test(rso[6] == Ice::Byte(0xf3)); - test(rso[7] == Ice::Byte(0xf4)); + Test::ByteS bsi1; + Test::ByteS bsi2; + + bsi1.push_back(Ice::Byte(0x01)); + bsi1.push_back(Ice::Byte(0x11)); + bsi1.push_back(Ice::Byte(0x12)); + bsi1.push_back(Ice::Byte(0x22)); + + bsi2.push_back(Ice::Byte(0xf1)); + bsi2.push_back(Ice::Byte(0xf2)); + bsi2.push_back(Ice::Byte(0xf3)); + bsi2.push_back(Ice::Byte(0xf4)); + + Test::ByteS bso; + Test::ByteS rso; + + rso = p->opByteS(bsi1, bsi2, bso); + test(bso.size() == 4); + test(bso[0] == Ice::Byte(0x22)); + test(bso[1] == Ice::Byte(0x12)); + test(bso[2] == Ice::Byte(0x11)); + test(bso[3] == Ice::Byte(0x01)); + test(rso.size() == 8); + test(rso[0] == Ice::Byte(0x01)); + test(rso[1] == Ice::Byte(0x11)); + test(rso[2] == Ice::Byte(0x12)); + test(rso[3] == Ice::Byte(0x22)); + test(rso[4] == Ice::Byte(0xf1)); + test(rso[5] == Ice::Byte(0xf2)); + test(rso[6] == Ice::Byte(0xf3)); + test(rso[7] == Ice::Byte(0xf4)); } { - Test::BoolS bsi1; - Test::BoolS bsi2; - - bsi1.push_back(true); - bsi1.push_back(true); - bsi1.push_back(false); - - bsi2.push_back(false); - - Test::BoolS bso; - Test::BoolS rso; - - rso = p->opBoolS(bsi1, bsi2, bso); - test(bso.size() == 4); - test(bso[0]); - test(bso[1]); - test(!bso[2]); - test(!bso[3]); - test(rso.size() == 3); - test(!rso[0]); - test(rso[1]); - test(rso[2]); + Test::BoolS bsi1; + Test::BoolS bsi2; + + bsi1.push_back(true); + bsi1.push_back(true); + bsi1.push_back(false); + + bsi2.push_back(false); + + Test::BoolS bso; + Test::BoolS rso; + + rso = p->opBoolS(bsi1, bsi2, bso); + test(bso.size() == 4); + test(bso[0]); + test(bso[1]); + test(!bso[2]); + test(!bso[3]); + test(rso.size() == 3); + test(!rso[0]); + test(rso[1]); + test(rso[2]); } { - Test::ShortS ssi; - Test::IntS isi; - Test::LongS lsi; - - ssi.push_back(1); - ssi.push_back(2); - ssi.push_back(3); - - isi.push_back(5); - isi.push_back(6); - isi.push_back(7); - isi.push_back(8); - - lsi.push_back(10); - lsi.push_back(30); - lsi.push_back(20); - - Test::ShortS sso; - Test::IntS iso; - Test::LongS lso; - Test::LongS rso; - - rso = p->opShortIntLongS(ssi, isi, lsi, sso, iso, lso); - test(sso.size() == 3); - test(sso[0] == 1); - test(sso[1] == 2); - test(sso[2] == 3); - test(iso.size() == 4); - test(iso[0] == 8); - test(iso[1] == 7); - test(iso[2] == 6); - test(iso[3] == 5); - test(lso.size() == 6); - test(lso[0] == 10); - test(lso[1] == 30); - test(lso[2] == 20); - test(lso[3] == 10); - test(lso[4] == 30); - test(lso[5] == 20); - test(rso.size() == 3); - test(rso[0] == 10); - test(rso[1] == 30); - test(rso[2] == 20); + Test::ShortS ssi; + Test::IntS isi; + Test::LongS lsi; + + ssi.push_back(1); + ssi.push_back(2); + ssi.push_back(3); + + isi.push_back(5); + isi.push_back(6); + isi.push_back(7); + isi.push_back(8); + + lsi.push_back(10); + lsi.push_back(30); + lsi.push_back(20); + + Test::ShortS sso; + Test::IntS iso; + Test::LongS lso; + Test::LongS rso; + + rso = p->opShortIntLongS(ssi, isi, lsi, sso, iso, lso); + test(sso.size() == 3); + test(sso[0] == 1); + test(sso[1] == 2); + test(sso[2] == 3); + test(iso.size() == 4); + test(iso[0] == 8); + test(iso[1] == 7); + test(iso[2] == 6); + test(iso[3] == 5); + test(lso.size() == 6); + test(lso[0] == 10); + test(lso[1] == 30); + test(lso[2] == 20); + test(lso[3] == 10); + test(lso[4] == 30); + test(lso[5] == 20); + test(rso.size() == 3); + test(rso[0] == 10); + test(rso[1] == 30); + test(rso[2] == 20); } { - Test::FloatS fsi; - Test::DoubleS dsi; - - fsi.push_back(Ice::Float(3.14)); - fsi.push_back(Ice::Float(1.11)); - - dsi.push_back(Ice::Double(1.1E10)); - dsi.push_back(Ice::Double(1.2E10)); - dsi.push_back(Ice::Double(1.3E10)); - - Test::FloatS fso; - Test::DoubleS dso; - Test::DoubleS rso; - - rso = p->opFloatDoubleS(fsi, dsi, fso, dso); - test(fso.size() == 2); - test(fso[0] == ::Ice::Float(3.14)); - test(fso[1] == ::Ice::Float(1.11)); - test(dso.size() == 3); - test(dso[0] == ::Ice::Double(1.3E10)); - test(dso[1] == ::Ice::Double(1.2E10)); - test(dso[2] == ::Ice::Double(1.1E10)); - test(rso.size() == 5); - test(rso[0] == ::Ice::Double(1.1E10)); - test(rso[1] == ::Ice::Double(1.2E10)); - test(rso[2] == ::Ice::Double(1.3E10)); - test(::Ice::Float(rso[3]) == ::Ice::Float(3.14)); - test(::Ice::Float(rso[4]) == ::Ice::Float(1.11)); + Test::FloatS fsi; + Test::DoubleS dsi; + + fsi.push_back(Ice::Float(3.14)); + fsi.push_back(Ice::Float(1.11)); + + dsi.push_back(Ice::Double(1.1E10)); + dsi.push_back(Ice::Double(1.2E10)); + dsi.push_back(Ice::Double(1.3E10)); + + Test::FloatS fso; + Test::DoubleS dso; + Test::DoubleS rso; + + rso = p->opFloatDoubleS(fsi, dsi, fso, dso); + test(fso.size() == 2); + test(fso[0] == ::Ice::Float(3.14)); + test(fso[1] == ::Ice::Float(1.11)); + test(dso.size() == 3); + test(dso[0] == ::Ice::Double(1.3E10)); + test(dso[1] == ::Ice::Double(1.2E10)); + test(dso[2] == ::Ice::Double(1.1E10)); + test(rso.size() == 5); + test(rso[0] == ::Ice::Double(1.1E10)); + test(rso[1] == ::Ice::Double(1.2E10)); + test(rso[2] == ::Ice::Double(1.3E10)); + test(::Ice::Float(rso[3]) == ::Ice::Float(3.14)); + test(::Ice::Float(rso[4]) == ::Ice::Float(1.11)); } { - Test::StringS ssi1; - Test::StringS ssi2; - - ssi1.push_back("abc"); - ssi1.push_back("de"); - ssi1.push_back("fghi"); - - ssi2.push_back("xyz"); - - Test::StringS sso; - Test::StringS rso; - - rso = p->opStringS(ssi1, ssi2, sso); - test(sso.size() == 4); - test(sso[0] == "abc"); - test(sso[1] == "de"); - test(sso[2] == "fghi"); - test(sso[3] == "xyz"); - test(rso.size() == 3); - test(rso[0] == "fghi"); - test(rso[1] == "de"); - test(rso[2] == "abc"); + Test::StringS ssi1; + Test::StringS ssi2; + + ssi1.push_back("abc"); + ssi1.push_back("de"); + ssi1.push_back("fghi"); + + ssi2.push_back("xyz"); + + Test::StringS sso; + Test::StringS rso; + + rso = p->opStringS(ssi1, ssi2, sso); + test(sso.size() == 4); + test(sso[0] == "abc"); + test(sso[1] == "de"); + test(sso[2] == "fghi"); + test(sso[3] == "xyz"); + test(rso.size() == 3); + test(rso[0] == "fghi"); + test(rso[1] == "de"); + test(rso[2] == "abc"); } { - Test::ByteSS bsi1; - bsi1.resize(2); - Test::ByteSS bsi2; - bsi2.resize(2); - - bsi1[0].push_back(Ice::Byte(0x01)); - bsi1[0].push_back(Ice::Byte(0x11)); - bsi1[0].push_back(Ice::Byte(0x12)); - bsi1[1].push_back(Ice::Byte(0xff)); - - bsi2[0].push_back(Ice::Byte(0x0e)); - bsi2[1].push_back(Ice::Byte(0xf2)); - bsi2[1].push_back(Ice::Byte(0xf1)); - - Test::ByteSS bso; - Test::ByteSS rso; - - rso = p->opByteSS(bsi1, bsi2, bso); - test(bso.size() == 2); - test(bso[0].size() == 1); - test(bso[0][0] == Ice::Byte(0xff)); - test(bso[1].size() == 3); - test(bso[1][0] == Ice::Byte(0x01)); - test(bso[1][1] == Ice::Byte(0x11)); - test(bso[1][2] == Ice::Byte(0x12)); - test(rso.size() == 4); - test(rso[0].size() == 3); - test(rso[0][0] == Ice::Byte(0x01)); - test(rso[0][1] == Ice::Byte(0x11)); - test(rso[0][2] == Ice::Byte(0x12)); - test(rso[1].size() == 1); - test(rso[1][0] == Ice::Byte(0xff)); - test(rso[2].size() == 1); - test(rso[2][0] == Ice::Byte(0x0e)); - test(rso[3].size() == 2); - test(rso[3][0] == Ice::Byte(0xf2)); - test(rso[3][1] == Ice::Byte(0xf1)); + Test::ByteSS bsi1; + bsi1.resize(2); + Test::ByteSS bsi2; + bsi2.resize(2); + + bsi1[0].push_back(Ice::Byte(0x01)); + bsi1[0].push_back(Ice::Byte(0x11)); + bsi1[0].push_back(Ice::Byte(0x12)); + bsi1[1].push_back(Ice::Byte(0xff)); + + bsi2[0].push_back(Ice::Byte(0x0e)); + bsi2[1].push_back(Ice::Byte(0xf2)); + bsi2[1].push_back(Ice::Byte(0xf1)); + + Test::ByteSS bso; + Test::ByteSS rso; + + rso = p->opByteSS(bsi1, bsi2, bso); + test(bso.size() == 2); + test(bso[0].size() == 1); + test(bso[0][0] == Ice::Byte(0xff)); + test(bso[1].size() == 3); + test(bso[1][0] == Ice::Byte(0x01)); + test(bso[1][1] == Ice::Byte(0x11)); + test(bso[1][2] == Ice::Byte(0x12)); + test(rso.size() == 4); + test(rso[0].size() == 3); + test(rso[0][0] == Ice::Byte(0x01)); + test(rso[0][1] == Ice::Byte(0x11)); + test(rso[0][2] == Ice::Byte(0x12)); + test(rso[1].size() == 1); + test(rso[1][0] == Ice::Byte(0xff)); + test(rso[2].size() == 1); + test(rso[2][0] == Ice::Byte(0x0e)); + test(rso[3].size() == 2); + test(rso[3][0] == Ice::Byte(0xf2)); + test(rso[3][1] == Ice::Byte(0xf1)); } { - Test::FloatSS fsi; - fsi.resize(3); - Test::DoubleSS dsi; - dsi.resize(1); - - fsi[0].push_back(Ice::Float(3.14)); - fsi[1].push_back(Ice::Float(1.11)); - - dsi[0].push_back(Ice::Double(1.1E10)); - dsi[0].push_back(Ice::Double(1.2E10)); - dsi[0].push_back(Ice::Double(1.3E10)); - - Test::FloatSS fso; - Test::DoubleSS dso; - Test::DoubleSS rso; - - rso = p->opFloatDoubleSS(fsi, dsi, fso, dso); - test(fso.size() == 3); - test(fso[0].size() == 1); - test(fso[0][0] == ::Ice::Float(3.14)); - test(fso[1].size() == 1); - test(fso[1][0] == ::Ice::Float(1.11)); - test(fso[2].size() == 0); - test(dso.size() == 1); - test(dso[0].size() == 3); - test(dso[0][0] == ::Ice::Double(1.1E10)); - test(dso[0][1] == ::Ice::Double(1.2E10)); - test(dso[0][2] == ::Ice::Double(1.3E10)); - test(rso.size() == 2); - test(rso[0].size() == 3); - test(rso[0][0] == ::Ice::Double(1.1E10)); - test(rso[0][1] == ::Ice::Double(1.2E10)); - test(rso[0][2] == ::Ice::Double(1.3E10)); - test(rso[1].size() == 3); - test(rso[1][0] == ::Ice::Double(1.1E10)); - test(rso[1][1] == ::Ice::Double(1.2E10)); - test(rso[1][2] == ::Ice::Double(1.3E10)); + Test::FloatSS fsi; + fsi.resize(3); + Test::DoubleSS dsi; + dsi.resize(1); + + fsi[0].push_back(Ice::Float(3.14)); + fsi[1].push_back(Ice::Float(1.11)); + + dsi[0].push_back(Ice::Double(1.1E10)); + dsi[0].push_back(Ice::Double(1.2E10)); + dsi[0].push_back(Ice::Double(1.3E10)); + + Test::FloatSS fso; + Test::DoubleSS dso; + Test::DoubleSS rso; + + rso = p->opFloatDoubleSS(fsi, dsi, fso, dso); + test(fso.size() == 3); + test(fso[0].size() == 1); + test(fso[0][0] == ::Ice::Float(3.14)); + test(fso[1].size() == 1); + test(fso[1][0] == ::Ice::Float(1.11)); + test(fso[2].size() == 0); + test(dso.size() == 1); + test(dso[0].size() == 3); + test(dso[0][0] == ::Ice::Double(1.1E10)); + test(dso[0][1] == ::Ice::Double(1.2E10)); + test(dso[0][2] == ::Ice::Double(1.3E10)); + test(rso.size() == 2); + test(rso[0].size() == 3); + test(rso[0][0] == ::Ice::Double(1.1E10)); + test(rso[0][1] == ::Ice::Double(1.2E10)); + test(rso[0][2] == ::Ice::Double(1.3E10)); + test(rso[1].size() == 3); + test(rso[1][0] == ::Ice::Double(1.1E10)); + test(rso[1][1] == ::Ice::Double(1.2E10)); + test(rso[1][2] == ::Ice::Double(1.3E10)); } { - Test::StringSS ssi1; - ssi1.resize(2); - Test::StringSS ssi2; - ssi2.resize(3); - - ssi1[0].push_back("abc"); - ssi1[1].push_back("de"); - ssi1[1].push_back("fghi"); - - ssi2[2].push_back("xyz"); - - Test::StringSS sso; - Test::StringSS rso; - - rso = p->opStringSS(ssi1, ssi2, sso); - test(sso.size() == 5); - test(sso[0].size() == 1); - test(sso[0][0] == "abc"); - test(sso[1].size() == 2); - test(sso[1][0] == "de"); - test(sso[1][1] == "fghi"); - test(sso[2].size() == 0); - test(sso[3].size() == 0); - test(sso[4].size() == 1); - test(sso[4][0] == "xyz"); - test(rso.size() == 3); - test(rso[0].size() == 1); - test(rso[0][0] == "xyz"); - test(rso[1].size() == 0); - test(rso[2].size() == 0); + Test::StringSS ssi1; + ssi1.resize(2); + Test::StringSS ssi2; + ssi2.resize(3); + + ssi1[0].push_back("abc"); + ssi1[1].push_back("de"); + ssi1[1].push_back("fghi"); + + ssi2[2].push_back("xyz"); + + Test::StringSS sso; + Test::StringSS rso; + + rso = p->opStringSS(ssi1, ssi2, sso); + test(sso.size() == 5); + test(sso[0].size() == 1); + test(sso[0][0] == "abc"); + test(sso[1].size() == 2); + test(sso[1][0] == "de"); + test(sso[1][1] == "fghi"); + test(sso[2].size() == 0); + test(sso[3].size() == 0); + test(sso[4].size() == 1); + test(sso[4][0] == "xyz"); + test(rso.size() == 3); + test(rso[0].size() == 1); + test(rso[0][0] == "xyz"); + test(rso[1].size() == 0); + test(rso[2].size() == 0); } { - Test::StringSSS sssi1; - sssi1.resize(2); - sssi1[0].resize(2); - sssi1[0][0].push_back("abc"); - sssi1[0][0].push_back("de"); - sssi1[0][1].push_back("xyz"); - sssi1[1].resize(1); - sssi1[1][0].push_back("hello"); - - Test::StringSSS sssi2; - sssi2.resize(3); - sssi2[0].resize(2); - sssi2[0][0].push_back(""); - sssi2[0][0].push_back(""); - sssi2[0][1].push_back("abcd"); - sssi2[1].resize(1); - sssi2[1][0].push_back(""); - - Test::StringSSS ssso; - Test::StringSSS rsso; - - rsso = p->opStringSSS(sssi1, sssi2, ssso); - test(ssso.size() == 5); - test(ssso[0].size() == 2); - test(ssso[0][0].size() == 2); - test(ssso[0][1].size() == 1); - test(ssso[1].size() == 1); - test(ssso[1][0].size() == 1); - test(ssso[2].size() == 2); - test(ssso[2][0].size() == 2); - test(ssso[2][1].size() == 1); - test(ssso[3].size() == 1); - test(ssso[3][0].size() == 1); - test(ssso[4].size() == 0); - test(ssso[0][0][0] == "abc"); - test(ssso[0][0][1] == "de"); - test(ssso[0][1][0] == "xyz"); - test(ssso[1][0][0] == "hello"); - test(ssso[2][0][0] == ""); - test(ssso[2][0][1] == ""); - test(ssso[2][1][0] == "abcd"); - test(ssso[3][0][0] == ""); - - test(rsso.size() == 3); - test(rsso[0].size() == 0); - test(rsso[1].size() == 1); - test(rsso[1][0].size() == 1); - test(rsso[2].size() == 2); - test(rsso[2][0].size() == 2); - test(rsso[2][1].size() == 1); - test(rsso[1][0][0] == ""); - test(rsso[2][0][0] == ""); - test(rsso[2][0][1] == ""); - test(rsso[2][1][0] == "abcd"); + Test::StringSSS sssi1; + sssi1.resize(2); + sssi1[0].resize(2); + sssi1[0][0].push_back("abc"); + sssi1[0][0].push_back("de"); + sssi1[0][1].push_back("xyz"); + sssi1[1].resize(1); + sssi1[1][0].push_back("hello"); + + Test::StringSSS sssi2; + sssi2.resize(3); + sssi2[0].resize(2); + sssi2[0][0].push_back(""); + sssi2[0][0].push_back(""); + sssi2[0][1].push_back("abcd"); + sssi2[1].resize(1); + sssi2[1][0].push_back(""); + + Test::StringSSS ssso; + Test::StringSSS rsso; + + rsso = p->opStringSSS(sssi1, sssi2, ssso); + test(ssso.size() == 5); + test(ssso[0].size() == 2); + test(ssso[0][0].size() == 2); + test(ssso[0][1].size() == 1); + test(ssso[1].size() == 1); + test(ssso[1][0].size() == 1); + test(ssso[2].size() == 2); + test(ssso[2][0].size() == 2); + test(ssso[2][1].size() == 1); + test(ssso[3].size() == 1); + test(ssso[3][0].size() == 1); + test(ssso[4].size() == 0); + test(ssso[0][0][0] == "abc"); + test(ssso[0][0][1] == "de"); + test(ssso[0][1][0] == "xyz"); + test(ssso[1][0][0] == "hello"); + test(ssso[2][0][0] == ""); + test(ssso[2][0][1] == ""); + test(ssso[2][1][0] == "abcd"); + test(ssso[3][0][0] == ""); + + test(rsso.size() == 3); + test(rsso[0].size() == 0); + test(rsso[1].size() == 1); + test(rsso[1][0].size() == 1); + test(rsso[2].size() == 2); + test(rsso[2][0].size() == 2); + test(rsso[2][1].size() == 1); + test(rsso[1][0][0] == ""); + test(rsso[2][0][0] == ""); + test(rsso[2][0][1] == ""); + test(rsso[2][1][0] == "abcd"); } { - Test::ByteBoolD di1; - di1[10] = true; - di1[100] = false; - Test::ByteBoolD di2; - di2[10] = true; - di2[11] = false; - di2[101] = true; - - Test::ByteBoolD _do; - Test::ByteBoolD ro = p->opByteBoolD(di1, di2, _do); - - test(_do == di1); - test(ro.size() == 4); - test(ro[10] == true); - test(ro[11] == false); - test(ro[100] == false); - test(ro[101] == true); + Test::ByteBoolD di1; + di1[10] = true; + di1[100] = false; + Test::ByteBoolD di2; + di2[10] = true; + di2[11] = false; + di2[101] = true; + + Test::ByteBoolD _do; + Test::ByteBoolD ro = p->opByteBoolD(di1, di2, _do); + + test(_do == di1); + test(ro.size() == 4); + test(ro[10] == true); + test(ro[11] == false); + test(ro[100] == false); + test(ro[101] == true); } { - Test::ShortIntD di1; - di1[110] = -1; - di1[1100] = 123123; - Test::ShortIntD di2; - di2[110] = -1; - di2[111] = -100; - di2[1101] = 0; - - Test::ShortIntD _do; - Test::ShortIntD ro = p->opShortIntD(di1, di2, _do); - - test(_do == di1); - test(ro.size() == 4); - test(ro[110] == -1); - test(ro[111] == -100); - test(ro[1100] == 123123); - test(ro[1101] == 0); + Test::ShortIntD di1; + di1[110] = -1; + di1[1100] = 123123; + Test::ShortIntD di2; + di2[110] = -1; + di2[111] = -100; + di2[1101] = 0; + + Test::ShortIntD _do; + Test::ShortIntD ro = p->opShortIntD(di1, di2, _do); + + test(_do == di1); + test(ro.size() == 4); + test(ro[110] == -1); + test(ro[111] == -100); + test(ro[1100] == 123123); + test(ro[1101] == 0); } { - Test::LongFloatD di1; - di1[999999110] = Ice::Float(-1.1); - di1[999999111] = Ice::Float(123123.2); - Test::LongFloatD di2; - di2[999999110] = Ice::Float(-1.1); - di2[999999120] = Ice::Float(-100.4); - di2[999999130] = Ice::Float(0.5); - - Test::LongFloatD _do; - Test::LongFloatD ro = p->opLongFloatD(di1, di2, _do); - - test(_do == di1); - test(ro.size() == 4); - test(ro[999999110] == Ice::Float(-1.1)); - test(ro[999999120] == Ice::Float(-100.4)); - test(ro[999999111] == Ice::Float(123123.2)); - test(ro[999999130] == Ice::Float(0.5)); + Test::LongFloatD di1; + di1[999999110] = Ice::Float(-1.1); + di1[999999111] = Ice::Float(123123.2); + Test::LongFloatD di2; + di2[999999110] = Ice::Float(-1.1); + di2[999999120] = Ice::Float(-100.4); + di2[999999130] = Ice::Float(0.5); + + Test::LongFloatD _do; + Test::LongFloatD ro = p->opLongFloatD(di1, di2, _do); + + test(_do == di1); + test(ro.size() == 4); + test(ro[999999110] == Ice::Float(-1.1)); + test(ro[999999120] == Ice::Float(-100.4)); + test(ro[999999111] == Ice::Float(123123.2)); + test(ro[999999130] == Ice::Float(0.5)); } { - Test::StringStringD di1; - di1["foo"] = "abc -1.1"; - di1["bar"] = "abc 123123.2"; - Test::StringStringD di2; - di2["foo"] = "abc -1.1"; - di2["FOO"] = "abc -100.4"; - di2["BAR"] = "abc 0.5"; - - Test::StringStringD _do; - Test::StringStringD ro = p->opStringStringD(di1, di2, _do); - - test(_do == di1); - test(ro.size() == 4); - test(ro["foo"] == "abc -1.1"); - test(ro["FOO"] == "abc -100.4"); - test(ro["bar"] == "abc 123123.2"); - test(ro["BAR"] == "abc 0.5"); + Test::StringStringD di1; + di1["foo"] = "abc -1.1"; + di1["bar"] = "abc 123123.2"; + Test::StringStringD di2; + di2["foo"] = "abc -1.1"; + di2["FOO"] = "abc -100.4"; + di2["BAR"] = "abc 0.5"; + + Test::StringStringD _do; + Test::StringStringD ro = p->opStringStringD(di1, di2, _do); + + test(_do == di1); + test(ro.size() == 4); + test(ro["foo"] == "abc -1.1"); + test(ro["FOO"] == "abc -100.4"); + test(ro["bar"] == "abc 123123.2"); + test(ro["BAR"] == "abc 0.5"); } { - Test::StringMyEnumD di1; - di1["abc"] = Test::enum1; - di1[""] = Test::enum2; - Test::StringMyEnumD di2; - di2["abc"] = Test::enum1; - di2["qwerty"] = Test::enum3; - di2["Hello!!"] = Test::enum2; - - Test::StringMyEnumD _do; - Test::StringMyEnumD ro = p->opStringMyEnumD(di1, di2, _do); - - test(_do == di1); - test(ro.size() == 4); - test(ro["abc"] == Test::enum1); - test(ro["qwerty"] == Test::enum3); - test(ro[""] == Test::enum2); - test(ro["Hello!!"] == Test::enum2); + Test::StringMyEnumD di1; + di1["abc"] = Test::enum1; + di1[""] = Test::enum2; + Test::StringMyEnumD di2; + di2["abc"] = Test::enum1; + di2["qwerty"] = Test::enum3; + di2["Hello!!"] = Test::enum2; + + Test::StringMyEnumD _do; + Test::StringMyEnumD ro = p->opStringMyEnumD(di1, di2, _do); + + test(_do == di1); + test(ro.size() == 4); + test(ro["abc"] == Test::enum1); + test(ro["qwerty"] == Test::enum3); + test(ro[""] == Test::enum2); + test(ro["Hello!!"] == Test::enum2); } { - const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; - - for(int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) - { - Test::IntS s; - for(int i = 0; i < lengths[l]; ++i) - { - s.push_back(i); - } - Test::IntS r = p->opIntS(s); - test(r.size() == static_cast<size_t>(lengths[l])); - for(int j = 0; j < static_cast<int>(r.size()); ++j) - { - test(r[j] == -j); - } - } + const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; + + for(int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) + { + Test::IntS s; + for(int i = 0; i < lengths[l]; ++i) + { + s.push_back(i); + } + Test::IntS r = p->opIntS(s); + test(r.size() == static_cast<size_t>(lengths[l])); + for(int j = 0; j < static_cast<int>(r.size()); ++j) + { + test(r[j] == -j); + } + } } { - Ice::Context ctx; - ctx["one"] = "ONE"; - ctx["two"] = "TWO"; - ctx["three"] = "THREE"; - { - Test::StringStringD r = p->opContext(); - test(p->ice_getContext().empty()); - test(r != ctx); - } - { - Test::StringStringD r = p->opContext(ctx); - test(p->ice_getContext().empty()); - test(r == ctx); - } - { - Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx)); - test(p2->ice_getContext() == ctx); - Test::StringStringD r = p2->opContext(); - test(r == ctx); - r = p2->opContext(ctx); - test(r == ctx); - } - - { - // - // Test that default context is obtained correctly from communicator. - // + Ice::Context ctx; + ctx["one"] = "ONE"; + ctx["two"] = "TWO"; + ctx["three"] = "THREE"; + { + Test::StringStringD r = p->opContext(); + test(p->ice_getContext().empty()); + test(r != ctx); + } + { + Test::StringStringD r = p->opContext(ctx); + test(p->ice_getContext().empty()); + test(r == ctx); + } + { + Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx)); + test(p2->ice_getContext() == ctx); + Test::StringStringD r = p2->opContext(); + test(r == ctx); + r = p2->opContext(ctx); + test(r == ctx); + } + + { + // + // Test that default context is obtained correctly from communicator. + // /* DEPRECATED - Ice::Context dflt; - dflt["a"] = "b"; - communicator->setDefaultContext(dflt); - test(p->opContext() != dflt); + Ice::Context dflt; + dflt["a"] = "b"; + communicator->setDefaultContext(dflt); + test(p->opContext() != dflt); - Test::MyClassPrx p2 = Test::MyClassPrx::uncheckedCast(p->ice_context(Ice::Context())); - test(p2->opContext().empty()); + Test::MyClassPrx p2 = Test::MyClassPrx::uncheckedCast(p->ice_context(Ice::Context())); + test(p2->opContext().empty()); - p2 = Test::MyClassPrx::uncheckedCast(p->ice_defaultContext()); - test(p2->opContext() == dflt); + p2 = Test::MyClassPrx::uncheckedCast(p->ice_defaultContext()); + test(p2->opContext() == dflt); - communicator->setDefaultContext(Ice::Context()); - test(!p2->opContext().empty()); + communicator->setDefaultContext(Ice::Context()); + test(!p2->opContext().empty()); - communicator->setDefaultContext(dflt); - Test::MyClassPrx c = Test::MyClassPrx::checkedCast( - communicator->stringToProxy("test:default -p 12010 -t 10000")); - test(c->opContext() == dflt); + communicator->setDefaultContext(dflt); + Test::MyClassPrx c = Test::MyClassPrx::checkedCast( + communicator->stringToProxy("test:default -p 12010 -t 10000")); + test(c->opContext() == dflt); - dflt["a"] = "c"; - Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_context(dflt)); - test(c2->opContext()["a"] == "c"); + dflt["a"] = "c"; + Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_context(dflt)); + test(c2->opContext()["a"] == "c"); - dflt.clear(); - Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_context(dflt)); - Ice::Context tmp = c3->opContext(); - test(tmp.find("a") == tmp.end()); + dflt.clear(); + Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_context(dflt)); + Ice::Context tmp = c3->opContext(); + test(tmp.find("a") == tmp.end()); - Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext()); - test(c4->opContext()["a"] == "b"); + Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext()); + test(c4->opContext()["a"] == "b"); - dflt["a"] = "d"; - communicator->setDefaultContext(dflt); + dflt["a"] = "d"; + communicator->setDefaultContext(dflt); - Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext()); - test(c5->opContext()["a"] == "d"); + Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext()); + test(c5->opContext()["a"] == "d"); - communicator->setDefaultContext(Ice::Context()); + communicator->setDefaultContext(Ice::Context()); */ - } - - { - // - // Test implicit context propagation - // - - string impls[] = {"Shared", "SharedWithoutLocking", "PerThread"}; - for(int i = 0; i < 3; i++) - { - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.ImplicitContext", impls[i]); - - Ice::CommunicatorPtr ic = Ice::initialize(initData); - - Ice::Context ctx; - ctx["one"] = "ONE"; - ctx["two"] = "TWO"; - ctx["three"] = "THREE"; - - Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast( - ic->stringToProxy("test:default -p 12010 -t 10000")); - - ic->getImplicitContext()->setContext(ctx); - test(ic->getImplicitContext()->getContext() == ctx); - test(p->opContext() == ctx); - - ic->getImplicitContext()->set("zero", "ZERO"); - test(ic->getImplicitContext()->get("zero") == "ZERO"); - test(ic->getImplicitContext()->getWithDefault("foobar", "foo") == "foo"); - - ctx = ic->getImplicitContext()->getContext(); - test(p->opContext() == ctx); - - Ice::Context prxContext; - prxContext["one"] = "UN"; - prxContext["four"] = "QUATRE"; - - Ice::Context combined = prxContext; - combined.insert(ctx.begin(), ctx.end()); - test(combined["one"] == "UN"); - - p = Test::MyClassPrx::uncheckedCast(p->ice_context(prxContext)); - - ic->getImplicitContext()->setContext(Ice::Context()); - test(p->opContext() == prxContext); - - ic->getImplicitContext()->setContext(ctx); - test(p->opContext() == combined); - - ic->destroy(); - } - } - + } + + { + // + // Test implicit context propagation + // + + string impls[] = {"Shared", "SharedWithoutLocking", "PerThread"}; + for(int i = 0; i < 3; i++) + { + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.ImplicitContext", impls[i]); + + Ice::CommunicatorPtr ic = Ice::initialize(initData); + + Ice::Context ctx; + ctx["one"] = "ONE"; + ctx["two"] = "TWO"; + ctx["three"] = "THREE"; + + Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast( + ic->stringToProxy("test:default -p 12010 -t 10000")); + + ic->getImplicitContext()->setContext(ctx); + test(ic->getImplicitContext()->getContext() == ctx); + test(p->opContext() == ctx); + + ic->getImplicitContext()->set("zero", "ZERO"); + test(ic->getImplicitContext()->get("zero") == "ZERO"); + test(ic->getImplicitContext()->getWithDefault("foobar", "foo") == "foo"); + + ctx = ic->getImplicitContext()->getContext(); + test(p->opContext() == ctx); + + Ice::Context prxContext; + prxContext["one"] = "UN"; + prxContext["four"] = "QUATRE"; + + Ice::Context combined = prxContext; + combined.insert(ctx.begin(), ctx.end()); + test(combined["one"] == "UN"); + + p = Test::MyClassPrx::uncheckedCast(p->ice_context(prxContext)); + + ic->getImplicitContext()->setContext(Ice::Context()); + test(p->opContext() == prxContext); + + ic->getImplicitContext()->setContext(ctx); + test(p->opContext() == combined); + + ic->destroy(); + } + } + } { Ice::Double d = 1278312346.0 / 13.0; - Test::DoubleS ds(5, d); - p->opDoubleMarshaling(d, ds); + Test::DoubleS ds(5, d); + p->opDoubleMarshaling(d, ds); } } diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp index 55cfdaf9841..37bdf2895b4 100644 --- a/cpp/test/Ice/operations/TwowaysAMI.cpp +++ b/cpp/test/Ice/operations/TwowaysAMI.cpp @@ -29,7 +29,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -39,26 +39,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -72,12 +72,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -89,12 +89,12 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); + test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); called(); } }; @@ -107,14 +107,14 @@ public: virtual void ice_response(::Ice::Byte r, ::Ice::Byte b) { - test(b == Ice::Byte(0xf0)); - test(r == Ice::Byte(0xff)); - called(); + test(b == Ice::Byte(0xf0)); + test(r == Ice::Byte(0xff)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -126,12 +126,12 @@ public: virtual void ice_response(::Ice::Byte r, ::Ice::Byte b) { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); + test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); called(); } }; @@ -145,14 +145,14 @@ public: virtual void ice_response(bool r, bool b) { - test(b); - test(!r); - called(); + test(b); + test(!r); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -164,16 +164,16 @@ public: virtual void ice_response(::Ice::Long r, ::Ice::Short s, ::Ice::Int i, ::Ice::Long l) { - test(s == 10); - test(i == 11); - test(l == 12); - test(r == 12); - called(); + test(s == 10); + test(i == 11); + test(l == 12); + test(r == 12); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -185,15 +185,15 @@ public: virtual void ice_response(::Ice::Double r, ::Ice::Float f, ::Ice::Double d) { - test(f == Ice::Float(3.14)); - test(d == Ice::Double(1.1E10)); - test(r == Ice::Double(1.1E10)); - called(); + test(f == Ice::Float(3.14)); + test(d == Ice::Double(1.1E10)); + test(r == Ice::Double(1.1E10)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -205,14 +205,14 @@ public: virtual void ice_response(const ::std::string& r, const ::std::string& s) { - test(s == "world hello"); - test(r == "hello world"); - called(); + test(s == "world hello"); + test(r == "hello world"); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -224,14 +224,14 @@ public: virtual void ice_response(::Test::MyEnum r, ::Test::MyEnum e) { - test(e == Test::enum2); - test(r == Test::enum3); - called(); + test(e == Test::enum2); + test(r == Test::enum3); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -248,29 +248,29 @@ public: virtual void ice_response(const ::Test::MyClassPrx& r, const ::Test::MyClassPrx& c1, const ::Test::MyClassPrx& c2) { - test(c1->ice_getIdentity() == _communicator->stringToIdentity("test")); - test(c2->ice_getIdentity() == _communicator->stringToIdentity("noSuchIdentity")); - test(r->ice_getIdentity() == _communicator->stringToIdentity("test")); - // We can't do the callbacks below in thread per connection mode. - if(!_communicator->getProperties()->getPropertyAsInt("Ice.ThreadPerConnection")) - { - r->opVoid(); - c1->opVoid(); - try - { - c2->opVoid(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - } - called(); + test(c1->ice_getIdentity() == _communicator->stringToIdentity("test")); + test(c2->ice_getIdentity() == _communicator->stringToIdentity("noSuchIdentity")); + test(r->ice_getIdentity() == _communicator->stringToIdentity("test")); + // We can't do the callbacks below in thread per connection mode. + if(!_communicator->getProperties()->getPropertyAsInt("Ice.ThreadPerConnection")) + { + r->opVoid(); + c1->opVoid(); + try + { + c2->opVoid(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + } + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } private: @@ -291,22 +291,22 @@ public: virtual void ice_response(const ::Test::Structure& rso, const ::Test::Structure& so) { - test(rso.p == 0); - test(rso.e == Test::enum2); - test(rso.s.s == "def"); - test(so.e == Test::enum3); - test(so.s.s == "a new string"); - // We can't do the callbacks below in thread per connection mode. - if(!_communicator->getProperties()->getPropertyAsInt("Ice.ThreadPerConnection")) - { - so.p->opVoid(); - } - called(); + test(rso.p == 0); + test(rso.e == Test::enum2); + test(rso.s.s == "def"); + test(so.e == Test::enum3); + test(so.s.s == "a new string"); + // We can't do the callbacks below in thread per connection mode. + if(!_communicator->getProperties()->getPropertyAsInt("Ice.ThreadPerConnection")) + { + so.p->opVoid(); + } + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } private: @@ -322,26 +322,26 @@ public: virtual void ice_response(const ::Test::ByteS& rso, const ::Test::ByteS& bso) { - test(bso.size() == 4); - test(bso[0] == Ice::Byte(0x22)); - test(bso[1] == Ice::Byte(0x12)); - test(bso[2] == Ice::Byte(0x11)); - test(bso[3] == Ice::Byte(0x01)); - test(rso.size() == 8); - test(rso[0] == Ice::Byte(0x01)); - test(rso[1] == Ice::Byte(0x11)); - test(rso[2] == Ice::Byte(0x12)); - test(rso[3] == Ice::Byte(0x22)); - test(rso[4] == Ice::Byte(0xf1)); - test(rso[5] == Ice::Byte(0xf2)); - test(rso[6] == Ice::Byte(0xf3)); - test(rso[7] == Ice::Byte(0xf4)); - called(); + test(bso.size() == 4); + test(bso[0] == Ice::Byte(0x22)); + test(bso[1] == Ice::Byte(0x12)); + test(bso[2] == Ice::Byte(0x11)); + test(bso[3] == Ice::Byte(0x01)); + test(rso.size() == 8); + test(rso[0] == Ice::Byte(0x01)); + test(rso[1] == Ice::Byte(0x11)); + test(rso[2] == Ice::Byte(0x12)); + test(rso[3] == Ice::Byte(0x22)); + test(rso[4] == Ice::Byte(0xf1)); + test(rso[5] == Ice::Byte(0xf2)); + test(rso[6] == Ice::Byte(0xf3)); + test(rso[7] == Ice::Byte(0xf4)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -353,21 +353,21 @@ public: virtual void ice_response(const ::Test::BoolS& rso, const ::Test::BoolS& bso) { - test(bso.size() == 4); - test(bso[0]); - test(bso[1]); - test(!bso[2]); - test(!bso[3]); - test(rso.size() == 3); - test(!rso[0]); - test(rso[1]); - test(rso[2]); - called(); + test(bso.size() == 4); + test(bso[0]); + test(bso[1]); + test(!bso[2]); + test(!bso[3]); + test(rso.size() == 3); + test(!rso[0]); + test(rso[1]); + test(rso[2]); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -378,34 +378,34 @@ class AMI_MyClass_opShortIntLongSI : public Test::AMI_MyClass_opShortIntLongS, p public: virtual void ice_response(const ::Test::LongS& rso, const ::Test::ShortS& sso, const ::Test::IntS& iso, - const ::Test::LongS& lso) - { - test(sso.size() == 3); - test(sso[0] == 1); - test(sso[1] == 2); - test(sso[2] == 3); - test(iso.size() == 4); - test(iso[0] == 8); - test(iso[1] == 7); - test(iso[2] == 6); - test(iso[3] == 5); - test(lso.size() == 6); - test(lso[0] == 10); - test(lso[1] == 30); - test(lso[2] == 20); - test(lso[3] == 10); - test(lso[4] == 30); - test(lso[5] == 20); - test(rso.size() == 3); - test(rso[0] == 10); - test(rso[1] == 30); - test(rso[2] == 20); - called(); + const ::Test::LongS& lso) + { + test(sso.size() == 3); + test(sso[0] == 1); + test(sso[1] == 2); + test(sso[2] == 3); + test(iso.size() == 4); + test(iso[0] == 8); + test(iso[1] == 7); + test(iso[2] == 6); + test(iso[3] == 5); + test(lso.size() == 6); + test(lso[0] == 10); + test(lso[1] == 30); + test(lso[2] == 20); + test(lso[3] == 10); + test(lso[4] == 30); + test(lso[5] == 20); + test(rso.size() == 3); + test(rso[0] == 10); + test(rso[1] == 30); + test(rso[2] == 20); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -417,25 +417,25 @@ public: virtual void ice_response(const ::Test::DoubleS& rso, const ::Test::FloatS& fso, const ::Test::DoubleS& dso) { - test(fso.size() == 2); - test(fso[0] == ::Ice::Float(3.14)); - test(fso[1] == ::Ice::Float(1.11)); - test(dso.size() == 3); - test(dso[0] == ::Ice::Double(1.3E10)); - test(dso[1] == ::Ice::Double(1.2E10)); - test(dso[2] == ::Ice::Double(1.1E10)); - test(rso.size() == 5); - test(rso[0] == ::Ice::Double(1.1E10)); - test(rso[1] == ::Ice::Double(1.2E10)); - test(rso[2] == ::Ice::Double(1.3E10)); - test(::Ice::Float(rso[3]) == ::Ice::Float(3.14)); - test(::Ice::Float(rso[4]) == ::Ice::Float(1.11)); - called(); + test(fso.size() == 2); + test(fso[0] == ::Ice::Float(3.14)); + test(fso[1] == ::Ice::Float(1.11)); + test(dso.size() == 3); + test(dso[0] == ::Ice::Double(1.3E10)); + test(dso[1] == ::Ice::Double(1.2E10)); + test(dso[2] == ::Ice::Double(1.1E10)); + test(rso.size() == 5); + test(rso[0] == ::Ice::Double(1.1E10)); + test(rso[1] == ::Ice::Double(1.2E10)); + test(rso[2] == ::Ice::Double(1.3E10)); + test(::Ice::Float(rso[3]) == ::Ice::Float(3.14)); + test(::Ice::Float(rso[4]) == ::Ice::Float(1.11)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -447,21 +447,21 @@ public: virtual void ice_response(const ::Test::StringS& rso, const ::Test::StringS& sso) { - test(sso.size() == 4); - test(sso[0] == "abc"); - test(sso[1] == "de"); - test(sso[2] == "fghi"); - test(sso[3] == "xyz"); - test(rso.size() == 3); - test(rso[0] == "fghi"); - test(rso[1] == "de"); - test(rso[2] == "abc"); - called(); + test(sso.size() == 4); + test(sso[0] == "abc"); + test(sso[1] == "de"); + test(sso[2] == "fghi"); + test(sso[3] == "xyz"); + test(rso.size() == 3); + test(rso[0] == "fghi"); + test(rso[1] == "de"); + test(rso[2] == "abc"); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -473,31 +473,31 @@ public: virtual void ice_response(const ::Test::ByteSS& rso, const ::Test::ByteSS& bso) { - test(bso.size() == 2); - test(bso[0].size() == 1); - test(bso[0][0] == Ice::Byte(0xff)); - test(bso[1].size() == 3); - test(bso[1][0] == Ice::Byte(0x01)); - test(bso[1][1] == Ice::Byte(0x11)); - test(bso[1][2] == Ice::Byte(0x12)); - test(rso.size() == 4); - test(rso[0].size() == 3); - test(rso[0][0] == Ice::Byte(0x01)); - test(rso[0][1] == Ice::Byte(0x11)); - test(rso[0][2] == Ice::Byte(0x12)); - test(rso[1].size() == 1); - test(rso[1][0] == Ice::Byte(0xff)); - test(rso[2].size() == 1); - test(rso[2][0] == Ice::Byte(0x0e)); - test(rso[3].size() == 2); - test(rso[3][0] == Ice::Byte(0xf2)); - test(rso[3][1] == Ice::Byte(0xf1)); - called(); + test(bso.size() == 2); + test(bso[0].size() == 1); + test(bso[0][0] == Ice::Byte(0xff)); + test(bso[1].size() == 3); + test(bso[1][0] == Ice::Byte(0x01)); + test(bso[1][1] == Ice::Byte(0x11)); + test(bso[1][2] == Ice::Byte(0x12)); + test(rso.size() == 4); + test(rso[0].size() == 3); + test(rso[0][0] == Ice::Byte(0x01)); + test(rso[0][1] == Ice::Byte(0x11)); + test(rso[0][2] == Ice::Byte(0x12)); + test(rso[1].size() == 1); + test(rso[1][0] == Ice::Byte(0xff)); + test(rso[2].size() == 1); + test(rso[2][0] == Ice::Byte(0x0e)); + test(rso[3].size() == 2); + test(rso[3][0] == Ice::Byte(0xf2)); + test(rso[3][1] == Ice::Byte(0xf1)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -509,12 +509,12 @@ public: virtual void ice_response(const ::Test::BoolSS&, const ::Test::BoolSS& bso) { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -525,14 +525,14 @@ class AMI_MyClass_opShortIntLongSSI : public Test::AMI_MyClass_opShortIntLongSS, public: virtual void ice_response(const ::Test::LongSS&, const ::Test::ShortSS&, const ::Test::IntSS&, - const ::Test::LongSS&) + const ::Test::LongSS&) { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -544,32 +544,32 @@ public: virtual void ice_response(const ::Test::DoubleSS& rso, const ::Test::FloatSS& fso, const ::Test::DoubleSS& dso) { - test(fso.size() == 3); - test(fso[0].size() == 1); - test(fso[0][0] == ::Ice::Float(3.14)); - test(fso[1].size() == 1); - test(fso[1][0] == ::Ice::Float(1.11)); - test(fso[2].size() == 0); - test(dso.size() == 1); - test(dso[0].size() == 3); - test(dso[0][0] == ::Ice::Double(1.1E10)); - test(dso[0][1] == ::Ice::Double(1.2E10)); - test(dso[0][2] == ::Ice::Double(1.3E10)); - test(rso.size() == 2); - test(rso[0].size() == 3); - test(rso[0][0] == ::Ice::Double(1.1E10)); - test(rso[0][1] == ::Ice::Double(1.2E10)); - test(rso[0][2] == ::Ice::Double(1.3E10)); - test(rso[1].size() == 3); - test(rso[1][0] == ::Ice::Double(1.1E10)); - test(rso[1][1] == ::Ice::Double(1.2E10)); - test(rso[1][2] == ::Ice::Double(1.3E10)); - called(); + test(fso.size() == 3); + test(fso[0].size() == 1); + test(fso[0][0] == ::Ice::Float(3.14)); + test(fso[1].size() == 1); + test(fso[1][0] == ::Ice::Float(1.11)); + test(fso[2].size() == 0); + test(dso.size() == 1); + test(dso[0].size() == 3); + test(dso[0][0] == ::Ice::Double(1.1E10)); + test(dso[0][1] == ::Ice::Double(1.2E10)); + test(dso[0][2] == ::Ice::Double(1.3E10)); + test(rso.size() == 2); + test(rso[0].size() == 3); + test(rso[0][0] == ::Ice::Double(1.1E10)); + test(rso[0][1] == ::Ice::Double(1.2E10)); + test(rso[0][2] == ::Ice::Double(1.3E10)); + test(rso[1].size() == 3); + test(rso[1][0] == ::Ice::Double(1.1E10)); + test(rso[1][1] == ::Ice::Double(1.2E10)); + test(rso[1][2] == ::Ice::Double(1.3E10)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -581,27 +581,27 @@ public: virtual void ice_response(const ::Test::StringSS& rso, const ::Test::StringSS& sso) { - test(sso.size() == 5); - test(sso[0].size() == 1); - test(sso[0][0] == "abc"); - test(sso[1].size() == 2); - test(sso[1][0] == "de"); - test(sso[1][1] == "fghi"); - test(sso[2].size() == 0); - test(sso[3].size() == 0); - test(sso[4].size() == 1); - test(sso[4][0] == "xyz"); - test(rso.size() == 3); - test(rso[0].size() == 1); - test(rso[0][0] == "xyz"); - test(rso[1].size() == 0); - test(rso[2].size() == 0); - called(); + test(sso.size() == 5); + test(sso[0].size() == 1); + test(sso[0][0] == "abc"); + test(sso[1].size() == 2); + test(sso[1][0] == "de"); + test(sso[1][1] == "fghi"); + test(sso[2].size() == 0); + test(sso[3].size() == 0); + test(sso[4].size() == 1); + test(sso[4][0] == "xyz"); + test(rso.size() == 3); + test(rso[0].size() == 1); + test(rso[0][0] == "xyz"); + test(rso[1].size() == 0); + test(rso[2].size() == 0); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -613,25 +613,25 @@ public: virtual void ice_response(const ::Test::ByteBoolD& ro, const ::Test::ByteBoolD& _do) { - Test::ByteBoolD di1; - di1[10] = true; - di1[100] = false; - test(_do == di1); - test(ro.size() == 4); - test(ro.find(10) != ro.end()); - test(ro.find(10)->second == true); - test(ro.find(11) != ro.end()); - test(ro.find(11)->second == false); - test(ro.find(100) != ro.end()); - test(ro.find(100)->second == false); - test(ro.find(101) != ro.end()); - test(ro.find(101)->second == true); - called(); + Test::ByteBoolD di1; + di1[10] = true; + di1[100] = false; + test(_do == di1); + test(ro.size() == 4); + test(ro.find(10) != ro.end()); + test(ro.find(10)->second == true); + test(ro.find(11) != ro.end()); + test(ro.find(11)->second == false); + test(ro.find(100) != ro.end()); + test(ro.find(100)->second == false); + test(ro.find(101) != ro.end()); + test(ro.find(101)->second == true); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -643,25 +643,25 @@ public: virtual void ice_response(const ::Test::ShortIntD& ro, const ::Test::ShortIntD& _do) { - Test::ShortIntD di1; - di1[110] = -1; - di1[1100] = 123123; - test(_do == di1); - test(ro.size() == 4); - test(ro.find(110) != ro.end()); - test(ro.find(110)->second == -1); - test(ro.find(111) != ro.end()); - test(ro.find(111)->second == -100); - test(ro.find(1100) != ro.end()); - test(ro.find(1100)->second == 123123); - test(ro.find(1101) != ro.end()); - test(ro.find(1101)->second == 0); - called(); + Test::ShortIntD di1; + di1[110] = -1; + di1[1100] = 123123; + test(_do == di1); + test(ro.size() == 4); + test(ro.find(110) != ro.end()); + test(ro.find(110)->second == -1); + test(ro.find(111) != ro.end()); + test(ro.find(111)->second == -100); + test(ro.find(1100) != ro.end()); + test(ro.find(1100)->second == 123123); + test(ro.find(1101) != ro.end()); + test(ro.find(1101)->second == 0); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -673,25 +673,25 @@ public: virtual void ice_response(const ::Test::LongFloatD& ro, const ::Test::LongFloatD& _do) { - Test::LongFloatD di1; - di1[999999110] = Ice::Float(-1.1); - di1[999999111] = Ice::Float(123123.2); - test(_do == di1); - test(ro.size() == 4); - test(ro.find(999999110) != ro.end()); - test(ro.find(999999110)->second == Ice::Float(-1.1)); - test(ro.find(999999120) != ro.end()); - test(ro.find(999999120)->second == Ice::Float(-100.4)); - test(ro.find(999999111) != ro.end()); - test(ro.find(999999111)->second == Ice::Float(123123.2)); - test(ro.find(999999130) != ro.end()); - test(ro.find(999999130)->second == Ice::Float(0.5)); - called(); + Test::LongFloatD di1; + di1[999999110] = Ice::Float(-1.1); + di1[999999111] = Ice::Float(123123.2); + test(_do == di1); + test(ro.size() == 4); + test(ro.find(999999110) != ro.end()); + test(ro.find(999999110)->second == Ice::Float(-1.1)); + test(ro.find(999999120) != ro.end()); + test(ro.find(999999120)->second == Ice::Float(-100.4)); + test(ro.find(999999111) != ro.end()); + test(ro.find(999999111)->second == Ice::Float(123123.2)); + test(ro.find(999999130) != ro.end()); + test(ro.find(999999130)->second == Ice::Float(0.5)); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -703,25 +703,25 @@ public: virtual void ice_response(const ::Test::StringStringD& ro, const ::Test::StringStringD& _do) { - Test::StringStringD di1; - di1["foo"] = "abc -1.1"; - di1["bar"] = "abc 123123.2"; - test(_do == di1); - test(ro.size() == 4); - test(ro.find("foo") != ro.end()); - test(ro.find("foo")->second == "abc -1.1"); - test(ro.find("FOO") != ro.end()); - test(ro.find("FOO")->second == "abc -100.4"); - test(ro.find("bar") != ro.end()); - test(ro.find("bar")->second == "abc 123123.2"); - test(ro.find("BAR") != ro.end()); - test(ro.find("BAR")->second == "abc 0.5"); - called(); + Test::StringStringD di1; + di1["foo"] = "abc -1.1"; + di1["bar"] = "abc 123123.2"; + test(_do == di1); + test(ro.size() == 4); + test(ro.find("foo") != ro.end()); + test(ro.find("foo")->second == "abc -1.1"); + test(ro.find("FOO") != ro.end()); + test(ro.find("FOO")->second == "abc -100.4"); + test(ro.find("bar") != ro.end()); + test(ro.find("bar")->second == "abc 123123.2"); + test(ro.find("BAR") != ro.end()); + test(ro.find("BAR")->second == "abc 0.5"); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -733,25 +733,25 @@ public: virtual void ice_response(const ::Test::StringMyEnumD& ro, const ::Test::StringMyEnumD& _do) { - Test::StringMyEnumD di1; - di1["abc"] = Test::enum1; - di1[""] = Test::enum2; - test(_do == di1); - test(ro.size() == 4); - test(ro.find("abc") != ro.end()); - test(ro.find("abc")->second == Test::enum1); - test(ro.find("qwerty") != ro.end()); - test(ro.find("qwerty")->second == Test::enum3); - test(ro.find("") != ro.end()); - test(ro.find("")->second == Test::enum2); - test(ro.find("Hello!!") != ro.end()); - test(ro.find("Hello!!")->second == Test::enum2); - called(); + Test::StringMyEnumD di1; + di1["abc"] = Test::enum1; + di1[""] = Test::enum2; + test(_do == di1); + test(ro.size() == 4); + test(ro.find("abc") != ro.end()); + test(ro.find("abc")->second == Test::enum1); + test(ro.find("qwerty") != ro.end()); + test(ro.find("qwerty")->second == Test::enum3); + test(ro.find("") != ro.end()); + test(ro.find("")->second == Test::enum2); + test(ro.find("Hello!!") != ro.end()); + test(ro.find("Hello!!")->second == Test::enum2); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -765,17 +765,17 @@ public: virtual void ice_response(const Test::IntS& r) { - test(r.size() == static_cast<size_t>(_l)); - for(int j = 0; j < _l; ++j) - { - test(r[j] == -j); - } - called(); + test(r.size() == static_cast<size_t>(_l)); + for(int j = 0; j < _l; ++j) + { + test(r[j] == -j); + } + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } private: @@ -795,13 +795,13 @@ public: virtual void ice_response(const Test::StringStringD& r) { - test(r == _d); - called(); + test(r == _d); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } private: @@ -821,13 +821,13 @@ public: virtual void ice_response(const Test::StringStringD& r) { - test(r != _d); - called(); + test(r != _d); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } private: @@ -843,12 +843,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -860,12 +860,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(false); + test(false); } }; @@ -876,541 +876,541 @@ twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) { { // Check that a call to a void operation raises TwowayOnlyException - // in the ice_exception() callback instead of at the point of call. - Test::MyClassPrx oneway = Test::MyClassPrx::uncheckedCast(p->ice_oneway()); - AMI_MyClass_opVoidExIPtr cb = new AMI_MyClass_opVoidExI; - try { - oneway->opVoid_async(cb); - } - catch(const Ice::Exception&) - { - test(false); - } - test(cb->check()); + // in the ice_exception() callback instead of at the point of call. + Test::MyClassPrx oneway = Test::MyClassPrx::uncheckedCast(p->ice_oneway()); + AMI_MyClass_opVoidExIPtr cb = new AMI_MyClass_opVoidExI; + try { + oneway->opVoid_async(cb); + } + catch(const Ice::Exception&) + { + test(false); + } + test(cb->check()); } { // Check that a call to a twoway operation raises TwowayOnlyException - // in the ice_exception() callback instead of at the point of call. - Test::MyClassPrx oneway = Test::MyClassPrx::uncheckedCast(p->ice_oneway()); - AMI_MyClass_opByteExIPtr cb = new AMI_MyClass_opByteExI; - try - { - oneway->opByte_async(cb, 0, 0); - } - catch(const Ice::Exception&) - { - test(false); - } - test(cb->check()); + // in the ice_exception() callback instead of at the point of call. + Test::MyClassPrx oneway = Test::MyClassPrx::uncheckedCast(p->ice_oneway()); + AMI_MyClass_opByteExIPtr cb = new AMI_MyClass_opByteExI; + try + { + oneway->opByte_async(cb, 0, 0); + } + catch(const Ice::Exception&) + { + test(false); + } + test(cb->check()); } { - AMI_MyClass_opVoidIPtr cb = new AMI_MyClass_opVoidI; - p->opVoid_async(cb); - test(cb->check()); - // Let's check if we can reuse the same callback object for another call. - p->opVoid_async(cb); - test(cb->check()); + AMI_MyClass_opVoidIPtr cb = new AMI_MyClass_opVoidI; + p->opVoid_async(cb); + test(cb->check()); + // Let's check if we can reuse the same callback object for another call. + p->opVoid_async(cb); + test(cb->check()); } { - AMI_MyClass_opByteIPtr cb = new AMI_MyClass_opByteI; - p->opByte_async(cb, Ice::Byte(0xff), Ice::Byte(0x0f)); - test(cb->check()); + AMI_MyClass_opByteIPtr cb = new AMI_MyClass_opByteI; + p->opByte_async(cb, Ice::Byte(0xff), Ice::Byte(0x0f)); + test(cb->check()); } { - AMI_MyClass_opBoolIPtr cb = new AMI_MyClass_opBoolI; - p->opBool_async(cb, true, false); - test(cb->check()); + AMI_MyClass_opBoolIPtr cb = new AMI_MyClass_opBoolI; + p->opBool_async(cb, true, false); + test(cb->check()); } { - AMI_MyClass_opShortIntLongIPtr cb = new AMI_MyClass_opShortIntLongI; - p->opShortIntLong_async(cb, 10, 11, 12); - test(cb->check()); + AMI_MyClass_opShortIntLongIPtr cb = new AMI_MyClass_opShortIntLongI; + p->opShortIntLong_async(cb, 10, 11, 12); + test(cb->check()); } { - AMI_MyClass_opFloatDoubleIPtr cb = new AMI_MyClass_opFloatDoubleI; - p->opFloatDouble_async(cb, Ice::Float(3.14), Ice::Double(1.1E10)); - test(cb->check()); - // Let's check if we can reuse the same callback object for another call. - p->opFloatDouble_async(cb, Ice::Float(3.14), Ice::Double(1.1E10)); - test(cb->check()); + AMI_MyClass_opFloatDoubleIPtr cb = new AMI_MyClass_opFloatDoubleI; + p->opFloatDouble_async(cb, Ice::Float(3.14), Ice::Double(1.1E10)); + test(cb->check()); + // Let's check if we can reuse the same callback object for another call. + p->opFloatDouble_async(cb, Ice::Float(3.14), Ice::Double(1.1E10)); + test(cb->check()); } { - AMI_MyClass_opStringIPtr cb = new AMI_MyClass_opStringI; - p->opString_async(cb, "hello", "world"); - test(cb->check()); + AMI_MyClass_opStringIPtr cb = new AMI_MyClass_opStringI; + p->opString_async(cb, "hello", "world"); + test(cb->check()); } { - AMI_MyClass_opMyEnumIPtr cb = new AMI_MyClass_opMyEnumI; - p->opMyEnum_async(cb, Test::enum2); - test(cb->check()); + AMI_MyClass_opMyEnumIPtr cb = new AMI_MyClass_opMyEnumI; + p->opMyEnum_async(cb, Test::enum2); + test(cb->check()); } { - AMI_MyClass_opMyClassIPtr cb = new AMI_MyClass_opMyClassI(communicator); - p->opMyClass_async(cb, p); - test(cb->check()); + AMI_MyClass_opMyClassIPtr cb = new AMI_MyClass_opMyClassI(communicator); + p->opMyClass_async(cb, p); + test(cb->check()); } { - Test::Structure si1; - si1.p = p; - si1.e = Test::enum3; - si1.s.s = "abc"; - Test::Structure si2; - si2.p = 0; - si2.e = Test::enum2; - si2.s.s = "def"; - - AMI_MyClass_opStructIPtr cb = new AMI_MyClass_opStructI(communicator); - p->opStruct_async(cb, si1, si2); - test(cb->check()); + Test::Structure si1; + si1.p = p; + si1.e = Test::enum3; + si1.s.s = "abc"; + Test::Structure si2; + si2.p = 0; + si2.e = Test::enum2; + si2.s.s = "def"; + + AMI_MyClass_opStructIPtr cb = new AMI_MyClass_opStructI(communicator); + p->opStruct_async(cb, si1, si2); + test(cb->check()); } { - Test::ByteS bsi1; - Test::ByteS bsi2; + Test::ByteS bsi1; + Test::ByteS bsi2; - bsi1.push_back(Ice::Byte(0x01)); - bsi1.push_back(Ice::Byte(0x11)); - bsi1.push_back(Ice::Byte(0x12)); - bsi1.push_back(Ice::Byte(0x22)); + bsi1.push_back(Ice::Byte(0x01)); + bsi1.push_back(Ice::Byte(0x11)); + bsi1.push_back(Ice::Byte(0x12)); + bsi1.push_back(Ice::Byte(0x22)); - bsi2.push_back(Ice::Byte(0xf1)); - bsi2.push_back(Ice::Byte(0xf2)); - bsi2.push_back(Ice::Byte(0xf3)); - bsi2.push_back(Ice::Byte(0xf4)); + bsi2.push_back(Ice::Byte(0xf1)); + bsi2.push_back(Ice::Byte(0xf2)); + bsi2.push_back(Ice::Byte(0xf3)); + bsi2.push_back(Ice::Byte(0xf4)); - AMI_MyClass_opByteSIPtr cb = new AMI_MyClass_opByteSI; - p->opByteS_async(cb, bsi1, bsi2); - test(cb->check()); + AMI_MyClass_opByteSIPtr cb = new AMI_MyClass_opByteSI; + p->opByteS_async(cb, bsi1, bsi2); + test(cb->check()); } { - Test::BoolS bsi1; - Test::BoolS bsi2; + Test::BoolS bsi1; + Test::BoolS bsi2; - bsi1.push_back(true); - bsi1.push_back(true); - bsi1.push_back(false); + bsi1.push_back(true); + bsi1.push_back(true); + bsi1.push_back(false); - bsi2.push_back(false); + bsi2.push_back(false); - AMI_MyClass_opBoolSIPtr cb = new AMI_MyClass_opBoolSI; - p->opBoolS_async(cb, bsi1, bsi2); - test(cb->check()); + AMI_MyClass_opBoolSIPtr cb = new AMI_MyClass_opBoolSI; + p->opBoolS_async(cb, bsi1, bsi2); + test(cb->check()); } { - Test::ShortS ssi; - Test::IntS isi; - Test::LongS lsi; + Test::ShortS ssi; + Test::IntS isi; + Test::LongS lsi; - ssi.push_back(1); - ssi.push_back(2); - ssi.push_back(3); + ssi.push_back(1); + ssi.push_back(2); + ssi.push_back(3); - isi.push_back(5); - isi.push_back(6); - isi.push_back(7); - isi.push_back(8); + isi.push_back(5); + isi.push_back(6); + isi.push_back(7); + isi.push_back(8); - lsi.push_back(10); - lsi.push_back(30); - lsi.push_back(20); + lsi.push_back(10); + lsi.push_back(30); + lsi.push_back(20); - AMI_MyClass_opShortIntLongSIPtr cb = new AMI_MyClass_opShortIntLongSI; - p->opShortIntLongS_async(cb, ssi, isi, lsi); - test(cb->check()); + AMI_MyClass_opShortIntLongSIPtr cb = new AMI_MyClass_opShortIntLongSI; + p->opShortIntLongS_async(cb, ssi, isi, lsi); + test(cb->check()); } { - Test::FloatS fsi; - Test::DoubleS dsi; + Test::FloatS fsi; + Test::DoubleS dsi; - fsi.push_back(Ice::Float(3.14)); - fsi.push_back(Ice::Float(1.11)); + fsi.push_back(Ice::Float(3.14)); + fsi.push_back(Ice::Float(1.11)); - dsi.push_back(Ice::Double(1.1E10)); - dsi.push_back(Ice::Double(1.2E10)); - dsi.push_back(Ice::Double(1.3E10)); + dsi.push_back(Ice::Double(1.1E10)); + dsi.push_back(Ice::Double(1.2E10)); + dsi.push_back(Ice::Double(1.3E10)); - AMI_MyClass_opFloatDoubleSIPtr cb = new AMI_MyClass_opFloatDoubleSI; - p->opFloatDoubleS_async(cb, fsi, dsi); - test(cb->check()); + AMI_MyClass_opFloatDoubleSIPtr cb = new AMI_MyClass_opFloatDoubleSI; + p->opFloatDoubleS_async(cb, fsi, dsi); + test(cb->check()); } { - Test::StringS ssi1; - Test::StringS ssi2; + Test::StringS ssi1; + Test::StringS ssi2; - ssi1.push_back("abc"); - ssi1.push_back("de"); - ssi1.push_back("fghi"); + ssi1.push_back("abc"); + ssi1.push_back("de"); + ssi1.push_back("fghi"); - ssi2.push_back("xyz"); + ssi2.push_back("xyz"); - AMI_MyClass_opStringSIPtr cb = new AMI_MyClass_opStringSI; - p->opStringS_async(cb, ssi1, ssi2); - test(cb->check()); + AMI_MyClass_opStringSIPtr cb = new AMI_MyClass_opStringSI; + p->opStringS_async(cb, ssi1, ssi2); + test(cb->check()); } { - Test::ByteSS bsi1; - bsi1.resize(2); - Test::ByteSS bsi2; - bsi2.resize(2); + Test::ByteSS bsi1; + bsi1.resize(2); + Test::ByteSS bsi2; + bsi2.resize(2); - bsi1[0].push_back(Ice::Byte(0x01)); - bsi1[0].push_back(Ice::Byte(0x11)); - bsi1[0].push_back(Ice::Byte(0x12)); - bsi1[1].push_back(Ice::Byte(0xff)); + bsi1[0].push_back(Ice::Byte(0x01)); + bsi1[0].push_back(Ice::Byte(0x11)); + bsi1[0].push_back(Ice::Byte(0x12)); + bsi1[1].push_back(Ice::Byte(0xff)); - bsi2[0].push_back(Ice::Byte(0x0e)); - bsi2[1].push_back(Ice::Byte(0xf2)); - bsi2[1].push_back(Ice::Byte(0xf1)); + bsi2[0].push_back(Ice::Byte(0x0e)); + bsi2[1].push_back(Ice::Byte(0xf2)); + bsi2[1].push_back(Ice::Byte(0xf1)); - AMI_MyClass_opByteSSIPtr cb = new AMI_MyClass_opByteSSI; - p->opByteSS_async(cb, bsi1, bsi2); - test(cb->check()); + AMI_MyClass_opByteSSIPtr cb = new AMI_MyClass_opByteSSI; + p->opByteSS_async(cb, bsi1, bsi2); + test(cb->check()); } { - Test::FloatSS fsi; - fsi.resize(3); - Test::DoubleSS dsi; - dsi.resize(1); + Test::FloatSS fsi; + fsi.resize(3); + Test::DoubleSS dsi; + dsi.resize(1); - fsi[0].push_back(Ice::Float(3.14)); - fsi[1].push_back(Ice::Float(1.11)); + fsi[0].push_back(Ice::Float(3.14)); + fsi[1].push_back(Ice::Float(1.11)); - dsi[0].push_back(Ice::Double(1.1E10)); - dsi[0].push_back(Ice::Double(1.2E10)); - dsi[0].push_back(Ice::Double(1.3E10)); + dsi[0].push_back(Ice::Double(1.1E10)); + dsi[0].push_back(Ice::Double(1.2E10)); + dsi[0].push_back(Ice::Double(1.3E10)); - AMI_MyClass_opFloatDoubleSSIPtr cb = new AMI_MyClass_opFloatDoubleSSI; - p->opFloatDoubleSS_async(cb, fsi, dsi); - test(cb->check()); + AMI_MyClass_opFloatDoubleSSIPtr cb = new AMI_MyClass_opFloatDoubleSSI; + p->opFloatDoubleSS_async(cb, fsi, dsi); + test(cb->check()); } { - Test::StringSS ssi1; - ssi1.resize(2); - Test::StringSS ssi2; - ssi2.resize(3); + Test::StringSS ssi1; + ssi1.resize(2); + Test::StringSS ssi2; + ssi2.resize(3); - ssi1[0].push_back("abc"); - ssi1[1].push_back("de"); - ssi1[1].push_back("fghi"); + ssi1[0].push_back("abc"); + ssi1[1].push_back("de"); + ssi1[1].push_back("fghi"); - ssi2[2].push_back("xyz"); + ssi2[2].push_back("xyz"); - AMI_MyClass_opStringSSIPtr cb = new AMI_MyClass_opStringSSI; - p->opStringSS_async(cb, ssi1, ssi2); - test(cb->check()); + AMI_MyClass_opStringSSIPtr cb = new AMI_MyClass_opStringSSI; + p->opStringSS_async(cb, ssi1, ssi2); + test(cb->check()); } { - Test::ByteBoolD di1; - di1[10] = true; - di1[100] = false; - Test::ByteBoolD di2; - di2[10] = true; - di2[11] = false; - di2[101] = true; + Test::ByteBoolD di1; + di1[10] = true; + di1[100] = false; + Test::ByteBoolD di2; + di2[10] = true; + di2[11] = false; + di2[101] = true; - AMI_MyClass_opByteBoolDIPtr cb = new AMI_MyClass_opByteBoolDI; - p->opByteBoolD_async(cb, di1, di2); - test(cb->check()); + AMI_MyClass_opByteBoolDIPtr cb = new AMI_MyClass_opByteBoolDI; + p->opByteBoolD_async(cb, di1, di2); + test(cb->check()); } { - Test::ShortIntD di1; - di1[110] = -1; - di1[1100] = 123123; - Test::ShortIntD di2; - di2[110] = -1; - di2[111] = -100; - di2[1101] = 0; + Test::ShortIntD di1; + di1[110] = -1; + di1[1100] = 123123; + Test::ShortIntD di2; + di2[110] = -1; + di2[111] = -100; + di2[1101] = 0; - AMI_MyClass_opShortIntDIPtr cb = new AMI_MyClass_opShortIntDI; - p->opShortIntD_async(cb, di1, di2); - test(cb->check()); + AMI_MyClass_opShortIntDIPtr cb = new AMI_MyClass_opShortIntDI; + p->opShortIntD_async(cb, di1, di2); + test(cb->check()); } { - Test::LongFloatD di1; - di1[999999110] = Ice::Float(-1.1); - di1[999999111] = Ice::Float(123123.2); - Test::LongFloatD di2; - di2[999999110] = Ice::Float(-1.1); - di2[999999120] = Ice::Float(-100.4); - di2[999999130] = Ice::Float(0.5); + Test::LongFloatD di1; + di1[999999110] = Ice::Float(-1.1); + di1[999999111] = Ice::Float(123123.2); + Test::LongFloatD di2; + di2[999999110] = Ice::Float(-1.1); + di2[999999120] = Ice::Float(-100.4); + di2[999999130] = Ice::Float(0.5); - AMI_MyClass_opLongFloatDIPtr cb = new AMI_MyClass_opLongFloatDI; - p->opLongFloatD_async(cb, di1, di2); - test(cb->check()); + AMI_MyClass_opLongFloatDIPtr cb = new AMI_MyClass_opLongFloatDI; + p->opLongFloatD_async(cb, di1, di2); + test(cb->check()); } { - Test::StringStringD di1; - di1["foo"] = "abc -1.1"; - di1["bar"] = "abc 123123.2"; - Test::StringStringD di2; - di2["foo"] = "abc -1.1"; - di2["FOO"] = "abc -100.4"; - di2["BAR"] = "abc 0.5"; + Test::StringStringD di1; + di1["foo"] = "abc -1.1"; + di1["bar"] = "abc 123123.2"; + Test::StringStringD di2; + di2["foo"] = "abc -1.1"; + di2["FOO"] = "abc -100.4"; + di2["BAR"] = "abc 0.5"; - AMI_MyClass_opStringStringDIPtr cb = new AMI_MyClass_opStringStringDI; - p->opStringStringD_async(cb, di1, di2); - test(cb->check()); + AMI_MyClass_opStringStringDIPtr cb = new AMI_MyClass_opStringStringDI; + p->opStringStringD_async(cb, di1, di2); + test(cb->check()); } { - Test::StringMyEnumD di1; - di1["abc"] = Test::enum1; - di1[""] = Test::enum2; - Test::StringMyEnumD di2; - di2["abc"] = Test::enum1; - di2["qwerty"] = Test::enum3; - di2["Hello!!"] = Test::enum2; - - AMI_MyClass_opStringMyEnumDIPtr cb = new AMI_MyClass_opStringMyEnumDI; - p->opStringMyEnumD_async(cb, di1, di2); - test(cb->check()); - } + Test::StringMyEnumD di1; + di1["abc"] = Test::enum1; + di1[""] = Test::enum2; + Test::StringMyEnumD di2; + di2["abc"] = Test::enum1; + di2["qwerty"] = Test::enum3; + di2["Hello!!"] = Test::enum2; + + AMI_MyClass_opStringMyEnumDIPtr cb = new AMI_MyClass_opStringMyEnumDI; + p->opStringMyEnumD_async(cb, di1, di2); + test(cb->check()); + } { - const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; - - for(int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) - { - Test::IntS s; - for(int i = 0; i < lengths[l]; ++i) - { - s.push_back(i); - } - AMI_MyClass_opIntSIPtr cb = new AMI_MyClass_opIntSI(lengths[l]); - p->opIntS_async(cb, s); - test(cb->check()); - } - } - - { - Test::StringStringD ctx; - ctx["one"] = "ONE"; - ctx["two"] = "TWO"; - ctx["three"] = "THREE"; - { - test(p->ice_getContext().empty()); - AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(ctx); - p->opContext_async(cb); - test(cb->check()); - } - { - test(p->ice_getContext().empty()); - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); - p->opContext_async(cb, ctx); - test(cb->check()); - } - Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx)); - test(p2->ice_getContext() == ctx); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); - p2->opContext_async(cb); - test(cb->check()); - } - { - Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx)); - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); - p2->opContext_async(cb, ctx); - test(cb->check()); - } - - { - // - // Test that default context is obtained correctly from communicator. - // + const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; + + for(int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) + { + Test::IntS s; + for(int i = 0; i < lengths[l]; ++i) + { + s.push_back(i); + } + AMI_MyClass_opIntSIPtr cb = new AMI_MyClass_opIntSI(lengths[l]); + p->opIntS_async(cb, s); + test(cb->check()); + } + } + + { + Test::StringStringD ctx; + ctx["one"] = "ONE"; + ctx["two"] = "TWO"; + ctx["three"] = "THREE"; + { + test(p->ice_getContext().empty()); + AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(ctx); + p->opContext_async(cb); + test(cb->check()); + } + { + test(p->ice_getContext().empty()); + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p->opContext_async(cb, ctx); + test(cb->check()); + } + Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx)); + test(p2->ice_getContext() == ctx); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p2->opContext_async(cb); + test(cb->check()); + } + { + Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx)); + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p2->opContext_async(cb, ctx); + test(cb->check()); + } + + { + // + // Test that default context is obtained correctly from communicator. + // /* DEPRECATED - Ice::Context dflt; - dflt["a"] = "b"; - communicator->setDefaultContext(dflt); - { - AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(dflt); - p->opContext_async(cb); - test(cb->check()); - } - - Test::MyClassPrx p2 = Test::MyClassPrx::uncheckedCast(p->ice_context(Ice::Context())); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(Ice::Context()); - p2->opContext_async(cb); - test(cb->check()); - } - - p2 = Test::MyClassPrx::uncheckedCast(p->ice_defaultContext()); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(dflt); - p2->opContext_async(cb); - test(cb->check()); - } - - communicator->setDefaultContext(Ice::Context()); - { - AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(Ice::Context()); - p2->opContext_async(cb); - test(cb->check()); - } - - communicator->setDefaultContext(dflt); - Test::MyClassPrx c = Test::MyClassPrx::checkedCast( - communicator->stringToProxy("test:default -p 12010 -t 10000")); - { - Ice::Context tmp; - tmp["a"] = "b"; - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); - c->opContext_async(cb); - test(cb->check()); - } - - dflt["a"] = "c"; - Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_context(dflt)); - { - Ice::Context tmp; - tmp["a"] = "c"; - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); - c2->opContext_async(cb); - test(cb->check()); - } - - dflt.clear(); - Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_context(dflt)); - { - Ice::Context tmp; - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); - c3->opContext_async(cb); - test(cb->check()); - } - - Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext()); - { - Ice::Context tmp; - tmp["a"] = "b"; - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); - c4->opContext_async(cb); - test(cb->check()); - } - - dflt["a"] = "d"; - communicator->setDefaultContext(dflt); - - Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext()); - { - Ice::Context tmp; - tmp["a"] = "d"; - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); - c5->opContext_async(cb); - test(cb->check()); - } - - communicator->setDefaultContext(Ice::Context()); + Ice::Context dflt; + dflt["a"] = "b"; + communicator->setDefaultContext(dflt); + { + AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(dflt); + p->opContext_async(cb); + test(cb->check()); + } + + Test::MyClassPrx p2 = Test::MyClassPrx::uncheckedCast(p->ice_context(Ice::Context())); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(Ice::Context()); + p2->opContext_async(cb); + test(cb->check()); + } + + p2 = Test::MyClassPrx::uncheckedCast(p->ice_defaultContext()); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(dflt); + p2->opContext_async(cb); + test(cb->check()); + } + + communicator->setDefaultContext(Ice::Context()); + { + AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(Ice::Context()); + p2->opContext_async(cb); + test(cb->check()); + } + + communicator->setDefaultContext(dflt); + Test::MyClassPrx c = Test::MyClassPrx::checkedCast( + communicator->stringToProxy("test:default -p 12010 -t 10000")); + { + Ice::Context tmp; + tmp["a"] = "b"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c->opContext_async(cb); + test(cb->check()); + } + + dflt["a"] = "c"; + Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_context(dflt)); + { + Ice::Context tmp; + tmp["a"] = "c"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c2->opContext_async(cb); + test(cb->check()); + } + + dflt.clear(); + Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_context(dflt)); + { + Ice::Context tmp; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c3->opContext_async(cb); + test(cb->check()); + } + + Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext()); + { + Ice::Context tmp; + tmp["a"] = "b"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c4->opContext_async(cb); + test(cb->check()); + } + + dflt["a"] = "d"; + communicator->setDefaultContext(dflt); + + Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext()); + { + Ice::Context tmp; + tmp["a"] = "d"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c5->opContext_async(cb); + test(cb->check()); + } + + communicator->setDefaultContext(Ice::Context()); */ - } - - { - // - // Test implicit context propagation - // - - string impls[] = {"Shared", "SharedWithoutLocking", "PerThread"}; - for(int i = 0; i < 3; i++) - { - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.ImplicitContext", impls[i]); - - Ice::CommunicatorPtr ic = Ice::initialize(initData); - - Ice::Context ctx; - ctx["one"] = "ONE"; - ctx["two"] = "TWO"; - ctx["three"] = "THREE"; - - - Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast( - ic->stringToProxy("test:default -p 12010 -t 10000")); - - - ic->getImplicitContext()->setContext(ctx); - test(ic->getImplicitContext()->getContext() == ctx); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); - p->opContext_async(cb); - test(cb->check()); - } - - ic->getImplicitContext()->set("zero", "ZERO"); - test(ic->getImplicitContext()->get("zero") == "ZERO"); - test(ic->getImplicitContext()->getWithDefault("foobar", "foo") == "foo"); - - ctx = ic->getImplicitContext()->getContext(); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); - p->opContext_async(cb); - test(cb->check()); - } - - Ice::Context prxContext; - prxContext["one"] = "UN"; - prxContext["four"] = "QUATRE"; - - Ice::Context combined = prxContext; - combined.insert(ctx.begin(), ctx.end()); - test(combined["one"] == "UN"); - - p = Test::MyClassPrx::uncheckedCast(p->ice_context(prxContext)); - - ic->getImplicitContext()->setContext(Ice::Context()); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(prxContext); - p->opContext_async(cb); - test(cb->check()); - } - - ic->getImplicitContext()->setContext(ctx); - { - AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(combined); - p->opContext_async(cb); - test(cb->check()); - } - - ic->destroy(); - } - } + } + + { + // + // Test implicit context propagation + // + + string impls[] = {"Shared", "SharedWithoutLocking", "PerThread"}; + for(int i = 0; i < 3; i++) + { + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.ImplicitContext", impls[i]); + + Ice::CommunicatorPtr ic = Ice::initialize(initData); + + Ice::Context ctx; + ctx["one"] = "ONE"; + ctx["two"] = "TWO"; + ctx["three"] = "THREE"; + + + Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast( + ic->stringToProxy("test:default -p 12010 -t 10000")); + + + ic->getImplicitContext()->setContext(ctx); + test(ic->getImplicitContext()->getContext() == ctx); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p->opContext_async(cb); + test(cb->check()); + } + + ic->getImplicitContext()->set("zero", "ZERO"); + test(ic->getImplicitContext()->get("zero") == "ZERO"); + test(ic->getImplicitContext()->getWithDefault("foobar", "foo") == "foo"); + + ctx = ic->getImplicitContext()->getContext(); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p->opContext_async(cb); + test(cb->check()); + } + + Ice::Context prxContext; + prxContext["one"] = "UN"; + prxContext["four"] = "QUATRE"; + + Ice::Context combined = prxContext; + combined.insert(ctx.begin(), ctx.end()); + test(combined["one"] == "UN"); + + p = Test::MyClassPrx::uncheckedCast(p->ice_context(prxContext)); + + ic->getImplicitContext()->setContext(Ice::Context()); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(prxContext); + p->opContext_async(cb); + test(cb->check()); + } + + ic->getImplicitContext()->setContext(ctx); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(combined); + p->opContext_async(cb); + test(cb->check()); + } + + ic->destroy(); + } + } } { Ice::Double d = 1278312346.0 / 13.0; - Test::DoubleS ds(5, d); - AMI_MyClass_opDoubleMarshalingIPtr cb = new AMI_MyClass_opDoubleMarshalingI; - p->opDoubleMarshaling_async(cb, d, ds); - test(cb->check()); + Test::DoubleS ds(5, d); + AMI_MyClass_opDoubleMarshalingIPtr cb = new AMI_MyClass_opDoubleMarshalingI; + p->opDoubleMarshaling_async(cb, d, ds); + test(cb->check()); } { - Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(p); - test(derived); - AMI_MyDerivedClass_opDerivedIPtr cb = new AMI_MyDerivedClass_opDerivedI; - derived->opDerived_async(cb); - test(cb->check()); + Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(p); + test(derived); + AMI_MyDerivedClass_opDerivedIPtr cb = new AMI_MyDerivedClass_opDerivedI; + derived->opDerived_async(cb); + test(cb->check()); } } diff --git a/cpp/test/Ice/retry/AllTests.cpp b/cpp/test/Ice/retry/AllTests.cpp index 9e9c9f353fb..4ebb0915d56 100644 --- a/cpp/test/Ice/retry/AllTests.cpp +++ b/cpp/test/Ice/retry/AllTests.cpp @@ -19,7 +19,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -29,26 +29,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -62,12 +62,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; @@ -79,13 +79,13 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const Ice::ConnectionLostException*>(&ex)); - called(); + test(dynamic_cast<const Ice::ConnectionLostException*>(&ex)); + called(); } }; @@ -118,12 +118,12 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "calling operation to kill connection with second proxy... " << flush; try { - retry2->op(true); - test(false); + retry2->op(true); + test(false); } catch(Ice::ConnectionLostException) { - cout << "ok" << endl; + cout << "ok" << endl; } cout << "calling regular operation with first proxy again... " << flush; diff --git a/cpp/test/Ice/retry/Client.cpp b/cpp/test/Ice/retry/Client.cpp index cd47cb999cc..17cad12407f 100644 --- a/cpp/test/Ice/retry/Client.cpp +++ b/cpp/test/Ice/retry/Client.cpp @@ -31,38 +31,38 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); - // - // For this test, we want to disable retries. - // - initData.properties->setProperty("Ice.RetryIntervals", "-1"); + // + // For this test, we want to disable retries. + // + initData.properties->setProperty("Ice.RetryIntervals", "-1"); - // - // This test kills connections, so we don't want warnings. - // - initData.properties->setProperty("Ice.Warn.Connections", "0"); + // + // This test kills connections, so we don't want warnings. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception&) { - status = EXIT_FAILURE; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/retry/Server.cpp b/cpp/test/Ice/retry/Server.cpp index 628bd83a2c2..2fc3aa5d171 100644 --- a/cpp/test/Ice/retry/Server.cpp +++ b/cpp/test/Ice/retry/Server.cpp @@ -32,26 +32,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/retry/TestI.cpp b/cpp/test/Ice/retry/TestI.cpp index e8c05542146..3bd0d68364d 100644 --- a/cpp/test/Ice/retry/TestI.cpp +++ b/cpp/test/Ice/retry/TestI.cpp @@ -15,7 +15,7 @@ RetryI::op(bool kill, const Ice::Current& current) { if(kill) { - current.con->close(true); + current.con->close(true); } } diff --git a/cpp/test/Ice/servantLocator/AllTests.cpp b/cpp/test/Ice/servantLocator/AllTests.cpp index 36f9fecf4d1..cbfda04dcd1 100644 --- a/cpp/test/Ice/servantLocator/AllTests.cpp +++ b/cpp/test/Ice/servantLocator/AllTests.cpp @@ -21,121 +21,121 @@ testExceptions(const TestIntfPrx& obj, bool collocated) { try { - obj->requestFailedException(); - test(false); + obj->requestFailedException(); + test(false); } catch(const ObjectNotExistException& ex) { - if(!collocated) - { - test(ex.id == obj->ice_getIdentity()); - test(ex.facet == obj->ice_getFacet()); - test(ex.operation == "requestFailedException"); - } + if(!collocated) + { + test(ex.id == obj->ice_getIdentity()); + test(ex.facet == obj->ice_getFacet()); + test(ex.operation == "requestFailedException"); + } } try { - obj->unknownUserException(); - test(false); + obj->unknownUserException(); + test(false); } catch(const UnknownUserException& ex) { - test(ex.unknown == "reason"); + test(ex.unknown == "reason"); } try { - obj->unknownLocalException(); - test(false); + obj->unknownLocalException(); + test(false); } catch(const UnknownLocalException& ex) { - test(ex.unknown == "reason"); + test(ex.unknown == "reason"); } try { - obj->unknownException(); - test(false); + obj->unknownException(); + test(false); } catch(const UnknownException& ex) { - test(ex.unknown == "reason"); + test(ex.unknown == "reason"); } try { - obj->userException(); - test(false); + obj->userException(); + test(false); } catch(const UnknownUserException& ex) { - //cerr << ex.unknown << endl; - test(!collocated); - test(ex.unknown == "Test::TestIntfUserException"); + //cerr << ex.unknown << endl; + test(!collocated); + test(ex.unknown == "Test::TestIntfUserException"); } catch(const TestIntfUserException&) { - test(collocated); + test(collocated); } try { - obj->localException(); - test(false); + obj->localException(); + test(false); } catch(const UnknownLocalException& ex) { - //cerr << ex.unknown << endl; - test(!collocated); - test(ex.unknown.find("Ice::SocketException:\nsocket exception: unknown error") != string::npos); + //cerr << ex.unknown << endl; + test(!collocated); + test(ex.unknown.find("Ice::SocketException:\nsocket exception: unknown error") != string::npos); } catch(const SocketException&) { - test(collocated); + test(collocated); } try { - obj->stdException(); - test(false); + obj->stdException(); + test(false); } catch(const UnknownException& ex) { - //cerr << ex.unknown << endl; - test(!collocated); - test(ex.unknown == "std::exception: Hello"); + //cerr << ex.unknown << endl; + test(!collocated); + test(ex.unknown == "std::exception: Hello"); } catch(const std::runtime_error&) { - test(collocated); + test(collocated); } try { - obj->cppException(); - test(false); + obj->cppException(); + test(false); } catch(const UnknownException& ex) { - //cerr << ex.unknown << endl; - test(!collocated); - test(ex.unknown == "unknown c++ exception"); + //cerr << ex.unknown << endl; + test(!collocated); + test(ex.unknown == "unknown c++ exception"); } catch(const int&) { - test(collocated); + test(collocated); } try { - obj->unknownExceptionWithServantException(); - test(false); + obj->unknownExceptionWithServantException(); + test(false); } catch(const UnknownException& ex) { - test(ex.unknown == "reason"); + test(ex.unknown == "reason"); } } @@ -158,7 +158,7 @@ allTests(const CommunicatorPtr& communicator, bool collocated) obj = TestIntfPrx::checkedCast(base); try { - TestIntfPrx::checkedCast(communicator->stringToProxy("category/unknown:default -p 12010 -t 10000")); + TestIntfPrx::checkedCast(communicator->stringToProxy("category/unknown:default -p 12010 -t 10000")); } catch(const ObjectNotExistException&) { @@ -172,14 +172,14 @@ allTests(const CommunicatorPtr& communicator, bool collocated) obj = TestIntfPrx::checkedCast(base); try { - TestIntfPrx::checkedCast(communicator->stringToProxy("anothercategory/unknown:default -p 12010 -t 10000")); + TestIntfPrx::checkedCast(communicator->stringToProxy("anothercategory/unknown:default -p 12010 -t 10000")); } catch(const ObjectNotExistException&) { } try { - TestIntfPrx::checkedCast(communicator->stringToProxy("unknown:default -p 12010 -t 10000")); + TestIntfPrx::checkedCast(communicator->stringToProxy("unknown:default -p 12010 -t 10000")); } catch(const Ice::ObjectNotExistException&) { diff --git a/cpp/test/Ice/servantLocator/Collocated.cpp b/cpp/test/Ice/servantLocator/Collocated.cpp index fec4143c667..53348a0799e 100644 --- a/cpp/test/Ice/servantLocator/Collocated.cpp +++ b/cpp/test/Ice/servantLocator/Collocated.cpp @@ -29,22 +29,22 @@ protected: virtual Ice::ObjectPtr newServantAndCookie(Ice::LocalObjectPtr& cookie) const { - cookie = new CookieI(); - return new TestI(); + cookie = new CookieI(); + return new TestI(); } virtual void checkCookie(const Ice::LocalObjectPtr& cookie) const { - Test::CookiePtr co = Test::CookiePtr::dynamicCast(cookie); - test(co); - test(co->message() == "blahblah"); + Test::CookiePtr co = Test::CookiePtr::dynamicCast(cookie); + test(co); + test(co->message() == "blahblah"); } virtual void throwTestIntfUserException() const { - throw Test::TestIntfUserException(); + throw Test::TestIntfUserException(); } }; diff --git a/cpp/test/Ice/servantLocator/ServantLocatorI.cpp b/cpp/test/Ice/servantLocator/ServantLocatorI.cpp index 4b51ac1cf29..93727d24be1 100644 --- a/cpp/test/Ice/servantLocator/ServantLocatorI.cpp +++ b/cpp/test/Ice/servantLocator/ServantLocatorI.cpp @@ -35,13 +35,13 @@ ServantLocatorI::locate(const Ice::Current& current, Ice::LocalObjectPtr& cookie if(current.id.name == "unknown") { - return 0; + return 0; } test(current.id.name == "locate" || current.id.name == "finished"); if(current.id.name == "locate") { - exception(current); + exception(current); } return newServantAndCookie(cookie); @@ -49,7 +49,7 @@ ServantLocatorI::locate(const Ice::Current& current, Ice::LocalObjectPtr& cookie void ServantLocatorI::finished(const Ice::Current& current, const Ice::ObjectPtr& servant, - const Ice::LocalObjectPtr& cookie) + const Ice::LocalObjectPtr& cookie) { test(!_deactivated); test(current.id.category == _category || _category.empty()); @@ -57,7 +57,7 @@ ServantLocatorI::finished(const Ice::Current& current, const Ice::ObjectPtr& ser if(current.id.name == "finished") { - exception(current); + exception(current); } checkCookie(cookie); @@ -76,38 +76,38 @@ ServantLocatorI::exception(const Ice::Current& current) { if(current.operation == "requestFailedException") { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } else if(current.operation == "unknownUserException") { - throw UnknownUserException(__FILE__, __LINE__, "reason"); + throw UnknownUserException(__FILE__, __LINE__, "reason"); } else if(current.operation == "unknownLocalException") { - throw UnknownLocalException(__FILE__, __LINE__, "reason"); + throw UnknownLocalException(__FILE__, __LINE__, "reason"); } else if(current.operation == "unknownException") { - throw UnknownException(__FILE__, __LINE__, "reason"); + throw UnknownException(__FILE__, __LINE__, "reason"); } else if(current.operation == "userException") { - throwTestIntfUserException(); + throwTestIntfUserException(); } else if(current.operation == "localException") { - throw Ice::SocketException(__FILE__, __LINE__, 0); + throw Ice::SocketException(__FILE__, __LINE__, 0); } else if(current.operation == "stdException") { - throw std::runtime_error("Hello"); + throw std::runtime_error("Hello"); } else if(current.operation == "cppException") { - throw 5; + throw 5; } else if(current.operation == "unknownExceptionWithServantException") { - throw UnknownException(__FILE__, __LINE__, "reason"); + throw UnknownException(__FILE__, __LINE__, "reason"); } } diff --git a/cpp/test/Ice/servantLocator/Server.cpp b/cpp/test/Ice/servantLocator/Server.cpp index d07116aed9f..8777fcd5135 100644 --- a/cpp/test/Ice/servantLocator/Server.cpp +++ b/cpp/test/Ice/servantLocator/Server.cpp @@ -28,22 +28,22 @@ protected: virtual Ice::ObjectPtr newServantAndCookie(Ice::LocalObjectPtr& cookie) const { - cookie = new CookieI(); - return new TestI(); + cookie = new CookieI(); + return new TestI(); } virtual void checkCookie(const Ice::LocalObjectPtr& cookie) const { - Test::CookiePtr co = Test::CookiePtr::dynamicCast(cookie); - test(co); - test(co->message() == "blahblah"); + Test::CookiePtr co = Test::CookiePtr::dynamicCast(cookie); + test(co); + test(co->message() == "blahblah"); } virtual void throwTestIntfUserException() const { - throw Test::TestIntfUserException(); + throw Test::TestIntfUserException(); } }; diff --git a/cpp/test/Ice/servantLocator/ServerAMD.cpp b/cpp/test/Ice/servantLocator/ServerAMD.cpp index 59ae7efe8dd..470a67c51c7 100644 --- a/cpp/test/Ice/servantLocator/ServerAMD.cpp +++ b/cpp/test/Ice/servantLocator/ServerAMD.cpp @@ -28,22 +28,22 @@ protected: virtual Ice::ObjectPtr newServantAndCookie(Ice::LocalObjectPtr& cookie) const { - cookie = new CookieI(); - return new TestAMDI(); + cookie = new CookieI(); + return new TestAMDI(); } virtual void checkCookie(const Ice::LocalObjectPtr& cookie) const { - Test::CookiePtr co = Test::CookiePtr::dynamicCast(cookie); - test(co); - test(co->message() == "blahblah"); + Test::CookiePtr co = Test::CookiePtr::dynamicCast(cookie); + test(co); + test(co->message() == "blahblah"); } virtual void throwTestIntfUserException() const { - throw Test::TestIntfUserException(); + throw Test::TestIntfUserException(); } }; diff --git a/cpp/test/Ice/slicing/exceptions/AllTests.cpp b/cpp/test/Ice/slicing/exceptions/AllTests.cpp index 49dc930773f..4a43cc2823f 100644 --- a/cpp/test/Ice/slicing/exceptions/AllTests.cpp +++ b/cpp/test/Ice/slicing/exceptions/AllTests.cpp @@ -19,7 +19,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -29,26 +29,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -61,26 +61,26 @@ class AMI_Test_baseAsBaseI : public AMI_TestIntf_baseAsBase, public CallbackBase virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Base& b) - { - test(b.b == "Base.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Base& b) + { + test(b.b == "Base.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -91,26 +91,26 @@ class AMI_Test_unknownDerivedAsBaseI : public AMI_TestIntf_unknownDerivedAsBase, virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Base& b) - { - test(b.b == "UnknownDerived.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Base& b) + { + test(b.b == "UnknownDerived.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -121,27 +121,27 @@ class AMI_Test_knownDerivedAsBaseI : public AMI_TestIntf_knownDerivedAsBase, pub virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownDerived& k) - { - test(k.b == "KnownDerived.b"); - test(k.kd == "KnownDerived.kd"); - test(k.ice_name() =="Test::KnownDerived"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownDerived& k) + { + test(k.b == "KnownDerived.b"); + test(k.kd == "KnownDerived.kd"); + test(k.ice_name() =="Test::KnownDerived"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -152,27 +152,27 @@ class AMI_Test_knownDerivedAsKnownDerivedI : public AMI_TestIntf_knownDerivedAsK virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownDerived& k) - { - test(k.b == "KnownDerived.b"); - test(k.kd == "KnownDerived.kd"); - test(k.ice_name() =="Test::KnownDerived"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownDerived& k) + { + test(k.b == "KnownDerived.b"); + test(k.kd == "KnownDerived.kd"); + test(k.ice_name() =="Test::KnownDerived"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -183,26 +183,26 @@ class AMI_Test_unknownIntermediateAsBaseI : public AMI_TestIntf_unknownIntermedi virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Base& b) - { - test(b.b == "UnknownIntermediate.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Base& b) + { + test(b.b == "UnknownIntermediate.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -213,60 +213,60 @@ class AMI_Test_knownIntermediateAsBaseI : public AMI_TestIntf_knownIntermediateA virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "KnownIntermediate.b"); - test(ki.ki == "KnownIntermediate.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "KnownIntermediate.b"); + test(ki.ki == "KnownIntermediate.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } + called(); } }; typedef IceUtil::Handle<AMI_Test_knownIntermediateAsBaseI> AMI_Test_knownIntermediateAsBaseIPtr; class AMI_Test_knownMostDerivedAsBaseI : public AMI_TestIntf_knownMostDerivedAsBase, - public CallbackBase + public CallbackBase { virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownMostDerived& kmd) - { - test(kmd.b == "KnownMostDerived.b"); - test(kmd.ki == "KnownMostDerived.ki"); - test(kmd.kmd == "KnownMostDerived.kmd"); - test(kmd.ice_name() =="Test::KnownMostDerived"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownMostDerived& kmd) + { + test(kmd.b == "KnownMostDerived.b"); + test(kmd.ki == "KnownMostDerived.ki"); + test(kmd.kmd == "KnownMostDerived.kmd"); + test(kmd.ice_name() =="Test::KnownMostDerived"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -278,27 +278,27 @@ class AMI_Test_knownIntermediateAsKnownIntermediateI : public AMI_TestIntf_known virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "KnownIntermediate.b"); - test(ki.ki == "KnownIntermediate.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "KnownIntermediate.b"); + test(ki.ki == "KnownIntermediate.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -310,28 +310,28 @@ class AMI_Test_knownMostDerivedAsKnownMostDerivedI : public AMI_TestIntf_knownMo virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownMostDerived& kmd) - { - test(kmd.b == "KnownMostDerived.b"); - test(kmd.ki == "KnownMostDerived.ki"); - test(kmd.kmd == "KnownMostDerived.kmd"); - test(kmd.ice_name() =="Test::KnownMostDerived"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownMostDerived& kmd) + { + test(kmd.b == "KnownMostDerived.b"); + test(kmd.ki == "KnownMostDerived.ki"); + test(kmd.kmd == "KnownMostDerived.kmd"); + test(kmd.ice_name() =="Test::KnownMostDerived"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -343,28 +343,28 @@ class AMI_Test_knownMostDerivedAsKnownIntermediateI : public AMI_TestIntf_knownM virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownMostDerived& kmd) - { - test(kmd.b == "KnownMostDerived.b"); - test(kmd.ki == "KnownMostDerived.ki"); - test(kmd.kmd == "KnownMostDerived.kmd"); - test(kmd.ice_name() =="Test::KnownMostDerived"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownMostDerived& kmd) + { + test(kmd.b == "KnownMostDerived.b"); + test(kmd.ki == "KnownMostDerived.ki"); + test(kmd.kmd == "KnownMostDerived.kmd"); + test(kmd.ice_name() =="Test::KnownMostDerived"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -376,27 +376,27 @@ class AMI_Test_unknownMostDerived1AsBaseI : public AMI_TestIntf_unknownMostDeriv virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "UnknownMostDerived1.b"); - test(ki.ki == "UnknownMostDerived1.ki"); - test(string(ki.ice_name()) =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "UnknownMostDerived1.b"); + test(ki.ki == "UnknownMostDerived1.ki"); + test(string(ki.ice_name()) =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -408,32 +408,32 @@ class AMI_Test_unknownMostDerived1AsKnownIntermediateI : public AMI_TestIntf_unk virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "UnknownMostDerived1.b"); - test(ki.ki == "UnknownMostDerived1.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "UnknownMostDerived1.b"); + test(ki.ki == "UnknownMostDerived1.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } + called(); } }; typedef IceUtil::Handle<AMI_Test_unknownMostDerived1AsKnownIntermediateI> - AMI_Test_unknownMostDerived1AsKnownIntermediateIPtr; + AMI_Test_unknownMostDerived1AsKnownIntermediateIPtr; class AMI_Test_unknownMostDerived2AsBaseI : public AMI_TestIntf_unknownMostDerived2AsBase, public CallbackBase @@ -441,26 +441,26 @@ class AMI_Test_unknownMostDerived2AsBaseI : public AMI_TestIntf_unknownMostDeriv virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { - try - { - exc.ice_throw(); - } - catch(const Base& b) - { - test(b.b == "UnknownMostDerived2.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } - called(); + try + { + exc.ice_throw(); + } + catch(const Base& b) + { + test(b.b == "UnknownMostDerived2.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } + called(); } }; @@ -474,364 +474,364 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "base... " << flush; { - try - { - test->baseAsBase(); - test(false); - } - catch(const Base& b) - { - test(b.b == "Base.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } + try + { + test->baseAsBase(); + test(false); + } + catch(const Base& b) + { + test(b.b == "Base.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "base (AMI)... " << flush; { - AMI_Test_baseAsBaseIPtr cb = new AMI_Test_baseAsBaseI; - test->baseAsBase_async(cb); - test(cb->check()); + AMI_Test_baseAsBaseIPtr cb = new AMI_Test_baseAsBaseI; + test->baseAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of unknown derived... " << flush; { - try - { - test->unknownDerivedAsBase(); - test(false); - } - catch(const Base& b) - { - test(b.b == "UnknownDerived.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } + try + { + test->unknownDerivedAsBase(); + test(false); + } + catch(const Base& b) + { + test(b.b == "UnknownDerived.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of unknown derived (AMI)... " << flush; { - AMI_Test_unknownDerivedAsBaseIPtr cb = new AMI_Test_unknownDerivedAsBaseI; - test->unknownDerivedAsBase_async(cb); - test(cb->check()); + AMI_Test_unknownDerivedAsBaseIPtr cb = new AMI_Test_unknownDerivedAsBaseI; + test->unknownDerivedAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "non-slicing of known derived as base... " << flush; { - try - { - test->knownDerivedAsBase(); - test(false); - } - catch(const KnownDerived& k) - { - test(k.b == "KnownDerived.b"); - test(k.kd == "KnownDerived.kd"); - test(k.ice_name() =="Test::KnownDerived"); - } - catch(...) - { - test(false); - } + try + { + test->knownDerivedAsBase(); + test(false); + } + catch(const KnownDerived& k) + { + test(k.b == "KnownDerived.b"); + test(k.kd == "KnownDerived.kd"); + test(k.ice_name() =="Test::KnownDerived"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "non-slicing of known derived as base (AMI)... " << flush; { - AMI_Test_knownDerivedAsBaseIPtr cb = new AMI_Test_knownDerivedAsBaseI; - test->knownDerivedAsBase_async(cb); - test(cb->check()); + AMI_Test_knownDerivedAsBaseIPtr cb = new AMI_Test_knownDerivedAsBaseI; + test->knownDerivedAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "non-slicing of known derived as derived... " << flush; { - try - { - test->knownDerivedAsKnownDerived(); - test(false); - } - catch(const KnownDerived& k) - { - test(k.b == "KnownDerived.b"); - test(k.kd == "KnownDerived.kd"); - test(k.ice_name() =="Test::KnownDerived"); - } - catch(...) - { - test(false); - } + try + { + test->knownDerivedAsKnownDerived(); + test(false); + } + catch(const KnownDerived& k) + { + test(k.b == "KnownDerived.b"); + test(k.kd == "KnownDerived.kd"); + test(k.ice_name() =="Test::KnownDerived"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "non-slicing of known derived as derived (AMI)... " << flush; { - AMI_Test_knownDerivedAsKnownDerivedIPtr cb = new AMI_Test_knownDerivedAsKnownDerivedI; - test->knownDerivedAsKnownDerived_async(cb); - test(cb->check()); + AMI_Test_knownDerivedAsKnownDerivedIPtr cb = new AMI_Test_knownDerivedAsKnownDerivedI; + test->knownDerivedAsKnownDerived_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of unknown intermediate as base... " << flush; { - try - { - test->unknownIntermediateAsBase(); - test(false); - } - catch(const Base& b) - { - test(b.b == "UnknownIntermediate.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } + try + { + test->unknownIntermediateAsBase(); + test(false); + } + catch(const Base& b) + { + test(b.b == "UnknownIntermediate.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of unknown intermediate as base (AMI)... " << flush; { - AMI_Test_unknownIntermediateAsBaseIPtr cb = new AMI_Test_unknownIntermediateAsBaseI; - test->unknownIntermediateAsBase_async(cb); - test(cb->check()); + AMI_Test_unknownIntermediateAsBaseIPtr cb = new AMI_Test_unknownIntermediateAsBaseI; + test->unknownIntermediateAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of known intermediate as base... " << flush; { - try - { - test->knownIntermediateAsBase(); - test(false); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "KnownIntermediate.b"); - test(ki.ki == "KnownIntermediate.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } + try + { + test->knownIntermediateAsBase(); + test(false); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "KnownIntermediate.b"); + test(ki.ki == "KnownIntermediate.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of known intermediate as base (AMI)... " << flush; { - AMI_Test_knownIntermediateAsBaseIPtr cb = new AMI_Test_knownIntermediateAsBaseI; - test->knownIntermediateAsBase_async(cb); - test(cb->check()); + AMI_Test_knownIntermediateAsBaseIPtr cb = new AMI_Test_knownIntermediateAsBaseI; + test->knownIntermediateAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of known most derived as base... " << flush; { - try - { - test->knownMostDerivedAsBase(); - test(false); - } - catch(const KnownMostDerived& kmd) - { - test(kmd.b == "KnownMostDerived.b"); - test(kmd.ki == "KnownMostDerived.ki"); - test(kmd.kmd == "KnownMostDerived.kmd"); - test(kmd.ice_name() =="Test::KnownMostDerived"); - } - catch(...) - { - test(false); - } + try + { + test->knownMostDerivedAsBase(); + test(false); + } + catch(const KnownMostDerived& kmd) + { + test(kmd.b == "KnownMostDerived.b"); + test(kmd.ki == "KnownMostDerived.ki"); + test(kmd.kmd == "KnownMostDerived.kmd"); + test(kmd.ice_name() =="Test::KnownMostDerived"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of known most derived as base (AMI)... " << flush; { - AMI_Test_knownMostDerivedAsBaseIPtr cb = new AMI_Test_knownMostDerivedAsBaseI; - test->knownMostDerivedAsBase_async(cb); - test(cb->check()); + AMI_Test_knownMostDerivedAsBaseIPtr cb = new AMI_Test_knownMostDerivedAsBaseI; + test->knownMostDerivedAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "non-slicing of known intermediate as intermediate... " << flush; { - try - { - test->knownIntermediateAsKnownIntermediate(); - test(false); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "KnownIntermediate.b"); - test(ki.ki == "KnownIntermediate.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } + try + { + test->knownIntermediateAsKnownIntermediate(); + test(false); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "KnownIntermediate.b"); + test(ki.ki == "KnownIntermediate.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "non-slicing of known intermediate as intermediate (AMI)... " << flush; { - AMI_Test_knownIntermediateAsKnownIntermediateIPtr cb = new AMI_Test_knownIntermediateAsKnownIntermediateI; - test->knownIntermediateAsKnownIntermediate_async(cb); - test(cb->check()); + AMI_Test_knownIntermediateAsKnownIntermediateIPtr cb = new AMI_Test_knownIntermediateAsKnownIntermediateI; + test->knownIntermediateAsKnownIntermediate_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "non-slicing of known most derived exception as intermediate... " << flush; { - try - { - test->knownMostDerivedAsKnownIntermediate(); - test(false); - } - catch(const KnownMostDerived& kmd) - { - test(kmd.b == "KnownMostDerived.b"); - test(kmd.ki == "KnownMostDerived.ki"); - test(kmd.kmd == "KnownMostDerived.kmd"); - test(kmd.ice_name() =="Test::KnownMostDerived"); - } - catch(...) - { - test(false); - } + try + { + test->knownMostDerivedAsKnownIntermediate(); + test(false); + } + catch(const KnownMostDerived& kmd) + { + test(kmd.b == "KnownMostDerived.b"); + test(kmd.ki == "KnownMostDerived.ki"); + test(kmd.kmd == "KnownMostDerived.kmd"); + test(kmd.ice_name() =="Test::KnownMostDerived"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "non-slicing of known most derived as intermediate (AMI)... " << flush; { - AMI_Test_knownMostDerivedAsKnownIntermediateIPtr cb = new AMI_Test_knownMostDerivedAsKnownIntermediateI; - test->knownMostDerivedAsKnownIntermediate_async(cb); - test(cb->check()); + AMI_Test_knownMostDerivedAsKnownIntermediateIPtr cb = new AMI_Test_knownMostDerivedAsKnownIntermediateI; + test->knownMostDerivedAsKnownIntermediate_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "non-slicing of known most derived as most derived... " << flush; { - try - { - test->knownMostDerivedAsKnownMostDerived(); - test(false); - } - catch(const KnownMostDerived& kmd) - { - test(kmd.b == "KnownMostDerived.b"); - test(kmd.ki == "KnownMostDerived.ki"); - test(kmd.kmd == "KnownMostDerived.kmd"); - test(kmd.ice_name() =="Test::KnownMostDerived"); - } - catch(...) - { - test(false); - } + try + { + test->knownMostDerivedAsKnownMostDerived(); + test(false); + } + catch(const KnownMostDerived& kmd) + { + test(kmd.b == "KnownMostDerived.b"); + test(kmd.ki == "KnownMostDerived.ki"); + test(kmd.kmd == "KnownMostDerived.kmd"); + test(kmd.ice_name() =="Test::KnownMostDerived"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "non-slicing of known most derived as most derived (AMI)... " << flush; { - AMI_Test_knownMostDerivedAsKnownMostDerivedIPtr cb = new AMI_Test_knownMostDerivedAsKnownMostDerivedI; - test->knownMostDerivedAsKnownMostDerived_async(cb); - test(cb->check()); + AMI_Test_knownMostDerivedAsKnownMostDerivedIPtr cb = new AMI_Test_knownMostDerivedAsKnownMostDerivedI; + test->knownMostDerivedAsKnownMostDerived_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of unknown most derived, known intermediate as base... " << flush; { - try - { - test->unknownMostDerived1AsBase(); - test(false); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "UnknownMostDerived1.b"); - test(ki.ki == "UnknownMostDerived1.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } + try + { + test->unknownMostDerived1AsBase(); + test(false); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "UnknownMostDerived1.b"); + test(ki.ki == "UnknownMostDerived1.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of unknown most derived, known intermediate as base (AMI)... " << flush; { - AMI_Test_unknownMostDerived1AsBaseIPtr cb = new AMI_Test_unknownMostDerived1AsBaseI; - test->unknownMostDerived1AsBase_async(cb); - test(cb->check()); + AMI_Test_unknownMostDerived1AsBaseIPtr cb = new AMI_Test_unknownMostDerived1AsBaseI; + test->unknownMostDerived1AsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of unknown most derived, known intermediate as intermediate... " << flush; { - try - { - test->unknownMostDerived1AsKnownIntermediate(); - test(false); - } - catch(const KnownIntermediate& ki) - { - test(ki.b == "UnknownMostDerived1.b"); - test(ki.ki == "UnknownMostDerived1.ki"); - test(ki.ice_name() =="Test::KnownIntermediate"); - } - catch(...) - { - test(false); - } + try + { + test->unknownMostDerived1AsKnownIntermediate(); + test(false); + } + catch(const KnownIntermediate& ki) + { + test(ki.b == "UnknownMostDerived1.b"); + test(ki.ki == "UnknownMostDerived1.ki"); + test(ki.ice_name() =="Test::KnownIntermediate"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of unknown most derived, known intermediate as intermediate (AMI)... " << flush; { - AMI_Test_unknownMostDerived1AsKnownIntermediateIPtr cb = new AMI_Test_unknownMostDerived1AsKnownIntermediateI; - test->unknownMostDerived1AsKnownIntermediate_async(cb); - test(cb->check()); + AMI_Test_unknownMostDerived1AsKnownIntermediateIPtr cb = new AMI_Test_unknownMostDerived1AsKnownIntermediateI; + test->unknownMostDerived1AsKnownIntermediate_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "slicing of unknown most derived, unknown intermediate as base... " << flush; { - try - { - test->unknownMostDerived2AsBase(); - test(false); - } - catch(const Base& b) - { - test(b.b == "UnknownMostDerived2.b"); - test(b.ice_name() =="Test::Base"); - } - catch(...) - { - test(false); - } + try + { + test->unknownMostDerived2AsBase(); + test(false); + } + catch(const Base& b) + { + test(b.b == "UnknownMostDerived2.b"); + test(b.ice_name() =="Test::Base"); + } + catch(...) + { + test(false); + } } cout << "ok" << endl; cout << "slicing of unknown most derived, unknown intermediate as base (AMI)... " << flush; { - AMI_Test_unknownMostDerived2AsBaseIPtr cb = new AMI_Test_unknownMostDerived2AsBaseI; - test->unknownMostDerived2AsBase_async(cb); - test(cb->check()); + AMI_Test_unknownMostDerived2AsBaseIPtr cb = new AMI_Test_unknownMostDerived2AsBaseI; + test->unknownMostDerived2AsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; diff --git a/cpp/test/Ice/slicing/exceptions/Client.cpp b/cpp/test/Ice/slicing/exceptions/Client.cpp index f3ac4fd8322..a48e0a0bf39 100644 --- a/cpp/test/Ice/slicing/exceptions/Client.cpp +++ b/cpp/test/Ice/slicing/exceptions/Client.cpp @@ -31,26 +31,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/slicing/exceptions/Server.cpp b/cpp/test/Ice/slicing/exceptions/Server.cpp index 9a7ad52c084..697d3b3cbfa 100644 --- a/cpp/test/Ice/slicing/exceptions/Server.cpp +++ b/cpp/test/Ice/slicing/exceptions/Server.cpp @@ -34,26 +34,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/slicing/exceptions/ServerAMD.cpp b/cpp/test/Ice/slicing/exceptions/ServerAMD.cpp index f19fcbf7f44..16190251017 100644 --- a/cpp/test/Ice/slicing/exceptions/ServerAMD.cpp +++ b/cpp/test/Ice/slicing/exceptions/ServerAMD.cpp @@ -34,26 +34,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp b/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp index e1286426788..f6f2810fcff 100644 --- a/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp +++ b/cpp/test/Ice/slicing/exceptions/TestAMDI.cpp @@ -82,7 +82,7 @@ TestI::knownMostDerivedAsBase_async(const AMD_TestIntf_knownMostDerivedAsBasePtr void TestI::knownIntermediateAsKnownIntermediate_async(const AMD_TestIntf_knownIntermediateAsKnownIntermediatePtr& cb, - const ::Ice::Current&) + const ::Ice::Current&) { KnownIntermediate ki; ki.b = "KnownIntermediate.b"; @@ -92,7 +92,7 @@ TestI::knownIntermediateAsKnownIntermediate_async(const AMD_TestIntf_knownInterm void TestI::knownMostDerivedAsKnownIntermediate_async(const AMD_TestIntf_knownMostDerivedAsKnownIntermediatePtr& cb, - const ::Ice::Current&) + const ::Ice::Current&) { KnownMostDerived kmd; kmd.b = "KnownMostDerived.b"; @@ -104,7 +104,7 @@ TestI::knownMostDerivedAsKnownIntermediate_async(const AMD_TestIntf_knownMostDer void TestI:: knownMostDerivedAsKnownMostDerived_async(const AMD_TestIntf_knownMostDerivedAsKnownMostDerivedPtr& cb, - const ::Ice::Current&) + const ::Ice::Current&) { KnownMostDerived kmd; kmd.b = "KnownMostDerived.b"; @@ -125,7 +125,7 @@ TestI::unknownMostDerived1AsBase_async(const AMD_TestIntf_unknownMostDerived1AsB void TestI::unknownMostDerived1AsKnownIntermediate_async(const AMD_TestIntf_unknownMostDerived1AsKnownIntermediatePtr& cb, - const ::Ice::Current&) + const ::Ice::Current&) { UnknownMostDerived1 umd1; umd1.b = "UnknownMostDerived1.b"; diff --git a/cpp/test/Ice/slicing/exceptions/TestAMDI.h b/cpp/test/Ice/slicing/exceptions/TestAMDI.h index d390cf82bd9..a806e61c5aa 100644 --- a/cpp/test/Ice/slicing/exceptions/TestAMDI.h +++ b/cpp/test/Ice/slicing/exceptions/TestAMDI.h @@ -22,33 +22,33 @@ public: virtual void unknownDerivedAsBase_async(const ::Test::AMD_TestIntf_unknownDerivedAsBasePtr&, const ::Ice::Current&); virtual void knownDerivedAsBase_async(const ::Test::AMD_TestIntf_knownDerivedAsBasePtr&, const ::Ice::Current&); virtual void knownDerivedAsKnownDerived_async(const ::Test::AMD_TestIntf_knownDerivedAsKnownDerivedPtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void unknownIntermediateAsBase_async(const ::Test::AMD_TestIntf_unknownIntermediateAsBasePtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void knownIntermediateAsBase_async(const ::Test::AMD_TestIntf_knownIntermediateAsBasePtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void knownMostDerivedAsBase_async(const ::Test::AMD_TestIntf_knownMostDerivedAsBasePtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void knownIntermediateAsKnownIntermediate_async( - const ::Test::AMD_TestIntf_knownIntermediateAsKnownIntermediatePtr&, - const ::Ice::Current&); + const ::Test::AMD_TestIntf_knownIntermediateAsKnownIntermediatePtr&, + const ::Ice::Current&); virtual void knownMostDerivedAsKnownIntermediate_async( - const ::Test::AMD_TestIntf_knownMostDerivedAsKnownIntermediatePtr&, - const ::Ice::Current&); + const ::Test::AMD_TestIntf_knownMostDerivedAsKnownIntermediatePtr&, + const ::Ice::Current&); virtual void knownMostDerivedAsKnownMostDerived_async( - const ::Test::AMD_TestIntf_knownMostDerivedAsKnownMostDerivedPtr&, - const ::Ice::Current&); + const ::Test::AMD_TestIntf_knownMostDerivedAsKnownMostDerivedPtr&, + const ::Ice::Current&); virtual void unknownMostDerived1AsBase_async( - const ::Test::AMD_TestIntf_unknownMostDerived1AsBasePtr&, - const ::Ice::Current&); + const ::Test::AMD_TestIntf_unknownMostDerived1AsBasePtr&, + const ::Ice::Current&); virtual void unknownMostDerived1AsKnownIntermediate_async( - const ::Test::AMD_TestIntf_unknownMostDerived1AsKnownIntermediatePtr&, - const ::Ice::Current&); + const ::Test::AMD_TestIntf_unknownMostDerived1AsKnownIntermediatePtr&, + const ::Ice::Current&); virtual void unknownMostDerived2AsBase_async( - const ::Test::AMD_TestIntf_unknownMostDerived2AsBasePtr&, - const ::Ice::Current&); + const ::Test::AMD_TestIntf_unknownMostDerived2AsBasePtr&, + const ::Ice::Current&); virtual void shutdown_async(const ::Test::AMD_TestIntf_shutdownPtr&, const ::Ice::Current&); diff --git a/cpp/test/Ice/slicing/objects/AllTests.cpp b/cpp/test/Ice/slicing/objects/AllTests.cpp index 7646554dcca..b9f102b6c5a 100644 --- a/cpp/test/Ice/slicing/objects/AllTests.cpp +++ b/cpp/test/Ice/slicing/objects/AllTests.cpp @@ -20,7 +20,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -30,26 +30,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -62,18 +62,18 @@ class AMI_Test_SBaseAsObjectI : public AMI_TestIntf_SBaseAsObject, public Callba virtual void ice_response(const ::Ice::ObjectPtr& o) { - test(o); - test(o->ice_id() == "::Test::SBase"); - SBasePtr sb = SBasePtr::dynamicCast(o); - test(sb); - test(sb->sb == "SBase.sb"); - called(); + test(o); + test(o->ice_id() == "::Test::SBase"); + SBasePtr sb = SBasePtr::dynamicCast(o); + test(sb); + test(sb->sb == "SBase.sb"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -84,14 +84,14 @@ class AMI_Test_SBaseAsSBaseI : public AMI_TestIntf_SBaseAsSBase, public Callback virtual void ice_response(const SBasePtr& sb) { - test(sb->sb == "SBase.sb"); - called(); + test(sb->sb == "SBase.sb"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -102,16 +102,16 @@ class AMI_Test_SBSKnownDerivedAsSBaseI : public AMI_TestIntf_SBSKnownDerivedAsSB virtual void ice_response(const SBasePtr& sb) { - SBSKnownDerivedPtr sbskd = SBSKnownDerivedPtr::dynamicCast(sb); - test(sbskd); - test(sbskd->sbskd == "SBSKnownDerived.sbskd"); - called(); + SBSKnownDerivedPtr sbskd = SBSKnownDerivedPtr::dynamicCast(sb); + test(sbskd); + test(sbskd->sbskd == "SBSKnownDerived.sbskd"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -123,14 +123,14 @@ class AMI_Test_SBSKnownDerivedAsSBSKnownDerivedI virtual void ice_response(const SBSKnownDerivedPtr& sbskd) { - test(sbskd->sbskd == "SBSKnownDerived.sbskd"); - called(); + test(sbskd->sbskd == "SBSKnownDerived.sbskd"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -141,14 +141,14 @@ class AMI_Test_SBSUnknownDerivedAsSBaseI : public AMI_TestIntf_SBSUnknownDerived virtual void ice_response(const SBasePtr& sb) { - test(sb->sb == "SBSUnknownDerived.sb"); - called(); + test(sb->sb == "SBSUnknownDerived.sb"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -159,14 +159,14 @@ class AMI_Test_SUnknownAsObjectI : public AMI_TestIntf_SUnknownAsObject, public virtual void ice_response(const Ice::ObjectPtr& o) { - test(false); + test(false); } virtual void ice_exception(const Ice::Exception& exc) { test(exc.ice_name() == "Ice::NoObjectFactoryException"); - called(); + called(); } }; @@ -177,17 +177,17 @@ class AMI_Test_oneElementCycleI : public AMI_TestIntf_oneElementCycle, public Ca virtual void ice_response(const BPtr& b) { - test(b); - test(b->ice_id() == "::Test::B"); - test(b->sb == "B1.sb"); - test(b->pb == b); - called(); + test(b); + test(b->ice_id() == "::Test::B"); + test(b->sb == "B1.sb"); + test(b->pb == b); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -198,22 +198,22 @@ class AMI_Test_twoElementCycleI : public AMI_TestIntf_twoElementCycle, public Ca virtual void ice_response(const BPtr& b1) { - test(b1); - test(b1->ice_id() == "::Test::B"); - test(b1->sb == "B1.sb"); + test(b1); + test(b1->ice_id() == "::Test::B"); + test(b1->sb == "B1.sb"); - BPtr b2 = b1->pb; - test(b2); - test(b2->ice_id() == "::Test::B"); - test(b2->sb == "B2.sb"); - test(b2->pb == b1); - called(); + BPtr b2 = b1->pb; + test(b2); + test(b2->ice_id() == "::Test::B"); + test(b2->sb == "B2.sb"); + test(b2->pb == b1); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -224,30 +224,30 @@ class AMI_Test_D1AsBI : public AMI_TestIntf_D1AsB, public CallbackBase virtual void ice_response(const BPtr& b1) { - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb); - test(b1->pb != b1); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1); - test(d1->pd1 != b1); - test(b1->pb == d1->pd1); - - BPtr b2 = b1->pb; - test(b2); - test(b2->pb == b1); - test(b2->sb == "D2.sb"); - test(b2->ice_id() == "::Test::B"); - called(); + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb); + test(b1->pb != b1); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1); + test(d1->pd1 != b1); + test(b1->pb == d1->pd1); + + BPtr b2 = b1->pb; + test(b2); + test(b2->pb == b1); + test(b2->sb == "D2.sb"); + test(b2->ice_id() == "::Test::B"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -258,24 +258,24 @@ class AMI_Test_D1AsD1I : public AMI_TestIntf_D1AsD1, public CallbackBase virtual void ice_response(const D1Ptr& d1) { - test(d1); - test(d1->ice_id() == "::Test::D1"); - test(d1->sb == "D1.sb"); - test(d1->pb); - test(d1->pb != d1); + test(d1); + test(d1->ice_id() == "::Test::D1"); + test(d1->sb == "D1.sb"); + test(d1->pb); + test(d1->pb != d1); - BPtr b2 = d1->pb; - test(b2); - test(b2->ice_id() == "::Test::B"); - test(b2->sb == "D2.sb"); - test(b2->pb == d1); - called(); + BPtr b2 = d1->pb; + test(b2); + test(b2->ice_id() == "::Test::B"); + test(b2->sb == "D2.sb"); + test(b2->pb == d1); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -286,28 +286,28 @@ class AMI_Test_D2AsBI : public AMI_TestIntf_D2AsB, public CallbackBase virtual void ice_response(const BPtr& b2) { - test(b2); - test(b2->ice_id() == "::Test::B"); - test(b2->sb == "D2.sb"); - test(b2->pb); - test(b2->pb != b2); + test(b2); + test(b2->ice_id() == "::Test::B"); + test(b2->sb == "D2.sb"); + test(b2->pb); + test(b2->pb != b2); - BPtr b1 = b2->pb; - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb == b2); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1 == b2); - called(); + BPtr b1 = b2->pb; + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb == b2); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1 == b2); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -318,26 +318,26 @@ class AMI_Test_paramTest1I : public AMI_TestIntf_paramTest1, public CallbackBase virtual void ice_response(const BPtr& b1, const BPtr& b2) { - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb == b2); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1 == b2); + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb == b2); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1 == b2); - test(b2); - test(b2->ice_id() == "::Test::B"); // No factory, must be sliced - test(b2->sb == "D2.sb"); - test(b2->pb == b1); - called(); + test(b2); + test(b2->ice_id() == "::Test::B"); // No factory, must be sliced + test(b2->sb == "D2.sb"); + test(b2->pb == b1); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -348,14 +348,14 @@ class AMI_Test_returnTest1I : public AMI_TestIntf_returnTest1, public CallbackBa virtual void ice_response(const BPtr& r, const BPtr& p1, const BPtr& p2) { - test(r == p1); - called(); + test(r == p1); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -366,14 +366,14 @@ class AMI_Test_returnTest2I : public AMI_TestIntf_returnTest2, public CallbackBa virtual void ice_response(const BPtr& r, const BPtr& p1, const BPtr& p2) { - test(r == p1); - called(); + test(r == p1); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -385,14 +385,14 @@ public: virtual void ice_response(const BPtr& b) { - r = b; - called(); + r = b; + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } BPtr r; @@ -405,27 +405,27 @@ class AMI_Test_paramTest3I : public AMI_TestIntf_paramTest3, public CallbackBase virtual void ice_response(const BPtr& ret, const BPtr& p1, const BPtr& p2) { - test(p1); - test(p1->sb == "D2.sb (p1 1)"); - test(p1->pb == 0); - test(p1->ice_id() == "::Test::B"); + test(p1); + test(p1->sb == "D2.sb (p1 1)"); + test(p1->pb == 0); + test(p1->ice_id() == "::Test::B"); - test(p2); - test(p2->sb == "D2.sb (p2 1)"); - test(p2->pb == 0); - test(p2->ice_id() == "::Test::B"); + test(p2); + test(p2->sb == "D2.sb (p2 1)"); + test(p2->pb == 0); + test(p2->ice_id() == "::Test::B"); - test(ret); - test(ret->sb == "D1.sb (p2 2)"); - test(ret->pb == 0); - test(ret->ice_id() == "::Test::D1"); - called(); + test(ret); + test(ret->sb == "D1.sb (p2 2)"); + test(ret->pb == 0); + test(ret->ice_id() == "::Test::D1"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -436,22 +436,22 @@ class AMI_Test_paramTest4I : public AMI_TestIntf_paramTest4, public CallbackBase virtual void ice_response(const BPtr& ret, const BPtr& b) { - test(b); - test(b->sb == "D4.sb (1)"); - test(b->pb == 0); - test(b->ice_id() == "::Test::B"); + test(b); + test(b->sb == "D4.sb (1)"); + test(b->pb == 0); + test(b->ice_id() == "::Test::B"); - test(ret); - test(ret->sb == "B.sb (2)"); - test(ret->pb == 0); - test(ret->ice_id() == "::Test::B"); - called(); + test(ret); + test(ret->sb == "B.sb (2)"); + test(ret->pb == 0); + test(ret->ice_id() == "::Test::B"); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -462,14 +462,14 @@ class AMI_Test_sequenceTestI : public AMI_TestIntf_sequenceTest, public Callback virtual void ice_response(const SS& ss) { - r = ss; - called(); + r = ss; + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } public: @@ -484,15 +484,15 @@ class AMI_Test_dictionaryTestI : public AMI_TestIntf_dictionaryTest, public Call virtual void ice_response(const BDict& r, const BDict& bout) { - this->r = r; - this->bout = bout; - called(); + this->r = r; + this->bout = bout; + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } public: @@ -508,19 +508,19 @@ class AMI_Test_throwBaseAsBaseI : public AMI_TestIntf_throwBaseAsBase, public Ca virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(ex.ice_name() == "Test::BaseException"); - const BaseException& e = dynamic_cast<const BaseException&>(ex); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb"); - test(e.pb->pb == e.pb); - called(); + test(ex.ice_name() == "Test::BaseException"); + const BaseException& e = dynamic_cast<const BaseException&>(ex); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb"); + test(e.pb->pb == e.pb); + called(); } }; @@ -531,25 +531,25 @@ class AMI_Test_throwDerivedAsBaseI : public AMI_TestIntf_throwDerivedAsBase, pub virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(ex.ice_name() == "Test::DerivedException"); - const DerivedException& e = dynamic_cast<const DerivedException&>(ex); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb1"); - test(e.pb->pb == e.pb); - test(e.sde == "sde1"); - test(e.pd1); - test(e.pd1->sb == "sb2"); - test(e.pd1->pb == e.pd1); - test(e.pd1->sd1 == "sd2"); - test(e.pd1->pd1 == e.pd1); - called(); + test(ex.ice_name() == "Test::DerivedException"); + const DerivedException& e = dynamic_cast<const DerivedException&>(ex); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb1"); + test(e.pb->pb == e.pb); + test(e.sde == "sde1"); + test(e.pd1); + test(e.pd1->sb == "sb2"); + test(e.pd1->pb == e.pd1); + test(e.pd1->sd1 == "sd2"); + test(e.pd1->pd1 == e.pd1); + called(); } }; @@ -560,25 +560,25 @@ class AMI_Test_throwDerivedAsDerivedI : public AMI_TestIntf_throwDerivedAsDerive virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(ex.ice_name() == "Test::DerivedException"); - const DerivedException& e = dynamic_cast<const DerivedException&>(ex); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb1"); - test(e.pb->pb == e.pb); - test(e.sde == "sde1"); - test(e.pd1); - test(e.pd1->sb == "sb2"); - test(e.pd1->pb == e.pd1); - test(e.pd1->sd1 == "sd2"); - test(e.pd1->pd1 == e.pd1); - called(); + test(ex.ice_name() == "Test::DerivedException"); + const DerivedException& e = dynamic_cast<const DerivedException&>(ex); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb1"); + test(e.pb->pb == e.pb); + test(e.sde == "sde1"); + test(e.pd1); + test(e.pd1->sb == "sb2"); + test(e.pd1->pb == e.pd1); + test(e.pd1->sd1 == "sd2"); + test(e.pd1->pd1 == e.pd1); + called(); } }; @@ -589,19 +589,19 @@ class AMI_Test_throwUnknownDerivedAsBaseI : public AMI_TestIntf_throwUnknownDeri virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(ex.ice_name() == "Test::BaseException"); - const BaseException& e = dynamic_cast<const BaseException&>(ex); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb d2"); - test(e.pb->pb == e.pb); - called(); + test(ex.ice_name() == "Test::BaseException"); + const BaseException& e = dynamic_cast<const BaseException&>(ex); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb d2"); + test(e.pb->pb == e.pb); + called(); } }; @@ -612,14 +612,14 @@ class AMI_Test_useForwardI : public AMI_TestIntf_useForward, public CallbackBase virtual void ice_response(const ForwardPtr& f) { - test(f); - called(); + test(f); + called(); } virtual void ice_exception(const Ice::Exception& exc) { - test(false); + test(false); } }; @@ -633,1281 +633,1281 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "base as Object... " << flush; { - Ice::ObjectPtr o; - try - { - o = test->SBaseAsObject(); - test(o); - test(o->ice_id() == "::Test::SBase"); - } - catch(...) - { - test(0); - } - SBasePtr sb = SBasePtr::dynamicCast(o); - test(sb); - test(sb->sb == "SBase.sb"); + Ice::ObjectPtr o; + try + { + o = test->SBaseAsObject(); + test(o); + test(o->ice_id() == "::Test::SBase"); + } + catch(...) + { + test(0); + } + SBasePtr sb = SBasePtr::dynamicCast(o); + test(sb); + test(sb->sb == "SBase.sb"); } cout << "ok" << endl; cout << "base as Object (AMI)... " << flush; { - AMI_Test_SBaseAsObjectIPtr cb = new AMI_Test_SBaseAsObjectI; - test->SBaseAsObject_async(cb); - test(cb->check()); + AMI_Test_SBaseAsObjectIPtr cb = new AMI_Test_SBaseAsObjectI; + test->SBaseAsObject_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "base as base... " << flush; { - SBasePtr sb; - try - { - sb = test->SBaseAsSBase(); - test(sb->sb == "SBase.sb"); - } - catch(...) - { - test(0); - } + SBasePtr sb; + try + { + sb = test->SBaseAsSBase(); + test(sb->sb == "SBase.sb"); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "base as base (AMI)... " << flush; { - AMI_Test_SBaseAsSBaseIPtr cb = new AMI_Test_SBaseAsSBaseI; - test->SBaseAsSBase_async(cb); - test(cb->check()); + AMI_Test_SBaseAsSBaseIPtr cb = new AMI_Test_SBaseAsSBaseI; + test->SBaseAsSBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "base with known derived as base... " << flush; { - SBasePtr sb; - try - { - sb = test->SBSKnownDerivedAsSBase(); - test(sb->sb == "SBSKnownDerived.sb"); - } - catch(...) - { - test(0); - } - SBSKnownDerivedPtr sbskd = SBSKnownDerivedPtr::dynamicCast(sb); - test(sbskd); - test(sbskd->sbskd == "SBSKnownDerived.sbskd"); + SBasePtr sb; + try + { + sb = test->SBSKnownDerivedAsSBase(); + test(sb->sb == "SBSKnownDerived.sb"); + } + catch(...) + { + test(0); + } + SBSKnownDerivedPtr sbskd = SBSKnownDerivedPtr::dynamicCast(sb); + test(sbskd); + test(sbskd->sbskd == "SBSKnownDerived.sbskd"); } cout << "ok" << endl; cout << "base with known derived as base (AMI)... " << flush; { - AMI_Test_SBSKnownDerivedAsSBaseIPtr cb = new AMI_Test_SBSKnownDerivedAsSBaseI; - test->SBSKnownDerivedAsSBase_async(cb); - test(cb->check()); + AMI_Test_SBSKnownDerivedAsSBaseIPtr cb = new AMI_Test_SBSKnownDerivedAsSBaseI; + test->SBSKnownDerivedAsSBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "base with known derived as known derived... " << flush; { - SBSKnownDerivedPtr sbskd; - try - { - sbskd = test->SBSKnownDerivedAsSBSKnownDerived(); - test(sbskd->sbskd == "SBSKnownDerived.sbskd"); - } - catch(...) - { - test(0); - } + SBSKnownDerivedPtr sbskd; + try + { + sbskd = test->SBSKnownDerivedAsSBSKnownDerived(); + test(sbskd->sbskd == "SBSKnownDerived.sbskd"); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "base with known derived as known derived (AMI)... " << flush; { - AMI_Test_SBSKnownDerivedAsSBSKnownDerivedIPtr cb = new AMI_Test_SBSKnownDerivedAsSBSKnownDerivedI; - test->SBSKnownDerivedAsSBSKnownDerived_async(cb); - test(cb->check()); + AMI_Test_SBSKnownDerivedAsSBSKnownDerivedIPtr cb = new AMI_Test_SBSKnownDerivedAsSBSKnownDerivedI; + test->SBSKnownDerivedAsSBSKnownDerived_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "base with unknown derived as base... " << flush; { - SBasePtr sb; - try - { - sb = test->SBSUnknownDerivedAsSBase(); - test(sb->sb == "SBSUnknownDerived.sb"); - } - catch(...) - { - test(0); - } + SBasePtr sb; + try + { + sb = test->SBSUnknownDerivedAsSBase(); + test(sb->sb == "SBSUnknownDerived.sb"); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "base with unknown derived as base (AMI)... " << flush; { - AMI_Test_SBSUnknownDerivedAsSBaseIPtr cb = new AMI_Test_SBSUnknownDerivedAsSBaseI; - test->SBSUnknownDerivedAsSBase_async(cb); - test(cb->check()); + AMI_Test_SBSUnknownDerivedAsSBaseIPtr cb = new AMI_Test_SBSUnknownDerivedAsSBaseI; + test->SBSUnknownDerivedAsSBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "unknown with Object as Object... " << flush; { - Ice::ObjectPtr o; - try - { - o = test->SUnknownAsObject(); - test(0); - } - catch(const Ice::NoObjectFactoryException&) - { - } - catch(...) - { - test(0); - } + Ice::ObjectPtr o; + try + { + o = test->SUnknownAsObject(); + test(0); + } + catch(const Ice::NoObjectFactoryException&) + { + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "unknown with Object as Object (AMI)... " << flush; { - try - { - AMI_Test_SUnknownAsObjectIPtr cb = new AMI_Test_SUnknownAsObjectI; - test->SUnknownAsObject_async(cb);
- test(cb->check()); - } - catch(...) - { - test(0); - } + try + { + AMI_Test_SUnknownAsObjectIPtr cb = new AMI_Test_SUnknownAsObjectI; + test->SUnknownAsObject_async(cb);
+ test(cb->check()); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "one-element cycle... " << flush; { - try - { - BPtr b = test->oneElementCycle(); - test(b); - test(b->ice_id() == "::Test::B"); - test(b->sb == "B1.sb"); - test(b->pb == b); - } - catch(...) - { - test(0); - } + try + { + BPtr b = test->oneElementCycle(); + test(b); + test(b->ice_id() == "::Test::B"); + test(b->sb == "B1.sb"); + test(b->pb == b); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "one-element cycle (AMI)... " << flush; { - AMI_Test_oneElementCycleIPtr cb = new AMI_Test_oneElementCycleI; - test->oneElementCycle_async(cb); - test(cb->check()); + AMI_Test_oneElementCycleIPtr cb = new AMI_Test_oneElementCycleI; + test->oneElementCycle_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "two-element cycle... " << flush; { - try - { - BPtr b1 = test->twoElementCycle(); - test(b1); - test(b1->ice_id() == "::Test::B"); - test(b1->sb == "B1.sb"); - - BPtr b2 = b1->pb; - test(b2); - test(b2->ice_id() == "::Test::B"); - test(b2->sb == "B2.sb"); - test(b2->pb == b1); - } - catch(...) - { - test(0); - } + try + { + BPtr b1 = test->twoElementCycle(); + test(b1); + test(b1->ice_id() == "::Test::B"); + test(b1->sb == "B1.sb"); + + BPtr b2 = b1->pb; + test(b2); + test(b2->ice_id() == "::Test::B"); + test(b2->sb == "B2.sb"); + test(b2->pb == b1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "two-element cycle (AMI)... " << flush; { - AMI_Test_twoElementCycleIPtr cb = new AMI_Test_twoElementCycleI; - test->twoElementCycle_async(cb); - test(cb->check()); + AMI_Test_twoElementCycleIPtr cb = new AMI_Test_twoElementCycleI; + test->twoElementCycle_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "known derived pointer slicing as base... " << flush; { - try - { - BPtr b1; - b1 = test->D1AsB(); - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb); - test(b1->pb != b1); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1); - test(d1->pd1 != b1); - test(b1->pb == d1->pd1); - - BPtr b2 = b1->pb; - test(b2); - test(b2->pb == b1); - test(b2->sb == "D2.sb"); - test(b2->ice_id() == "::Test::B"); - } - catch(...) - { - test(0); - } + try + { + BPtr b1; + b1 = test->D1AsB(); + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb); + test(b1->pb != b1); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1); + test(d1->pd1 != b1); + test(b1->pb == d1->pd1); + + BPtr b2 = b1->pb; + test(b2); + test(b2->pb == b1); + test(b2->sb == "D2.sb"); + test(b2->ice_id() == "::Test::B"); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "known derived pointer slicing as base (AMI)... " << flush; { - AMI_Test_D1AsBIPtr cb = new AMI_Test_D1AsBI; - test->D1AsB_async(cb); - test(cb->check()); + AMI_Test_D1AsBIPtr cb = new AMI_Test_D1AsBI; + test->D1AsB_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "known derived pointer slicing as derived... " << flush; { - try - { - D1Ptr d1; - d1 = test->D1AsD1(); - test(d1); - test(d1->ice_id() == "::Test::D1"); - test(d1->sb == "D1.sb"); - test(d1->pb); - test(d1->pb != d1); - - BPtr b2 = d1->pb; - test(b2); - test(b2->ice_id() == "::Test::B"); - test(b2->sb == "D2.sb"); - test(b2->pb == d1); - } - catch(...) - { - test(0); - } + try + { + D1Ptr d1; + d1 = test->D1AsD1(); + test(d1); + test(d1->ice_id() == "::Test::D1"); + test(d1->sb == "D1.sb"); + test(d1->pb); + test(d1->pb != d1); + + BPtr b2 = d1->pb; + test(b2); + test(b2->ice_id() == "::Test::B"); + test(b2->sb == "D2.sb"); + test(b2->pb == d1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "known derived pointer slicing as derived (AMI)... " << flush; { - AMI_Test_D1AsD1IPtr cb = new AMI_Test_D1AsD1I; - test->D1AsD1_async(cb); - test(cb->check()); + AMI_Test_D1AsD1IPtr cb = new AMI_Test_D1AsD1I; + test->D1AsD1_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "unknown derived pointer slicing as base... " << flush; { - try - { - BPtr b2; - b2 = test->D2AsB(); - test(b2); - test(b2->ice_id() == "::Test::B"); - test(b2->sb == "D2.sb"); - test(b2->pb); - test(b2->pb != b2); - - BPtr b1 = b2->pb; - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb == b2); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1 == b2); - } - catch(...) - { - test(0); - } + try + { + BPtr b2; + b2 = test->D2AsB(); + test(b2); + test(b2->ice_id() == "::Test::B"); + test(b2->sb == "D2.sb"); + test(b2->pb); + test(b2->pb != b2); + + BPtr b1 = b2->pb; + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb == b2); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1 == b2); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "unknown derived pointer slicing as base (AMI)... " << flush; { - AMI_Test_D2AsBIPtr cb = new AMI_Test_D2AsBI; - test->D2AsB_async(cb); - test(cb->check()); + AMI_Test_D2AsBIPtr cb = new AMI_Test_D2AsBI; + test->D2AsB_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "param ptr slicing with known first... " << flush; { - try - { - BPtr b1; - BPtr b2; - test->paramTest1(b1, b2); - - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb == b2); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1 == b2); - - test(b2); - test(b2->ice_id() == "::Test::B"); // No factory, must be sliced - test(b2->sb == "D2.sb"); - test(b2->pb == b1); - } - catch(...) - { - test(0); - } + try + { + BPtr b1; + BPtr b2; + test->paramTest1(b1, b2); + + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb == b2); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1 == b2); + + test(b2); + test(b2->ice_id() == "::Test::B"); // No factory, must be sliced + test(b2->sb == "D2.sb"); + test(b2->pb == b1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "param ptr slicing with known first (AMI)... " << flush; { - AMI_Test_paramTest1IPtr cb = new AMI_Test_paramTest1I; - test->paramTest1_async(cb); - test(cb->check()); + AMI_Test_paramTest1IPtr cb = new AMI_Test_paramTest1I; + test->paramTest1_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "param ptr slicing with unknown first... " << flush; { - try - { - BPtr b2; - BPtr b1; - test->paramTest2(b2, b1); - - test(b1); - test(b1->ice_id() == "::Test::D1"); - test(b1->sb == "D1.sb"); - test(b1->pb == b2); - D1Ptr d1 = D1Ptr::dynamicCast(b1); - test(d1); - test(d1->sd1 == "D1.sd1"); - test(d1->pd1 == b2); - - test(b2); - test(b2->ice_id() == "::Test::B"); // No factory, must be sliced - test(b2->sb == "D2.sb"); - test(b2->pb == b1); - } - catch(...) - { - test(0); - } + try + { + BPtr b2; + BPtr b1; + test->paramTest2(b2, b1); + + test(b1); + test(b1->ice_id() == "::Test::D1"); + test(b1->sb == "D1.sb"); + test(b1->pb == b2); + D1Ptr d1 = D1Ptr::dynamicCast(b1); + test(d1); + test(d1->sd1 == "D1.sd1"); + test(d1->pd1 == b2); + + test(b2); + test(b2->ice_id() == "::Test::B"); // No factory, must be sliced + test(b2->sb == "D2.sb"); + test(b2->pb == b1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "return value identity with known first... " << flush; { - try - { - BPtr p1; - BPtr p2; - BPtr r = test->returnTest1(p1, p2); - test(r == p1); - } - catch(...) - { - test(0); - } + try + { + BPtr p1; + BPtr p2; + BPtr r = test->returnTest1(p1, p2); + test(r == p1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "return value identity with known first (AMI)... " << flush; { - AMI_Test_returnTest1IPtr cb = new AMI_Test_returnTest1I; - test->returnTest1_async(cb); - test(cb->check()); + AMI_Test_returnTest1IPtr cb = new AMI_Test_returnTest1I; + test->returnTest1_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "return value identity with unknown first... " << flush; { - try - { - BPtr p1; - BPtr p2; - BPtr r = test->returnTest2(p1, p2); - test(r == p1); - } - catch(...) - { - test(0); - } + try + { + BPtr p1; + BPtr p2; + BPtr r = test->returnTest2(p1, p2); + test(r == p1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "return value identity with unknown first (AMI)... " << flush; { - AMI_Test_returnTest2IPtr cb = new AMI_Test_returnTest2I; - test->returnTest2_async(cb); - test(cb->check()); + AMI_Test_returnTest2IPtr cb = new AMI_Test_returnTest2I; + test->returnTest2_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "return value identity for input params known first... " << flush; { - try - { - D1Ptr d1 = new D1; - d1->sb = "D1.sb"; - d1->sd1 = "D1.sd1"; - D3Ptr d3 = new D3; - d3->pb = d1; - d3->sb = "D3.sb"; - d3->sd3 = "D3.sd3"; - d3->pd3 = d1; - d1->pb = d3; - d1->pd1 = d3; - - BPtr b1 = test->returnTest3(d1, d3); - - test(b1); - test(b1->sb == "D1.sb"); - test(b1->ice_id() == "::Test::D1"); - D1Ptr p1 = D1Ptr::dynamicCast(b1); - test(p1); - test(p1->sd1 == "D1.sd1"); - test(p1->pd1 == b1->pb); - - BPtr b2 = b1->pb; - test(b2); - test(b2->sb == "D3.sb"); - test(b2->ice_id() == "::Test::B"); // Sliced by server - test(b2->pb == b1); - D3Ptr p3 = D3Ptr::dynamicCast(b2); - test(!p3); - - test(b1 != d1); - test(b1 != d3); - test(b2 != d1); - test(b2 != d3); - } - catch(...) - { - test(0); - } + try + { + D1Ptr d1 = new D1; + d1->sb = "D1.sb"; + d1->sd1 = "D1.sd1"; + D3Ptr d3 = new D3; + d3->pb = d1; + d3->sb = "D3.sb"; + d3->sd3 = "D3.sd3"; + d3->pd3 = d1; + d1->pb = d3; + d1->pd1 = d3; + + BPtr b1 = test->returnTest3(d1, d3); + + test(b1); + test(b1->sb == "D1.sb"); + test(b1->ice_id() == "::Test::D1"); + D1Ptr p1 = D1Ptr::dynamicCast(b1); + test(p1); + test(p1->sd1 == "D1.sd1"); + test(p1->pd1 == b1->pb); + + BPtr b2 = b1->pb; + test(b2); + test(b2->sb == "D3.sb"); + test(b2->ice_id() == "::Test::B"); // Sliced by server + test(b2->pb == b1); + D3Ptr p3 = D3Ptr::dynamicCast(b2); + test(!p3); + + test(b1 != d1); + test(b1 != d3); + test(b2 != d1); + test(b2 != d3); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "return value identity for input params known first (AMI)... " << flush; { - try - { - D1Ptr d1 = new D1; - d1->sb = "D1.sb"; - d1->sd1 = "D1.sd1"; - D3Ptr d3 = new D3; - d3->pb = d1; - d3->sb = "D3.sb"; - d3->sd3 = "D3.sd3"; - d3->pd3 = d1; - d1->pb = d3; - d1->pd1 = d3; - - AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; - test->returnTest3_async(cb, d1, d3); - test(cb->check()); - BPtr b1 = cb->r; - - test(b1); - test(b1->sb == "D1.sb"); - test(b1->ice_id() == "::Test::D1"); - D1Ptr p1 = D1Ptr::dynamicCast(b1); - test(p1); - test(p1->sd1 == "D1.sd1"); - test(p1->pd1 == b1->pb); - - BPtr b2 = b1->pb; - test(b2); - test(b2->sb == "D3.sb"); - test(b2->ice_id() == "::Test::B"); // Sliced by server - test(b2->pb == b1); - D3Ptr p3 = D3Ptr::dynamicCast(b2); - test(!p3); - - test(b1 != d1); - test(b1 != d3); - test(b2 != d1); - test(b2 != d3); - } - catch(...) - { - test(0); - } + try + { + D1Ptr d1 = new D1; + d1->sb = "D1.sb"; + d1->sd1 = "D1.sd1"; + D3Ptr d3 = new D3; + d3->pb = d1; + d3->sb = "D3.sb"; + d3->sd3 = "D3.sd3"; + d3->pd3 = d1; + d1->pb = d3; + d1->pd1 = d3; + + AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; + test->returnTest3_async(cb, d1, d3); + test(cb->check()); + BPtr b1 = cb->r; + + test(b1); + test(b1->sb == "D1.sb"); + test(b1->ice_id() == "::Test::D1"); + D1Ptr p1 = D1Ptr::dynamicCast(b1); + test(p1); + test(p1->sd1 == "D1.sd1"); + test(p1->pd1 == b1->pb); + + BPtr b2 = b1->pb; + test(b2); + test(b2->sb == "D3.sb"); + test(b2->ice_id() == "::Test::B"); // Sliced by server + test(b2->pb == b1); + D3Ptr p3 = D3Ptr::dynamicCast(b2); + test(!p3); + + test(b1 != d1); + test(b1 != d3); + test(b2 != d1); + test(b2 != d3); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "return value identity for input params unknown first... " << flush; { - try - { - D1Ptr d1 = new D1; - d1->sb = "D1.sb"; - d1->sd1 = "D1.sd1"; - D3Ptr d3 = new D3; - d3->pb = d1; - d3->sb = "D3.sb"; - d3->sd3 = "D3.sd3"; - d3->pd3 = d1; - d1->pb = d3; - d1->pd1 = d3; - - BPtr b1 = test->returnTest3(d3, d1); - - test(b1); - test(b1->sb == "D3.sb"); - test(b1->ice_id() == "::Test::B"); // Sliced by server - D3Ptr p1 = D3Ptr::dynamicCast(b1); - test(!p1); - - BPtr b2 = b1->pb; - test(b2); - test(b2->sb == "D1.sb"); - test(b2->ice_id() == "::Test::D1"); - test(b2->pb == b1); - D1Ptr p3 = D1Ptr::dynamicCast(b2); - test(p3); - test(p3->sd1 == "D1.sd1"); - test(p3->pd1 == b1); - - test(b1 != d1); - test(b1 != d3); - test(b2 != d1); - test(b2 != d3); - } - catch(...) - { - test(0); - } + try + { + D1Ptr d1 = new D1; + d1->sb = "D1.sb"; + d1->sd1 = "D1.sd1"; + D3Ptr d3 = new D3; + d3->pb = d1; + d3->sb = "D3.sb"; + d3->sd3 = "D3.sd3"; + d3->pd3 = d1; + d1->pb = d3; + d1->pd1 = d3; + + BPtr b1 = test->returnTest3(d3, d1); + + test(b1); + test(b1->sb == "D3.sb"); + test(b1->ice_id() == "::Test::B"); // Sliced by server + D3Ptr p1 = D3Ptr::dynamicCast(b1); + test(!p1); + + BPtr b2 = b1->pb; + test(b2); + test(b2->sb == "D1.sb"); + test(b2->ice_id() == "::Test::D1"); + test(b2->pb == b1); + D1Ptr p3 = D1Ptr::dynamicCast(b2); + test(p3); + test(p3->sd1 == "D1.sd1"); + test(p3->pd1 == b1); + + test(b1 != d1); + test(b1 != d3); + test(b2 != d1); + test(b2 != d3); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "return value identity for input params unknown first (AMI)... " << flush; { - try - { - D1Ptr d1 = new D1; - d1->sb = "D1.sb"; - d1->sd1 = "D1.sd1"; - D3Ptr d3 = new D3; - d3->pb = d1; - d3->sb = "D3.sb"; - d3->sd3 = "D3.sd3"; - d3->pd3 = d1; - d1->pb = d3; - d1->pd1 = d3; - - AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; - test->returnTest3_async(cb, d3, d1); - test(cb->check()); - BPtr b1 = cb->r; - - test(b1); - test(b1->sb == "D3.sb"); - test(b1->ice_id() == "::Test::B"); // Sliced by server - D3Ptr p1 = D3Ptr::dynamicCast(b1); - test(!p1); - - BPtr b2 = b1->pb; - test(b2); - test(b2->sb == "D1.sb"); - test(b2->ice_id() == "::Test::D1"); - test(b2->pb == b1); - D1Ptr p3 = D1Ptr::dynamicCast(b2); - test(p3); - test(p3->sd1 == "D1.sd1"); - test(p3->pd1 == b1); - - test(b1 != d1); - test(b1 != d3); - test(b2 != d1); - test(b2 != d3); - } - catch(...) - { - test(0); - } + try + { + D1Ptr d1 = new D1; + d1->sb = "D1.sb"; + d1->sd1 = "D1.sd1"; + D3Ptr d3 = new D3; + d3->pb = d1; + d3->sb = "D3.sb"; + d3->sd3 = "D3.sd3"; + d3->pd3 = d1; + d1->pb = d3; + d1->pd1 = d3; + + AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; + test->returnTest3_async(cb, d3, d1); + test(cb->check()); + BPtr b1 = cb->r; + + test(b1); + test(b1->sb == "D3.sb"); + test(b1->ice_id() == "::Test::B"); // Sliced by server + D3Ptr p1 = D3Ptr::dynamicCast(b1); + test(!p1); + + BPtr b2 = b1->pb; + test(b2); + test(b2->sb == "D1.sb"); + test(b2->ice_id() == "::Test::D1"); + test(b2->pb == b1); + D1Ptr p3 = D1Ptr::dynamicCast(b2); + test(p3); + test(p3->sd1 == "D1.sd1"); + test(p3->pd1 == b1); + + test(b1 != d1); + test(b1 != d3); + test(b2 != d1); + test(b2 != d3); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "remainder unmarshaling (3 instances)... " << flush; { - try - { - BPtr p1; - BPtr p2; - BPtr ret = test->paramTest3(p1, p2); - - test(p1); - test(p1->sb == "D2.sb (p1 1)"); - test(p1->pb == 0); - test(p1->ice_id() == "::Test::B"); - - test(p2); - test(p2->sb == "D2.sb (p2 1)"); - test(p2->pb == 0); - test(p2->ice_id() == "::Test::B"); - - test(ret); - test(ret->sb == "D1.sb (p2 2)"); - test(ret->pb == 0); - test(ret->ice_id() == "::Test::D1"); - } - catch(...) - { - test(0); - } + try + { + BPtr p1; + BPtr p2; + BPtr ret = test->paramTest3(p1, p2); + + test(p1); + test(p1->sb == "D2.sb (p1 1)"); + test(p1->pb == 0); + test(p1->ice_id() == "::Test::B"); + + test(p2); + test(p2->sb == "D2.sb (p2 1)"); + test(p2->pb == 0); + test(p2->ice_id() == "::Test::B"); + + test(ret); + test(ret->sb == "D1.sb (p2 2)"); + test(ret->pb == 0); + test(ret->ice_id() == "::Test::D1"); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "remainder unmarshaling (3 instances) (AMI)... " << flush; { - AMI_Test_paramTest3IPtr cb = new AMI_Test_paramTest3I; - test->paramTest3_async(cb); - test(cb->check()); + AMI_Test_paramTest3IPtr cb = new AMI_Test_paramTest3I; + test->paramTest3_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "remainder unmarshaling (4 instances)... " << flush; { - try - { - BPtr b; - BPtr ret = test->paramTest4(b); - - test(b); - test(b->sb == "D4.sb (1)"); - test(b->pb == 0); - test(b->ice_id() == "::Test::B"); - - test(ret); - test(ret->sb == "B.sb (2)"); - test(ret->pb == 0); - test(ret->ice_id() == "::Test::B"); - } - catch(...) - { - test(0); - } + try + { + BPtr b; + BPtr ret = test->paramTest4(b); + + test(b); + test(b->sb == "D4.sb (1)"); + test(b->pb == 0); + test(b->ice_id() == "::Test::B"); + + test(ret); + test(ret->sb == "B.sb (2)"); + test(ret->pb == 0); + test(ret->ice_id() == "::Test::B"); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "remainder unmarshaling (4 instances) (AMI)... " << flush; { - BPtr b; - AMI_Test_paramTest4IPtr cb = new AMI_Test_paramTest4I; - test->paramTest4_async(cb); - test(cb->check()); + BPtr b; + AMI_Test_paramTest4IPtr cb = new AMI_Test_paramTest4I; + test->paramTest4_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "param ptr slicing, instance marshaled in unknown derived as base... " << flush; { - try - { - BPtr b1 = new B; - b1->sb = "B.sb(1)"; - b1->pb = b1; - - D3Ptr d3 = new D3; - d3->sb = "D3.sb"; - d3->pb = d3; - d3->sd3 = "D3.sd3"; - d3->pd3 = b1; - - BPtr b2 = new B; - b2->sb = "B.sb(2)"; - b2->pb = b1; - - BPtr r = test->returnTest3(d3, b2); - - test(r); - test(r->ice_id() == "::Test::B"); - test(r->sb == "D3.sb"); - test(r->pb == r); - } - catch(...) - { - test(0); - } + try + { + BPtr b1 = new B; + b1->sb = "B.sb(1)"; + b1->pb = b1; + + D3Ptr d3 = new D3; + d3->sb = "D3.sb"; + d3->pb = d3; + d3->sd3 = "D3.sd3"; + d3->pd3 = b1; + + BPtr b2 = new B; + b2->sb = "B.sb(2)"; + b2->pb = b1; + + BPtr r = test->returnTest3(d3, b2); + + test(r); + test(r->ice_id() == "::Test::B"); + test(r->sb == "D3.sb"); + test(r->pb == r); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "param ptr slicing, instance marshaled in unknown derived as base (AMI)... " << flush; { - try - { - BPtr b1 = new B; - b1->sb = "B.sb(1)"; - b1->pb = b1; - - D3Ptr d3 = new D3; - d3->sb = "D3.sb"; - d3->pb = d3; - d3->sd3 = "D3.sd3"; - d3->pd3 = b1; - - BPtr b2 = new B; - b2->sb = "B.sb(2)"; - b2->pb = b1; - - AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; - test->returnTest3_async(cb, d3, b2); - test(cb->check()); - BPtr r = cb->r; - - test(r); - test(r->ice_id() == "::Test::B"); - test(r->sb == "D3.sb"); - test(r->pb == r); - } - catch(...) - { - test(0); - } + try + { + BPtr b1 = new B; + b1->sb = "B.sb(1)"; + b1->pb = b1; + + D3Ptr d3 = new D3; + d3->sb = "D3.sb"; + d3->pb = d3; + d3->sd3 = "D3.sd3"; + d3->pd3 = b1; + + BPtr b2 = new B; + b2->sb = "B.sb(2)"; + b2->pb = b1; + + AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; + test->returnTest3_async(cb, d3, b2); + test(cb->check()); + BPtr r = cb->r; + + test(r); + test(r->ice_id() == "::Test::B"); + test(r->sb == "D3.sb"); + test(r->pb == r); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "param ptr slicing, instance marshaled in unknown derived as derived... " - << flush; - { - try - { - D1Ptr d11 = new D1; - d11->sb = "D1.sb(1)"; - d11->pb = d11; - d11->sd1 = "D1.sd1(1)"; - - D3Ptr d3 = new D3; - d3->sb = "D3.sb"; - d3->pb = d3; - d3->sd3 = "D3.sd3"; - d3->pd3 = d11; - - D1Ptr d12 = new D1; - d12->sb = "D1.sb(2)"; - d12->pb = d12; - d12->sd1 = "D1.sd1(2)"; - d12->pd1 = d11; - - BPtr r = test->returnTest3(d3, d12); - test(r); - test(r->ice_id() == "::Test::B"); - test(r->sb == "D3.sb"); - test(r->pb == r); - } - catch(...) - { - test(0); - } + << flush; + { + try + { + D1Ptr d11 = new D1; + d11->sb = "D1.sb(1)"; + d11->pb = d11; + d11->sd1 = "D1.sd1(1)"; + + D3Ptr d3 = new D3; + d3->sb = "D3.sb"; + d3->pb = d3; + d3->sd3 = "D3.sd3"; + d3->pd3 = d11; + + D1Ptr d12 = new D1; + d12->sb = "D1.sb(2)"; + d12->pb = d12; + d12->sd1 = "D1.sd1(2)"; + d12->pd1 = d11; + + BPtr r = test->returnTest3(d3, d12); + test(r); + test(r->ice_id() == "::Test::B"); + test(r->sb == "D3.sb"); + test(r->pb == r); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "param ptr slicing, instance marshaled in unknown derived as derived (AMI)... " - << flush; - { - try - { - D1Ptr d11 = new D1; - d11->sb = "D1.sb(1)"; - d11->pb = d11; - d11->sd1 = "D1.sd1(1)"; - - D3Ptr d3 = new D3; - d3->sb = "D3.sb"; - d3->pb = d3; - d3->sd3 = "D3.sd3"; - d3->pd3 = d11; - - D1Ptr d12 = new D1; - d12->sb = "D1.sb(2)"; - d12->pb = d12; - d12->sd1 = "D1.sd1(2)"; - d12->pd1 = d11; - - AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; - test->returnTest3_async(cb, d3, d12); - test(cb->check()); - BPtr r = cb->r; - test(r); - test(r->ice_id() == "::Test::B"); - test(r->sb == "D3.sb"); - test(r->pb == r); - } - catch(...) - { - test(0); - } + << flush; + { + try + { + D1Ptr d11 = new D1; + d11->sb = "D1.sb(1)"; + d11->pb = d11; + d11->sd1 = "D1.sd1(1)"; + + D3Ptr d3 = new D3; + d3->sb = "D3.sb"; + d3->pb = d3; + d3->sd3 = "D3.sd3"; + d3->pd3 = d11; + + D1Ptr d12 = new D1; + d12->sb = "D1.sb(2)"; + d12->pb = d12; + d12->sd1 = "D1.sd1(2)"; + d12->pd1 = d11; + + AMI_Test_returnTest3IPtr cb = new AMI_Test_returnTest3I; + test->returnTest3_async(cb, d3, d12); + test(cb->check()); + BPtr r = cb->r; + test(r); + test(r->ice_id() == "::Test::B"); + test(r->sb == "D3.sb"); + test(r->pb == r); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "sequence slicing... " << flush; { - try - { - SS ss; - { - BPtr ss1b = new B; - ss1b->sb = "B.sb"; - ss1b->pb = ss1b; - - D1Ptr ss1d1 = new D1; - ss1d1->sb = "D1.sb"; - ss1d1->sd1 = "D1.sd1"; - ss1d1->pb = ss1b; - - D3Ptr ss1d3 = new D3; - ss1d3->sb = "D3.sb"; - ss1d3->sd3 = "D3.sd3"; - ss1d3->pb = ss1b; - - BPtr ss2b = new B; - ss2b->sb = "B.sb"; - ss2b->pb = ss1b; - - D1Ptr ss2d1 = new D1; - ss2d1->sb = "D1.sb"; - ss2d1->sd1 = "D1.sd1"; - ss2d1->pb = ss2b; - - D3Ptr ss2d3 = new D3; - ss2d3->sb = "D3.sb"; - ss2d3->sd3 = "D3.sd3"; - ss2d3->pb = ss2b; - - ss1d1->pd1 = ss2b; - ss1d3->pd3 = ss2d1; - - ss2d1->pd1 = ss1d3; - ss2d3->pd3 = ss1d1; - - SS1Ptr ss1 = new SS1; - ss1->s.push_back(ss1b); - ss1->s.push_back(ss1d1); - ss1->s.push_back(ss1d3); - - SS2Ptr ss2 = new SS2; - ss2->s.push_back(ss2b); - ss2->s.push_back(ss2d1); - ss2->s.push_back(ss2d3); - - ss = test->sequenceTest(ss1, ss2); - } - - test(ss.c1); - BPtr ss1b = ss.c1->s[0]; - BPtr ss1d1 = ss.c1->s[1]; - test(ss.c2); - BPtr ss1d3 = ss.c1->s[2]; - - test(ss.c2); - BPtr ss2b = ss.c2->s[0]; - BPtr ss2d1 = ss.c2->s[1]; - BPtr ss2d3 = ss.c2->s[2]; - - test(ss1b->pb == ss1b); - test(ss1d1->pb == ss1b); - test(ss1d3->pb == ss1b); - - test(ss2b->pb == ss1b); - test(ss2d1->pb == ss2b); - test(ss2d3->pb == ss2b); - - test(ss1b->ice_id() == "::Test::B"); - test(ss1d1->ice_id() == "::Test::D1"); - test(ss1d3->ice_id() == "::Test::B"); - - test(ss2b->ice_id() == "::Test::B"); - test(ss2d1->ice_id() == "::Test::D1"); - test(ss2d3->ice_id() == "::Test::B"); - } - catch(const ::Ice::Exception&) - { - test(0); - } + try + { + SS ss; + { + BPtr ss1b = new B; + ss1b->sb = "B.sb"; + ss1b->pb = ss1b; + + D1Ptr ss1d1 = new D1; + ss1d1->sb = "D1.sb"; + ss1d1->sd1 = "D1.sd1"; + ss1d1->pb = ss1b; + + D3Ptr ss1d3 = new D3; + ss1d3->sb = "D3.sb"; + ss1d3->sd3 = "D3.sd3"; + ss1d3->pb = ss1b; + + BPtr ss2b = new B; + ss2b->sb = "B.sb"; + ss2b->pb = ss1b; + + D1Ptr ss2d1 = new D1; + ss2d1->sb = "D1.sb"; + ss2d1->sd1 = "D1.sd1"; + ss2d1->pb = ss2b; + + D3Ptr ss2d3 = new D3; + ss2d3->sb = "D3.sb"; + ss2d3->sd3 = "D3.sd3"; + ss2d3->pb = ss2b; + + ss1d1->pd1 = ss2b; + ss1d3->pd3 = ss2d1; + + ss2d1->pd1 = ss1d3; + ss2d3->pd3 = ss1d1; + + SS1Ptr ss1 = new SS1; + ss1->s.push_back(ss1b); + ss1->s.push_back(ss1d1); + ss1->s.push_back(ss1d3); + + SS2Ptr ss2 = new SS2; + ss2->s.push_back(ss2b); + ss2->s.push_back(ss2d1); + ss2->s.push_back(ss2d3); + + ss = test->sequenceTest(ss1, ss2); + } + + test(ss.c1); + BPtr ss1b = ss.c1->s[0]; + BPtr ss1d1 = ss.c1->s[1]; + test(ss.c2); + BPtr ss1d3 = ss.c1->s[2]; + + test(ss.c2); + BPtr ss2b = ss.c2->s[0]; + BPtr ss2d1 = ss.c2->s[1]; + BPtr ss2d3 = ss.c2->s[2]; + + test(ss1b->pb == ss1b); + test(ss1d1->pb == ss1b); + test(ss1d3->pb == ss1b); + + test(ss2b->pb == ss1b); + test(ss2d1->pb == ss2b); + test(ss2d3->pb == ss2b); + + test(ss1b->ice_id() == "::Test::B"); + test(ss1d1->ice_id() == "::Test::D1"); + test(ss1d3->ice_id() == "::Test::B"); + + test(ss2b->ice_id() == "::Test::B"); + test(ss2d1->ice_id() == "::Test::D1"); + test(ss2d3->ice_id() == "::Test::B"); + } + catch(const ::Ice::Exception&) + { + test(0); + } } cout << "ok" << endl; cout << "sequence slicing (AMI)... " << flush; { - try - { - SS ss; - { - BPtr ss1b = new B; - ss1b->sb = "B.sb"; - ss1b->pb = ss1b; - - D1Ptr ss1d1 = new D1; - ss1d1->sb = "D1.sb"; - ss1d1->sd1 = "D1.sd1"; - ss1d1->pb = ss1b; - - D3Ptr ss1d3 = new D3; - ss1d3->sb = "D3.sb"; - ss1d3->sd3 = "D3.sd3"; - ss1d3->pb = ss1b; - - BPtr ss2b = new B; - ss2b->sb = "B.sb"; - ss2b->pb = ss1b; - - D1Ptr ss2d1 = new D1; - ss2d1->sb = "D1.sb"; - ss2d1->sd1 = "D1.sd1"; - ss2d1->pb = ss2b; - - D3Ptr ss2d3 = new D3; - ss2d3->sb = "D3.sb"; - ss2d3->sd3 = "D3.sd3"; - ss2d3->pb = ss2b; - - ss1d1->pd1 = ss2b; - ss1d3->pd3 = ss2d1; - - ss2d1->pd1 = ss1d3; - ss2d3->pd3 = ss1d1; - - SS1Ptr ss1 = new SS1; - ss1->s.push_back(ss1b); - ss1->s.push_back(ss1d1); - ss1->s.push_back(ss1d3); - - SS2Ptr ss2 = new SS2; - ss2->s.push_back(ss2b); - ss2->s.push_back(ss2d1); - ss2->s.push_back(ss2d3); - - AMI_Test_sequenceTestIPtr cb = new AMI_Test_sequenceTestI; - test->sequenceTest_async(cb, ss1, ss2); - test(cb->check()); - ss = cb->r; - } - - test(ss.c1); - BPtr ss1b = ss.c1->s[0]; - BPtr ss1d1 = ss.c1->s[1]; - test(ss.c2); - BPtr ss1d3 = ss.c1->s[2]; - - test(ss.c2); - BPtr ss2b = ss.c2->s[0]; - BPtr ss2d1 = ss.c2->s[1]; - BPtr ss2d3 = ss.c2->s[2]; - - test(ss1b->pb == ss1b); - test(ss1d1->pb == ss1b); - test(ss1d3->pb == ss1b); - - test(ss2b->pb == ss1b); - test(ss2d1->pb == ss2b); - test(ss2d3->pb == ss2b); - - test(ss1b->ice_id() == "::Test::B"); - test(ss1d1->ice_id() == "::Test::D1"); - test(ss1d3->ice_id() == "::Test::B"); - - test(ss2b->ice_id() == "::Test::B"); - test(ss2d1->ice_id() == "::Test::D1"); - test(ss2d3->ice_id() == "::Test::B"); - } - catch(const ::Ice::Exception&) - { - test(0); - } + try + { + SS ss; + { + BPtr ss1b = new B; + ss1b->sb = "B.sb"; + ss1b->pb = ss1b; + + D1Ptr ss1d1 = new D1; + ss1d1->sb = "D1.sb"; + ss1d1->sd1 = "D1.sd1"; + ss1d1->pb = ss1b; + + D3Ptr ss1d3 = new D3; + ss1d3->sb = "D3.sb"; + ss1d3->sd3 = "D3.sd3"; + ss1d3->pb = ss1b; + + BPtr ss2b = new B; + ss2b->sb = "B.sb"; + ss2b->pb = ss1b; + + D1Ptr ss2d1 = new D1; + ss2d1->sb = "D1.sb"; + ss2d1->sd1 = "D1.sd1"; + ss2d1->pb = ss2b; + + D3Ptr ss2d3 = new D3; + ss2d3->sb = "D3.sb"; + ss2d3->sd3 = "D3.sd3"; + ss2d3->pb = ss2b; + + ss1d1->pd1 = ss2b; + ss1d3->pd3 = ss2d1; + + ss2d1->pd1 = ss1d3; + ss2d3->pd3 = ss1d1; + + SS1Ptr ss1 = new SS1; + ss1->s.push_back(ss1b); + ss1->s.push_back(ss1d1); + ss1->s.push_back(ss1d3); + + SS2Ptr ss2 = new SS2; + ss2->s.push_back(ss2b); + ss2->s.push_back(ss2d1); + ss2->s.push_back(ss2d3); + + AMI_Test_sequenceTestIPtr cb = new AMI_Test_sequenceTestI; + test->sequenceTest_async(cb, ss1, ss2); + test(cb->check()); + ss = cb->r; + } + + test(ss.c1); + BPtr ss1b = ss.c1->s[0]; + BPtr ss1d1 = ss.c1->s[1]; + test(ss.c2); + BPtr ss1d3 = ss.c1->s[2]; + + test(ss.c2); + BPtr ss2b = ss.c2->s[0]; + BPtr ss2d1 = ss.c2->s[1]; + BPtr ss2d3 = ss.c2->s[2]; + + test(ss1b->pb == ss1b); + test(ss1d1->pb == ss1b); + test(ss1d3->pb == ss1b); + + test(ss2b->pb == ss1b); + test(ss2d1->pb == ss2b); + test(ss2d3->pb == ss2b); + + test(ss1b->ice_id() == "::Test::B"); + test(ss1d1->ice_id() == "::Test::D1"); + test(ss1d3->ice_id() == "::Test::B"); + + test(ss2b->ice_id() == "::Test::B"); + test(ss2d1->ice_id() == "::Test::D1"); + test(ss2d3->ice_id() == "::Test::B"); + } + catch(const ::Ice::Exception&) + { + test(0); + } } cout << "ok" << endl; cout << "dictionary slicing... " << flush; { - try - { - BDict bin; - BDict bout; - BDict r; - int i; - for(i = 0; i < 10; ++i) - { - ostringstream s; - s << "D1." << i; - D1Ptr d1 = new D1; - d1->sb = s.str(); - d1->pb = d1; - d1->sd1 = s.str(); - bin[i] = d1; - } - - r = test->dictionaryTest(bin, bout); - - test(bout.size() == 10); - for(i = 0; i < 10; ++i) - { - BPtr b = bout.find(i * 10)->second; - test(b); - std::ostringstream s; - s << "D1." << i; - test(b->sb == s.str()); - test(b->pb); - test(b->pb != b); - test(b->pb->sb == s.str()); - test(b->pb->pb == b->pb); - } - - test(r.size() == 10); - for(i = 0; i < 10; ++i) - { - BPtr b = r.find(i * 20)->second; - test(b); - std::ostringstream s; - s << "D1." << i * 20; - test(b->sb == s.str()); - test(b->pb == (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second)); - D1Ptr d1 = D1Ptr::dynamicCast(b); - test(d1); - test(d1->sd1 == s.str()); - test(d1->pd1 == d1); - } - } - catch(const ::Ice::Exception&) - { - test(0); - } + try + { + BDict bin; + BDict bout; + BDict r; + int i; + for(i = 0; i < 10; ++i) + { + ostringstream s; + s << "D1." << i; + D1Ptr d1 = new D1; + d1->sb = s.str(); + d1->pb = d1; + d1->sd1 = s.str(); + bin[i] = d1; + } + + r = test->dictionaryTest(bin, bout); + + test(bout.size() == 10); + for(i = 0; i < 10; ++i) + { + BPtr b = bout.find(i * 10)->second; + test(b); + std::ostringstream s; + s << "D1." << i; + test(b->sb == s.str()); + test(b->pb); + test(b->pb != b); + test(b->pb->sb == s.str()); + test(b->pb->pb == b->pb); + } + + test(r.size() == 10); + for(i = 0; i < 10; ++i) + { + BPtr b = r.find(i * 20)->second; + test(b); + std::ostringstream s; + s << "D1." << i * 20; + test(b->sb == s.str()); + test(b->pb == (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second)); + D1Ptr d1 = D1Ptr::dynamicCast(b); + test(d1); + test(d1->sd1 == s.str()); + test(d1->pd1 == d1); + } + } + catch(const ::Ice::Exception&) + { + test(0); + } } cout << "ok" << endl; cout << "dictionary slicing (AMI)... " << flush; { - try - { - BDict bin; - BDict bout; - BDict r; - int i; - for(i = 0; i < 10; ++i) - { - ostringstream s; - s << "D1." << i; - D1Ptr d1 = new D1; - d1->sb = s.str(); - d1->pb = d1; - d1->sd1 = s.str(); - bin[i] = d1; - } - - AMI_Test_dictionaryTestIPtr cb = new AMI_Test_dictionaryTestI; - test->dictionaryTest_async(cb, bin); - test(cb->check()); - bout = cb->bout; - r = cb->r; - - test(bout.size() == 10); - for(i = 0; i < 10; ++i) - { - BPtr b = bout.find(i * 10)->second; - test(b); - std::ostringstream s; - s << "D1." << i; - test(b->sb == s.str()); - test(b->pb); - test(b->pb != b); - test(b->pb->sb == s.str()); - test(b->pb->pb == b->pb); - } - - test(r.size() == 10); - for(i = 0; i < 10; ++i) - { - BPtr b = r.find(i * 20)->second; - test(b); - std::ostringstream s; - s << "D1." << i * 20; - test(b->sb == s.str()); - test(b->pb == (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second)); - D1Ptr d1 = D1Ptr::dynamicCast(b); - test(d1); - test(d1->sd1 == s.str()); - test(d1->pd1 == d1); - } - } - catch(const ::Ice::Exception&) - { - test(0); - } + try + { + BDict bin; + BDict bout; + BDict r; + int i; + for(i = 0; i < 10; ++i) + { + ostringstream s; + s << "D1." << i; + D1Ptr d1 = new D1; + d1->sb = s.str(); + d1->pb = d1; + d1->sd1 = s.str(); + bin[i] = d1; + } + + AMI_Test_dictionaryTestIPtr cb = new AMI_Test_dictionaryTestI; + test->dictionaryTest_async(cb, bin); + test(cb->check()); + bout = cb->bout; + r = cb->r; + + test(bout.size() == 10); + for(i = 0; i < 10; ++i) + { + BPtr b = bout.find(i * 10)->second; + test(b); + std::ostringstream s; + s << "D1." << i; + test(b->sb == s.str()); + test(b->pb); + test(b->pb != b); + test(b->pb->sb == s.str()); + test(b->pb->pb == b->pb); + } + + test(r.size() == 10); + for(i = 0; i < 10; ++i) + { + BPtr b = r.find(i * 20)->second; + test(b); + std::ostringstream s; + s << "D1." << i * 20; + test(b->sb == s.str()); + test(b->pb == (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second)); + D1Ptr d1 = D1Ptr::dynamicCast(b); + test(d1); + test(d1->sd1 == s.str()); + test(d1->pd1 == d1); + } + } + catch(const ::Ice::Exception&) + { + test(0); + } } cout << "ok" << endl; cout << "base exception thrown as base exception... " << flush; { - try - { - test->throwBaseAsBase(); - test(0); - } - catch(const BaseException& e) - { - test(e.ice_name() == "Test::BaseException"); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb"); - test(e.pb->pb == e.pb); - } - catch(...) - { - test(0); - } + try + { + test->throwBaseAsBase(); + test(0); + } + catch(const BaseException& e) + { + test(e.ice_name() == "Test::BaseException"); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb"); + test(e.pb->pb == e.pb); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "base exception thrown as base exception (AMI)... " << flush; { - AMI_Test_throwBaseAsBaseIPtr cb = new AMI_Test_throwBaseAsBaseI; - test->throwBaseAsBase_async(cb); - test(cb->check()); + AMI_Test_throwBaseAsBaseIPtr cb = new AMI_Test_throwBaseAsBaseI; + test->throwBaseAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "derived exception thrown as base exception... " << flush; { - try - { - test->throwDerivedAsBase(); - test(0); - } - catch(const DerivedException& e) - { - test(e.ice_name() == "Test::DerivedException"); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb1"); - test(e.pb->pb == e.pb); - test(e.sde == "sde1"); - test(e.pd1); - test(e.pd1->sb == "sb2"); - test(e.pd1->pb == e.pd1); - test(e.pd1->sd1 == "sd2"); - test(e.pd1->pd1 == e.pd1); - } - catch(...) - { - test(0); - } + try + { + test->throwDerivedAsBase(); + test(0); + } + catch(const DerivedException& e) + { + test(e.ice_name() == "Test::DerivedException"); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb1"); + test(e.pb->pb == e.pb); + test(e.sde == "sde1"); + test(e.pd1); + test(e.pd1->sb == "sb2"); + test(e.pd1->pb == e.pd1); + test(e.pd1->sd1 == "sd2"); + test(e.pd1->pd1 == e.pd1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "derived exception thrown as base exception (AMI)... " << flush; { - AMI_Test_throwDerivedAsBaseIPtr cb = new AMI_Test_throwDerivedAsBaseI; - test->throwDerivedAsBase_async(cb); - test(cb->check()); + AMI_Test_throwDerivedAsBaseIPtr cb = new AMI_Test_throwDerivedAsBaseI; + test->throwDerivedAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "derived exception thrown as derived exception... " << flush; { - try - { - test->throwDerivedAsDerived(); - test(0); - } - catch(const DerivedException& e) - { - test(e.ice_name() == "Test::DerivedException"); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb1"); - test(e.pb->pb == e.pb); - test(e.sde == "sde1"); - test(e.pd1); - test(e.pd1->sb == "sb2"); - test(e.pd1->pb == e.pd1); - test(e.pd1->sd1 == "sd2"); - test(e.pd1->pd1 == e.pd1); - } - catch(...) - { - test(0); - } + try + { + test->throwDerivedAsDerived(); + test(0); + } + catch(const DerivedException& e) + { + test(e.ice_name() == "Test::DerivedException"); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb1"); + test(e.pb->pb == e.pb); + test(e.sde == "sde1"); + test(e.pd1); + test(e.pd1->sb == "sb2"); + test(e.pd1->pb == e.pd1); + test(e.pd1->sd1 == "sd2"); + test(e.pd1->pd1 == e.pd1); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "derived exception thrown as derived exception (AMI)... " << flush; { - AMI_Test_throwDerivedAsDerivedIPtr cb = new AMI_Test_throwDerivedAsDerivedI; - test->throwDerivedAsDerived_async(cb); - test(cb->check()); + AMI_Test_throwDerivedAsDerivedIPtr cb = new AMI_Test_throwDerivedAsDerivedI; + test->throwDerivedAsDerived_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "unknown derived exception thrown as base exception... " << flush; { - try - { - test->throwUnknownDerivedAsBase(); - test(0); - } - catch(const BaseException& e) - { - test(e.ice_name() == "Test::BaseException"); - test(e.sbe == "sbe"); - test(e.pb); - test(e.pb->sb == "sb d2"); - test(e.pb->pb == e.pb); - } - catch(...) - { - test(0); - } + try + { + test->throwUnknownDerivedAsBase(); + test(0); + } + catch(const BaseException& e) + { + test(e.ice_name() == "Test::BaseException"); + test(e.sbe == "sbe"); + test(e.pb); + test(e.pb->sb == "sb d2"); + test(e.pb->pb == e.pb); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "unknown derived exception thrown as base exception (AMI)... " << flush; { - AMI_Test_throwUnknownDerivedAsBaseIPtr cb = new AMI_Test_throwUnknownDerivedAsBaseI; - test->throwUnknownDerivedAsBase_async(cb); - test(cb->check()); + AMI_Test_throwUnknownDerivedAsBaseIPtr cb = new AMI_Test_throwUnknownDerivedAsBaseI; + test->throwUnknownDerivedAsBase_async(cb); + test(cb->check()); } cout << "ok" << endl; cout << "forward-declared class... " << flush; { - try - { - ForwardPtr f; - test->useForward(f); - test(f); - } - catch(...) - { - test(0); - } + try + { + ForwardPtr f; + test->useForward(f); + test(f); + } + catch(...) + { + test(0); + } } cout << "ok" << endl; cout << "forward-declared class (AMI)... " << flush; { - AMI_Test_useForwardIPtr cb = new AMI_Test_useForwardI; - test->useForward_async(cb); - test(cb->check()); + AMI_Test_useForwardIPtr cb = new AMI_Test_useForwardI; + test->useForward_async(cb); + test(cb->check()); } cout << "ok" << endl; diff --git a/cpp/test/Ice/slicing/objects/Client.cpp b/cpp/test/Ice/slicing/objects/Client.cpp index 94509fc0099..f3ca8da558d 100644 --- a/cpp/test/Ice/slicing/objects/Client.cpp +++ b/cpp/test/Ice/slicing/objects/Client.cpp @@ -31,26 +31,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/slicing/objects/Server.cpp b/cpp/test/Ice/slicing/objects/Server.cpp index 9a7ad52c084..697d3b3cbfa 100644 --- a/cpp/test/Ice/slicing/objects/Server.cpp +++ b/cpp/test/Ice/slicing/objects/Server.cpp @@ -34,26 +34,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/slicing/objects/ServerAMD.cpp b/cpp/test/Ice/slicing/objects/ServerAMD.cpp index f19fcbf7f44..16190251017 100644 --- a/cpp/test/Ice/slicing/objects/ServerAMD.cpp +++ b/cpp/test/Ice/slicing/objects/ServerAMD.cpp @@ -34,26 +34,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/slicing/objects/Test.ice b/cpp/test/Ice/slicing/objects/Test.ice index 9d31ce660b5..01e91579311 100644 --- a/cpp/test/Ice/slicing/objects/Test.ice +++ b/cpp/test/Ice/slicing/objects/Test.ice @@ -67,7 +67,7 @@ exception DerivedException extends BaseException D1 pd1; }; -class Forward; // Forward-declared class defined in another compilation unit +class Forward; // Forward-declared class defined in another compilation unit ["ami"] interface TestIntf { @@ -104,7 +104,7 @@ class Forward; // Forward-declared class defined in another compilation unit void throwDerivedAsDerived() throws DerivedException; void throwUnknownDerivedAsBase() throws BaseException; - void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. + void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. void shutdown(); }; diff --git a/cpp/test/Ice/slicing/objects/TestAMD.ice b/cpp/test/Ice/slicing/objects/TestAMD.ice index 9303d9e8325..1fe41bec3f5 100644 --- a/cpp/test/Ice/slicing/objects/TestAMD.ice +++ b/cpp/test/Ice/slicing/objects/TestAMD.ice @@ -67,7 +67,7 @@ exception DerivedException extends BaseException D1 pd1; }; -class Forward; // Forward-declared class defined in another compilation unit +class Forward; // Forward-declared class defined in another compilation unit ["ami", "amd"] interface TestIntf { @@ -104,7 +104,7 @@ class Forward; // Forward-declared class defined in another compilation unit void throwDerivedAsDerived() throws DerivedException; void throwUnknownDerivedAsBase() throws BaseException; - void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. + void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. void shutdown(); }; diff --git a/cpp/test/Ice/slicing/objects/TestAMDI.cpp b/cpp/test/Ice/slicing/objects/TestAMDI.cpp index b8ca525e84c..ec4dfa48769 100644 --- a/cpp/test/Ice/slicing/objects/TestAMDI.cpp +++ b/cpp/test/Ice/slicing/objects/TestAMDI.cpp @@ -45,7 +45,7 @@ TestI::SBSKnownDerivedAsSBase_async(const AMD_TestIntf_SBSKnownDerivedAsSBasePtr void TestI::SBSKnownDerivedAsSBSKnownDerived_async(const AMD_TestIntf_SBSKnownDerivedAsSBSKnownDerivedPtr& cb, - const ::Ice::Current&) + const ::Ice::Current&) { SBSKnownDerivedPtr sbskd = new SBSKnownDerived; sbskd->sb = "SBSKnownDerived.sb"; @@ -254,7 +254,7 @@ TestI::returnTest3_async(const AMD_TestIntf_returnTest3Ptr& cb, const BPtr& p1, void TestI::sequenceTest_async(const AMD_TestIntf_sequenceTestPtr& cb, - const SS1Ptr& p1, const SS2Ptr& p2, const ::Ice::Current&) + const SS1Ptr& p1, const SS2Ptr& p2, const ::Ice::Current&) { SS ss; ss.c1 = p1; @@ -269,25 +269,25 @@ TestI::dictionaryTest_async(const AMD_TestIntf_dictionaryTestPtr& cb, const BDic int i; for(i = 0; i < 10; ++i) { - BPtr b = bin.find(i)->second; - D2Ptr d2 = new D2; - d2->sb = b->sb; - d2->pb = b->pb; - d2->sd2 = "D2"; - d2->pd2 = d2; - bout[i * 10] = d2; + BPtr b = bin.find(i)->second; + D2Ptr d2 = new D2; + d2->sb = b->sb; + d2->pb = b->pb; + d2->sd2 = "D2"; + d2->pd2 = d2; + bout[i * 10] = d2; } BDict r; for(i = 0; i < 10; ++i) { - std::ostringstream s; - s << "D1." << i * 20; - D1Ptr d1 = new D1; - d1->sb = s.str(); - d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second); - d1->sd1 = s.str(); - d1->pd1 = d1; - r[i * 20] = d1; + std::ostringstream s; + s << "D1." << i * 20; + D1Ptr d1 = new D1; + d1->sb = s.str(); + d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second); + d1->sd1 = s.str(); + d1->pd1 = d1; + r[i * 20] = d1; } cb->ice_response(r, bout); } diff --git a/cpp/test/Ice/slicing/objects/TestAMDI.h b/cpp/test/Ice/slicing/objects/TestAMDI.h index edb10690fce..81224a27376 100644 --- a/cpp/test/Ice/slicing/objects/TestAMDI.h +++ b/cpp/test/Ice/slicing/objects/TestAMDI.h @@ -22,12 +22,12 @@ public: virtual void SBaseAsObject_async(const ::Test::AMD_TestIntf_SBaseAsObjectPtr&, const ::Ice::Current&); virtual void SBaseAsSBase_async(const ::Test::AMD_TestIntf_SBaseAsSBasePtr&, const ::Ice::Current&); virtual void SBSKnownDerivedAsSBase_async(const ::Test::AMD_TestIntf_SBSKnownDerivedAsSBasePtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void SBSKnownDerivedAsSBSKnownDerived_async(const ::Test::AMD_TestIntf_SBSKnownDerivedAsSBSKnownDerivedPtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void SBSUnknownDerivedAsSBase_async(const ::Test::AMD_TestIntf_SBSUnknownDerivedAsSBasePtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void SUnknownAsObject_async(const ::Test::AMD_TestIntf_SUnknownAsObjectPtr&, const ::Ice::Current&); @@ -46,20 +46,20 @@ public: virtual void returnTest1_async(const ::Test::AMD_TestIntf_returnTest1Ptr&, const ::Ice::Current&); virtual void returnTest2_async(const ::Test::AMD_TestIntf_returnTest2Ptr&, const ::Ice::Current&); virtual void returnTest3_async(const ::Test::AMD_TestIntf_returnTest3Ptr&, const ::Test::BPtr&, const ::Test::BPtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void sequenceTest_async(const ::Test::AMD_TestIntf_sequenceTestPtr&, - const ::Test::SS1Ptr&, const ::Test::SS2Ptr&, const ::Ice::Current&); + const ::Test::SS1Ptr&, const ::Test::SS2Ptr&, const ::Ice::Current&); virtual void dictionaryTest_async(const ::Test::AMD_TestIntf_dictionaryTestPtr&, - const ::Test::BDict&, const ::Ice::Current&); + const ::Test::BDict&, const ::Ice::Current&); virtual void throwBaseAsBase_async(const ::Test::AMD_TestIntf_throwBaseAsBasePtr&, const ::Ice::Current&); virtual void throwDerivedAsBase_async(const ::Test::AMD_TestIntf_throwDerivedAsBasePtr&, const ::Ice::Current&); virtual void throwDerivedAsDerived_async(const ::Test::AMD_TestIntf_throwDerivedAsDerivedPtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void throwUnknownDerivedAsBase_async(const ::Test::AMD_TestIntf_throwUnknownDerivedAsBasePtr&, - const ::Ice::Current&); + const ::Ice::Current&); virtual void useForward_async(const ::Test::AMD_TestIntf_useForwardPtr&, const ::Ice::Current&); diff --git a/cpp/test/Ice/slicing/objects/TestI.cpp b/cpp/test/Ice/slicing/objects/TestI.cpp index 660ba0b86dc..bf33febf78d 100644 --- a/cpp/test/Ice/slicing/objects/TestI.cpp +++ b/cpp/test/Ice/slicing/objects/TestI.cpp @@ -245,25 +245,25 @@ TestI::dictionaryTest(const BDict& bin, BDict& bout, const ::Ice::Current&) int i; for(i = 0; i < 10; ++i) { - BPtr b = bin.find(i)->second; - D2Ptr d2 = new D2; - d2->sb = b->sb; - d2->pb = b->pb; - d2->sd2 = "D2"; - d2->pd2 = d2; - bout[i * 10] = d2; + BPtr b = bin.find(i)->second; + D2Ptr d2 = new D2; + d2->sb = b->sb; + d2->pb = b->pb; + d2->sd2 = "D2"; + d2->pd2 = d2; + bout[i * 10] = d2; } BDict r; for(i = 0; i < 10; ++i) { - std::ostringstream s; - s << "D1." << i * 20; - D1Ptr d1 = new D1; - d1->sb = s.str(); - d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second); - d1->sd1 = s.str(); - d1->pd1 = d1; - r[i * 20] = d1; + std::ostringstream s; + s << "D1." << i * 20; + D1Ptr d1 = new D1; + d1->sb = s.str(); + d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second); + d1->sd1 = s.str(); + d1->pd1 = d1; + r[i * 20] = d1; } return r; } diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp index 6861067f468..efa8f77f459 100644 --- a/cpp/test/Ice/stream/Client.cpp +++ b/cpp/test/Ice/stream/Client.cpp @@ -99,7 +99,7 @@ public: virtual Ice::ObjectPtr create(const string& type) { - return _factory->create(type); + return _factory->create(type); } virtual void @@ -110,7 +110,7 @@ public: void setFactory(const Ice::ObjectFactoryPtr& factory) { - _factory = factory; + _factory = factory; } private: diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp index 71af9e97b60..694604304f9 100644 --- a/cpp/test/Ice/timeout/AllTests.cpp +++ b/cpp/test/Ice/timeout/AllTests.cpp @@ -19,7 +19,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -29,26 +29,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; } protected: void called() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - assert(!_called); - _called = true; - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -62,12 +62,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; typedef IceUtil::Handle<AMISendData> AMISendDataPtr; @@ -78,13 +78,13 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const Ice::TimeoutException*>(&ex)); - called(); + test(dynamic_cast<const Ice::TimeoutException*>(&ex)); + called(); } }; typedef IceUtil::Handle<AMISendDataEx> AMISendDataExPtr; @@ -95,12 +95,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; typedef IceUtil::Handle<AMISleep> AMISleepPtr; @@ -111,13 +111,13 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const Ice::TimeoutException*>(&ex)); - called(); + test(dynamic_cast<const Ice::TimeoutException*>(&ex)); + called(); } }; typedef IceUtil::Handle<AMISleepEx> AMISleepExPtr; @@ -134,249 +134,249 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing connect timeout... " << flush; { - // - // Expect ConnectTimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - to->holdAdapter(750); - to->ice_getConnection()->close(true); // Force a reconnect. - try - { - to->op(); - test(false); - } - catch(const Ice::ConnectTimeoutException&) - { - // Expected. - } + // + // Expect ConnectTimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + to->holdAdapter(750); + to->ice_getConnection()->close(true); // Force a reconnect. + try + { + to->op(); + test(false); + } + catch(const Ice::ConnectTimeoutException&) + { + // Expected. + } } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - to->holdAdapter(500); - to->ice_getConnection()->close(true); // Force a reconnect. - try - { - to->op(); - } - catch(const Ice::ConnectTimeoutException&) - { - test(false); - } + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + to->holdAdapter(500); + to->ice_getConnection()->close(true); // Force a reconnect. + try + { + to->op(); + } + catch(const Ice::ConnectTimeoutException&) + { + test(false); + } } cout << "ok" << endl; cout << "testing read timeout... " << flush; { - // - // Expect TimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - try - { - to->sleep(750); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } + // + // Expect TimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + try + { + to->sleep(750); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - try - { - to->sleep(500); - } - catch(const Ice::TimeoutException&) - { - test(false); - } + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + try + { + to->sleep(500); + } + catch(const Ice::TimeoutException&) + { + test(false); + } } cout << "ok" << endl; cout << "testing write timeout... " << flush; { - // - // Expect TimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - to->holdAdapter(750); - try - { - ByteSeq seq(100000); - to->sendData(seq); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } + // + // Expect TimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + to->holdAdapter(750); + try + { + ByteSeq seq(100000); + to->sendData(seq); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - to->holdAdapter(500); - try - { - ByteSeq seq(100000); - to->sendData(seq); - } - catch(const Ice::TimeoutException&) - { - test(false); - } + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + to->holdAdapter(500); + try + { + ByteSeq seq(100000); + to->sendData(seq); + } + catch(const Ice::TimeoutException&) + { + test(false); + } } cout << "ok" << endl; cout << "testing AMI read timeout... " << flush; { - // - // The resolution of AMI timeouts is limited by the connection monitor - // thread. We set Ice.MonitorConnections=1 (one second) in main(). - // - // Expect TimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - AMISleepExPtr cb = new AMISleepEx; - to->sleep_async(cb, 2000); - test(cb->check()); + // + // The resolution of AMI timeouts is limited by the connection monitor + // thread. We set Ice.MonitorConnections=1 (one second) in main(). + // + // Expect TimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + AMISleepExPtr cb = new AMISleepEx; + to->sleep_async(cb, 2000); + test(cb->check()); } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - AMISleepPtr cb = new AMISleep; - to->sleep_async(cb, 500); - test(cb->check()); + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + AMISleepPtr cb = new AMISleep; + to->sleep_async(cb, 500); + test(cb->check()); } cout << "ok" << endl; cout << "testing AMI write timeout... " << flush; { - // - // The resolution of AMI timeouts is limited by the connection monitor - // thread. We set Ice.MonitorConnections=1 (one second) in main(). - // - // Expect TimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - to->holdAdapter(2000); - ByteSeq seq(100000); - AMISendDataExPtr cb = new AMISendDataEx; - to->sendData_async(cb, seq); - test(cb->check()); + // + // The resolution of AMI timeouts is limited by the connection monitor + // thread. We set Ice.MonitorConnections=1 (one second) in main(). + // + // Expect TimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + to->holdAdapter(2000); + ByteSeq seq(100000); + AMISendDataExPtr cb = new AMISendDataEx; + to->sendData_async(cb, seq); + test(cb->check()); } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - to->holdAdapter(500); - ByteSeq seq(100000); - AMISendDataPtr cb = new AMISendData; - to->sendData_async(cb, seq); - test(cb->check()); + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + to->holdAdapter(500); + ByteSeq seq(100000); + AMISendDataPtr cb = new AMISendData; + to->sendData_async(cb, seq); + test(cb->check()); } cout << "ok" << endl; cout << "testing timeout overrides... " << flush; { - // - // Test Ice.Override.Timeout. This property overrides all - // endpoint timeouts. - // - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.Override.Timeout", "500"); - Ice::CommunicatorPtr comm = Ice::initialize(initData); - TimeoutPrx to = TimeoutPrx::checkedCast(comm->stringToProxy(sref)); - try - { - to->sleep(750); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } - // - // Calling ice_timeout() should have no effect. - // - timeout->op(); // Ensure adapter is active. - to = TimeoutPrx::checkedCast(to->ice_timeout(1000)); - try - { - to->sleep(750); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } - comm->destroy(); + // + // Test Ice.Override.Timeout. This property overrides all + // endpoint timeouts. + // + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.Override.Timeout", "500"); + Ice::CommunicatorPtr comm = Ice::initialize(initData); + TimeoutPrx to = TimeoutPrx::checkedCast(comm->stringToProxy(sref)); + try + { + to->sleep(750); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } + // + // Calling ice_timeout() should have no effect. + // + timeout->op(); // Ensure adapter is active. + to = TimeoutPrx::checkedCast(to->ice_timeout(1000)); + try + { + to->sleep(750); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } + comm->destroy(); } { - // - // Test Ice.Override.ConnectTimeout. - // - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.Override.ConnectTimeout", "750"); - Ice::CommunicatorPtr comm = Ice::initialize(initData); - timeout->holdAdapter(1000); - TimeoutPrx to = TimeoutPrx::uncheckedCast(comm->stringToProxy(sref)); - try - { - to->op(); - test(false); - } - catch(const Ice::ConnectTimeoutException&) - { - // Expected. - } - // - // Calling ice_timeout() should have no effect on the connect timeout. - // - timeout->op(); // Ensure adapter is active. - timeout->holdAdapter(1000); - to = TimeoutPrx::uncheckedCast(to->ice_timeout(1250)); - try - { - to->op(); - test(false); - } - catch(const Ice::ConnectTimeoutException&) - { - // Expected. - } - // - // Verify that timeout set via ice_timeout() is still used for requests. - // - to->op(); // Force connection. - try - { - to->sleep(1500); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } - comm->destroy(); + // + // Test Ice.Override.ConnectTimeout. + // + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.Override.ConnectTimeout", "750"); + Ice::CommunicatorPtr comm = Ice::initialize(initData); + timeout->holdAdapter(1000); + TimeoutPrx to = TimeoutPrx::uncheckedCast(comm->stringToProxy(sref)); + try + { + to->op(); + test(false); + } + catch(const Ice::ConnectTimeoutException&) + { + // Expected. + } + // + // Calling ice_timeout() should have no effect on the connect timeout. + // + timeout->op(); // Ensure adapter is active. + timeout->holdAdapter(1000); + to = TimeoutPrx::uncheckedCast(to->ice_timeout(1250)); + try + { + to->op(); + test(false); + } + catch(const Ice::ConnectTimeoutException&) + { + // Expected. + } + // + // Verify that timeout set via ice_timeout() is still used for requests. + // + to->op(); // Force connection. + try + { + to->sleep(1500); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } + comm->destroy(); } cout << "ok" << endl; diff --git a/cpp/test/Ice/timeout/Client.cpp b/cpp/test/Ice/timeout/Client.cpp index fef4d9c797e..b3c9c744c72 100644 --- a/cpp/test/Ice/timeout/Client.cpp +++ b/cpp/test/Ice/timeout/Client.cpp @@ -31,44 +31,44 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); - // - // For this test, we want to disable retries. - // - initData.properties->setProperty("Ice.RetryIntervals", "-1"); + // + // For this test, we want to disable retries. + // + initData.properties->setProperty("Ice.RetryIntervals", "-1"); - // - // This test kills connections, so we don't want warnings. - // - initData.properties->setProperty("Ice.Warn.Connections", "0"); + // + // This test kills connections, so we don't want warnings. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); - // - // Check for AMI timeouts every second. - // - initData.properties->setProperty("Ice.MonitorConnections", "1"); + // + // Check for AMI timeouts every second. + // + initData.properties->setProperty("Ice.MonitorConnections", "1"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { cerr << ex << endl; - status = EXIT_FAILURE; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/timeout/Server.cpp b/cpp/test/Ice/timeout/Server.cpp index bed1e7aeeaf..cd1d2159c86 100644 --- a/cpp/test/Ice/timeout/Server.cpp +++ b/cpp/test/Ice/timeout/Server.cpp @@ -32,34 +32,34 @@ main(int argc, char* argv[]) try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); - // - // This test kills connections, so we don't want warnings. - // - initData.properties->setProperty("Ice.Warn.Connections", "0"); + // + // This test kills connections, so we don't want warnings. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/Ice/timeout/TestI.cpp b/cpp/test/Ice/timeout/TestI.cpp index 23356bfb4a8..b69ac089a70 100644 --- a/cpp/test/Ice/timeout/TestI.cpp +++ b/cpp/test/Ice/timeout/TestI.cpp @@ -19,15 +19,15 @@ class ActivateAdapterThread : public IceUtil::Thread public: ActivateAdapterThread(const ObjectAdapterPtr& adapter, int timeout) : - _adapter(adapter), _timeout(timeout) + _adapter(adapter), _timeout(timeout) { } virtual void run() { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(_timeout)); - _adapter->activate(); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(_timeout)); + _adapter->activate(); } private: diff --git a/cpp/test/IceGrid/activation/AllTests.cpp b/cpp/test/IceGrid/activation/AllTests.cpp index 26460fe700f..8777ab9cba7 100644 --- a/cpp/test/IceGrid/activation/AllTests.cpp +++ b/cpp/test/IceGrid/activation/AllTests.cpp @@ -23,14 +23,14 @@ waitForServerState(const IceGrid::AdminPrx& admin, const std::string& server, Ic int nRetry = 0; while(admin->getServerState(server) != state && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; } if(admin->getServerState(server) != state) { - cerr << "server state change timed out:" << endl; - cerr << "server: " << server << endl; - cerr << "state: " << state << endl; + cerr << "server state change timed out:" << endl; + cerr << "server: " << server << endl; + cerr << "state: " << state << endl; } } @@ -39,42 +39,42 @@ class PingThread : public IceUtil::Thread, IceUtil::Monitor<IceUtil::Mutex> public: PingThread(const Ice::ObjectPrx& proxy, int nRepetitions) : - _proxy(proxy), _finished(false), _nRepetitions(nRepetitions) + _proxy(proxy), _finished(false), _nRepetitions(nRepetitions) { } virtual void run() { - for(int i = 0; i < _nRepetitions; ++i) - { - try - { - _proxy->ice_ping(); - } - catch(const Ice::LocalException& ex) - { - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); - } - catch(...) - { - assert(false); - } - } - - Lock sync(*this); - _finished = true; - notifyAll(); + for(int i = 0; i < _nRepetitions; ++i) + { + try + { + _proxy->ice_ping(); + } + catch(const Ice::LocalException& ex) + { + _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + } + catch(...) + { + assert(false); + } + } + + Lock sync(*this); + _finished = true; + notifyAll(); } auto_ptr<Ice::LocalException> waitUntilFinished() { - Lock sync(*this); - while(!_finished) - { - wait(); - } - return _exception; + Lock sync(*this); + while(!_finished) + { + wait(); + } + return _exception; } private: @@ -91,7 +91,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -106,15 +106,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -155,220 +155,220 @@ allTests(const Ice::CommunicatorPtr& communicator) int nRetry = 0; while(!admin->pingNode("node-1") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + ++nRetry; } nRetry = 0; while(!admin->pingNode("node-2") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + ++nRetry; } cout << "testing on-demand activation... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server")); - waitForServerState(admin, "server", IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server", IceGrid::Inactive); - nRetry = 4; - while(--nRetry > 0) - { - obj->shutdown(); - } - waitForServerState(admin, "server", IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server")); + waitForServerState(admin, "server", IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server", IceGrid::Inactive); + nRetry = 4; + while(--nRetry > 0) + { + obj->shutdown(); + } + waitForServerState(admin, "server", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing manual activation... " << flush; try { - test(admin->getServerState("server-manual") == IceGrid::Inactive); - TestIntfPrx obj; - try - { - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->startServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); - test(admin->getServerState("server-manual") == IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server-manual", IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::Inactive); + TestIntfPrx obj; + try + { + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->startServer("server-manual"); + test(admin->getServerState("server-manual") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); + test(admin->getServerState("server-manual") == IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server-manual", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing always activation... " << flush; try { - waitForServerState(admin, "server-always", IceGrid::Active); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always")); - admin->stopServer("server-always"); - waitForServerState(admin, "server-always", IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server-always", IceGrid::Active); - nRetry = 4; - while(--nRetry > 0) - { - obj->shutdown(); - } - waitForServerState(admin, "server-always", IceGrid::Active); + waitForServerState(admin, "server-always", IceGrid::Active); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always")); + admin->stopServer("server-always"); + waitForServerState(admin, "server-always", IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server-always", IceGrid::Active); + nRetry = 4; + while(--nRetry > 0) + { + obj->shutdown(); + } + waitForServerState(admin, "server-always", IceGrid::Active); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing session activation... " << flush; try { - IceGrid::SessionPrx session = registry->createSession("test", ""); - - test(admin->getServerState("server-session") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-session")); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - session->allocateObjectById(obj->ice_getIdentity()); - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server-session", IceGrid::Inactive); - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - nRetry = 4; - while(--nRetry > 0) - { - obj->shutdown(); - } - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - session->releaseObject(obj->ice_getIdentity()); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - waitForServerState(admin, "server-session", IceGrid::Inactive); - - session->allocateObjectById(obj->ice_getIdentity()); - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - session->destroy(); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - waitForServerState(admin, "server-session", IceGrid::Inactive); + IceGrid::SessionPrx session = registry->createSession("test", ""); + + test(admin->getServerState("server-session") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-session")); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + session->allocateObjectById(obj->ice_getIdentity()); + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server-session", IceGrid::Inactive); + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + nRetry = 4; + while(--nRetry > 0) + { + obj->shutdown(); + } + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + session->releaseObject(obj->ice_getIdentity()); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + waitForServerState(admin, "server-session", IceGrid::Inactive); + + session->allocateObjectById(obj->ice_getIdentity()); + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + session->destroy(); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + waitForServerState(admin, "server-session", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing server disable... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - admin->enableServer("server", false); - try - { - communicator->stringToProxy("server")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - try - { - admin->startServer("server"); - test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server") == IceGrid::Inactive); - - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->enableServer("server-manual", false); - try - { - communicator->stringToProxy("server-manual")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - try - { - admin->startServer("server-manual"); - test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-manual") == IceGrid::Inactive); - - test(admin->getServerState("server-always") == IceGrid::Active); - admin->enableServer("server-always", false); - admin->stopServer("server-always"); - test(admin->getServerState("server-always") == IceGrid::Inactive); - try - { - communicator->stringToProxy("server-always")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - try - { - admin->startServer("server-always"); - test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-always") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::Inactive); + admin->enableServer("server", false); + try + { + communicator->stringToProxy("server")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + admin->startServer("server"); + test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server") == IceGrid::Inactive); + + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->enableServer("server-manual", false); + try + { + communicator->stringToProxy("server-manual")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + admin->startServer("server-manual"); + test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server-manual") == IceGrid::Inactive); + + test(admin->getServerState("server-always") == IceGrid::Active); + admin->enableServer("server-always", false); + admin->stopServer("server-always"); + test(admin->getServerState("server-always") == IceGrid::Inactive); + try + { + communicator->stringToProxy("server-always")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + admin->startServer("server-always"); + test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server-always") == IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; @@ -376,277 +376,277 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing server enable... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - admin->enableServer("server", true); - communicator->stringToProxy("server")->ice_ping(); - admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); - admin->startServer("server"); - test(admin->getServerState("server") == IceGrid::Active); - admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); - - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->enableServer("server-manual", true); - try - { - communicator->stringToProxy("server-manual")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->startServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Active); - admin->stopServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Inactive); - - test(admin->getServerState("server-always") == IceGrid::Inactive); - admin->enableServer("server-always", true); - waitForServerState(admin, "server-always", IceGrid::Active); - admin->stopServer("server-always"); - try - { - admin->startServer("server-always"); -// test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-always") == IceGrid::Active); + test(admin->getServerState("server") == IceGrid::Inactive); + admin->enableServer("server", true); + communicator->stringToProxy("server")->ice_ping(); + admin->stopServer("server"); + test(admin->getServerState("server") == IceGrid::Inactive); + admin->startServer("server"); + test(admin->getServerState("server") == IceGrid::Active); + admin->stopServer("server"); + test(admin->getServerState("server") == IceGrid::Inactive); + + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->enableServer("server-manual", true); + try + { + communicator->stringToProxy("server-manual")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->startServer("server-manual"); + test(admin->getServerState("server-manual") == IceGrid::Active); + admin->stopServer("server-manual"); + test(admin->getServerState("server-manual") == IceGrid::Inactive); + + test(admin->getServerState("server-always") == IceGrid::Inactive); + admin->enableServer("server-always", true); + waitForServerState(admin, "server-always", IceGrid::Active); + admin->stopServer("server-always"); + try + { + admin->startServer("server-always"); +// test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server-always") == IceGrid::Active); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing activation failure... " << flush; try { - int i; - const int nThreads = 3; - Ice::ObjectPrx invalid = communicator->stringToProxy("invalid-exe"); - - vector<PingThreadPtr> threads; - threads.reserve(nThreads); - vector<PingThreadPtr>::const_iterator p; - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 10)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - threads.resize(0); - - invalid = communicator->stringToProxy("invalid-pwd"); - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 10)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - threads.resize(0); - - invalid = communicator->stringToProxy("fail-on-startup"); - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 5)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - threads.resize(0); + int i; + const int nThreads = 3; + Ice::ObjectPrx invalid = communicator->stringToProxy("invalid-exe"); + + vector<PingThreadPtr> threads; + threads.reserve(nThreads); + vector<PingThreadPtr>::const_iterator p; + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(invalid, 10)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + threads.resize(0); + + invalid = communicator->stringToProxy("invalid-pwd"); + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(invalid, 10)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + threads.resize(0); + + invalid = communicator->stringToProxy("fail-on-startup"); + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(invalid, 5)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + threads.resize(0); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing activation timeout... " << flush; try { - test(admin->getServerState("server-activation-timeout") == IceGrid::Inactive); - const int nThreads = 5; - Ice::ObjectPrx proxy = communicator->stringToProxy("server-activation-timeout"); - vector<PingThreadPtr> threads; - threads.reserve(nThreads); - vector<PingThreadPtr>::const_iterator p; - int i; - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(proxy, 1)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - admin->stopServer("server-activation-timeout"); + test(admin->getServerState("server-activation-timeout") == IceGrid::Inactive); + const int nThreads = 5; + Ice::ObjectPrx proxy = communicator->stringToProxy("server-activation-timeout"); + vector<PingThreadPtr> threads; + threads.reserve(nThreads); + vector<PingThreadPtr>::const_iterator p; + int i; + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(proxy, 1)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + admin->stopServer("server-activation-timeout"); } catch(const IceGrid::ServerStopException& ex) { - cerr << ex << ": " << ex.reason << endl; - test(false); + cerr << ex << ": " << ex.reason << endl; + test(false); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing deactivation timeout... " << flush; try { - test(admin->getServerState("server-deactivation-timeout") == IceGrid::Inactive); - communicator->stringToProxy("server-deactivation-timeout")->ice_ping(); - admin->stopServer("server-deactivation-timeout"); + test(admin->getServerState("server-deactivation-timeout") == IceGrid::Inactive); + communicator->stringToProxy("server-deactivation-timeout")->ice_ping(); + admin->stopServer("server-deactivation-timeout"); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing permanent disable on failure... " << flush; try { - test(admin->getServerState("server1") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1")); - waitForServerState(admin, "server1", IceGrid::Active); - obj->fail(); - waitForServerState(admin, "server1", IceGrid::Inactive); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(!admin->isServerEnabled("server1")); - - test(admin->getServerState("server1-manual") == IceGrid::Inactive); - admin->startServer("server1-manual"); - test(admin->getServerState("server1-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-manual")); - test(admin->getServerState("server1-manual") == IceGrid::Active); - obj->fail(); - waitForServerState(admin, "server1-manual", IceGrid::Inactive); - test(!admin->isServerEnabled("server1-manual")); - - test(admin->getServerState("server1-always") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-always")); - obj->fail(); - waitForServerState(admin, "server1-always", IceGrid::Inactive); - test(!admin->isServerEnabled("server1-always")); + test(admin->getServerState("server1") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1")); + waitForServerState(admin, "server1", IceGrid::Active); + obj->fail(); + waitForServerState(admin, "server1", IceGrid::Inactive); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(!admin->isServerEnabled("server1")); + + test(admin->getServerState("server1-manual") == IceGrid::Inactive); + admin->startServer("server1-manual"); + test(admin->getServerState("server1-manual") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-manual")); + test(admin->getServerState("server1-manual") == IceGrid::Active); + obj->fail(); + waitForServerState(admin, "server1-manual", IceGrid::Inactive); + test(!admin->isServerEnabled("server1-manual")); + + test(admin->getServerState("server1-always") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-always")); + obj->fail(); + waitForServerState(admin, "server1-always", IceGrid::Inactive); + test(!admin->isServerEnabled("server1-always")); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing temporary disable on failure... " << flush; try { - test(admin->getServerState("server2") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2")); - waitForServerState(admin, "server2", IceGrid::Active); - obj->fail(); - waitForServerState(admin, "server2", IceGrid::Inactive); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(!admin->isServerEnabled("server2")); - nRetry = 0; - while(!admin->isServerEnabled("server2") && nRetry < 15) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - try - { - obj->ice_ping(); - } - catch(const Ice::NoEndpointException&) - { - } - } - test(admin->isServerEnabled("server2")); - waitForServerState(admin, "server2", IceGrid::Active); - obj->ice_ping(); - admin->stopServer("server2"); - - test(admin->getServerState("server2-manual") == IceGrid::Inactive); - admin->startServer("server2-manual"); - test(admin->getServerState("server2-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-manual")); - obj->fail(); - waitForServerState(admin, "server2-manual", IceGrid::Inactive); - test(!admin->isServerEnabled("server2-manual")); - admin->startServer("server2-manual"); - test(admin->isServerEnabled("server2-manual")); - test(admin->getServerState("server2-manual") == IceGrid::Active); - admin->stopServer("server2-manual"); - - test(admin->getServerState("server2-always") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-always")); - obj->fail(); - waitForServerState(admin, "server2-always", IceGrid::Inactive); - test(!admin->isServerEnabled("server2-always")); - nRetry = 0; - while((!admin->isServerEnabled("server2-always") || - admin->getServerState("server2-always") != IceGrid::Active) && - nRetry < 15) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active); - obj->ice_ping(); + test(admin->getServerState("server2") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2")); + waitForServerState(admin, "server2", IceGrid::Active); + obj->fail(); + waitForServerState(admin, "server2", IceGrid::Inactive); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(!admin->isServerEnabled("server2")); + nRetry = 0; + while(!admin->isServerEnabled("server2") && nRetry < 15) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + try + { + obj->ice_ping(); + } + catch(const Ice::NoEndpointException&) + { + } + } + test(admin->isServerEnabled("server2")); + waitForServerState(admin, "server2", IceGrid::Active); + obj->ice_ping(); + admin->stopServer("server2"); + + test(admin->getServerState("server2-manual") == IceGrid::Inactive); + admin->startServer("server2-manual"); + test(admin->getServerState("server2-manual") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-manual")); + obj->fail(); + waitForServerState(admin, "server2-manual", IceGrid::Inactive); + test(!admin->isServerEnabled("server2-manual")); + admin->startServer("server2-manual"); + test(admin->isServerEnabled("server2-manual")); + test(admin->getServerState("server2-manual") == IceGrid::Active); + admin->stopServer("server2-manual"); + + test(admin->getServerState("server2-always") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-always")); + obj->fail(); + waitForServerState(admin, "server2-always", IceGrid::Inactive); + test(!admin->isServerEnabled("server2-always")); + nRetry = 0; + while((!admin->isServerEnabled("server2-always") || + admin->getServerState("server2-always") != IceGrid::Active) && + nRetry < 15) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active); + obj->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/activation/Client.cpp b/cpp/test/IceGrid/activation/Client.cpp index aaa0e585955..0162051684d 100644 --- a/cpp/test/IceGrid/activation/Client.cpp +++ b/cpp/test/IceGrid/activation/Client.cpp @@ -30,26 +30,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/activation/Server.cpp b/cpp/test/IceGrid/activation/Server.cpp index d9e5e6e0e4c..721c2132427 100644 --- a/cpp/test/IceGrid/activation/Server.cpp +++ b/cpp/test/IceGrid/activation/Server.cpp @@ -30,7 +30,7 @@ Server::run(int argc, char* argv[]) Ice::stringSeqToArgs(args, argc, argv); if(properties->getPropertyAsInt("FailOnStartup") > 0) { - return EXIT_FAILURE; + return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter"); @@ -41,13 +41,13 @@ Server::run(int argc, char* argv[]) int delay = properties->getPropertyAsInt("ActivationDelay"); if(delay > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); } shutdownOnInterrupt(); try { - adapter->activate(); + adapter->activate(); } catch(const Ice::ObjectAdapterDeactivatedException&) { @@ -58,7 +58,7 @@ Server::run(int argc, char* argv[]) delay = properties->getPropertyAsInt("DeactivationDelay"); if(delay > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); } return test->isFailed() ? EXIT_FAILURE : EXIT_SUCCESS; diff --git a/cpp/test/IceGrid/allocation/AllTests.cpp b/cpp/test/IceGrid/allocation/AllTests.cpp index 7079f31c4ed..dfc515d904f 100644 --- a/cpp/test/IceGrid/allocation/AllTests.cpp +++ b/cpp/test/IceGrid/allocation/AllTests.cpp @@ -32,47 +32,47 @@ public: void response(const Ice::ObjectPrx& obj) { - Lock sync(*this); - _response = true; - _obj = obj; - notify(); + Lock sync(*this); + _response = true; + _obj = obj; + notify(); } void exception() { - Lock sync(*this); - _exception = true; - notify(); + Lock sync(*this); + _exception = true; + notify(); } void waitResponse(const char* file, int line) { - Lock sync(*this); - while(!_response && !_exception) - { - if(!timedWait(IceUtil::Time::seconds(3))) - { - cerr << "timeout: " << file << ":" << line << endl; - test(false); // Timeout - } - } + Lock sync(*this); + while(!_response && !_exception) + { + if(!timedWait(IceUtil::Time::seconds(3))) + { + cerr << "timeout: " << file << ":" << line << endl; + test(false); // Timeout + } + } } bool hasResponse(Ice::ObjectPrx& obj) { - Lock sync(*this); - obj = _obj; - return _response; + Lock sync(*this); + obj = _obj; + return _response; } bool hasException() { - Lock sync(*this); - return _exception; + Lock sync(*this); + return _exception; } private: @@ -106,171 +106,171 @@ public: StressClient(int id, const RegistryPrx& registry, bool destroySession) : _communicator(registry->ice_getCommunicator()), - _id(id), - _registry(registry), - _notified(false), - _terminated(false), - _destroySession(destroySession) + _id(id), + _registry(registry), + _notified(false), + _terminated(false), + _destroySession(destroySession) { } StressClient(int id, const SessionPrx& session) : _communicator(session->ice_getCommunicator()), - _id(id), - _session(session), - _notified(false), - _terminated(false), - _destroySession(false) + _id(id), + _session(session), + _notified(false), + _terminated(false), + _destroySession(false) { } virtual void run() { - { - Lock sync(*this); - while(!_notified) - { - wait(); - } - } - - SessionPrx session; - while(true) - { - { - Lock sync(*this); - if(_terminated) - { - if(!_session && session) - { - session->destroy(); - } - return; - } - } - - if(!session) - { - ostringstream os; - os << "Client-" << _id; - if(_session) - { - session = _session; - } - else - { - session = _registry->createSession(os.str(), ""); - session->setAllocationTimeout(IceUtil::random(200)); // 200ms timeout - } - } - - assert(session); - session->keepAlive(); - - Ice::ObjectPrx object; - switch(IceUtil::random(_destroySession ? 4 : 2)) - { - case 0: - object = allocate(session); - break; - case 1: - object = allocateByType(session); - break; - case 2: - assert(!_session); - allocateAndDestroy(session); - session = 0; - break; - case 3: - assert(!_session); - allocateByTypeAndDestroy(session); - session = 0; - break; - } - - if(object) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(IceUtil::random(20))); - switch(IceUtil::random(_destroySession ? 2 : 1)) - { - case 0: - session->releaseObject(object->ice_getIdentity()); - break; - case 1: - assert(!_session); - session->destroy(); - session = 0; - break; - } - } - } + { + Lock sync(*this); + while(!_notified) + { + wait(); + } + } + + SessionPrx session; + while(true) + { + { + Lock sync(*this); + if(_terminated) + { + if(!_session && session) + { + session->destroy(); + } + return; + } + } + + if(!session) + { + ostringstream os; + os << "Client-" << _id; + if(_session) + { + session = _session; + } + else + { + session = _registry->createSession(os.str(), ""); + session->setAllocationTimeout(IceUtil::random(200)); // 200ms timeout + } + } + + assert(session); + session->keepAlive(); + + Ice::ObjectPrx object; + switch(IceUtil::random(_destroySession ? 4 : 2)) + { + case 0: + object = allocate(session); + break; + case 1: + object = allocateByType(session); + break; + case 2: + assert(!_session); + allocateAndDestroy(session); + session = 0; + break; + case 3: + assert(!_session); + allocateByTypeAndDestroy(session); + session = 0; + break; + } + + if(object) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(IceUtil::random(20))); + switch(IceUtil::random(_destroySession ? 2 : 1)) + { + case 0: + session->releaseObject(object->ice_getIdentity()); + break; + case 1: + assert(!_session); + session->destroy(); + session = 0; + break; + } + } + } } Ice::ObjectPrx allocate(const SessionPrx& session) { - ostringstream os; - os << "stress-" << IceUtil::random(6) + 1; - try - { - return session->allocateObjectById(_communicator->stringToIdentity(os.str())); - } - catch(const AllocationTimeoutException&) - { - } - catch(const AllocationException&) - { - // This can only happen if we are using the common session - // and the object is already allocated. - test(_session); - } - return 0; + ostringstream os; + os << "stress-" << IceUtil::random(6) + 1; + try + { + return session->allocateObjectById(_communicator->stringToIdentity(os.str())); + } + catch(const AllocationTimeoutException&) + { + } + catch(const AllocationException&) + { + // This can only happen if we are using the common session + // and the object is already allocated. + test(_session); + } + return 0; } Ice::ObjectPrx allocateByType(const SessionPrx& session) { - try - { - return session->allocateObjectByType("::StressTest"); - } - catch(const AllocationTimeoutException&) - { - } - return 0; + try + { + return session->allocateObjectByType("::StressTest"); + } + catch(const AllocationTimeoutException&) + { + } + return 0; } void allocateAndDestroy(const SessionPrx& session) { - ostringstream os; - os << "stress-" << IceUtil::random(3); - session->allocateObjectById_async(new AllocateObjectByIdCallback(), _communicator->stringToIdentity(os.str())); - session->destroy(); + ostringstream os; + os << "stress-" << IceUtil::random(3); + session->allocateObjectById_async(new AllocateObjectByIdCallback(), _communicator->stringToIdentity(os.str())); + session->destroy(); } void allocateByTypeAndDestroy(const SessionPrx& session) { - session->allocateObjectByType_async(new AllocateObjectByTypeCallback(), "::StressTest"); - session->destroy(); + session->allocateObjectByType_async(new AllocateObjectByTypeCallback(), "::StressTest"); + session->destroy(); } void notifyThread() { - Lock sync(*this); - _notified = true; - notify(); + Lock sync(*this); + _notified = true; + notify(); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } protected: @@ -290,72 +290,72 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const Ice::LoggerPtr& logger, const IceUtil::Time& timeout) : - _logger(logger), - _timeout(timeout), - _terminated(false) + _logger(logger), + _timeout(timeout), + _terminated(false) { } virtual void run() { - Lock sync(*this); - while(!_terminated) - { - timedWait(_timeout); - if(!_terminated) - { - vector<SessionPrx>::iterator p = _sessions.begin(); - while(p != _sessions.end()) - { - try - { - (*p)->keepAlive(); - ++p; - } - catch(const Ice::Exception&) - { - p = _sessions.erase(p); - } - } - - vector<AdminSessionPrx>::iterator q = _adminSessions.begin(); - while(q != _adminSessions.end()) - { - try - { - (*q)->keepAlive(); - ++q; - } - catch(const Ice::Exception&) - { - q = _adminSessions.erase(q); - } - } - } - } + Lock sync(*this); + while(!_terminated) + { + timedWait(_timeout); + if(!_terminated) + { + vector<SessionPrx>::iterator p = _sessions.begin(); + while(p != _sessions.end()) + { + try + { + (*p)->keepAlive(); + ++p; + } + catch(const Ice::Exception&) + { + p = _sessions.erase(p); + } + } + + vector<AdminSessionPrx>::iterator q = _adminSessions.begin(); + while(q != _adminSessions.end()) + { + try + { + (*q)->keepAlive(); + ++q; + } + catch(const Ice::Exception&) + { + q = _adminSessions.erase(q); + } + } + } + } } void add(const SessionPrx& session) { - Lock sync(*this); - _sessions.push_back(session); + Lock sync(*this); + _sessions.push_back(session); } void add(const AdminSessionPrx& session) { - Lock sync(*this); - _adminSessions.push_back(session); + Lock sync(*this); + _adminSessions.push_back(session); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } private: @@ -372,7 +372,7 @@ void allTests(const Ice::CommunicatorPtr& communicator) { SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread( - communicator->getLogger(), IceUtil::Time::seconds(5)); + communicator->getLogger(), IceUtil::Time::seconds(5)); keepAlive->start(); RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); @@ -387,12 +387,12 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "starting router... " << flush; try { - admin->startServer("Glacier2"); + admin->startServer("Glacier2"); } catch(const ServerStartException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "ok" << endl; @@ -403,756 +403,756 @@ allTests(const Ice::CommunicatorPtr& communicator) try { - cout << "testing create session... " << flush; - SessionPrx session1 = registry->createSession("Client1", ""); - SessionPrx session2 = registry->createSession("Client2", ""); - - keepAlive->add(session1); - keepAlive->add(session2); + cout << "testing create session... " << flush; + SessionPrx session1 = registry->createSession("Client1", ""); + SessionPrx session2 = registry->createSession("Client2", ""); + + keepAlive->add(session1); + keepAlive->add(session2); - cout << "ok" << endl; - - cout << "testing allocate object by identity... " << flush; - - Ice::Identity allocatable = communicator->stringToIdentity("allocatable"); - Ice::Identity allocatablebis = communicator->stringToIdentity("allocatablebis"); - - try - { - session1->allocateObjectById(communicator->stringToIdentity("dummy")); - } - catch(const ObjectNotRegisteredException&) - { - } - try - { - session1->releaseObject(communicator->stringToIdentity("dummy")); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session1->allocateObjectById(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session2->allocateObjectById(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session1->releaseObject(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session2->releaseObject(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - session1->allocateObjectById(allocatable); - try - { - session1->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationException&) - { - } - - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - - try - { - session2->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session2->releaseObject(allocatable); - test(false); - } - catch(const AllocationException&) - { - } - - session1->allocateObjectById(allocatablebis); - try - { - session2->allocateObjectById(allocatablebis); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->releaseObject(allocatablebis); - session2->allocateObjectById(allocatablebis); - try - { - session1->allocateObjectById(allocatablebis); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session2->releaseObject(allocatablebis); + cout << "ok" << endl; + + cout << "testing allocate object by identity... " << flush; + + Ice::Identity allocatable = communicator->stringToIdentity("allocatable"); + Ice::Identity allocatablebis = communicator->stringToIdentity("allocatablebis"); + + try + { + session1->allocateObjectById(communicator->stringToIdentity("dummy")); + } + catch(const ObjectNotRegisteredException&) + { + } + try + { + session1->releaseObject(communicator->stringToIdentity("dummy")); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session1->allocateObjectById(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session2->allocateObjectById(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session1->releaseObject(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session2->releaseObject(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + session1->allocateObjectById(allocatable); + try + { + session1->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationException&) + { + } + + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + + try + { + session2->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session2->releaseObject(allocatable); + test(false); + } + catch(const AllocationException&) + { + } + + session1->allocateObjectById(allocatablebis); + try + { + session2->allocateObjectById(allocatablebis); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->releaseObject(allocatablebis); + session2->allocateObjectById(allocatablebis); + try + { + session1->allocateObjectById(allocatablebis); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session2->releaseObject(allocatablebis); - session2->setAllocationTimeout(allocationTimeout); - AllocateObjectByIdCallbackPtr cb1 = new AllocateObjectByIdCallback(); - session2->allocateObjectById_async(cb1, allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); - session1->releaseObject(allocatable); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); - - session1->setAllocationTimeout(0); - try - { - session1->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session1->releaseObject(allocatable); - test(false); - } - catch(const AllocationException&) - { - } - session1->setAllocationTimeout(allocationTimeout); - cb1 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb1, allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); - session2->releaseObject(allocatable); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); - - session1->releaseObject(allocatable); - - cout << "ok" << endl; - - cout << "testing allocate object by type... " << flush; + session2->setAllocationTimeout(allocationTimeout); + AllocateObjectByIdCallbackPtr cb1 = new AllocateObjectByIdCallback(); + session2->allocateObjectById_async(cb1, allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb1->hasResponse(dummy)); + session1->releaseObject(allocatable); + cb1->waitResponse(__FILE__, __LINE__); + test(cb1->hasResponse(dummy)); + + session1->setAllocationTimeout(0); + try + { + session1->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session1->releaseObject(allocatable); + test(false); + } + catch(const AllocationException&) + { + } + session1->setAllocationTimeout(allocationTimeout); + cb1 = new AllocateObjectByIdCallback(); + session1->allocateObjectById_async(cb1, allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb1->hasResponse(dummy)); + session2->releaseObject(allocatable); + cb1->waitResponse(__FILE__, __LINE__); + test(cb1->hasResponse(dummy)); + + session1->releaseObject(allocatable); + + cout << "ok" << endl; + + cout << "testing allocate object by type... " << flush; - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - - - try - { - obj = session1->allocateObjectByType("::Unknown"); - test(false); - } - catch(const AllocationTimeoutException&) - { - test(false); - } - catch(const AllocationException&) - { - } - - try - { - obj = session1->allocateObjectByType("::NotAllocatable"); - test(false); - } - catch(const AllocationTimeoutException&) - { - test(false); - } - catch(const AllocationException&) - { - } - - obj = session1->allocateObjectByType("::Test"); - test(obj && obj->ice_getIdentity().name == "allocatable"); - try - { - session1->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationException&) - { - } - try - { - session2->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session2->releaseObject(obj->ice_getIdentity()); - } - catch(const AllocationException&) - { - } - - session1->releaseObject(obj->ice_getIdentity()); - try - { - session1->releaseObject(obj->ice_getIdentity()); - } - catch(const AllocationException&) - { - } - - obj = session2->allocateObjectByType("::Test"); // Allocate the object - test(obj && obj->ice_getIdentity().name == "allocatable"); - try - { - session2->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationException&) - { - } - try - { - session1->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->allocateObjectByType("::TestBis"); - try - { - session2->allocateObjectByType("::TestBis"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->releaseObject(allocatablebis); - session2->allocateObjectByType("::TestBis"); - try - { - session1->allocateObjectByType("::TestBis"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session2->releaseObject(allocatablebis); - - session1->setAllocationTimeout(allocationTimeout); - AllocateObjectByTypeCallbackPtr cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::Test"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); - session2->releaseObject(obj->ice_getIdentity()); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(obj)); - - session1->releaseObject(obj->ice_getIdentity()); + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + + + try + { + obj = session1->allocateObjectByType("::Unknown"); + test(false); + } + catch(const AllocationTimeoutException&) + { + test(false); + } + catch(const AllocationException&) + { + } + + try + { + obj = session1->allocateObjectByType("::NotAllocatable"); + test(false); + } + catch(const AllocationTimeoutException&) + { + test(false); + } + catch(const AllocationException&) + { + } + + obj = session1->allocateObjectByType("::Test"); + test(obj && obj->ice_getIdentity().name == "allocatable"); + try + { + session1->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationException&) + { + } + try + { + session2->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session2->releaseObject(obj->ice_getIdentity()); + } + catch(const AllocationException&) + { + } + + session1->releaseObject(obj->ice_getIdentity()); + try + { + session1->releaseObject(obj->ice_getIdentity()); + } + catch(const AllocationException&) + { + } + + obj = session2->allocateObjectByType("::Test"); // Allocate the object + test(obj && obj->ice_getIdentity().name == "allocatable"); + try + { + session2->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationException&) + { + } + try + { + session1->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->allocateObjectByType("::TestBis"); + try + { + session2->allocateObjectByType("::TestBis"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->releaseObject(allocatablebis); + session2->allocateObjectByType("::TestBis"); + try + { + session1->allocateObjectByType("::TestBis"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session2->releaseObject(allocatablebis); + + session1->setAllocationTimeout(allocationTimeout); + AllocateObjectByTypeCallbackPtr cb3 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb3, "::Test"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb3->hasResponse(dummy)); + session2->releaseObject(obj->ice_getIdentity()); + cb3->waitResponse(__FILE__, __LINE__); + test(cb3->hasResponse(obj)); + + session1->releaseObject(obj->ice_getIdentity()); - cout << "ok" << endl; - - cout << "testing object allocation timeout... " << flush; - - session1->allocateObjectById(allocatable); - IceUtil::Time time = IceUtil::Time::now(); - session2->setAllocationTimeout(500); - try - { - session2->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - } - time = IceUtil::Time::now(); - try - { - session2->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - time = IceUtil::Time::now(); - try - { - session2->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - - session1->releaseObject(allocatable); - session2->setAllocationTimeout(0); - - cout << "ok" << endl; - - cout << "testing server allocation... " << flush; - - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - - Ice::Identity allocatable3 = communicator->stringToIdentity("allocatable3"); - Ice::Identity allocatable4 = communicator->stringToIdentity("allocatable4"); - - session1->allocateObjectById(allocatable3); - try - { - session2->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session2->allocateObjectById(allocatable4); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - - session1->allocateObjectById(allocatable4); - session1->releaseObject(allocatable3); - try - { - session2->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->releaseObject(allocatable4); - session2->allocateObjectById(allocatable3); - try - { - session1->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session1->allocateObjectById(allocatable4); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session2->allocateObjectById(allocatable4); - session2->releaseObject(allocatable3); - try - { - session1->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session1->allocateObjectByType("::TestServer1"); - test(false); - } - catch(AllocationException&) - { - } - try - { - session1->allocateObjectByType("::TestServer2"); - test(false); - } - catch(AllocationException&) - { - } - test(session2->allocateObjectByType("::TestServer1")); - try - { - session2->allocateObjectByType("::TestServer1"); - test(false); - } - catch(AllocationException&) - { - } - try - { - session2->allocateObjectByType("::TestServer2"); - test(false); - } - catch(AllocationException&) - { - } - session2->releaseObject(allocatable3); - session2->releaseObject(allocatable4); - - session1->allocateObjectById(allocatable3); - session1->allocateObjectById(allocatable4); - - session2->setAllocationTimeout(allocationTimeout); - cb1 = new AllocateObjectByIdCallback(); - session2->allocateObjectById_async(cb1, allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); - session1->releaseObject(allocatable3); - test(!cb1->hasResponse(dummy)); - session1->releaseObject(allocatable4); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); - session2->releaseObject(allocatable3); - - session1->setAllocationTimeout(allocationTimeout); - test(session2->allocateObjectByType("::TestServer1")); - cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::TestServer2"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); - session2->releaseObject(allocatable3); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(dummy)); - session1->releaseObject(allocatable4); - - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - test(session1->allocateObjectByType("::TestMultipleByServer")); - try - { - session2->allocateObjectByType("::TestMultipleByServer"); - test(false); - } - catch(AllocationException&) - { - } - test(session1->allocateObjectByType("::TestMultipleByServer")); - session1->releaseObject(communicator->stringToIdentity("allocatable31")); - session1->releaseObject(communicator->stringToIdentity("allocatable41")); - test(session2->allocateObjectByType("::TestMultipleByServer")); - try - { - session1->allocateObjectByType("::TestMultipleByServer"); - test(false); - } - catch(AllocationException&) - { - } - test(session2->allocateObjectByType("::TestMultipleByServer")); - session2->releaseObject(communicator->stringToIdentity("allocatable31")); - session2->releaseObject(communicator->stringToIdentity("allocatable41")); - - Ice::ObjectPrx obj1 = session1->allocateObjectByType("::TestMultipleServer"); - test(obj1); - Ice::ObjectPrx obj2 = session2->allocateObjectByType("::TestMultipleServer"); - test(obj2); - try - { - session1->allocateObjectByType("::TestMultipleServer"); - test(false); - } - catch(AllocationTimeoutException&) - { - } - try - { - session2->allocateObjectByType("::TestMultipleServer"); - test(false); - } - catch(AllocationTimeoutException&) - { - } - session1->releaseObject(obj1->ice_getIdentity()); - obj1 = session2->allocateObjectByType("::TestMultipleServer"); - session2->releaseObject(obj1->ice_getIdentity()); - session2->releaseObject(obj2->ice_getIdentity()); - - cout << "ok" << endl; - - cout << "testing concurrent allocations... " << flush; - - session1->setAllocationTimeout(allocationTimeout); - session2->setAllocationTimeout(allocationTimeout); - - session2->allocateObjectById(allocatable); - AllocateObjectByIdCallbackPtr cb11 = new AllocateObjectByIdCallback(); - AllocateObjectByIdCallbackPtr cb12 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb11, allocatable); - session1->allocateObjectById_async(cb12, allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb11->hasResponse(dummy)); - test(!cb12->hasResponse(dummy)); - session2->releaseObject(allocatable); - cb11->waitResponse(__FILE__, __LINE__); - cb12->waitResponse(__FILE__, __LINE__); - test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); - test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); - session1->releaseObject(allocatable); - - session2->allocateObjectById(allocatable); - AllocateObjectByTypeCallbackPtr cb31 = new AllocateObjectByTypeCallback(); - AllocateObjectByTypeCallbackPtr cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::Test"); - session1->allocateObjectByType_async(cb32, "::Test"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); - session2->releaseObject(allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - do - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || - cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); - session1->releaseObject(allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - AllocateObjectByTypeCallbackPtr cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); - session1->releaseObject(allocatable); - - session2->allocateObjectById(allocatable3); - cb11 = new AllocateObjectByIdCallback(); - cb12 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb11, allocatable3); - session1->allocateObjectById_async(cb12, allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb11->hasResponse(dummy)); - test(!cb12->hasResponse(dummy)); - session2->releaseObject(allocatable3); - cb11->waitResponse(__FILE__, __LINE__); - cb12->waitResponse(__FILE__, __LINE__); - test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); - test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); - session1->releaseObject(allocatable3); - - session2->allocateObjectById(allocatable3); - cb31 = new AllocateObjectByTypeCallback(); - cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::TestServer1"); - session1->allocateObjectByType_async(cb32, "::TestServer1"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); - session2->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - do - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || - cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); - session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); - session1->releaseObject(allocatable3); - - session1->allocateObjectById(allocatable3); - cb31 = new AllocateObjectByTypeCallback(); - cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::TestServer1"); - session1->allocateObjectByType_async(cb32, "::TestServer1"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); - session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - do - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || - cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); - session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); - session1->releaseObject(allocatable3); - - cout << "ok" << endl; - - cout << "testing session destroy... " << flush; - - obj = session2->allocateObjectByType("::Test"); // Allocate the object - test(obj && obj->ice_getIdentity().name == "allocatable"); - - session1->setAllocationTimeout(allocationTimeout); - cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::Test"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); - session2->destroy(); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(obj)); - session1->destroy(); - - session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); - session2->setAllocationTimeout(0); - session2->allocateObjectById(allocatable); - session2->destroy(); - - cout << "ok" << endl; - - cout << "testing allocation with Glacier2 session... " << flush; - Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); - Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); - test(router1); - - Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); - try - { - session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); - test(session1); - session1->ice_ping(); - - Ice::ObjectPrx obj; - obj = session1->allocateObjectById(allocatable)->ice_connectionId("client1")->ice_router(router1); - obj->ice_ping(); - session1->releaseObject(allocatable); - try - { - obj->ice_ping(); - } - catch(const Ice::ObjectNotExistException&) - { - } - - obj = session1->allocateObjectById(allocatable3)->ice_connectionId("client1")->ice_router(router1); - obj->ice_ping(); - obj2 = communicator->stringToProxy("allocatable4")->ice_connectionId("client1")->ice_router(router1); - obj2->ice_ping(); - session1->releaseObject(allocatable3); - try - { - obj->ice_ping(); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - obj2->ice_ping(); - } - catch(const Ice::ObjectNotExistException&) - { - } - session1->destroy(); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "stress test... " << flush; - - SessionPrx stressSession = registry->createSession("StressSession", ""); - keepAlive->add(stressSession); - - const int nClients = 10; - int i; - vector<StressClientPtr> clients; - for(i = 0; i < nClients - 2; ++i) - { - if(IceUtil::random(2) == 1) - { - clients.push_back(new StressClient(i, registry, false)); - } - else - { - clients.push_back(new StressClient(i, stressSession)); - } - clients.back()->start(); - } - clients.push_back(new StressClient(i++, registry, true)); - clients.back()->start(); - clients.push_back(new StressClient(i++, registry, true)); - clients.back()->start(); - - for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) - { - (*p)->notifyThread(); - } - - // - // Let the stress client run for a bit. - // - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(8)); - - // - // Terminate the stress clients. - // - for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) - { - (*q)->terminate(); - (*q)->getThreadControl().join(); - } - - stressSession->destroy(); - - cout << "ok" << endl; + cout << "ok" << endl; + + cout << "testing object allocation timeout... " << flush; + + session1->allocateObjectById(allocatable); + IceUtil::Time time = IceUtil::Time::now(); + session2->setAllocationTimeout(500); + try + { + session2->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + } + time = IceUtil::Time::now(); + try + { + session2->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + time = IceUtil::Time::now(); + try + { + session2->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + + session1->releaseObject(allocatable); + session2->setAllocationTimeout(0); + + cout << "ok" << endl; + + cout << "testing server allocation... " << flush; + + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + + Ice::Identity allocatable3 = communicator->stringToIdentity("allocatable3"); + Ice::Identity allocatable4 = communicator->stringToIdentity("allocatable4"); + + session1->allocateObjectById(allocatable3); + try + { + session2->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session2->allocateObjectById(allocatable4); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + + session1->allocateObjectById(allocatable4); + session1->releaseObject(allocatable3); + try + { + session2->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->releaseObject(allocatable4); + session2->allocateObjectById(allocatable3); + try + { + session1->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session1->allocateObjectById(allocatable4); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session2->allocateObjectById(allocatable4); + session2->releaseObject(allocatable3); + try + { + session1->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session1->allocateObjectByType("::TestServer1"); + test(false); + } + catch(AllocationException&) + { + } + try + { + session1->allocateObjectByType("::TestServer2"); + test(false); + } + catch(AllocationException&) + { + } + test(session2->allocateObjectByType("::TestServer1")); + try + { + session2->allocateObjectByType("::TestServer1"); + test(false); + } + catch(AllocationException&) + { + } + try + { + session2->allocateObjectByType("::TestServer2"); + test(false); + } + catch(AllocationException&) + { + } + session2->releaseObject(allocatable3); + session2->releaseObject(allocatable4); + + session1->allocateObjectById(allocatable3); + session1->allocateObjectById(allocatable4); + + session2->setAllocationTimeout(allocationTimeout); + cb1 = new AllocateObjectByIdCallback(); + session2->allocateObjectById_async(cb1, allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb1->hasResponse(dummy)); + session1->releaseObject(allocatable3); + test(!cb1->hasResponse(dummy)); + session1->releaseObject(allocatable4); + cb1->waitResponse(__FILE__, __LINE__); + test(cb1->hasResponse(dummy)); + session2->releaseObject(allocatable3); + + session1->setAllocationTimeout(allocationTimeout); + test(session2->allocateObjectByType("::TestServer1")); + cb3 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb3, "::TestServer2"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb3->hasResponse(dummy)); + session2->releaseObject(allocatable3); + cb3->waitResponse(__FILE__, __LINE__); + test(cb3->hasResponse(dummy)); + session1->releaseObject(allocatable4); + + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + test(session1->allocateObjectByType("::TestMultipleByServer")); + try + { + session2->allocateObjectByType("::TestMultipleByServer"); + test(false); + } + catch(AllocationException&) + { + } + test(session1->allocateObjectByType("::TestMultipleByServer")); + session1->releaseObject(communicator->stringToIdentity("allocatable31")); + session1->releaseObject(communicator->stringToIdentity("allocatable41")); + test(session2->allocateObjectByType("::TestMultipleByServer")); + try + { + session1->allocateObjectByType("::TestMultipleByServer"); + test(false); + } + catch(AllocationException&) + { + } + test(session2->allocateObjectByType("::TestMultipleByServer")); + session2->releaseObject(communicator->stringToIdentity("allocatable31")); + session2->releaseObject(communicator->stringToIdentity("allocatable41")); + + Ice::ObjectPrx obj1 = session1->allocateObjectByType("::TestMultipleServer"); + test(obj1); + Ice::ObjectPrx obj2 = session2->allocateObjectByType("::TestMultipleServer"); + test(obj2); + try + { + session1->allocateObjectByType("::TestMultipleServer"); + test(false); + } + catch(AllocationTimeoutException&) + { + } + try + { + session2->allocateObjectByType("::TestMultipleServer"); + test(false); + } + catch(AllocationTimeoutException&) + { + } + session1->releaseObject(obj1->ice_getIdentity()); + obj1 = session2->allocateObjectByType("::TestMultipleServer"); + session2->releaseObject(obj1->ice_getIdentity()); + session2->releaseObject(obj2->ice_getIdentity()); + + cout << "ok" << endl; + + cout << "testing concurrent allocations... " << flush; + + session1->setAllocationTimeout(allocationTimeout); + session2->setAllocationTimeout(allocationTimeout); + + session2->allocateObjectById(allocatable); + AllocateObjectByIdCallbackPtr cb11 = new AllocateObjectByIdCallback(); + AllocateObjectByIdCallbackPtr cb12 = new AllocateObjectByIdCallback(); + session1->allocateObjectById_async(cb11, allocatable); + session1->allocateObjectById_async(cb12, allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb11->hasResponse(dummy)); + test(!cb12->hasResponse(dummy)); + session2->releaseObject(allocatable); + cb11->waitResponse(__FILE__, __LINE__); + cb12->waitResponse(__FILE__, __LINE__); + test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); + test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); + session1->releaseObject(allocatable); + + session2->allocateObjectById(allocatable); + AllocateObjectByTypeCallbackPtr cb31 = new AllocateObjectByTypeCallback(); + AllocateObjectByTypeCallbackPtr cb32 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb31, "::Test"); + session1->allocateObjectByType_async(cb32, "::Test"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb31->hasResponse(dummy)); + test(!cb32->hasResponse(dummy)); + session2->releaseObject(allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + do + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + } + while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); + test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || + cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); + session1->releaseObject(allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + AllocateObjectByTypeCallbackPtr cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; + cb33->waitResponse(__FILE__, __LINE__); + test(cb33->hasResponse(dummy) && dummy); + session1->releaseObject(allocatable); + + session2->allocateObjectById(allocatable3); + cb11 = new AllocateObjectByIdCallback(); + cb12 = new AllocateObjectByIdCallback(); + session1->allocateObjectById_async(cb11, allocatable3); + session1->allocateObjectById_async(cb12, allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb11->hasResponse(dummy)); + test(!cb12->hasResponse(dummy)); + session2->releaseObject(allocatable3); + cb11->waitResponse(__FILE__, __LINE__); + cb12->waitResponse(__FILE__, __LINE__); + test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); + test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); + session1->releaseObject(allocatable3); + + session2->allocateObjectById(allocatable3); + cb31 = new AllocateObjectByTypeCallback(); + cb32 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb31, "::TestServer1"); + session1->allocateObjectByType_async(cb32, "::TestServer1"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb31->hasResponse(dummy)); + test(!cb32->hasResponse(dummy)); + session2->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + do + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + } + while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); + test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || + cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); + session1->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; + cb33->waitResponse(__FILE__, __LINE__); + test(cb33->hasResponse(dummy) && dummy); + session1->releaseObject(allocatable3); + + session1->allocateObjectById(allocatable3); + cb31 = new AllocateObjectByTypeCallback(); + cb32 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb31, "::TestServer1"); + session1->allocateObjectByType_async(cb32, "::TestServer1"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb31->hasResponse(dummy)); + test(!cb32->hasResponse(dummy)); + session1->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + do + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + } + while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); + test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || + cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); + session1->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; + cb33->waitResponse(__FILE__, __LINE__); + test(cb33->hasResponse(dummy) && dummy); + session1->releaseObject(allocatable3); + + cout << "ok" << endl; + + cout << "testing session destroy... " << flush; + + obj = session2->allocateObjectByType("::Test"); // Allocate the object + test(obj && obj->ice_getIdentity().name == "allocatable"); + + session1->setAllocationTimeout(allocationTimeout); + cb3 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb3, "::Test"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb3->hasResponse(dummy)); + session2->destroy(); + cb3->waitResponse(__FILE__, __LINE__); + test(cb3->hasResponse(obj)); + session1->destroy(); + + session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); + session2->setAllocationTimeout(0); + session2->allocateObjectById(allocatable); + session2->destroy(); + + cout << "ok" << endl; + + cout << "testing allocation with Glacier2 session... " << flush; + Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); + Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); + test(router1); + + Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); + try + { + session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); + test(session1); + session1->ice_ping(); + + Ice::ObjectPrx obj; + obj = session1->allocateObjectById(allocatable)->ice_connectionId("client1")->ice_router(router1); + obj->ice_ping(); + session1->releaseObject(allocatable); + try + { + obj->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + + obj = session1->allocateObjectById(allocatable3)->ice_connectionId("client1")->ice_router(router1); + obj->ice_ping(); + obj2 = communicator->stringToProxy("allocatable4")->ice_connectionId("client1")->ice_router(router1); + obj2->ice_ping(); + session1->releaseObject(allocatable3); + try + { + obj->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + obj2->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + session1->destroy(); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "stress test... " << flush; + + SessionPrx stressSession = registry->createSession("StressSession", ""); + keepAlive->add(stressSession); + + const int nClients = 10; + int i; + vector<StressClientPtr> clients; + for(i = 0; i < nClients - 2; ++i) + { + if(IceUtil::random(2) == 1) + { + clients.push_back(new StressClient(i, registry, false)); + } + else + { + clients.push_back(new StressClient(i, stressSession)); + } + clients.back()->start(); + } + clients.push_back(new StressClient(i++, registry, true)); + clients.back()->start(); + clients.push_back(new StressClient(i++, registry, true)); + clients.back()->start(); + + for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) + { + (*p)->notifyThread(); + } + + // + // Let the stress client run for a bit. + // + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(8)); + + // + // Terminate the stress clients. + // + for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) + { + (*q)->terminate(); + (*q)->getThreadControl().join(); + } + + stressSession->destroy(); + + cout << "ok" << endl; } catch(const AllocationTimeoutException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } catch(const AllocationException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "shutting down router... " << flush; diff --git a/cpp/test/IceGrid/allocation/Client.cpp b/cpp/test/IceGrid/allocation/Client.cpp index 47f910e24da..940ae6bec73 100644 --- a/cpp/test/IceGrid/allocation/Client.cpp +++ b/cpp/test/IceGrid/allocation/Client.cpp @@ -27,28 +27,28 @@ main(int argc, char* argv[]) int status; Ice::CommunicatorPtr communicator; try - { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp b/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp index d5d8bbd5d0b..37e46baa4e9 100644 --- a/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp +++ b/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp @@ -19,7 +19,7 @@ public: virtual bool checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current& c) const { - return true; + return true; } }; @@ -29,11 +29,11 @@ public: virtual int run(int, char*[]) { - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PermissionsVerifier"); - adapter->add(new PermissionsVerifierI, communicator()->stringToIdentity("PermissionsVerifier")); - adapter->activate(); - communicator()->waitForShutdown(); - return EXIT_SUCCESS; + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PermissionsVerifier"); + adapter->add(new PermissionsVerifierI, communicator()->stringToIdentity("PermissionsVerifier")); + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; } }; diff --git a/cpp/test/IceGrid/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp index ca0c77d6e78..5a87f264d18 100644 --- a/cpp/test/IceGrid/deployer/AllTests.cpp +++ b/cpp/test/IceGrid/deployer/AllTests.cpp @@ -71,7 +71,7 @@ public: bool operator()(const Ice::ObjectPrx& p1, const string& id) const { - return p1->ice_getIdentity() == _communicator->stringToIdentity(id); + return p1->ice_getIdentity() == _communicator->stringToIdentity(id); } private: @@ -84,7 +84,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -99,15 +99,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -180,37 +180,37 @@ allTests(const Ice::CommunicatorPtr& comm) test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"ReplicatedObject")) != objs.end()); { - test(comm->identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); - test(comm->identityToString(query->findObjectByType("::TestId2")->ice_getIdentity()) == "cat1/name1"); - test(comm->identityToString(query->findObjectByType("::TestId3")->ice_getIdentity()) == "cat1/name1-bis"); - test(comm->identityToString(query->findObjectByType("::TestId4")->ice_getIdentity()) == "c2\\/c2/n2\\/n2"); - test(comm->identityToString(query->findObjectByType("::TestId5")->ice_getIdentity()) == "n2\\/n2"); + test(comm->identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); + test(comm->identityToString(query->findObjectByType("::TestId2")->ice_getIdentity()) == "cat1/name1"); + test(comm->identityToString(query->findObjectByType("::TestId3")->ice_getIdentity()) == "cat1/name1-bis"); + test(comm->identityToString(query->findObjectByType("::TestId4")->ice_getIdentity()) == "c2\\/c2/n2\\/n2"); + test(comm->identityToString(query->findObjectByType("::TestId5")->ice_getIdentity()) == "n2\\/n2"); } { - Ice::ObjectPrx obj = query->findObjectByType("::Test"); - string id = comm->identityToString(obj->ice_getIdentity()); - test(id == "Server1" || id == "Server2" || id == "SimpleServer" || - id == "IceBox1-Service1" || id == "IceBox1-Service2" || - id == "IceBox2-Service1" || id == "IceBox2-Service2" || - id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); + Ice::ObjectPrx obj = query->findObjectByType("::Test"); + string id = comm->identityToString(obj->ice_getIdentity()); + test(id == "Server1" || id == "Server2" || id == "SimpleServer" || + id == "IceBox1-Service1" || id == "IceBox1-Service2" || + id == "IceBox2-Service1" || id == "IceBox2-Service2" || + id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); } { - Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); - string id = comm->identityToString(obj->ice_getIdentity()); - test(id == "Server1" || id == "Server2" || id == "SimpleServer" || - id == "IceBox1-Service1" || id == "IceBox1-Service2" || - id == "IceBox2-Service1" || id == "IceBox2-Service2" || - id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); + Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); + string id = comm->identityToString(obj->ice_getIdentity()); + test(id == "Server1" || id == "Server2" || id == "SimpleServer" || + id == "IceBox1-Service1" || id == "IceBox1-Service2" || + id == "IceBox2-Service1" || id == "IceBox2-Service2" || + id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); } { - Ice::ObjectPrx obj = query->findObjectByType("::Foo"); - test(!obj); + Ice::ObjectPrx obj = query->findObjectByType("::Foo"); + test(!obj); - obj = query->findObjectByTypeOnLeastLoadedNode("::Foo", LoadSample15); - test(!obj); + obj = query->findObjectByTypeOnLeastLoadedNode("::Foo", LoadSample15); + test(!obj); } cout << "ok" << endl; @@ -233,7 +233,7 @@ allTests(const Ice::CommunicatorPtr& comm) obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); obj = TestIntfPrx::checkedCast( - comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); + comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); cout << "ok" << endl; cout << "testing server configuration... " << flush; @@ -280,21 +280,21 @@ allTests(const Ice::CommunicatorPtr& comm) obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server")); proxies.push_back(obj); obj = TestIntfPrx::checkedCast( - comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); + comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); proxies.push_back(obj); for(vector<TestIntfPrx>::const_iterator p = proxies.begin(); p != proxies.end(); ++p) { - test((*p)->getProperty("AppVarProp") == "AppVar"); - test((*p)->getProperty("NodeVarProp") == "NodeVar"); - test((*p)->getProperty("RecursiveAppVarProp") == "Test"); - test((*p)->getProperty("AppVarOverridedProp") == "OverridedInNode"); - test((*p)->getProperty("AppVarDefinedInNodeProp") == "localnode"); - test((*p)->getProperty("EscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("RecursiveEscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("Recursive2EscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("RecursiveNodeVarProp") == "localnode"); - test((*p)->getProperty("TestDirProp") != "NotThisValue"); + test((*p)->getProperty("AppVarProp") == "AppVar"); + test((*p)->getProperty("NodeVarProp") == "NodeVar"); + test((*p)->getProperty("RecursiveAppVarProp") == "Test"); + test((*p)->getProperty("AppVarOverridedProp") == "OverridedInNode"); + test((*p)->getProperty("AppVarDefinedInNodeProp") == "localnode"); + test((*p)->getProperty("EscapedAppVarProp") == "${escaped}"); + test((*p)->getProperty("RecursiveEscapedAppVarProp") == "${escaped}"); + test((*p)->getProperty("Recursive2EscapedAppVarProp") == "${escaped}"); + test((*p)->getProperty("RecursiveNodeVarProp") == "localnode"); + test((*p)->getProperty("TestDirProp") != "NotThisValue"); } cout << "ok" << endl; @@ -416,17 +416,17 @@ allTests(const Ice::CommunicatorPtr& comm) desc.serverTemplates["ServerTemplate"] = templ; try { - admin->addApplication(desc); - test(false); + admin->addApplication(desc); + test(false); } catch(const DeploymentException& ex) { - test(ex.reason.find("duplicate parameters") != string::npos); + test(ex.reason.find("duplicate parameters") != string::npos); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; @@ -731,7 +731,7 @@ void allTestsWithTarget(const Ice::CommunicatorPtr& comm) { RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - comm->stringToProxy("IceGrid/Registry")); + comm->stringToProxy("IceGrid/Registry")); test(registry); AdminSessionPrx session = registry->createAdminSession("foo", "bar"); diff --git a/cpp/test/IceGrid/deployer/Client.cpp b/cpp/test/IceGrid/deployer/Client.cpp index 1288409798d..50ee597c317 100644 --- a/cpp/test/IceGrid/deployer/Client.cpp +++ b/cpp/test/IceGrid/deployer/Client.cpp @@ -20,21 +20,21 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) bool withTemplates = false; if(argc > 1) { - int i = 1; - while(i < argc) - { - if(strcmp(argv[i], "-t") == 0) - { - withTarget = true; - break; - } - else if(strcmp(argv[i], "-e") == 0) - { - withTemplates = true; - break; - } - i++; - } + int i = 1; + while(i < argc) + { + if(strcmp(argv[i], "-t") == 0) + { + withTarget = true; + break; + } + else if(strcmp(argv[i], "-e") == 0) + { + withTemplates = true; + break; + } + i++; + } } Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); @@ -43,13 +43,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) if(!withTarget) { - void allTests(const Ice::CommunicatorPtr&); - allTests(communicator); + void allTests(const Ice::CommunicatorPtr&); + allTests(communicator); } else { - void allTestsWithTarget(const Ice::CommunicatorPtr&); - allTestsWithTarget(communicator); + void allTestsWithTarget(const Ice::CommunicatorPtr&); + allTestsWithTarget(communicator); } return EXIT_SUCCESS; @@ -63,26 +63,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/deployer/Service.cpp b/cpp/test/IceGrid/deployer/Service.cpp index 4e1b5d66e26..0bb30aff9bd 100644 --- a/cpp/test/IceGrid/deployer/Service.cpp +++ b/cpp/test/IceGrid/deployer/Service.cpp @@ -28,8 +28,8 @@ public: virtual ~ServiceI(); virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); + const CommunicatorPtr&, + const StringSeq&); virtual void stop(); }; @@ -58,17 +58,17 @@ ServiceI::~ServiceI() void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, - const StringSeq& args) + const CommunicatorPtr& communicator, + const StringSeq& args) { Ice::PropertiesPtr properties = communicator->getProperties(); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); if(properties->getPropertyAsInt(name + ".Freeze") > 0) { - // - // We do this to ensure the dbenv directory exists. - // - Freeze::createConnection(communicator, name); + // + // We do this to ensure the dbenv directory exists. + // + Freeze::createConnection(communicator, name); } Ice::ObjectPtr object = new TestI(adapter, properties); adapter->add(object, communicator->stringToIdentity(properties->getProperty(name + ".Identity"))); diff --git a/cpp/test/IceGrid/distribution/AllTests.cpp b/cpp/test/IceGrid/distribution/AllTests.cpp index d47a3a9263c..c8e0dfc169f 100644 --- a/cpp/test/IceGrid/distribution/AllTests.cpp +++ b/cpp/test/IceGrid/distribution/AllTests.cpp @@ -26,7 +26,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -41,15 +41,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -88,9 +88,9 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing distributions... " << flush; { - TestIntfPrx test; - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); - test(test->getServerFile("rootfile") == ""); + TestIntfPrx test; + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); + test(test->getServerFile("rootfile") == ""); try { @@ -102,15 +102,15 @@ allTests(const Ice::CommunicatorPtr& communicator) test(false); } - test(test->getServerFile("rootfile") == "rootfile"); - test(test->getServerFile("dir1/file1") == "dummy-file1"); - test(test->getServerFile("dir1/file2") == "dummy-file2"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("rootfile") == "rootfile"); + test(test->getServerFile("dir1/file1") == "dummy-file1"); + test(test->getServerFile("dir1/file2") == "dummy-file2"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); try { @@ -121,17 +121,17 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); - test(test->getServerFile("rootfile") == "rootfile"); - test(test->getServerFile("dir1/file1") == "dummy-file1"); - test(test->getServerFile("dir1/file2") == "dummy-file2"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("rootfile") == "rootfile"); + test(test->getServerFile("dir1/file1") == "dummy-file1"); + test(test->getServerFile("dir1/file2") == "dummy-file2"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); try { @@ -142,17 +142,17 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); - test(test->getServerFile("rootfile") == ""); - test(test->getServerFile("dir1/file1") == "dummy-file1"); - test(test->getServerFile("dir1/file2") == "dummy-file2"); - test(test->getServerFile("dir2/file3") == ""); + test(test->getServerFile("rootfile") == ""); + test(test->getServerFile("dir1/file1") == "dummy-file1"); + test(test->getServerFile("dir1/file2") == "dummy-file2"); + test(test->getServerFile("dir2/file3") == ""); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); } cout << "ok" << endl; @@ -169,9 +169,9 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing distributions after update... " << flush; { - TestIntfPrx test; - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); - test(test->getServerFile("rootfile") == "rootfile"); + TestIntfPrx test; + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); + test(test->getServerFile("rootfile") == "rootfile"); try { @@ -183,17 +183,17 @@ allTests(const Ice::CommunicatorPtr& communicator) test(false); } - test(test->getServerFile("rootfile") == "rootfile-updated!"); - test(test->getServerFile("dir1/file1") == ""); - test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getServerFile("dir2/file4") == "dummy-file4"); - - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("dir2/file4") == "dummy-file4"); + test(test->getServerFile("rootfile") == "rootfile-updated!"); + test(test->getServerFile("dir1/file1") == ""); + test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("dir2/file4") == "dummy-file4"); + + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("dir2/file4") == "dummy-file4"); try { @@ -204,19 +204,19 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); - test(test->getServerFile("rootfile") == "rootfile-updated!"); - test(test->getServerFile("dir1/file1") == ""); - test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getServerFile("dir2/file4") == "dummy-file4"); + test(test->getServerFile("rootfile") == "rootfile-updated!"); + test(test->getServerFile("dir1/file1") == ""); + test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("dir2/file4") == "dummy-file4"); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("dir2/file4") == "dummy-file4"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("dir2/file4") == "dummy-file4"); try { @@ -227,19 +227,19 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); - - test(test->getServerFile("rootfile") == ""); - test(test->getServerFile("dir1/file1") == ""); - test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); - test(test->getServerFile("dir2/file3") == ""); - test(test->getServerFile("dir2/file4") == ""); - - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("dir2/file4") == "dummy-file4"); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); + + test(test->getServerFile("rootfile") == ""); + test(test->getServerFile("dir1/file1") == ""); + test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); + test(test->getServerFile("dir2/file3") == ""); + test(test->getServerFile("dir2/file4") == ""); + + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("dir2/file4") == "dummy-file4"); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/distribution/Client.cpp b/cpp/test/IceGrid/distribution/Client.cpp index 47f910e24da..940ae6bec73 100644 --- a/cpp/test/IceGrid/distribution/Client.cpp +++ b/cpp/test/IceGrid/distribution/Client.cpp @@ -27,28 +27,28 @@ main(int argc, char* argv[]) int status; Ice::CommunicatorPtr communicator; try - { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/distribution/TestI.cpp b/cpp/test/IceGrid/distribution/TestI.cpp index d762e5a3ed0..903c51caeb9 100644 --- a/cpp/test/IceGrid/distribution/TestI.cpp +++ b/cpp/test/IceGrid/distribution/TestI.cpp @@ -28,7 +28,7 @@ TestI::getServerFile(const string& path, const Ice::Current&) string content; if(is.good()) { - is >> content; + is >> content; } return content; } @@ -41,7 +41,7 @@ TestI::getApplicationFile(const string& path, const Ice::Current&) string content; if(is.good()) { - is >> content; + is >> content; } return content; } diff --git a/cpp/test/IceGrid/distribution/run.py b/cpp/test/IceGrid/distribution/run.py index 81ca0f497d7..1e27b744862 100755 --- a/cpp/test/IceGrid/distribution/run.py +++ b/cpp/test/IceGrid/distribution/run.py @@ -57,7 +57,7 @@ else: for [file, content] in files: file = os.path.join(datadir, file) if not os.path.exists(os.path.dirname(file)): - os.makedirs(os.path.dirname(file)) + os.makedirs(os.path.dirname(file)) f = open(file, 'w') f.write(content) f.close() diff --git a/cpp/test/IceGrid/replicaGroup/AllTests.cpp b/cpp/test/IceGrid/replicaGroup/AllTests.cpp index 9ae9ce21c3c..d07d69a1c17 100644 --- a/cpp/test/IceGrid/replicaGroup/AllTests.cpp +++ b/cpp/test/IceGrid/replicaGroup/AllTests.cpp @@ -27,7 +27,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -42,15 +42,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -86,12 +86,12 @@ instantiateServer(const AdminPrx& admin, const string& templ, const string& node update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } } @@ -100,7 +100,7 @@ removeServer(const AdminPrx& admin, const string& id) { try { - admin->stopServer(id); + admin->stopServer(id); } catch(const ServerStopException&) { @@ -110,8 +110,8 @@ removeServer(const AdminPrx& admin, const string& id) } catch(const Ice::UserException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } NodeUpdateDescriptor nodeUpdate; @@ -122,12 +122,12 @@ removeServer(const AdminPrx& admin, const string& id) update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } } @@ -155,434 +155,434 @@ allTests(const Ice::CommunicatorPtr& comm) cout << "testing Query::findAllReplicas... " << flush; { - map<string, string> params; - params["replicaGroup"] = "RoundRobin"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - - QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); - test(query); - - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@RoundRobin")); - Ice::ObjectProxySeq objs = query->findAllReplicas(obj); - test(objs.size() == 3); - test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end()); - test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end()); - test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end()); - - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@dummy")); - objs = query->findAllReplicas(obj); - test(objs.empty()); - - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@Server1.ReplicatedAdapter")); - objs = query->findAllReplicas(obj); - test(objs.empty()); - - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp")); - objs = query->findAllReplicas(obj); - test(objs.empty()); - - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "RoundRobin"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + + QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); + test(query); + + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@RoundRobin")); + Ice::ObjectProxySeq objs = query->findAllReplicas(obj); + test(objs.size() == 3); + test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end()); + test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end()); + test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end()); + + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@dummy")); + objs = query->findAllReplicas(obj); + test(objs.empty()); + + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@Server1.ReplicatedAdapter")); + objs = query->findAllReplicas(obj); + test(objs.empty()); + + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp")); + objs = query->findAllReplicas(obj); + test(objs.empty()); + + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } cout << "ok" << endl; cout << "testing replication with round-robin load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "RoundRobin"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - try - { - test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); - test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); - test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "RoundRobin"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + try + { + test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); + test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); + test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "RoundRobin"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - try - { - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "RoundRobin"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + try + { + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing replication with ordered load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "Ordered"; - params["id"] = "Server1"; - params["priority"] = "3"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - params["priority"] = "1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - params["priority"] = "2"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); - try - { - test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); - admin->enableServer("Server2", false); - test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); - admin->enableServer("Server3", false); - test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "Ordered"; + params["id"] = "Server1"; + params["priority"] = "3"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + params["priority"] = "1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + params["priority"] = "2"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); + try + { + test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); + admin->enableServer("Server2", false); + test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); + admin->enableServer("Server3", false); + test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "Ordered"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); - try - { - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "Ordered"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); + try + { + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing replication with random load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "Random"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = serverReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "Random"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = serverReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "Random"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = svcReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::ConnectionRefusedException&) - { - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "Random"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = svcReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::ConnectionRefusedException&) + { + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing replication with adaptive load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "Adaptive"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = serverReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "Adaptive"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = serverReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "Adaptive"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = svcReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::ConnectionRefusedException&) - { - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "Adaptive"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = svcReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::ConnectionRefusedException&) + { + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing load balancing n-replicas..." << flush; { - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-2")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - - map<string, string> params; - params["replicaGroup"] = "RoundRobin-2"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - try - { - set<string> replicaIds; - set<string> expected; - replicaIds.insert("Server1.ReplicatedAdapter"); - replicaIds.insert("Server2.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - obj->ice_locatorCacheTimeout(0)->ice_ping(); - replicaIds.insert("Server2.ReplicatedAdapter"); - replicaIds.insert("Server3.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - obj->ice_locatorCacheTimeout(0)->ice_ping(); - replicaIds.insert("Server3.ReplicatedAdapter"); - replicaIds.insert("Server1.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-2")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + + map<string, string> params; + params["replicaGroup"] = "RoundRobin-2"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + try + { + set<string> replicaIds; + set<string> expected; + replicaIds.insert("Server1.ReplicatedAdapter"); + replicaIds.insert("Server2.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + obj->ice_locatorCacheTimeout(0)->ice_ping(); + replicaIds.insert("Server2.ReplicatedAdapter"); + replicaIds.insert("Server3.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + obj->ice_locatorCacheTimeout(0)->ice_ping(); + replicaIds.insert("Server3.ReplicatedAdapter"); + replicaIds.insert("Server1.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-All")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - - map<string, string> params; - params["replicaGroup"] = "RoundRobin-All"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - try - { - set<string> replicaIds; - set<string> expected; - replicaIds.insert("Server1.ReplicatedAdapter"); - replicaIds.insert("Server2.ReplicatedAdapter"); - replicaIds.insert("Server3.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - obj->ice_locatorCacheTimeout(0)->ice_ping(); - replicaIds.insert("Server1.ReplicatedAdapter"); - replicaIds.insert("Server2.ReplicatedAdapter"); - replicaIds.insert("Server3.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-All")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + + map<string, string> params; + params["replicaGroup"] = "RoundRobin-All"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + try + { + set<string> replicaIds; + set<string> expected; + replicaIds.insert("Server1.ReplicatedAdapter"); + replicaIds.insert("Server2.ReplicatedAdapter"); + replicaIds.insert("Server3.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + obj->ice_locatorCacheTimeout(0)->ice_ping(); + replicaIds.insert("Server1.ReplicatedAdapter"); + replicaIds.insert("Server2.ReplicatedAdapter"); + replicaIds.insert("Server3.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } cout << "ok" << endl; cout << "testing replication with inactive nodes... " << flush; { - map<string, string> params; - - params["replicaGroup"] = "Random"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - - // - // Also make sure that findObjectByTypeOnLeastLoadedNode still work. - // - QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); - obj = TestIntfPrx::uncheckedCast(query->findObjectByTypeOnLeastLoadedNode("::Test::TestIntf", LoadSample1)); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - - params["replicaGroup"] = "RoundRobin"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - - params["replicaGroup"] = "Adaptive"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - - params["replicaGroup"] = "Random"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - test(svcReplicaIds.find(obj->getReplicaId()) != svcReplicaIds.end()); - removeServer(admin, "IceBox1"); - removeServer(admin, "Server1"); + map<string, string> params; + + params["replicaGroup"] = "Random"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + + // + // Also make sure that findObjectByTypeOnLeastLoadedNode still work. + // + QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); + obj = TestIntfPrx::uncheckedCast(query->findObjectByTypeOnLeastLoadedNode("::Test::TestIntf", LoadSample1)); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + + params["replicaGroup"] = "RoundRobin"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + + params["replicaGroup"] = "Adaptive"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + + params["replicaGroup"] = "Random"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + test(svcReplicaIds.find(obj->getReplicaId()) != svcReplicaIds.end()); + removeServer(admin, "IceBox1"); + removeServer(admin, "Server1"); }; cout << "ok" << endl; diff --git a/cpp/test/IceGrid/replicaGroup/Client.cpp b/cpp/test/IceGrid/replicaGroup/Client.cpp index 0527d790712..a0f1ccc1976 100644 --- a/cpp/test/IceGrid/replicaGroup/Client.cpp +++ b/cpp/test/IceGrid/replicaGroup/Client.cpp @@ -29,26 +29,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/replicaGroup/Service.cpp b/cpp/test/IceGrid/replicaGroup/Service.cpp index 4948e4914a0..f90125bd4b8 100644 --- a/cpp/test/IceGrid/replicaGroup/Service.cpp +++ b/cpp/test/IceGrid/replicaGroup/Service.cpp @@ -27,8 +27,8 @@ public: virtual ~ServiceI(); virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); + const CommunicatorPtr&, + const StringSeq&); virtual void stop(); }; @@ -57,8 +57,8 @@ ServiceI::~ServiceI() void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, - const StringSeq& args) + const CommunicatorPtr& communicator, + const StringSeq& args) { Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); Ice::ObjectPtr object = new TestI(adapter, communicator->getProperties()); diff --git a/cpp/test/IceGrid/replication/AllTests.cpp b/cpp/test/IceGrid/replication/AllTests.cpp index 6ea8a923372..2ebf0731d48 100644 --- a/cpp/test/IceGrid/replication/AllTests.cpp +++ b/cpp/test/IceGrid/replication/AllTests.cpp @@ -28,7 +28,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -43,15 +43,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -78,13 +78,13 @@ waitForServerState(const IceGrid::AdminPrx& admin, const std::string& server, bo int nRetry = 0; while(nRetry < 30) { - if(admin->getServerState(server) == (up ? Active : Inactive)) - { - return; - } + if(admin->getServerState(server) == (up ? Active : Inactive)) + { + return; + } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; } test(false); } @@ -95,41 +95,41 @@ waitForNodeState(const IceGrid::AdminPrx& admin, const std::string& node, bool u int nRetry = 0; while(nRetry < 30) { - try - { - if(admin->pingNode(node) == up) // Wait for the node to be removed. - { - return; - } - } - catch(const NodeNotExistException&) - { - if(!up) - { - return; - } - } - - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; + try + { + if(admin->pingNode(node) == up) // Wait for the node to be removed. + { + return; + } + } + catch(const NodeNotExistException&) + { + if(!up) + { + return; + } + } + + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; } try { - if(admin->pingNode(node) != up) - { - cerr << "node state change timed out:" << endl; - cerr << "node: " << node << endl; - cerr << "state: " << up << endl; - } + if(admin->pingNode(node) != up) + { + cerr << "node state change timed out:" << endl; + cerr << "node: " << node << endl; + cerr << "state: " << up << endl; + } } catch(NodeNotExistException&) { - if(up) - { - cerr << "node state change timed out:" << endl; - cerr << "node: " << node << endl; - cerr << "state: " << up << endl; - } + if(up) + { + cerr << "node state change timed out:" << endl; + cerr << "node: " << node << endl; + cerr << "state: " << up << endl; + } } } @@ -147,17 +147,17 @@ instantiateServer(const AdminPrx& admin, const string& templ, const map<string, update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } } @@ -166,7 +166,7 @@ removeServer(const AdminPrx& admin, const string& id) { try { - admin->stopServer(id); + admin->stopServer(id); } catch(const ServerStopException&) { @@ -176,8 +176,8 @@ removeServer(const AdminPrx& admin, const string& id) } catch(const Ice::UserException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } NodeUpdateDescriptor nodeUpdate; @@ -188,12 +188,12 @@ removeServer(const AdminPrx& admin, const string& id) update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } } @@ -203,16 +203,16 @@ waitAndPing(const Ice::ObjectPrx& obj) int nRetry = 0; while(nRetry < 30) { - try - { - obj->ice_ping(); - return true; - } - catch(const Ice::LocalException&) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } + try + { + obj->ice_ping(); + return true; + } + catch(const Ice::LocalException&) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } } return false; } @@ -225,7 +225,7 @@ createAdminSession(const Ice::LocatorPrx& locator, const string& replica) string registryStr("TestIceGrid/Registry"); if(!replica.empty() && replica != "Master") { - registryStr += "-" + replica; + registryStr += "-" + replica; } Ice::ObjectPrx obj = locator->ice_getCommunicator()->stringToProxy(registryStr)->ice_locator(locator); RegistryPrx registry = RegistryPrx::checkedCast(obj); @@ -270,14 +270,14 @@ allTests(const Ice::CommunicatorPtr& comm) instantiateServer(admin, "IceGridRegistry", params); Ice::LocatorPrx masterLocator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12050")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12050")); Ice::LocatorPrx slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); Ice::LocatorPrx slave2Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave2:default -p 12052")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave2:default -p 12052")); Ice::LocatorPrx replicatedLocator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator:default -p 12050:default -p 12051")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator:default -p 12050:default -p 12051")); AdminPrx masterAdmin, slave1Admin, slave2Admin; @@ -300,203 +300,203 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing replicated locator and query interface... " << flush; { - Ice::EndpointSeq endpoints; - ObjectInfo info; - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - ObjectInfo info1 = slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); - test(info.type == Ice::Locator::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - // We eventually need to wait here for the update of the replicated objects to propagate to the replica. - int nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); - test(info.type == Ice::Locator::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 3); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - test(endpoints[2]->toString().find("-p 12052") != string::npos); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); - // We eventually need to wait here for the update of the replicated objects to propagate to the replica. - nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 3); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - test(endpoints[2]->toString().find("-p 12052") != string::npos); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - // We eventually need to wait here for the update of the replicated objects to propagate to the replica. - nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); - test(info.type == Ice::Locator::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); - nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - QueryPrx query; - query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[0]->toString())); - Ice::ObjectProxySeq objs = query->findAllObjectsByType("::IceGrid::Registry"); - test(objs.size() == 2); - query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[1]->toString())); - test(objs == query->findAllObjectsByType("::IceGrid::Registry")); + Ice::EndpointSeq endpoints; + ObjectInfo info; + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + ObjectInfo info1 = slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); + test(info.type == Ice::Locator::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); + test(info.type == IceGrid::Query::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + // We eventually need to wait here for the update of the replicated objects to propagate to the replica. + int nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); + test(info.type == Ice::Locator::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 3); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + test(endpoints[2]->toString().find("-p 12052") != string::npos); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); + // We eventually need to wait here for the update of the replicated objects to propagate to the replica. + nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); + test(info.type == IceGrid::Query::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 3); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + test(endpoints[2]->toString().find("-p 12052") != string::npos); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + // We eventually need to wait here for the update of the replicated objects to propagate to the replica. + nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); + test(info.type == Ice::Locator::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); + nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); + test(info.type == IceGrid::Query::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + QueryPrx query; + query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[0]->toString())); + Ice::ObjectProxySeq objs = query->findAllObjectsByType("::IceGrid::Registry"); + test(objs.size() == 2); + query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[1]->toString())); + test(objs == query->findAllObjectsByType("::IceGrid::Registry")); } cout << "ok" << endl; cout << "testing well-known IceGrid objects... " << flush; { - // - // Test Registry well-known object (we have already tested - // admin session creation for the creation of the admin - // session above!) - // - RegistryPrx masterRegistry = RegistryPrx::checkedCast( - comm->stringToProxy("TestIceGrid/Registry")->ice_locator(replicatedLocator)); - RegistryPrx slave1Registry = RegistryPrx::checkedCast( - comm->stringToProxy("TestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator)); - - SessionPrx session = masterRegistry->createSession("dummy", "dummy"); - session->destroy(); - if(comm->getProperties()->getProperty("Ice.Default.Protocol") == "ssl") - { - session = masterRegistry->createSessionFromSecureConnection(); - session->destroy(); - } - else - { - try - { - masterRegistry->createSessionFromSecureConnection(); - } - catch(const PermissionDeniedException&) - { - } - } - - try - { - slave1Registry->createSession("dummy", ""); - } - catch(const PermissionDeniedException&) - { - } - try - { - slave1Registry->createSessionFromSecureConnection(); - } - catch(const PermissionDeniedException&) - { - } - - // - // Test registry user-account mapper. - // - UserAccountMapperPrx masterMapper = UserAccountMapperPrx::checkedCast( - comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper")->ice_locator(replicatedLocator)); - UserAccountMapperPrx slave1Mapper = UserAccountMapperPrx::checkedCast( - comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper-Slave1")->ice_locator(replicatedLocator)); - - test(masterMapper->getUserAccount("Dummy User Account1") == "dummy1"); - test(masterMapper->getUserAccount("Dummy User Account2") == "dummy2"); - test(slave1Mapper->getUserAccount("Dummy User Account1") == "dummy1"); - test(slave1Mapper->getUserAccount("Dummy User Account2") == "dummy2"); - try - { - masterMapper->getUserAccount("unknown"); - test(false); - } - catch(UserAccountNotFoundException&) - { - } - try - { - slave1Mapper->getUserAccount("unknown"); - test(false); - } - catch(UserAccountNotFoundException&) - { - } - - // - // Test SessionManager, SSLSessionManager, - // AdminSessionManager, AdminSSLSessionManager - // - comm->stringToProxy("TestIceGrid/SessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/SSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - try - { - comm->stringToProxy("TestIceGrid/SessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - try - { - comm->stringToProxy("TestIceGrid/SSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - - comm->stringToProxy("TestIceGrid/AdminSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/AdminSSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/AdminSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/AdminSSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + // + // Test Registry well-known object (we have already tested + // admin session creation for the creation of the admin + // session above!) + // + RegistryPrx masterRegistry = RegistryPrx::checkedCast( + comm->stringToProxy("TestIceGrid/Registry")->ice_locator(replicatedLocator)); + RegistryPrx slave1Registry = RegistryPrx::checkedCast( + comm->stringToProxy("TestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator)); + + SessionPrx session = masterRegistry->createSession("dummy", "dummy"); + session->destroy(); + if(comm->getProperties()->getProperty("Ice.Default.Protocol") == "ssl") + { + session = masterRegistry->createSessionFromSecureConnection(); + session->destroy(); + } + else + { + try + { + masterRegistry->createSessionFromSecureConnection(); + } + catch(const PermissionDeniedException&) + { + } + } + + try + { + slave1Registry->createSession("dummy", ""); + } + catch(const PermissionDeniedException&) + { + } + try + { + slave1Registry->createSessionFromSecureConnection(); + } + catch(const PermissionDeniedException&) + { + } + + // + // Test registry user-account mapper. + // + UserAccountMapperPrx masterMapper = UserAccountMapperPrx::checkedCast( + comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper")->ice_locator(replicatedLocator)); + UserAccountMapperPrx slave1Mapper = UserAccountMapperPrx::checkedCast( + comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper-Slave1")->ice_locator(replicatedLocator)); + + test(masterMapper->getUserAccount("Dummy User Account1") == "dummy1"); + test(masterMapper->getUserAccount("Dummy User Account2") == "dummy2"); + test(slave1Mapper->getUserAccount("Dummy User Account1") == "dummy1"); + test(slave1Mapper->getUserAccount("Dummy User Account2") == "dummy2"); + try + { + masterMapper->getUserAccount("unknown"); + test(false); + } + catch(UserAccountNotFoundException&) + { + } + try + { + slave1Mapper->getUserAccount("unknown"); + test(false); + } + catch(UserAccountNotFoundException&) + { + } + + // + // Test SessionManager, SSLSessionManager, + // AdminSessionManager, AdminSSLSessionManager + // + comm->stringToProxy("TestIceGrid/SessionManager")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/SSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + try + { + comm->stringToProxy("TestIceGrid/SessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + try + { + comm->stringToProxy("TestIceGrid/SSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + + comm->stringToProxy("TestIceGrid/AdminSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/AdminSSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/AdminSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/AdminSSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); } cout << "ok" << endl; @@ -511,257 +511,257 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing registry updates... " << flush; { - ApplicationDescriptor app; - app.name = "TestApp"; - app.description = "added application"; - - AdapterInfo adpt; - adpt.id = "TestAdpt"; - adpt.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); - - ObjectInfo obj; - obj.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); - obj.type = "::Hello"; - - // - // We use the locator registry from Slave1 to ensure that the - // forwarding to the master work (the slave locator registry - // forwards everything to the master). - // - Ice::LocatorRegistryPrx locatorRegistry = slave1Locator->getRegistry(); - - // - // Test addition of application, adapter, object. - // - - try - { - slave1Admin->addApplication(app); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->addApplication(app); - - locatorRegistry->setAdapterDirectProxy(adpt.id, adpt.proxy); - - try - { - slave1Admin->addObjectWithType(obj.proxy, obj.type); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database - } - masterAdmin->addObjectWithType(obj.proxy, obj.type); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "added application"); - test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); - test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); - - test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); - - test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - // - // Test sync of application. - // - - app.description = "updated1 application"; - try - { - slave1Admin->syncApplication(app); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->syncApplication(app); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); - test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); - test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - // - // Test update of application, adapter, object. - // - - ApplicationUpdateDescriptor appUpdate; - appUpdate.name = "TestApp"; - appUpdate.description = new BoxedString("updated2 application"); - try - { - slave1Admin->updateApplication(appUpdate); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->updateApplication(appUpdate); - - adpt.replicaGroupId = "TestReplicaGroup"; - locatorRegistry->setReplicatedAdapterDirectProxy(adpt.id, adpt.replicaGroupId, adpt.proxy); - - obj.proxy = comm->stringToProxy("dummy:tcp -p 12346 -h 127.0.0.1"); - try - { - slave1Admin->updateObject(obj.proxy); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database - } - masterAdmin->updateObject(obj.proxy); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - - test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); - - test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - // - // Test removal of application, adapter and object. - - try - { - slave1Admin->removeApplication("TestApp"); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->removeApplication("TestApp"); - - try - { - slave1Admin->removeAdapter("TestAdpt"); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->removeAdapter("TestAdpt"); - try - { - slave1Admin->removeObject(obj.proxy->ice_getIdentity()); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->removeObject(obj.proxy->ice_getIdentity()); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - try - { - masterAdmin->getApplicationInfo("TestApp"); - test(false); - } - catch(const ApplicationNotExistException&) - { - } - try - { - slave1Admin->getApplicationInfo("TestApp"); - test(false); - } - catch(const ApplicationNotExistException&) - { - } - try - { - slave2Admin->getApplicationInfo("TestApp"); - test(false); - } - catch(const ApplicationNotExistException&) - { - } - try - { - masterAdmin->getAdapterInfo("TestAdpt"); - test(false); - } - catch(const AdapterNotExistException&) - { - } - try - { - slave1Admin->getAdapterInfo("TestAdpt"); - test(false); - } - catch(const AdapterNotExistException&) - { - } - try - { - slave2Admin->getAdapterInfo("TestAdpt"); - test(false); - } - catch(const AdapterNotExistException&) - { - } - try - { - masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()); - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - try - { - slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()); - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - try - { - slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()); - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); + ApplicationDescriptor app; + app.name = "TestApp"; + app.description = "added application"; + + AdapterInfo adpt; + adpt.id = "TestAdpt"; + adpt.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); + + ObjectInfo obj; + obj.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); + obj.type = "::Hello"; + + // + // We use the locator registry from Slave1 to ensure that the + // forwarding to the master work (the slave locator registry + // forwards everything to the master). + // + Ice::LocatorRegistryPrx locatorRegistry = slave1Locator->getRegistry(); + + // + // Test addition of application, adapter, object. + // + + try + { + slave1Admin->addApplication(app); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->addApplication(app); + + locatorRegistry->setAdapterDirectProxy(adpt.id, adpt.proxy); + + try + { + slave1Admin->addObjectWithType(obj.proxy, obj.type); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database + } + masterAdmin->addObjectWithType(obj.proxy, obj.type); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "added application"); + test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); + test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); + + test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); + + test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + // + // Test sync of application. + // + + app.description = "updated1 application"; + try + { + slave1Admin->syncApplication(app); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->syncApplication(app); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); + test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); + test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + // + // Test update of application, adapter, object. + // + + ApplicationUpdateDescriptor appUpdate; + appUpdate.name = "TestApp"; + appUpdate.description = new BoxedString("updated2 application"); + try + { + slave1Admin->updateApplication(appUpdate); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->updateApplication(appUpdate); + + adpt.replicaGroupId = "TestReplicaGroup"; + locatorRegistry->setReplicatedAdapterDirectProxy(adpt.id, adpt.replicaGroupId, adpt.proxy); + + obj.proxy = comm->stringToProxy("dummy:tcp -p 12346 -h 127.0.0.1"); + try + { + slave1Admin->updateObject(obj.proxy); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database + } + masterAdmin->updateObject(obj.proxy); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); + test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); + test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); + + test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); + + test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + // + // Test removal of application, adapter and object. + + try + { + slave1Admin->removeApplication("TestApp"); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->removeApplication("TestApp"); + + try + { + slave1Admin->removeAdapter("TestAdpt"); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->removeAdapter("TestAdpt"); + try + { + slave1Admin->removeObject(obj.proxy->ice_getIdentity()); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->removeObject(obj.proxy->ice_getIdentity()); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + try + { + masterAdmin->getApplicationInfo("TestApp"); + test(false); + } + catch(const ApplicationNotExistException&) + { + } + try + { + slave1Admin->getApplicationInfo("TestApp"); + test(false); + } + catch(const ApplicationNotExistException&) + { + } + try + { + slave2Admin->getApplicationInfo("TestApp"); + test(false); + } + catch(const ApplicationNotExistException&) + { + } + try + { + masterAdmin->getAdapterInfo("TestAdpt"); + test(false); + } + catch(const AdapterNotExistException&) + { + } + try + { + slave1Admin->getAdapterInfo("TestAdpt"); + test(false); + } + catch(const AdapterNotExistException&) + { + } + try + { + slave2Admin->getAdapterInfo("TestAdpt"); + test(false); + } + catch(const AdapterNotExistException&) + { + } + try + { + masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()); + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + try + { + slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()); + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + try + { + slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()); + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); } cout << "ok" << endl; @@ -779,12 +779,12 @@ allTests(const Ice::CommunicatorPtr& comm) app.nodes["Node1"].description = "dummy node"; try { - masterAdmin->addApplication(app); + masterAdmin->addApplication(app); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } // @@ -800,104 +800,104 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing node session establishment... " << flush; { - admin->startServer("Node1"); - - waitForNodeState(masterAdmin, "Node1", true); - waitForNodeState(slave1Admin, "Node1", true); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - waitForNodeState(slave2Admin, "Node1", true); // Node should connect. - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - try - { - test(slave1Admin->pingNode("Node1")); // Node should be re-connected. - } - catch(const NodeNotExistException&) - { - test(false); - } - - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - try - { - test(slave2Admin->pingNode("Node1")); // Node should be re-connected even if the master is down. - } - catch(const NodeNotExistException&) - { - test(false); - } - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - try - { - test(masterAdmin->pingNode("Node1")); // Node should be re-connected. - } - catch(const NodeNotExistException&) - { - test(false); - } - - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - try - { - test(slave1Admin->pingNode("Node1")); // Node should be re-connected. - } - catch(const NodeNotExistException&) - { - test(false); - } - - try - { - test(masterAdmin->pingNode("Node1")); - } - catch(const NodeNotExistException&) - { - test(false); - } - - try - { - test(slave2Admin->pingNode("Node1")); - } - catch(const NodeNotExistException&) - { - test(false); - } - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - try - { - test(slave2Admin->pingNode("Node1")); - } - catch(const NodeNotExistException&) - { - test(false); - } + admin->startServer("Node1"); + + waitForNodeState(masterAdmin, "Node1", true); + waitForNodeState(slave1Admin, "Node1", true); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + waitForNodeState(slave2Admin, "Node1", true); // Node should connect. + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + try + { + test(slave1Admin->pingNode("Node1")); // Node should be re-connected. + } + catch(const NodeNotExistException&) + { + test(false); + } + + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + try + { + test(slave2Admin->pingNode("Node1")); // Node should be re-connected even if the master is down. + } + catch(const NodeNotExistException&) + { + test(false); + } + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + try + { + test(masterAdmin->pingNode("Node1")); // Node should be re-connected. + } + catch(const NodeNotExistException&) + { + test(false); + } + + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + try + { + test(slave1Admin->pingNode("Node1")); // Node should be re-connected. + } + catch(const NodeNotExistException&) + { + test(false); + } + + try + { + test(masterAdmin->pingNode("Node1")); + } + catch(const NodeNotExistException&) + { + test(false); + } + + try + { + test(slave2Admin->pingNode("Node1")); + } + catch(const NodeNotExistException&) + { + test(false); + } + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + try + { + test(slave2Admin->pingNode("Node1")); + } + catch(const NodeNotExistException&) + { + test(false); + } } cout << "ok" << endl; @@ -906,267 +906,267 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing out-of-date replicas... " << flush; { - ApplicationDescriptor app; - app.name = "TestApp"; - app.description = "added application"; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "Server"; - server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; - server->pwd = "."; - server->activation = "on-demand"; - AdapterDescriptor adapter; - adapter.name = "TestAdapter"; - adapter.id = "TestAdapter.Server"; - adapter.registerProcess = true; - PropertyDescriptor property; - property.name = "Ice.OA.TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); - ObjectDescriptor object; - object.id = comm->stringToIdentity("test"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - app.nodes["Node1"].servers.push_back(server); - - masterAdmin->addApplication(app); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - masterAdmin->stopServer("Server"); - - // - // Shutdown Slave2 and update application. - // - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "Node1"; - node.servers.push_back(server); - update.nodes.push_back(node); - property.name = "Dummy"; - property.value = "val"; - server->propertySet.properties.push_back(property); - masterAdmin->updateApplication(update); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - try - { - slave2Admin->startServer("Server"); - test(false); - } - catch(const DeploymentException&) - { - } - try - { - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - // - // Shutdown Node1 and update the application, then, shutdown - // the master. - // - slave1Admin->shutdownNode("Node1"); - waitForServerState(admin, "Node1", false); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - property.name = "Dummy2"; - property.value = "val"; - server->propertySet.properties.push_back(property); - masterAdmin->updateApplication(update); - - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - - // - // Restart Node1 and Slave2, Slave2 still has the old version - // of the server so it should be able to load it. Slave1 has - // a more recent version, so it can't load it. - // - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - admin->startServer("Node1"); - - waitForNodeState(slave2Admin, "Node1", true); - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - try - { - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - } - catch(const Ice::NoEndpointException&) - { - } - - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - slave2Admin->stopServer("Server"); - - // - // Start the master. This will re-load the server on the node - // and update the out-of-date replicas. - // - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - slave2Admin->shutdownNode("Node1"); - waitForServerState(admin, "Node1", false); - admin->startServer("Node1"); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - waitForNodeState(masterAdmin, "Node1", true); - waitForNodeState(slave1Admin, "Node1", true); - waitForNodeState(slave2Admin, "Node1", true); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - slave2Admin->stopServer("Server"); - - masterAdmin->removeApplication("TestApp"); + ApplicationDescriptor app; + app.name = "TestApp"; + app.description = "added application"; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "Server"; + server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; + server->pwd = "."; + server->activation = "on-demand"; + AdapterDescriptor adapter; + adapter.name = "TestAdapter"; + adapter.id = "TestAdapter.Server"; + adapter.registerProcess = true; + PropertyDescriptor property; + property.name = "Ice.OA.TestAdapter.Endpoints"; + property.value = "default"; + server->propertySet.properties.push_back(property); + property.name = "Identity"; + property.value = "test"; + server->propertySet.properties.push_back(property); + ObjectDescriptor object; + object.id = comm->stringToIdentity("test"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + app.nodes["Node1"].servers.push_back(server); + + masterAdmin->addApplication(app); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + masterAdmin->stopServer("Server"); + + // + // Shutdown Slave2 and update application. + // + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "Node1"; + node.servers.push_back(server); + update.nodes.push_back(node); + property.name = "Dummy"; + property.value = "val"; + server->propertySet.properties.push_back(property); + masterAdmin->updateApplication(update); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + try + { + slave2Admin->startServer("Server"); + test(false); + } + catch(const DeploymentException&) + { + } + try + { + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + // + // Shutdown Node1 and update the application, then, shutdown + // the master. + // + slave1Admin->shutdownNode("Node1"); + waitForServerState(admin, "Node1", false); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + property.name = "Dummy2"; + property.value = "val"; + server->propertySet.properties.push_back(property); + masterAdmin->updateApplication(update); + + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + + // + // Restart Node1 and Slave2, Slave2 still has the old version + // of the server so it should be able to load it. Slave1 has + // a more recent version, so it can't load it. + // + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + admin->startServer("Node1"); + + waitForNodeState(slave2Admin, "Node1", true); + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + try + { + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + } + catch(const Ice::NoEndpointException&) + { + } + + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + slave2Admin->stopServer("Server"); + + // + // Start the master. This will re-load the server on the node + // and update the out-of-date replicas. + // + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + slave2Admin->shutdownNode("Node1"); + waitForServerState(admin, "Node1", false); + admin->startServer("Node1"); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + waitForNodeState(masterAdmin, "Node1", true); + waitForNodeState(slave1Admin, "Node1", true); + waitForNodeState(slave2Admin, "Node1", true); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + slave2Admin->stopServer("Server"); + + masterAdmin->removeApplication("TestApp"); } cout << "ok" << endl; cout << "testing master upgrade... " << flush; { - ApplicationDescriptor app; - app.name = "TestApp"; - app.description = "added application"; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "Server"; - server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; - server->pwd = "."; - server->activation = "on-demand"; - AdapterDescriptor adapter; - adapter.name = "TestAdapter"; - adapter.id = "TestAdapter.Server"; - adapter.registerProcess = true; - PropertyDescriptor property; - property.name = "Ice.OA.TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); - ObjectDescriptor object; - object.id = comm->stringToIdentity("test"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - app.nodes["Node1"].servers.push_back(server); - - masterAdmin->addApplication(app); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - masterAdmin->stopServer("Server"); - - // - // Shutdown the Master, update Slave1 to be the Master. - // - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - params["id"] = "Slave1"; - params["port"] = "12051"; - params["replicaName"] = "Master"; - instantiateServer(admin, "IceGridRegistry", params); - - admin->startServer("Slave1"); - slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12051")); - slave1Admin = createAdminSession(slave1Locator, ""); - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "Node1"; - node.servers.push_back(server); - update.nodes.push_back(node); - property.name = "Dummy"; - property.value = "val"; - server->propertySet.properties.push_back(property); - slave1Admin->updateApplication(update); - - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - params["id"] = "Slave1"; - params["replicaName"] = "Slave1"; - params["port"] = "12051"; - instantiateServer(admin, "IceGridRegistry", params); - - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - admin->startServer("Slave1"); - slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - masterAdmin->stopServer("Server"); - - masterAdmin->removeApplication("TestApp"); + ApplicationDescriptor app; + app.name = "TestApp"; + app.description = "added application"; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "Server"; + server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; + server->pwd = "."; + server->activation = "on-demand"; + AdapterDescriptor adapter; + adapter.name = "TestAdapter"; + adapter.id = "TestAdapter.Server"; + adapter.registerProcess = true; + PropertyDescriptor property; + property.name = "Ice.OA.TestAdapter.Endpoints"; + property.value = "default"; + server->propertySet.properties.push_back(property); + property.name = "Identity"; + property.value = "test"; + server->propertySet.properties.push_back(property); + ObjectDescriptor object; + object.id = comm->stringToIdentity("test"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + app.nodes["Node1"].servers.push_back(server); + + masterAdmin->addApplication(app); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + masterAdmin->stopServer("Server"); + + // + // Shutdown the Master, update Slave1 to be the Master. + // + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + params["id"] = "Slave1"; + params["port"] = "12051"; + params["replicaName"] = "Master"; + instantiateServer(admin, "IceGridRegistry", params); + + admin->startServer("Slave1"); + slave1Locator = + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12051")); + slave1Admin = createAdminSession(slave1Locator, ""); + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "Node1"; + node.servers.push_back(server); + update.nodes.push_back(node); + property.name = "Dummy"; + property.value = "val"; + server->propertySet.properties.push_back(property); + slave1Admin->updateApplication(update); + + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + params["id"] = "Slave1"; + params["replicaName"] = "Slave1"; + params["port"] = "12051"; + instantiateServer(admin, "IceGridRegistry", params); + + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + admin->startServer("Slave1"); + slave1Locator = + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + masterAdmin->stopServer("Server"); + + masterAdmin->removeApplication("TestApp"); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/replication/Client.cpp b/cpp/test/IceGrid/replication/Client.cpp index cf34f395e60..0d5fbf4b5bd 100644 --- a/cpp/test/IceGrid/replication/Client.cpp +++ b/cpp/test/IceGrid/replication/Client.cpp @@ -29,27 +29,27 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/session/AllTests.cpp b/cpp/test/IceGrid/session/AllTests.cpp index 73cb564752f..75b2e6b6031 100644 --- a/cpp/test/IceGrid/session/AllTests.cpp +++ b/cpp/test/IceGrid/session/AllTests.cpp @@ -34,51 +34,51 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const Ice::LoggerPtr& logger, const IceUtil::Time& timeout) : - _logger(logger), - _timeout(timeout), - _terminated(false) + _logger(logger), + _timeout(timeout), + _terminated(false) { } virtual void run() { - Lock sync(*this); - while(!_terminated) - { - timedWait(_timeout); - if(!_terminated) - { - vector<AdminSessionPrx>::iterator p = _sessions.begin(); - while(p != _sessions.end()) - { - try - { - (*p)->keepAlive(); - ++p; - } - catch(const Ice::Exception&) - { - p = _sessions.erase(p); - } - } - } - } + Lock sync(*this); + while(!_terminated) + { + timedWait(_timeout); + if(!_terminated) + { + vector<AdminSessionPrx>::iterator p = _sessions.begin(); + while(p != _sessions.end()) + { + try + { + (*p)->keepAlive(); + ++p; + } + catch(const Ice::Exception&) + { + p = _sessions.erase(p); + } + } + } + } } void add(const AdminSessionPrx& session) { - Lock sync(*this); - _sessions.push_back(session); + Lock sync(*this); + _sessions.push_back(session); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } private: @@ -96,59 +96,59 @@ public: ObserverBase(const string& name) : _name(name), _updated(0) { - _observers.insert(make_pair(name, this)); + _observers.insert(make_pair(name, this)); } virtual ~ObserverBase() { - _observers.erase(_name); + _observers.erase(_name); } static void printStack() { - map<string, ObserverBase*>::const_iterator p; - for(p = _observers.begin(); p != _observers.end(); ++p) - { - vector<string>::const_iterator q = p->second->_stack.begin(); - if(p->second->_stack.size() > 10) - { - q = p->second->_stack.begin() + p->second->_stack.size() - 10; - } - cerr << "Last 10 updates of observer `" << p->second->_name << "':" << endl; - for(; q != p->second->_stack.end(); ++q) - { - cerr << " " << *q << endl; - } - p->second->_stack.clear(); - } + map<string, ObserverBase*>::const_iterator p; + for(p = _observers.begin(); p != _observers.end(); ++p) + { + vector<string>::const_iterator q = p->second->_stack.begin(); + if(p->second->_stack.size() > 10) + { + q = p->second->_stack.begin() + p->second->_stack.size() - 10; + } + cerr << "Last 10 updates of observer `" << p->second->_name << "':" << endl; + for(; q != p->second->_stack.end(); ++q) + { + cerr << " " << *q << endl; + } + p->second->_stack.clear(); + } } void trace(const string& msg) { - _stack.push_back(msg); + _stack.push_back(msg); } void waitForUpdate(const char* file, int line) { - Lock sync(*this); - - ostringstream os; - os << "wait for update from line " << line; - trace(os.str()); - - while(!_updated) - { - if(!timedWait(IceUtil::Time::seconds(10))) - { - cerr << "timeout: " << file << ":" << line << endl; - ObserverBase::printStack(); - test(false); // Timeout - } - } - --_updated; + Lock sync(*this); + + ostringstream os; + os << "wait for update from line " << line; + trace(os.str()); + + while(!_updated) + { + if(!timedWait(IceUtil::Time::seconds(10))) + { + cerr << "timeout: " << file << ":" << line << endl; + ObserverBase::printStack(); + test(false); // Timeout + } + } + --_updated; } protected: @@ -156,9 +156,9 @@ protected: void updated(const string& update) { - trace(update); - ++_updated; - notifyAll(); + trace(update); + ++_updated; + notifyAll(); } string _name; @@ -172,54 +172,54 @@ class ApplicationObserverI : public ApplicationObserver, public ObserverBase { public: - ApplicationObserverI(const string& name) : ObserverBase(name) + ApplicationObserverI(const string& name) : ObserverBase(name) { } virtual void applicationInit(int serial, const ApplicationInfoSeq& apps, const Ice::Current&) { - Lock sync(*this); - for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p) - { - if(p->descriptor.name != "Test") // Ignore the test application from application.xml! - { - this->applications.insert(make_pair(p->descriptor.name, *p)); - } - } - updated(updateSerial(serial, "init update")); + Lock sync(*this); + for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p) + { + if(p->descriptor.name != "Test") // Ignore the test application from application.xml! + { + this->applications.insert(make_pair(p->descriptor.name, *p)); + } + } + updated(updateSerial(serial, "init update")); } virtual void applicationAdded(int serial, const ApplicationInfo& app, const Ice::Current&) { - Lock sync(*this); - this->applications.insert(make_pair(app.descriptor.name, app)); - updated(updateSerial(serial, "application added `" + app.descriptor.name + "'")); + Lock sync(*this); + this->applications.insert(make_pair(app.descriptor.name, app)); + updated(updateSerial(serial, "application added `" + app.descriptor.name + "'")); } virtual void applicationRemoved(int serial, const std::string& name, const Ice::Current&) { - Lock sync(*this); - this->applications.erase(name); - updated(updateSerial(serial, "application removed `" + name + "'")); + Lock sync(*this); + this->applications.erase(name); + updated(updateSerial(serial, "application removed `" + name + "'")); } virtual void applicationUpdated(int serial, const ApplicationUpdateInfo& info, const Ice::Current&) { - Lock sync(*this); - const ApplicationUpdateDescriptor& desc = info.descriptor; - for(Ice::StringSeq::const_iterator q = desc.removeVariables.begin(); q != desc.removeVariables.end(); ++q) - { - this->applications[desc.name].descriptor.variables.erase(*q); - } - for(map<string, string>::const_iterator p = desc.variables.begin(); p != desc.variables.end(); ++p) - { - this->applications[desc.name].descriptor.variables[p->first] = p->second; - } - updated(updateSerial(serial, "application updated `" + desc.name + "'")); + Lock sync(*this); + const ApplicationUpdateDescriptor& desc = info.descriptor; + for(Ice::StringSeq::const_iterator q = desc.removeVariables.begin(); q != desc.removeVariables.end(); ++q) + { + this->applications[desc.name].descriptor.variables.erase(*q); + } + for(map<string, string>::const_iterator p = desc.variables.begin(); p != desc.variables.end(); ++p) + { + this->applications[desc.name].descriptor.variables[p->first] = p->second; + } + updated(updateSerial(serial, "application updated `" + desc.name + "'")); } int serial; @@ -230,10 +230,10 @@ private: string updateSerial(int serial, const string& update) { - this->serial = serial; - ostringstream os; - os << update << " (serial = " << serial << ")"; - return os.str(); + this->serial = serial; + ostringstream os; + os << update << " (serial = " << serial << ")"; + return os.str(); } }; typedef IceUtil::Handle<ApplicationObserverI> ApplicationObserverIPtr; @@ -249,36 +249,36 @@ public: virtual void adapterInit(const AdapterInfoSeq& adapters, const Ice::Current&) { - Lock sync(*this); - for(AdapterInfoSeq::const_iterator q = adapters.begin(); q != adapters.end(); ++q) - { - this->adapters.insert(make_pair(q->id, *q)); - } - updated(updateSerial(0, "init update")); + Lock sync(*this); + for(AdapterInfoSeq::const_iterator q = adapters.begin(); q != adapters.end(); ++q) + { + this->adapters.insert(make_pair(q->id, *q)); + } + updated(updateSerial(0, "init update")); } void adapterAdded(const AdapterInfo& info, const Ice::Current&) { - Lock sync(*this); - this->adapters.insert(make_pair(info.id, info)); - updated(updateSerial(0, "adapter added `" + info.id + "'")); + Lock sync(*this); + this->adapters.insert(make_pair(info.id, info)); + updated(updateSerial(0, "adapter added `" + info.id + "'")); } void adapterUpdated(const AdapterInfo& info, const Ice::Current&) { - Lock sync(*this); - this->adapters[info.id] = info; - updated(updateSerial(0, "adapter updated `" + info.id + "'")); + Lock sync(*this); + this->adapters[info.id] = info; + updated(updateSerial(0, "adapter updated `" + info.id + "'")); } void adapterRemoved(const string& id, const Ice::Current&) { - Lock sync(*this); - this->adapters.erase(id); - updated(updateSerial(0, "adapter removed `" + id + "'")); + Lock sync(*this); + this->adapters.erase(id); + updated(updateSerial(0, "adapter removed `" + id + "'")); } int serial; @@ -289,10 +289,10 @@ private: string updateSerial(int serial, const string& update) { - this->serial = serial; - ostringstream os; - os << update << " (serial = " << serial << ")"; - return os.str(); + this->serial = serial; + ostringstream os; + os << update << " (serial = " << serial << ")"; + return os.str(); } }; typedef IceUtil::Handle<AdapterObserverI> AdapterObserverIPtr; @@ -308,37 +308,37 @@ public: virtual void objectInit(const ObjectInfoSeq& objects, const Ice::Current&) { - Lock sync(*this); - for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r) - { - this->objects.insert(make_pair(r->proxy->ice_getIdentity(), *r)); - } - updated(updateSerial(0, "init update")); + Lock sync(*this); + for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r) + { + this->objects.insert(make_pair(r->proxy->ice_getIdentity(), *r)); + } + updated(updateSerial(0, "init update")); } void objectAdded(const ObjectInfo& info, const Ice::Current&) { - Lock sync(*this); - this->objects.insert(make_pair(info.proxy->ice_getIdentity(), info)); - updated(updateSerial(0, "object added `" + info.proxy->ice_toString() + "'")); + Lock sync(*this); + this->objects.insert(make_pair(info.proxy->ice_getIdentity(), info)); + updated(updateSerial(0, "object added `" + info.proxy->ice_toString() + "'")); } void objectUpdated(const ObjectInfo& info, const Ice::Current&) { - Lock sync(*this); - this->objects[info.proxy->ice_getIdentity()] = info; - updated(updateSerial(0, "object updated `" + info.proxy->ice_toString() + "'")); + Lock sync(*this); + this->objects[info.proxy->ice_getIdentity()] = info; + updated(updateSerial(0, "object updated `" + info.proxy->ice_toString() + "'")); } void objectRemoved(const Ice::Identity& id, const Ice::Current& current) { - Lock sync(*this); - this->objects.erase(id); - updated(updateSerial(0, "object removed `" + - current.adapter->getCommunicator()->identityToString(id) + "'")); + Lock sync(*this); + this->objects.erase(id); + updated(updateSerial(0, "object removed `" + + current.adapter->getCommunicator()->identityToString(id) + "'")); } int serial; @@ -349,10 +349,10 @@ private: string updateSerial(int serial, const string& update) { - this->serial = serial; - ostringstream os; - os << update << " (serial = " << serial << ")"; - return os.str(); + this->serial = serial; + ostringstream os; + os << update << " (serial = " << serial << ")"; + return os.str(); } }; typedef IceUtil::Handle<ObjectObserverI> ObjectObserverIPtr; @@ -368,136 +368,136 @@ public: virtual void nodeInit(const NodeDynamicInfoSeq& info, const Ice::Current& current) { - Lock sync(*this); - for(NodeDynamicInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) - { - this->nodes[p->info.name] = filter(*p); - } - updated("init"); + Lock sync(*this); + for(NodeDynamicInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) + { + this->nodes[p->info.name] = filter(*p); + } + updated("init"); } virtual void nodeUp(const NodeDynamicInfo& info, const Ice::Current& current) { - Lock sync(*this); - this->nodes[info.info.name] = filter(info); - updated("node `" + info.info.name + "' up"); + Lock sync(*this); + this->nodes[info.info.name] = filter(info); + updated("node `" + info.info.name + "' up"); } virtual void nodeDown(const string& name, const Ice::Current& current) { - Lock sync(*this); - this->nodes.erase(name); - updated("node `" + name + "' down"); + Lock sync(*this); + this->nodes.erase(name); + updated("node `" + name + "' down"); } virtual void updateServer(const string& node, const ServerDynamicInfo& info, const Ice::Current& current) { - if(info.id == "Glacier2" || info.id == "Glacier2Admin" || info.id == "PermissionsVerifierServer") - { - return; - } - - Lock sync(*this); - //cerr << node << " " << info.id << " " << info.state << " " << info.pid << endl; - ServerDynamicInfoSeq& servers = this->nodes[node].servers; - ServerDynamicInfoSeq::iterator p; - for(p = servers.begin(); p != servers.end(); ++p) - { - if(p->id == info.id) - { - if(info.state == Destroyed) - { - servers.erase(p); - } - else - { - *p = info; - } - break; - } - } - if(info.state != Destroyed && p == servers.end()) - { - servers.push_back(info); - } - - ostringstream os; - os << "server `" << info.id << "' on node `" << node << "' state updated: " << info.state - << " (pid = " << info.pid << ")"; - updated(os.str()); + if(info.id == "Glacier2" || info.id == "Glacier2Admin" || info.id == "PermissionsVerifierServer") + { + return; + } + + Lock sync(*this); + //cerr << node << " " << info.id << " " << info.state << " " << info.pid << endl; + ServerDynamicInfoSeq& servers = this->nodes[node].servers; + ServerDynamicInfoSeq::iterator p; + for(p = servers.begin(); p != servers.end(); ++p) + { + if(p->id == info.id) + { + if(info.state == Destroyed) + { + servers.erase(p); + } + else + { + *p = info; + } + break; + } + } + if(info.state != Destroyed && p == servers.end()) + { + servers.push_back(info); + } + + ostringstream os; + os << "server `" << info.id << "' on node `" << node << "' state updated: " << info.state + << " (pid = " << info.pid << ")"; + updated(os.str()); } virtual void updateAdapter(const string& node, const AdapterDynamicInfo& info, const Ice::Current& current) { - if(info.id == "PermissionsVerifierServer.Server") - { - return; - } - - Lock sync(*this); - //cerr << "update adapter: " << info.id << " " << (info.proxy ? "active" : "inactive") << endl; - AdapterDynamicInfoSeq& adapters = this->nodes[node].adapters; - AdapterDynamicInfoSeq::iterator p; - for(p = adapters.begin(); p != adapters.end(); ++p) - { - if(p->id == info.id) - { - if(info.proxy) - { - *p = info; - } - else - { - adapters.erase(p); - } - break; - } - } - if(info.proxy && p == adapters.end()) - { - adapters.push_back(info); - } - - ostringstream os; - os << "adapter `" << info.id << " on node `" << node << "' state updated: " - << (info.proxy ? "active" : "inactive"); - updated(os.str()); + if(info.id == "PermissionsVerifierServer.Server") + { + return; + } + + Lock sync(*this); + //cerr << "update adapter: " << info.id << " " << (info.proxy ? "active" : "inactive") << endl; + AdapterDynamicInfoSeq& adapters = this->nodes[node].adapters; + AdapterDynamicInfoSeq::iterator p; + for(p = adapters.begin(); p != adapters.end(); ++p) + { + if(p->id == info.id) + { + if(info.proxy) + { + *p = info; + } + else + { + adapters.erase(p); + } + break; + } + } + if(info.proxy && p == adapters.end()) + { + adapters.push_back(info); + } + + ostringstream os; + os << "adapter `" << info.id << " on node `" << node << "' state updated: " + << (info.proxy ? "active" : "inactive"); + updated(os.str()); } NodeDynamicInfo filter(const NodeDynamicInfo& info) { - if(info.info.name != "localnode") - { - return info; - } - - NodeDynamicInfo filtered; - filtered.info = info.info; - - for(ServerDynamicInfoSeq::const_iterator p = info.servers.begin(); p != info.servers.end(); ++p) - { - if(p->id == "Glacier2" || p->id == "Glacier2Admin" || p->id == "PermissionsVerifierServer") - { - continue; - } - filtered.servers.push_back(*p); - } - - for(AdapterDynamicInfoSeq::const_iterator a = info.adapters.begin(); a != info.adapters.end(); ++a) - { - if(a->id == "PermissionsVerifierServer.Server") - { - continue; - } - filtered.adapters.push_back(*a); - } - - return filtered; + if(info.info.name != "localnode") + { + return info; + } + + NodeDynamicInfo filtered; + filtered.info = info.info; + + for(ServerDynamicInfoSeq::const_iterator p = info.servers.begin(); p != info.servers.end(); ++p) + { + if(p->id == "Glacier2" || p->id == "Glacier2Admin" || p->id == "PermissionsVerifierServer") + { + continue; + } + filtered.servers.push_back(*p); + } + + for(AdapterDynamicInfoSeq::const_iterator a = info.adapters.begin(); a != info.adapters.end(); ++a) + { + if(a->id == "PermissionsVerifierServer.Server") + { + continue; + } + filtered.adapters.push_back(*a); + } + + return filtered; } map<string, NodeDynamicInfo> nodes; @@ -515,29 +515,29 @@ public: virtual void registryInit(const RegistryInfoSeq& info, const Ice::Current& current) { - Lock sync(*this); - for(RegistryInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) - { - this->registries[p->name] = *p; - } - updated("init"); + Lock sync(*this); + for(RegistryInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) + { + this->registries[p->name] = *p; + } + updated("init"); } virtual void registryUp(const RegistryInfo& info, const Ice::Current& current) { - Lock sync(*this); - this->registries[info.name] = info; - updated("registry `" + info.name + "' up"); + Lock sync(*this); + this->registries[info.name] = info; + updated("registry `" + info.name + "' up"); } virtual void registryDown(const string& name, const Ice::Current& current) - { - Lock sync(*this); - this->registries.erase(name); - updated("registry `" + name + "' down"); - } + { + Lock sync(*this); + this->registries.erase(name); + updated("registry `" + name + "' down"); + } map<string, RegistryInfo> registries; }; @@ -557,7 +557,7 @@ void allTests(const Ice::CommunicatorPtr& communicator) { SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread( - communicator->getLogger(), IceUtil::Time::seconds(5)); + communicator->getLogger(), IceUtil::Time::seconds(5)); keepAlive->start(); RegistryPrx registry = RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); @@ -572,24 +572,24 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "starting router... " << flush; try { - admin->startServer("Glacier2"); + admin->startServer("Glacier2"); } catch(const ServerStartException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "ok" << endl; cout << "starting admin router... " << flush; try { - admin->startServer("Glacier2Admin"); + admin->startServer("Glacier2Admin"); } catch(const ServerStartException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "ok" << endl; @@ -613,1321 +613,1321 @@ allTests(const Ice::CommunicatorPtr& communicator) // while(true) { - try - { - router1->ice_ping(); - adminRouter1->ice_ping(); - break; - } - catch(const Ice::LocalException&) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); - } + try + { + router1->ice_ping(); + adminRouter1->ice_ping(); + break; + } + catch(const Ice::LocalException&) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + } } { - cout << "testing username/password sessions... " << flush; - - SessionPrx session1, session2; - - session1 = SessionPrx::uncheckedCast(registry1->createSession("client1", "test1")->ice_connectionId("reg1")); - session2 = SessionPrx::uncheckedCast(registry2->createSession("client2", "test2")->ice_connectionId("reg2")); - try - { - registry1->createSession("client3", "test1"); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - session1->ice_connectionId("reg2")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("reg1")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - - session1->destroy(); - session2->destroy(); - - AdminSessionPrx adminSession1, adminSession2; - - adminSession1 = AdminSessionPrx::uncheckedCast( - registry1->createAdminSession("admin1", "test1")->ice_connectionId("reg1")); - adminSession2 = AdminSessionPrx::uncheckedCast( - registry2->createAdminSession("admin2", "test2")->ice_connectionId("reg2")); - try - { - registry1->createAdminSession("admin3", "test1"); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - - adminSession1->ice_ping(); - adminSession2->ice_ping(); - - try - { - adminSession1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - adminSession2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - adminSession1->getAdmin()->ice_connectionId("reg1")->ice_ping(); - adminSession2->getAdmin()->ice_connectionId("reg2")->ice_ping(); - - try - { - adminSession1->getAdmin()->ice_connectionId("reg2")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - adminSession2->getAdmin()->ice_connectionId("reg1")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - adminSession1->destroy(); - adminSession2->destroy(); - - cout << "ok" << endl; + cout << "testing username/password sessions... " << flush; + + SessionPrx session1, session2; + + session1 = SessionPrx::uncheckedCast(registry1->createSession("client1", "test1")->ice_connectionId("reg1")); + session2 = SessionPrx::uncheckedCast(registry2->createSession("client2", "test2")->ice_connectionId("reg2")); + try + { + registry1->createSession("client3", "test1"); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + session1->ice_connectionId("reg2")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("reg1")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + + session1->destroy(); + session2->destroy(); + + AdminSessionPrx adminSession1, adminSession2; + + adminSession1 = AdminSessionPrx::uncheckedCast( + registry1->createAdminSession("admin1", "test1")->ice_connectionId("reg1")); + adminSession2 = AdminSessionPrx::uncheckedCast( + registry2->createAdminSession("admin2", "test2")->ice_connectionId("reg2")); + try + { + registry1->createAdminSession("admin3", "test1"); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + + adminSession1->ice_ping(); + adminSession2->ice_ping(); + + try + { + adminSession1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + adminSession2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + adminSession1->getAdmin()->ice_connectionId("reg1")->ice_ping(); + adminSession2->getAdmin()->ice_connectionId("reg2")->ice_ping(); + + try + { + adminSession1->getAdmin()->ice_connectionId("reg2")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + adminSession2->getAdmin()->ice_connectionId("reg1")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + adminSession1->destroy(); + adminSession2->destroy(); + + cout << "ok" << endl; } if(properties->getProperty("Ice.Default.Protocol") == "ssl") { - cout << "testing sessions from secure connection... " << flush; - - SessionPrx session1, session2; - - session1 = SessionPrx::uncheckedCast(registry1->createSessionFromSecureConnection()->ice_connectionId("reg1")); - session2 = SessionPrx::uncheckedCast(registry2->createSessionFromSecureConnection()->ice_connectionId("reg2")); - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - session1->destroy(); - session2->destroy(); - - AdminSessionPrx adminSession1, adminSession2; - - adminSession1 = AdminSessionPrx::uncheckedCast( - registry1->createAdminSessionFromSecureConnection()->ice_connectionId("reg1")); - adminSession2 = AdminSessionPrx::uncheckedCast( - registry2->createAdminSessionFromSecureConnection()->ice_connectionId("reg2")); - - adminSession1->ice_ping(); - adminSession2->ice_ping(); - - try - { - adminSession1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - adminSession2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - adminSession1->destroy(); - adminSession2->destroy(); - - cout << "ok" << endl; + cout << "testing sessions from secure connection... " << flush; + + SessionPrx session1, session2; + + session1 = SessionPrx::uncheckedCast(registry1->createSessionFromSecureConnection()->ice_connectionId("reg1")); + session2 = SessionPrx::uncheckedCast(registry2->createSessionFromSecureConnection()->ice_connectionId("reg2")); + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + session1->destroy(); + session2->destroy(); + + AdminSessionPrx adminSession1, adminSession2; + + adminSession1 = AdminSessionPrx::uncheckedCast( + registry1->createAdminSessionFromSecureConnection()->ice_connectionId("reg1")); + adminSession2 = AdminSessionPrx::uncheckedCast( + registry2->createAdminSessionFromSecureConnection()->ice_connectionId("reg2")); + + adminSession1->ice_ping(); + adminSession2->ice_ping(); + + try + { + adminSession1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + adminSession2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + adminSession1->destroy(); + adminSession2->destroy(); + + cout << "ok" << endl; } else { - cout << "testing sessions from secure connection... " << flush; - try - { - registry1->createSessionFromSecureConnection(); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - try - { - registry1->createAdminSessionFromSecureConnection(); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - cout << "ok" << endl; + cout << "testing sessions from secure connection... " << flush; + try + { + registry1->createSessionFromSecureConnection(); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + try + { + registry1->createAdminSessionFromSecureConnection(); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + cout << "ok" << endl; } { - cout << "testing Glacier2 username/password sessions... " << flush; - - SessionPrx session1, session2; - - Glacier2::SessionPrx base; - - base = router1->createSession("client1", "test1"); - test(base); - session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router1")->ice_router(router1)); - - base = router2->createSession("client2", "test2"); - test(base); - session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router2")->ice_router(router2)); - - try - { - router1->createSession("client3", "test1"); - test(false); - } - catch(const Glacier2::CannotCreateSessionException&) - { - } - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("router2")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("router1")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); - obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Registry"); - try - { - obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - router1->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - router2->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - - AdminSessionPrx admSession1, admSession2; - - base = adminRouter1->createSession("admin1", "test1"); - admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter1")->ice_router(adminRouter1)); - - base = adminRouter2->createSession("admin2", "test2"); - admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter2")->ice_router(adminRouter2)); - - try - { - adminRouter1->createSession("client3", "test1"); - test(false); - } - catch(const Glacier2::CannotCreateSessionException&) - { - } - - admSession1->ice_ping(); - admSession2->ice_ping(); - - Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter1"); - Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter2"); - - admin1->ice_ping(); - admin2->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); - obj->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); - - try - { - admSession1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admSession2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - admin1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admin2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - adminRouter1->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - adminRouter2->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - - cout << "ok" << endl; + cout << "testing Glacier2 username/password sessions... " << flush; + + SessionPrx session1, session2; + + Glacier2::SessionPrx base; + + base = router1->createSession("client1", "test1"); + test(base); + session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router1")->ice_router(router1)); + + base = router2->createSession("client2", "test2"); + test(base); + session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router2")->ice_router(router2)); + + try + { + router1->createSession("client3", "test1"); + test(false); + } + catch(const Glacier2::CannotCreateSessionException&) + { + } + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("router2")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("router1")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); + obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Registry"); + try + { + obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + router1->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + router2->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + + AdminSessionPrx admSession1, admSession2; + + base = adminRouter1->createSession("admin1", "test1"); + admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter1")->ice_router(adminRouter1)); + + base = adminRouter2->createSession("admin2", "test2"); + admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter2")->ice_router(adminRouter2)); + + try + { + adminRouter1->createSession("client3", "test1"); + test(false); + } + catch(const Glacier2::CannotCreateSessionException&) + { + } + + admSession1->ice_ping(); + admSession2->ice_ping(); + + Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter1"); + Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter2"); + + admin1->ice_ping(); + admin2->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); + obj->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); + + try + { + admSession1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admSession2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + admin1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admin2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + adminRouter1->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + adminRouter2->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + + cout << "ok" << endl; } if(properties->getProperty("Ice.Default.Protocol") == "ssl") { - cout << "testing Glacier2 sessions from secure connection... " << flush; - - SessionPrx session1, session2; - - Glacier2::SessionPrx base; - - // - // BUGFIX: We can't re-use the same router proxies because of bug 1034. - // - router1 = Glacier2::RouterPrx::uncheckedCast(router1->ice_connectionId("router11")); - router2 = Glacier2::RouterPrx::uncheckedCast(router2->ice_connectionId("router21")); - - base = router1->createSessionFromSecureConnection(); - session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router11")->ice_router(router1)); - - base = router2->createSessionFromSecureConnection(); - session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router21")->ice_router(router2)); - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("router21")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("router11")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); - obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Registry"); - try - { - obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - router1->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - router2->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - - AdminSessionPrx admSession1, admSession2; - - // - // BUGFIX: We can't re-use the same router proxies because of bug 1034. - // - adminRouter1 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter11")); - adminRouter2 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter21")); - - base = adminRouter1->createSessionFromSecureConnection(); - admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter11")->ice_router(adminRouter1)); - - base = adminRouter2->createSessionFromSecureConnection(); - admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter21")->ice_router(adminRouter2)); - - admSession1->ice_ping(); - admSession2->ice_ping(); - - Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter11"); - Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter21"); - - admin1->ice_ping(); - admin2->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); - obj->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); - - try - { - admSession1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admSession2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - admin1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admin2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - adminRouter1->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - adminRouter2->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - - cout << "ok" << endl; + cout << "testing Glacier2 sessions from secure connection... " << flush; + + SessionPrx session1, session2; + + Glacier2::SessionPrx base; + + // + // BUGFIX: We can't re-use the same router proxies because of bug 1034. + // + router1 = Glacier2::RouterPrx::uncheckedCast(router1->ice_connectionId("router11")); + router2 = Glacier2::RouterPrx::uncheckedCast(router2->ice_connectionId("router21")); + + base = router1->createSessionFromSecureConnection(); + session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router11")->ice_router(router1)); + + base = router2->createSessionFromSecureConnection(); + session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router21")->ice_router(router2)); + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("router21")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("router11")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); + obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Registry"); + try + { + obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + router1->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + router2->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + + AdminSessionPrx admSession1, admSession2; + + // + // BUGFIX: We can't re-use the same router proxies because of bug 1034. + // + adminRouter1 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter11")); + adminRouter2 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter21")); + + base = adminRouter1->createSessionFromSecureConnection(); + admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter11")->ice_router(adminRouter1)); + + base = adminRouter2->createSessionFromSecureConnection(); + admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter21")->ice_router(adminRouter2)); + + admSession1->ice_ping(); + admSession2->ice_ping(); + + Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter11"); + Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter21"); + + admin1->ice_ping(); + admin2->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); + obj->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); + + try + { + admSession1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admSession2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + admin1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admin2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + adminRouter1->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + adminRouter2->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + + cout << "ok" << endl; } else { - cout << "testing Glacier2 sessions from secure connection... " << flush; - try - { - router1->createSessionFromSecureConnection(); - test(false); - } - catch(const Glacier2::PermissionDeniedException&) - { - } - try - { - adminRouter1->createSessionFromSecureConnection(); - test(false); - } - catch(const Glacier2::PermissionDeniedException&) - { - } - cout << "ok" << endl; + cout << "testing Glacier2 sessions from secure connection... " << flush; + try + { + router1->createSessionFromSecureConnection(); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + } + try + { + adminRouter1->createSessionFromSecureConnection(); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + } + cout << "ok" << endl; } { - cout << "testing updates with admin sessions... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminSessionPrx session2 = registry->createAdminSession("admin2", "test2"); - - keepAlive->add(session1); - keepAlive->add(session2); - - AdminPrx admin1 = session1->getAdmin(); - AdminPrx admin2 = session2->getAdmin(); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.1"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - no1->ice_getIdentity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - Ice::ObjectAdapterPtr adpt2 = communicator->createObjectAdapterWithEndpoints("Observer2", "default"); - ApplicationObserverIPtr appObs2 = new ApplicationObserverI("appObs2"); - Ice::ObjectPrx app2 = adpt2->addWithUUID(appObs2); - NodeObserverIPtr nodeObs2 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no2 = adpt2->addWithUUID(nodeObs2); - adpt2->activate(); - session2->setObservers(0, - NodeObserverPrx::uncheckedCast(no2), - ApplicationObserverPrx::uncheckedCast(app2), - 0, - 0); - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - int serial = appObs1->serial; - test(serial == appObs2->serial); - - try - { - session1->getAdmin()->ice_ping(); - } - catch(const Ice::LocalException&) - { - test(false); - } - - try - { - int s = session1->startUpdate(); - test(s != serial + 1); - } - catch(const AccessDeniedException&) - { - test(false); - } - - try - { - int s = session1->startUpdate(); - test(s == serial); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - session2->startUpdate(); - test(false); - } - catch(const AccessDeniedException& ex) - { - test(ex.lockUserId == "admin1"); - } - - try - { - session1->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - int s = session2->startUpdate(); - test(s == appObs2->serial); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - ApplicationDescriptor app; - app.name = "Application"; - admin2->addApplication(app); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - admin1->addApplication(ApplicationDescriptor()); - test(false); - } - catch(const AccessDeniedException&) - { - } - - try - { - session2->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - test(serial + 1 == appObs1->serial); - test(serial + 1 == appObs2->serial); - ++serial; - - try - { - int s = session1->startUpdate(); - test(s == serial); - ApplicationUpdateDescriptor update; - update.name = "Application"; - update.variables.insert(make_pair(string("test"), string("test"))); - admin1->updateApplication(update); - session1->finishUpdate(); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - test(serial + 1 == appObs1->serial); - test(serial + 1 == appObs2->serial); - ++serial; - - // - // We now allow modifying the database without holding the - // exclusive lock. - // -// try -// { -// ApplicationUpdateDescriptor update; -// update.name = "Application"; -// admin1->updateApplication(update); -// test(false); -// } -// catch(const AccessDeniedException&) -// { -// } - - try - { - int s = session2->startUpdate(); - test(s == serial); - admin2->removeApplication("Application"); - session2->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - test(serial + 1 == appObs1->serial); - test(serial + 1 == appObs2->serial); - ++serial; - - try - { - int s = session1->startUpdate(); - test(s == serial); - } - catch(const Ice::UserException&) - { - test(false); - } - session1->destroy(); - - try - { - int s = session2->startUpdate(); - test(s == serial); - session2->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - session2->destroy(); - - adpt1->destroy(); - adpt2->destroy(); - - // - // TODO: test session reaping? - // - - cout << "ok" << endl; + cout << "testing updates with admin sessions... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + AdminSessionPrx session2 = registry->createAdminSession("admin2", "test2"); + + keepAlive->add(session1); + keepAlive->add(session2); + + AdminPrx admin1 = session1->getAdmin(); + AdminPrx admin2 = session2->getAdmin(); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.1"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); + Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + no1->ice_getIdentity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + Ice::ObjectAdapterPtr adpt2 = communicator->createObjectAdapterWithEndpoints("Observer2", "default"); + ApplicationObserverIPtr appObs2 = new ApplicationObserverI("appObs2"); + Ice::ObjectPrx app2 = adpt2->addWithUUID(appObs2); + NodeObserverIPtr nodeObs2 = new NodeObserverI("nodeObs1"); + Ice::ObjectPrx no2 = adpt2->addWithUUID(nodeObs2); + adpt2->activate(); + session2->setObservers(0, + NodeObserverPrx::uncheckedCast(no2), + ApplicationObserverPrx::uncheckedCast(app2), + 0, + 0); + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + int serial = appObs1->serial; + test(serial == appObs2->serial); + + try + { + session1->getAdmin()->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + int s = session1->startUpdate(); + test(s != serial + 1); + } + catch(const AccessDeniedException&) + { + test(false); + } + + try + { + int s = session1->startUpdate(); + test(s == serial); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + session2->startUpdate(); + test(false); + } + catch(const AccessDeniedException& ex) + { + test(ex.lockUserId == "admin1"); + } + + try + { + session1->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + int s = session2->startUpdate(); + test(s == appObs2->serial); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + ApplicationDescriptor app; + app.name = "Application"; + admin2->addApplication(app); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + admin1->addApplication(ApplicationDescriptor()); + test(false); + } + catch(const AccessDeniedException&) + { + } + + try + { + session2->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + test(serial + 1 == appObs1->serial); + test(serial + 1 == appObs2->serial); + ++serial; + + try + { + int s = session1->startUpdate(); + test(s == serial); + ApplicationUpdateDescriptor update; + update.name = "Application"; + update.variables.insert(make_pair(string("test"), string("test"))); + admin1->updateApplication(update); + session1->finishUpdate(); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + test(serial + 1 == appObs1->serial); + test(serial + 1 == appObs2->serial); + ++serial; + + // + // We now allow modifying the database without holding the + // exclusive lock. + // +// try +// { +// ApplicationUpdateDescriptor update; +// update.name = "Application"; +// admin1->updateApplication(update); +// test(false); +// } +// catch(const AccessDeniedException&) +// { +// } + + try + { + int s = session2->startUpdate(); + test(s == serial); + admin2->removeApplication("Application"); + session2->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + test(serial + 1 == appObs1->serial); + test(serial + 1 == appObs2->serial); + ++serial; + + try + { + int s = session1->startUpdate(); + test(s == serial); + } + catch(const Ice::UserException&) + { + test(false); + } + session1->destroy(); + + try + { + int s = session2->startUpdate(); + test(s == serial); + session2->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + session2->destroy(); + + adpt1->destroy(); + adpt2->destroy(); + + // + // TODO: test session reaping? + // + + cout << "ok" << endl; } { - cout << "testing application observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminPrx admin1 = session1->getAdmin(); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.2"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - Ice::Identity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - - int serial = appObs1->serial; - test(appObs1->applications.empty()); - - try - { - ApplicationDescriptor app; - app.name = "Application"; - int s = session1->startUpdate(); - test(s == serial); - admin1->addApplication(app); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.find("Application") != appObs1->applications.end()); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - ApplicationUpdateDescriptor update; - update.name = "Application"; - update.variables.insert(make_pair(string("test"), string("test"))); - admin1->updateApplication(update); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.find("Application") != appObs1->applications.end()); - test(appObs1->applications["Application"].descriptor.variables["test"] == "test"); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - ApplicationDescriptor app; - app = appObs1->applications["Application"].descriptor; - app.variables.clear(); - app.variables["test1"] = "test"; - admin1->syncApplication(app); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.find("Application") != appObs1->applications.end()); - test(appObs1->applications["Application"].descriptor.variables.size() == 1); - test(appObs1->applications["Application"].descriptor.variables["test1"] == "test"); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - admin1->removeApplication("Application"); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.empty()); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - session1->destroy(); - adpt1->destroy(); - - cout << "ok" << endl; + cout << "testing application observer... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + AdminPrx admin1 = session1->getAdmin(); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.2"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + Ice::Identity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + + int serial = appObs1->serial; + test(appObs1->applications.empty()); + + try + { + ApplicationDescriptor app; + app.name = "Application"; + int s = session1->startUpdate(); + test(s == serial); + admin1->addApplication(app); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.find("Application") != appObs1->applications.end()); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + ApplicationUpdateDescriptor update; + update.name = "Application"; + update.variables.insert(make_pair(string("test"), string("test"))); + admin1->updateApplication(update); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.find("Application") != appObs1->applications.end()); + test(appObs1->applications["Application"].descriptor.variables["test"] == "test"); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + ApplicationDescriptor app; + app = appObs1->applications["Application"].descriptor; + app.variables.clear(); + app.variables["test1"] = "test"; + admin1->syncApplication(app); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.find("Application") != appObs1->applications.end()); + test(appObs1->applications["Application"].descriptor.variables.size() == 1); + test(appObs1->applications["Application"].descriptor.variables["test1"] == "test"); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + admin1->removeApplication("Application"); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.empty()); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + session1->destroy(); + adpt1->destroy(); + + cout << "ok" << endl; } { - cout << "testing adapter observer... " << flush; - - AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); - AdminPrx admin1 = session1->getAdmin(); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - AdapterObserverIPtr adptObs1 = new AdapterObserverI("adptObs1"); - Ice::ObjectPrx adapter1 = adpt1->addWithUUID(adptObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - Ice::Identity(), - Ice::Identity(), - adapter1->ice_getIdentity(), - Ice::Identity()); - - adptObs1->waitForUpdate(__FILE__, __LINE__); // init - - try - { - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); - - Ice::LocatorRegistryPrx locatorRegistry = communicator->getDefaultLocator()->getRegistry(); - locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); - test(adptObs1->adapters["DummyAdapter"].replicaGroupId == "DummyReplicaGroup"); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter1", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter1") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter1"].proxy == obj); - test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == "DummyReplicaGroup"); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter2", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter2") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter2"].proxy == obj); - test(adptObs1->adapters["DummyAdapter2"].replicaGroupId == "DummyReplicaGroup"); - - admin->removeAdapter("DummyAdapter2"); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter2") == adptObs1->adapters.end()); - - admin->removeAdapter("DummyReplicaGroup"); - adptObs1->waitForUpdate(__FILE__, __LINE__); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters["DummyAdapter"].replicaGroupId == ""); - test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == ""); - - locatorRegistry->setAdapterDirectProxy("DummyAdapter", 0); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") == adptObs1->adapters.end()); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - session1->destroy(); - adpt1->destroy(); - - cout << "ok" << endl; + cout << "testing adapter observer... " << flush; + + AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); + AdminPrx admin1 = session1->getAdmin(); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + AdapterObserverIPtr adptObs1 = new AdapterObserverI("adptObs1"); + Ice::ObjectPrx adapter1 = adpt1->addWithUUID(adptObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + Ice::Identity(), + Ice::Identity(), + adapter1->ice_getIdentity(), + Ice::Identity()); + + adptObs1->waitForUpdate(__FILE__, __LINE__); // init + + try + { + Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + + Ice::LocatorRegistryPrx locatorRegistry = communicator->getDefaultLocator()->getRegistry(); + locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter"].proxy == obj); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter"].proxy == obj); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter", "DummyReplicaGroup", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter"].proxy == obj); + test(adptObs1->adapters["DummyAdapter"].replicaGroupId == "DummyReplicaGroup"); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter1", "DummyReplicaGroup", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter1") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter1"].proxy == obj); + test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == "DummyReplicaGroup"); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter2", "DummyReplicaGroup", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter2") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter2"].proxy == obj); + test(adptObs1->adapters["DummyAdapter2"].replicaGroupId == "DummyReplicaGroup"); + + admin->removeAdapter("DummyAdapter2"); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter2") == adptObs1->adapters.end()); + + admin->removeAdapter("DummyReplicaGroup"); + adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters["DummyAdapter"].replicaGroupId == ""); + test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == ""); + + locatorRegistry->setAdapterDirectProxy("DummyAdapter", 0); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") == adptObs1->adapters.end()); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + session1->destroy(); + adpt1->destroy(); + + cout << "ok" << endl; } { - cout << "testing object observer... " << flush; - - AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); - AdminPrx admin1 = session1->getAdmin(); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ObjectObserverIPtr objectObs1 = new ObjectObserverI("objectObs1"); - Ice::ObjectPrx object1 = adpt1->addWithUUID(objectObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - Ice::Identity(), - Ice::Identity(), - Ice::Identity(), - object1->ice_getIdentity()); - - objectObs1->waitForUpdate(__FILE__, __LINE__); // init - - try - { - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); - - admin->addObjectWithType(obj, "::Dummy"); - objectObs1->waitForUpdate(__FILE__, __LINE__); - test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - admin->updateObject(obj); - objectObs1->waitForUpdate(__FILE__, __LINE__); - test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); - - admin->removeObject(obj->ice_getIdentity()); - objectObs1->waitForUpdate(__FILE__, __LINE__); - test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) == objectObs1->objects.end()); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - session1->destroy(); - adpt1->destroy(); - - cout << "ok" << endl; + cout << "testing object observer... " << flush; + + AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); + AdminPrx admin1 = session1->getAdmin(); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ObjectObserverIPtr objectObs1 = new ObjectObserverI("objectObs1"); + Ice::ObjectPrx object1 = adpt1->addWithUUID(objectObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + Ice::Identity(), + Ice::Identity(), + Ice::Identity(), + object1->ice_getIdentity()); + + objectObs1->waitForUpdate(__FILE__, __LINE__); // init + + try + { + Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + + admin->addObjectWithType(obj, "::Dummy"); + objectObs1->waitForUpdate(__FILE__, __LINE__); + test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + admin->updateObject(obj); + objectObs1->waitForUpdate(__FILE__, __LINE__); + test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); + + admin->removeObject(obj->ice_getIdentity()); + objectObs1->waitForUpdate(__FILE__, __LINE__); + test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) == objectObs1->objects.end()); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + session1->destroy(); + adpt1->destroy(); + + cout << "ok" << endl; } { -// cout << "???" << endl; - -// // -// // Setup a descriptor to deploy a node on the node. -// // -// ApplicationDescriptor nodeApp; -// nodeApp.name = "NodeApp"; -// ServerDescriptorPtr server = new ServerDescriptor(); -// server->id = "node-1"; -// server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; -// server->options.push_back("--nowarn"); -// server->pwd = "."; -// AdapterDescriptor adapter; -// adapter.name = "IceGrid.Node"; -// adapter.id = "IceGrid.Node.node-1"; -// adapter.registerProcess = true; -// adapter.waitForActivation = false; -// server->adapters.push_back(adapter); -// addProperty(server, "IceGrid.Node.Name", "node-1"); -// addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); -// addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); -// NodeDescriptor node; -// node.servers.push_back(server); -// nodeApp.nodes["localnode"] = node; - -// try -// { -// int s = session1->startUpdate(); -// test(s == serial); -// admin1->addApplication(nodeApp); -// appObs1->waitForUpdate(__FILE__, __LINE__); // application added -// test(appObs1->applications.find("NodeApp") != appObs1->applications.end()); -// test(++serial == appObs1->serial); -// } -// catch(const DeploymentException& ex) -// { -// cerr << ex.reason << endl; -// test(false); -// } -// catch(const Ice::UserException& ex) -// { -// cerr << ex << endl; -// test(false); -// } - -// try -// { -// admin->startServer("node-1"); -// } -// catch(const NodeUnreachableException& ex) -// { -// cerr << ex << ":\n"; -// cerr << "node = " << ex.name << endl; -// cerr << "reason = " << ex.reason << endl; -// } -// appObs1->waitForUpdate(__FILE__, __LINE__); // object added (for node well-known proxy) -// test(++serial == appObs1->serial); - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// do -// { -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp -// } -// while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - -// try -// { -// admin->stopServer("node-1"); -// } -// catch(const NodeUnreachableException& ex) -// { -// cerr << ex << ":\n"; -// cerr << "node = " << ex.name << endl; -// cerr << "reason = " << ex.reason << endl; -// } -// appObs1->waitForUpdate(__FILE__, __LINE__); // object removed (for node well-known proxy) -// test(++serial == appObs1->serial); - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown -// test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - -// try -// { -// admin1->removeApplication("NodeApp"); -// appObs1->waitForUpdate(__FILE__, __LINE__); // application removed -// test(appObs1->applications.empty()); -// test(++serial == appObs1->serial); -// } -// catch(const DeploymentException& ex) -// { -// cerr << ex.reason << endl; -// test(false); -// } -// catch(const Ice::UserException& ex) -// { -// cerr << ex << endl; -// test(false); -// } - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - -// session1->destroy(); -// adpt1->destroy(); - -// cout << "ok" << endl; +// cout << "???" << endl; + +// // +// // Setup a descriptor to deploy a node on the node. +// // +// ApplicationDescriptor nodeApp; +// nodeApp.name = "NodeApp"; +// ServerDescriptorPtr server = new ServerDescriptor(); +// server->id = "node-1"; +// server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; +// server->options.push_back("--nowarn"); +// server->pwd = "."; +// AdapterDescriptor adapter; +// adapter.name = "IceGrid.Node"; +// adapter.id = "IceGrid.Node.node-1"; +// adapter.registerProcess = true; +// adapter.waitForActivation = false; +// server->adapters.push_back(adapter); +// addProperty(server, "IceGrid.Node.Name", "node-1"); +// addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); +// addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); +// NodeDescriptor node; +// node.servers.push_back(server); +// nodeApp.nodes["localnode"] = node; + +// try +// { +// int s = session1->startUpdate(); +// test(s == serial); +// admin1->addApplication(nodeApp); +// appObs1->waitForUpdate(__FILE__, __LINE__); // application added +// test(appObs1->applications.find("NodeApp") != appObs1->applications.end()); +// test(++serial == appObs1->serial); +// } +// catch(const DeploymentException& ex) +// { +// cerr << ex.reason << endl; +// test(false); +// } +// catch(const Ice::UserException& ex) +// { +// cerr << ex << endl; +// test(false); +// } + +// try +// { +// admin->startServer("node-1"); +// } +// catch(const NodeUnreachableException& ex) +// { +// cerr << ex << ":\n"; +// cerr << "node = " << ex.name << endl; +// cerr << "reason = " << ex.reason << endl; +// } +// appObs1->waitForUpdate(__FILE__, __LINE__); // object added (for node well-known proxy) +// test(++serial == appObs1->serial); + +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// do +// { +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp +// } +// while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + +// try +// { +// admin->stopServer("node-1"); +// } +// catch(const NodeUnreachableException& ex) +// { +// cerr << ex << ":\n"; +// cerr << "node = " << ex.name << endl; +// cerr << "reason = " << ex.reason << endl; +// } +// appObs1->waitForUpdate(__FILE__, __LINE__); // object removed (for node well-known proxy) +// test(++serial == appObs1->serial); + +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown +// test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + +// try +// { +// admin1->removeApplication("NodeApp"); +// appObs1->waitForUpdate(__FILE__, __LINE__); // application removed +// test(appObs1->applications.empty()); +// test(++serial == appObs1->serial); +// } +// catch(const DeploymentException& ex) +// { +// cerr << ex.reason << endl; +// test(false); +// } +// catch(const Ice::UserException& ex) +// { +// cerr << ex << endl; +// test(false); +// } + +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + +// session1->destroy(); +// adpt1->destroy(); + +// cout << "ok" << endl; } { - cout << "testing node observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.3"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - no1->ice_getIdentity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // init - - test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); - test(appObs1->applications.empty()); - - ApplicationDescriptor nodeApp; - nodeApp.name = "NodeApp"; - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "node-1"; - server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; - server->options.push_back("--nowarn"); - server->pwd = "."; - AdapterDescriptor adapter; - adapter.name = "IceGrid.Node"; - adapter.id = "IceGrid.Node.node-1"; - adapter.registerProcess = true; - adapter.serverLifetime = false; - server->adapters.push_back(adapter); - addProperty(server, "IceGrid.Node.Name", "node-1"); - addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); - addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); - NodeDescriptor node; - node.servers.push_back(server); - nodeApp.nodes["localnode"] = node; - - session->startUpdate(); - admin->addApplication(nodeApp); - session->finishUpdate(); - appObs1->waitForUpdate(__FILE__, __LINE__); - - admin->startServer("node-1"); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - do - { - nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp - } - while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - - test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Active); - admin->stopServer("node-1"); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Deactivating) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Inactive) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown - test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); - - session->startUpdate(); - admin->removeApplication("NodeApp"); - session->finishUpdate(); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - - appObs1->waitForUpdate(__FILE__, __LINE__); - test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - - server = new ServerDescriptor(); - server->id = "Server"; - server->exe = properties->getProperty("TestDir") + "/server"; - server->pwd = "."; - adapter.name = "Server"; - adapter.id = "ServerAdapter"; - adapter.registerProcess = true; - adapter.serverLifetime = true; - server->adapters.push_back(adapter); - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - node = NodeDescriptor(); - node.servers.push_back(server); - testApp.nodes["localnode"] = node; - - session->startUpdate(); - admin->addApplication(testApp); - session->finishUpdate(); - appObs1->waitForUpdate(__FILE__, __LINE__); - - - session->startUpdate(); - admin->startServer("Server"); - session->finishUpdate(); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate - - test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); - test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Active); - test(nodeObs1->nodes["localnode"].adapters.size() == 1); - test(nodeObs1->nodes["localnode"].adapters[0].proxy); - - test(nodeObs1->nodes["localnode"].servers[0].enabled); - admin->enableServer("Server", false); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - test(!nodeObs1->nodes["localnode"].servers[0].enabled); - admin->enableServer("Server", true); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - test(nodeObs1->nodes["localnode"].servers[0].enabled); - - admin->stopServer("Server"); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate - - test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); - test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); - test(nodeObs1->nodes["localnode"].adapters.empty()); - - session->startUpdate(); - admin->removeApplication("TestApp"); - session->finishUpdate(); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - test(nodeObs1->nodes["localnode"].servers.empty()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - - cout << "ok" << endl; + cout << "testing node observer... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.3"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); + Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + no1->ice_getIdentity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // init + + test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); + test(appObs1->applications.empty()); + + ApplicationDescriptor nodeApp; + nodeApp.name = "NodeApp"; + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "node-1"; + server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; + server->options.push_back("--nowarn"); + server->pwd = "."; + AdapterDescriptor adapter; + adapter.name = "IceGrid.Node"; + adapter.id = "IceGrid.Node.node-1"; + adapter.registerProcess = true; + adapter.serverLifetime = false; + server->adapters.push_back(adapter); + addProperty(server, "IceGrid.Node.Name", "node-1"); + addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); + addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); + NodeDescriptor node; + node.servers.push_back(server); + nodeApp.nodes["localnode"] = node; + + session->startUpdate(); + admin->addApplication(nodeApp); + session->finishUpdate(); + appObs1->waitForUpdate(__FILE__, __LINE__); + + admin->startServer("node-1"); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + do + { + nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp + } + while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + + test(nodeObs1->nodes["localnode"].servers.size() == 1); + test(nodeObs1->nodes["localnode"].servers[0].state == Active); + admin->stopServer("node-1"); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Deactivating) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Inactive) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown + test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); + + session->startUpdate(); + admin->removeApplication("NodeApp"); + session->finishUpdate(); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + + appObs1->waitForUpdate(__FILE__, __LINE__); + test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + + server = new ServerDescriptor(); + server->id = "Server"; + server->exe = properties->getProperty("TestDir") + "/server"; + server->pwd = "."; + adapter.name = "Server"; + adapter.id = "ServerAdapter"; + adapter.registerProcess = true; + adapter.serverLifetime = true; + server->adapters.push_back(adapter); + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + node = NodeDescriptor(); + node.servers.push_back(server); + testApp.nodes["localnode"] = node; + + session->startUpdate(); + admin->addApplication(testApp); + session->finishUpdate(); + appObs1->waitForUpdate(__FILE__, __LINE__); + + + session->startUpdate(); + admin->startServer("Server"); + session->finishUpdate(); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate + + test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); + test(nodeObs1->nodes["localnode"].servers.size() == 1); + test(nodeObs1->nodes["localnode"].servers[0].state == Active); + test(nodeObs1->nodes["localnode"].adapters.size() == 1); + test(nodeObs1->nodes["localnode"].adapters[0].proxy); + + test(nodeObs1->nodes["localnode"].servers[0].enabled); + admin->enableServer("Server", false); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + test(!nodeObs1->nodes["localnode"].servers[0].enabled); + admin->enableServer("Server", true); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + test(nodeObs1->nodes["localnode"].servers[0].enabled); + + admin->stopServer("Server"); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate + + test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); + test(nodeObs1->nodes["localnode"].servers.size() == 1); + test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); + test(nodeObs1->nodes["localnode"].adapters.empty()); + + session->startUpdate(); + admin->removeApplication("TestApp"); + session->finishUpdate(); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + test(nodeObs1->nodes["localnode"].servers.empty()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + + cout << "ok" << endl; } { - cout << "testing registry observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.4"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - RegistryObserverIPtr registryObs1 = new RegistryObserverI("registryObs1"); - Ice::ObjectPrx ro1 = adpt1->addWithUUID(registryObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(ro1->ice_getIdentity(), - Ice::Identity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - registryObs1->waitForUpdate(__FILE__, __LINE__); // init - - test(registryObs1->registries.find("Master") != registryObs1->registries.end()); - test(appObs1->applications.empty()); - - QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy("IceGrid/Query")); - Ice::ObjectProxySeq registries = query->findAllObjectsByType("::IceGrid::Registry"); - const string prefix("Registry-"); - for(Ice::ObjectProxySeq::const_iterator p = registries.begin(); p != registries.end(); ++p) - { - string name = (*p)->ice_getIdentity().name; - string::size_type pos = name.find(prefix); - if(pos != string::npos) - { - name = name.substr(prefix.size()); - test(registryObs1->registries.find(name) != registryObs1->registries.end()); - } - } - cout << "ok" << endl; + cout << "testing registry observer... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.4"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + RegistryObserverIPtr registryObs1 = new RegistryObserverI("registryObs1"); + Ice::ObjectPrx ro1 = adpt1->addWithUUID(registryObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(ro1->ice_getIdentity(), + Ice::Identity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + registryObs1->waitForUpdate(__FILE__, __LINE__); // init + + test(registryObs1->registries.find("Master") != registryObs1->registries.end()); + test(appObs1->applications.empty()); + + QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy("IceGrid/Query")); + Ice::ObjectProxySeq registries = query->findAllObjectsByType("::IceGrid::Registry"); + const string prefix("Registry-"); + for(Ice::ObjectProxySeq::const_iterator p = registries.begin(); p != registries.end(); ++p) + { + string name = (*p)->ice_getIdentity().name; + string::size_type pos = name.find(prefix); + if(pos != string::npos) + { + name = name.substr(prefix.size()); + test(registryObs1->registries.find(name) != registryObs1->registries.end()); + } + } + cout << "ok" << endl; } diff --git a/cpp/test/IceGrid/session/Client.cpp b/cpp/test/IceGrid/session/Client.cpp index 3074006cc71..a2b38017c27 100644 --- a/cpp/test/IceGrid/session/Client.cpp +++ b/cpp/test/IceGrid/session/Client.cpp @@ -27,30 +27,30 @@ main(int argc, char* argv[]) Ice::CommunicatorPtr communicator; try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); + communicator = Ice::initialize(argc, argv, initData); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/session/PermissionsVerifier.cpp b/cpp/test/IceGrid/session/PermissionsVerifier.cpp index 11ce11e3e98..726464c29d4 100644 --- a/cpp/test/IceGrid/session/PermissionsVerifier.cpp +++ b/cpp/test/IceGrid/session/PermissionsVerifier.cpp @@ -20,13 +20,13 @@ public: virtual bool checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current& c) const { - if(userId == "shutdown") - { - c.adapter->getCommunicator()->shutdown(); - return true; - } - return userId == "admin1" && passwd == "test1" || userId == "admin2" && passwd == "test2" || - userId == "admin3" && passwd == "test3"; + if(userId == "shutdown") + { + c.adapter->getCommunicator()->shutdown(); + return true; + } + return userId == "admin1" && passwd == "test1" || userId == "admin2" && passwd == "test2" || + userId == "admin3" && passwd == "test3"; } }; @@ -36,12 +36,12 @@ public: virtual int run(int, char*[]) { - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints( - "PermissionsVerifier", "tcp -p 12002"); - adapter->add(new AdminPermissionsVerifierI, communicator()->stringToIdentity("AdminPermissionsVerifier")); - adapter->activate(); - communicator()->waitForShutdown(); - return EXIT_SUCCESS; + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints( + "PermissionsVerifier", "tcp -p 12002"); + adapter->add(new AdminPermissionsVerifierI, communicator()->stringToIdentity("AdminPermissionsVerifier")); + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; } }; diff --git a/cpp/test/IceGrid/session/Server.cpp b/cpp/test/IceGrid/session/Server.cpp index a52ac4fa42e..c22cebc53ec 100644 --- a/cpp/test/IceGrid/session/Server.cpp +++ b/cpp/test/IceGrid/session/Server.cpp @@ -21,7 +21,7 @@ public: virtual bool checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current&) const { - return userId == "client1" && passwd == "test1" || userId == "client2" && passwd == "test2"; + return userId == "client1" && passwd == "test1" || userId == "client2" && passwd == "test2"; } }; @@ -32,15 +32,15 @@ public: virtual bool authorize(const Glacier2::SSLInfo& info, string&, const Ice::Current& current) const { - IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); - test(cert->getIssuerDN() == IceSSL::DistinguishedName( - "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.,L=Palm Beach Gardens," - "ST=Florida,C=US")); - test(cert->getSubjectDN() == IceSSL::DistinguishedName( - "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); - test(cert->checkValidity()); + IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); + test(cert->getIssuerDN() == IceSSL::DistinguishedName( + "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.,L=Palm Beach Gardens," + "ST=Florida,C=US")); + test(cert->getSubjectDN() == IceSSL::DistinguishedName( + "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); + test(cert->checkValidity()); - return true; + return true; } }; @@ -57,8 +57,8 @@ Server::run(int argc, char* argv[]) Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Server"); if(communicator()->getProperties()->getPropertyAsInt("AddPermissionsVerifiers") > 0) { - adapter->add(new ClientPermissionsVerifierI(), communicator()->stringToIdentity("ClientPermissionsVerifier")); - adapter->add(new SSLPermissionsVerifierI(), communicator()->stringToIdentity("SSLPermissionsVerifier")); + adapter->add(new ClientPermissionsVerifierI(), communicator()->stringToIdentity("ClientPermissionsVerifier")); + adapter->add(new SSLPermissionsVerifierI(), communicator()->stringToIdentity("SSLPermissionsVerifier")); } adapter->activate(); diff --git a/cpp/test/IceGrid/simple/AllTests.cpp b/cpp/test/IceGrid/simple/AllTests.cpp index cf759e6d78f..a2e502ae1fc 100644 --- a/cpp/test/IceGrid/simple/AllTests.cpp +++ b/cpp/test/IceGrid/simple/AllTests.cpp @@ -22,7 +22,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -37,15 +37,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -116,31 +116,31 @@ allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) cout << "testing reference with unknown identity... " << flush; try { - communicator->stringToProxy("unknown/unknown")->ice_ping(); - test(false); + communicator->stringToProxy("unknown/unknown")->ice_ping(); + test(false); } catch (const Ice::NotRegisteredException& ex) { - test(ex.kindOfObject == "object"); - test(ex.id == "unknown/unknown"); + test(ex.kindOfObject == "object"); + test(ex.id == "unknown/unknown"); } cout << "ok" << endl; cout << "testing reference with unknown adapter... " << flush; try { - communicator->stringToProxy("test @ TestAdapterUnknown")->ice_ping(); - test(false); + communicator->stringToProxy("test @ TestAdapterUnknown")->ice_ping(); + test(false); } catch (const Ice::NotRegisteredException& ex) { - test(ex.kindOfObject == "object adapter"); - test(ex.id == "TestAdapterUnknown"); + test(ex.kindOfObject == "object adapter"); + test(ex.id == "TestAdapterUnknown"); } cout << "ok" << endl; IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy("IceGrid/Registry")); + communicator->stringToProxy("IceGrid/Registry")); test(registry); IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar"); @@ -156,16 +156,16 @@ allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) cout << "testing whether server is still reachable... " << flush; try { - obj = TestIntfPrx::checkedCast(base); - test(false); + obj = TestIntfPrx::checkedCast(base); + test(false); } catch(const Ice::NoEndpointException&) { } try { - obj2 = TestIntfPrx::checkedCast(base2); - test(false); + obj2 = TestIntfPrx::checkedCast(base2); + test(false); } catch(const Ice::NoEndpointException&) { @@ -175,19 +175,19 @@ allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) try { - obj = TestIntfPrx::checkedCast(base); + obj = TestIntfPrx::checkedCast(base); } catch(const Ice::NoEndpointException&) { - test(false); + test(false); } try { - obj2 = TestIntfPrx::checkedCast(base2); + obj2 = TestIntfPrx::checkedCast(base2); } catch(const Ice::NoEndpointException&) { - test(false); + test(false); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/simple/Client.cpp b/cpp/test/IceGrid/simple/Client.cpp index 57499a1d856..57c7ae95e38 100644 --- a/cpp/test/IceGrid/simple/Client.cpp +++ b/cpp/test/IceGrid/simple/Client.cpp @@ -22,22 +22,22 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(int i = 1; i < argc; ++i) { - if(strcmp(argv[i], "--with-deploy") == 0) - { - withDeploy = true; - break; - } + if(strcmp(argv[i], "--with-deploy") == 0) + { + withDeploy = true; + break; + } } if(!withDeploy) { - void allTests(const Ice::CommunicatorPtr&); - allTests(communicator); + void allTests(const Ice::CommunicatorPtr&); + allTests(communicator); } else { - void allTestsWithDeploy(const Ice::CommunicatorPtr&); - allTestsWithDeploy(communicator); + void allTestsWithDeploy(const Ice::CommunicatorPtr&); + allTestsWithDeploy(communicator); } return EXIT_SUCCESS; @@ -52,26 +52,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/simple/Server.cpp b/cpp/test/IceGrid/simple/Server.cpp index 17146db154f..0a54b1a3a77 100644 --- a/cpp/test/IceGrid/simple/Server.cpp +++ b/cpp/test/IceGrid/simple/Server.cpp @@ -34,7 +34,7 @@ Server::run(int argc, char* argv[]) shutdownOnInterrupt(); try { - adapter->activate(); + adapter->activate(); } catch(const Ice::ObjectAdapterDeactivatedException&) { diff --git a/cpp/test/IceGrid/simple/run.py b/cpp/test/IceGrid/simple/run.py index e6a9b24de2d..adda46062b3 100755 --- a/cpp/test/IceGrid/simple/run.py +++ b/cpp/test/IceGrid/simple/run.py @@ -27,7 +27,7 @@ name = os.path.join("IceGrid", "simple") # Test client/server without on demand activation. # IceGridAdmin.iceGridClientServerTest(name, "", "--Ice.OA.TestAdapter.Endpoints=default" + \ - " --Ice.OA.TestAdapter.AdapterId=TestAdapter") + " --Ice.OA.TestAdapter.AdapterId=TestAdapter") # # Test client/server with on demand activation. diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp index 4ab8362766c..37ceba2b818 100644 --- a/cpp/test/IceGrid/update/AllTests.cpp +++ b/cpp/test/IceGrid/update/AllTests.cpp @@ -24,7 +24,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -39,15 +39,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -82,10 +82,10 @@ getProperty(const PropertyDescriptorSeq& properties, const string& name) { for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) { - if(q->name == name) - { - return q->value; - } + if(q->name == name) + { + return q->value; + } } return ""; } @@ -103,12 +103,12 @@ bool hasProperty(const CommunicatorDescriptorPtr& desc, const string& name, const string& value) { for(PropertyDescriptorSeq::const_iterator p = desc->propertySet.properties.begin(); - p != desc->propertySet.properties.end(); ++p) + p != desc->propertySet.properties.end(); ++p) { - if(p->name == name) - { - return p->value == value; - } + if(p->name == name) + { + return p->value == value; + } } return false; } @@ -117,7 +117,7 @@ void allTests(const Ice::CommunicatorPtr& communicator) { RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy("IceGrid/Registry")); + communicator->stringToProxy("IceGrid/Registry")); test(registry); AdminSessionPrx session = registry->createAdminSession("foo", "bar"); @@ -130,1085 +130,1085 @@ allTests(const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); { - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - admin->addApplication(testApp); - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "localnode"; - empty.nodes.push_back(node); - - ApplicationUpdateDescriptor update = empty; - - cout << "testing server add... " << flush; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "Server"; - server->exe = properties->getProperty("TestDir") + "/server"; - server->pwd = "."; - AdapterDescriptor adapter; - adapter.name = "Server"; - adapter.id = "ServerAdapter"; - adapter.registerProcess = true; - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - ObjectDescriptor object; - object.id = communicator->stringToIdentity("test"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - update.nodes[0].servers.push_back(server); - admin->updateApplication(update); - - update.nodes[0].servers[0]->id = "Server2"; - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Adapter already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update.nodes[0].servers[0]->adapters[0].id = "ServerAdapter2"; - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Object already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update.nodes[0].servers[0]->adapters[0].objects[0].id = communicator->stringToIdentity("test2"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - TemplateDescriptor templ; - templ.parameters.push_back("name"); - templ.descriptor = new ServerDescriptor(); - server = ServerDescriptorPtr::dynamicCast(templ.descriptor); - server->id = "${name}"; - server->exe = "${test.dir}/server"; - server->pwd = "."; - adapter = AdapterDescriptor(); - adapter.name = "Server"; - adapter.id = "${server}"; - adapter.registerProcess = true; - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - object = ObjectDescriptor(); - object.id = communicator->stringToIdentity("${server}"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - update = empty; - update.serverTemplates["ServerTemplate"] = templ; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - ServerInstanceDescriptor instance; - instance._cpp_template = "ServerTemplate"; - update.nodes[0].serverInstances.push_back(instance); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing parameter - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - update.variables["test.dir"] = properties->getProperty("TestDir"); - update.variables["variable"] = ""; - instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; - instance.parameterValues["name"] = "Server1"; - update.nodes[0].serverInstances.push_back(instance); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - cout << "ok" << endl; - - cout << "testing server remove... " << flush; - update = empty; - update.nodes[0].removeServers.push_back("Server2"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - admin->getServerInfo("Server2"); - test(false); - } - catch(const ServerNotExistException&) - { - } - - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - update.removeServerTemplates.push_back("ServerTemplate"); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Server without template! - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - update.nodes[0].removeServers.push_back("Server1"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - admin->getServerInfo("Server1"); - test(false); - } - catch(const ServerNotExistException&) - { - } - - update = empty; - update.removeServerTemplates.push_back("ServerTemplate"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "testing server update... " << flush; - - ServerInfo info = admin->getServerInfo("Server"); - test(info.descriptor); - addProperty(info.descriptor, "test", "test"); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - info = admin->getServerInfo("Server"); - test(info.descriptor); - test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); - - update = empty; - update.serverTemplates["ServerTemplate"] = templ; - instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; - instance.parameterValues["name"] = "Server1"; - update.nodes[0].serverInstances.push_back(instance); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - addProperty(server, "test", "test"); - assert(templ.descriptor == server); - update.serverTemplates["ServerTemplate"] = templ; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - info = admin->getServerInfo("Server1"); - test(info.descriptor); - test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); - - info = admin->getServerInfo("Server"); - test(info.descriptor); - adapter = AdapterDescriptor(); - adapter.id = "Server1"; - info.descriptor->adapters.push_back(adapter); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Adapter already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - info = admin->getServerInfo("Server"); - test(info.descriptor); - adapter = AdapterDescriptor(); - adapter.id = "ServerX"; - object = ObjectDescriptor(); - object.id = communicator->stringToIdentity("test"); - adapter.objects.push_back(object); - info.descriptor->adapters.push_back(adapter); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Object already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - admin->removeApplication("TestApp"); + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + admin->addApplication(testApp); + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "localnode"; + empty.nodes.push_back(node); + + ApplicationUpdateDescriptor update = empty; + + cout << "testing server add... " << flush; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "Server"; + server->exe = properties->getProperty("TestDir") + "/server"; + server->pwd = "."; + AdapterDescriptor adapter; + adapter.name = "Server"; + adapter.id = "ServerAdapter"; + adapter.registerProcess = true; + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + ObjectDescriptor object; + object.id = communicator->stringToIdentity("test"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + update.nodes[0].servers.push_back(server); + admin->updateApplication(update); + + update.nodes[0].servers[0]->id = "Server2"; + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Adapter already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update.nodes[0].servers[0]->adapters[0].id = "ServerAdapter2"; + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Object already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update.nodes[0].servers[0]->adapters[0].objects[0].id = communicator->stringToIdentity("test2"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + TemplateDescriptor templ; + templ.parameters.push_back("name"); + templ.descriptor = new ServerDescriptor(); + server = ServerDescriptorPtr::dynamicCast(templ.descriptor); + server->id = "${name}"; + server->exe = "${test.dir}/server"; + server->pwd = "."; + adapter = AdapterDescriptor(); + adapter.name = "Server"; + adapter.id = "${server}"; + adapter.registerProcess = true; + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + object = ObjectDescriptor(); + object.id = communicator->stringToIdentity("${server}"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + update = empty; + update.serverTemplates["ServerTemplate"] = templ; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + ServerInstanceDescriptor instance; + instance._cpp_template = "ServerTemplate"; + update.nodes[0].serverInstances.push_back(instance); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing parameter + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + update.variables["test.dir"] = properties->getProperty("TestDir"); + update.variables["variable"] = ""; + instance = ServerInstanceDescriptor(); + instance._cpp_template = "ServerTemplate"; + instance.parameterValues["name"] = "Server1"; + update.nodes[0].serverInstances.push_back(instance); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + cout << "ok" << endl; + + cout << "testing server remove... " << flush; + update = empty; + update.nodes[0].removeServers.push_back("Server2"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + admin->getServerInfo("Server2"); + test(false); + } + catch(const ServerNotExistException&) + { + } + + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + update.removeServerTemplates.push_back("ServerTemplate"); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Server without template! + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + update.nodes[0].removeServers.push_back("Server1"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + admin->getServerInfo("Server1"); + test(false); + } + catch(const ServerNotExistException&) + { + } + + update = empty; + update.removeServerTemplates.push_back("ServerTemplate"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing server update... " << flush; + + ServerInfo info = admin->getServerInfo("Server"); + test(info.descriptor); + addProperty(info.descriptor, "test", "test"); + update = empty; + update.nodes[0].servers.push_back(info.descriptor); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + info = admin->getServerInfo("Server"); + test(info.descriptor); + test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); + + update = empty; + update.serverTemplates["ServerTemplate"] = templ; + instance = ServerInstanceDescriptor(); + instance._cpp_template = "ServerTemplate"; + instance.parameterValues["name"] = "Server1"; + update.nodes[0].serverInstances.push_back(instance); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + addProperty(server, "test", "test"); + assert(templ.descriptor == server); + update.serverTemplates["ServerTemplate"] = templ; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + info = admin->getServerInfo("Server1"); + test(info.descriptor); + test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); + + info = admin->getServerInfo("Server"); + test(info.descriptor); + adapter = AdapterDescriptor(); + adapter.id = "Server1"; + info.descriptor->adapters.push_back(adapter); + update = empty; + update.nodes[0].servers.push_back(info.descriptor); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Adapter already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + info = admin->getServerInfo("Server"); + test(info.descriptor); + adapter = AdapterDescriptor(); + adapter.id = "ServerX"; + object = ObjectDescriptor(); + object.id = communicator->stringToIdentity("test"); + adapter.objects.push_back(object); + info.descriptor->adapters.push_back(adapter); + update = empty; + update.nodes[0].servers.push_back(info.descriptor); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Object already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + admin->removeApplication("TestApp"); } { - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - admin->addApplication(testApp); - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "localnode"; - empty.nodes.push_back(node); - - ApplicationUpdateDescriptor update = empty; - - cout << "testing icebox server add... " << flush; - - ServiceDescriptorPtr service = new ServiceDescriptor(); - service->name = "Service1"; - service->entry = "TestService:create"; - AdapterDescriptor adapter; - adapter.name = "${service}"; - adapter.id = "${server}.${service}"; - adapter.registerProcess = true; - addProperty(service, "Ice.OA.${service}.Endpoints", "default"); - service->adapters.push_back(adapter); - - IceBoxDescriptorPtr server = new IceBoxDescriptor(); - server->id = "IceBox"; - server->exe = properties->getProperty("IceDir") + "/bin/icebox"; - server->services.resize(3); - server->services[0].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); - service->name = "Service2"; - server->services[1].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); - service->name = "Service3"; - server->services[2].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); - - update.nodes[0].servers.push_back(server); - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "testing service add... " << flush; - service->name = "First"; - server->services.resize(4); - server->services[3].descriptor = service; - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "testing service remove... " << flush; - server->services.resize(3); - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - admin->removeApplication("TestApp"); + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + admin->addApplication(testApp); + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "localnode"; + empty.nodes.push_back(node); + + ApplicationUpdateDescriptor update = empty; + + cout << "testing icebox server add... " << flush; + + ServiceDescriptorPtr service = new ServiceDescriptor(); + service->name = "Service1"; + service->entry = "TestService:create"; + AdapterDescriptor adapter; + adapter.name = "${service}"; + adapter.id = "${server}.${service}"; + adapter.registerProcess = true; + addProperty(service, "Ice.OA.${service}.Endpoints", "default"); + service->adapters.push_back(adapter); + + IceBoxDescriptorPtr server = new IceBoxDescriptor(); + server->id = "IceBox"; + server->exe = properties->getProperty("IceDir") + "/bin/icebox"; + server->services.resize(3); + server->services[0].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + service->name = "Service2"; + server->services[1].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + service->name = "Service3"; + server->services[2].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + + update.nodes[0].servers.push_back(server); + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing service add... " << flush; + service->name = "First"; + server->services.resize(4); + server->services[3].descriptor = service; + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing service remove... " << flush; + server->services.resize(3); + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + admin->removeApplication("TestApp"); } { - cout << "testing node add... " << flush; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - NodeDescriptor node; - node.variables["nodename"] = "node1"; - testApp.nodes["node1"] = node; - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node2"; - nodeUpdate.variables["nodename"] = "node2"; - update.nodes.push_back(nodeUpdate); - - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.nodes.size() == 2); - test(testApp.nodes["node1"].variables["nodename"] == "node1"); - test(testApp.nodes["node2"].variables["nodename"] == "node2"); - cout << "ok" << endl; - - cout << "testing node update... " << flush; - - nodeUpdate.name = "node2"; - nodeUpdate.variables["nodename"] = "node2updated"; - update.nodes.back() = nodeUpdate; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.nodes.size() == 2); - test(testApp.nodes["node1"].variables["nodename"] == "node1"); - test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); - - cout << "ok" << endl; - - cout << "testing node remove... " << flush; - - update.nodes.clear(); - update.removeNodes.push_back("node1"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.nodes.size() == 1); - test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); - - admin->removeApplication("TestApp"); - - cout << "ok" << endl; - } + cout << "testing node add... " << flush; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + NodeDescriptor node; + node.variables["nodename"] = "node1"; + testApp.nodes["node1"] = node; + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node2"; + nodeUpdate.variables["nodename"] = "node2"; + update.nodes.push_back(nodeUpdate); + + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.nodes.size() == 2); + test(testApp.nodes["node1"].variables["nodename"] == "node1"); + test(testApp.nodes["node2"].variables["nodename"] == "node2"); + cout << "ok" << endl; + + cout << "testing node update... " << flush; + + nodeUpdate.name = "node2"; + nodeUpdate.variables["nodename"] = "node2updated"; + update.nodes.back() = nodeUpdate; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.nodes.size() == 2); + test(testApp.nodes["node1"].variables["nodename"] == "node1"); + test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); + + cout << "ok" << endl; + + cout << "testing node remove... " << flush; + + update.nodes.clear(); + update.removeNodes.push_back("node1"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.nodes.size() == 1); + test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); + + admin->removeApplication("TestApp"); + + cout << "ok" << endl; + } { - cout << "testing variable update... " << flush; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "${name}"; - server->exe = "server"; - server->pwd = "."; - - addProperty(server, "ApplicationVar", "${appvar}"); - addProperty(server, "NodeVar", "${nodevar}"); - addProperty(server, "ServerParamVar", "${serverparamvar}"); - - TemplateDescriptor templ; - templ.parameters.push_back("name"); - templ.parameters.push_back("serverparamvar"); - templ.descriptor = server; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - testApp.variables["appvar"] = "AppValue"; - testApp.serverTemplates["ServerTemplate"] = templ; - - NodeDescriptor node; - node.variables["nodevar"] = "NodeValue"; - - ServerInstanceDescriptor serverInstance; - serverInstance._cpp_template = "ServerTemplate"; - serverInstance.parameterValues["name"] = "Server"; - serverInstance.parameterValues["serverparamvar"] = "ServerParamValue"; - node.serverInstances.push_back(serverInstance); - - testApp.nodes["node1"] = node; - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - ApplicationUpdateDescriptor update = empty; - update.removeVariables.push_back("appvar"); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing app variable - //cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node1"; - nodeUpdate.removeVariables.push_back("nodevar"); - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing node variable - //cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - serverInstance = ServerInstanceDescriptor(); - serverInstance._cpp_template = "ServerTemplate"; - serverInstance.parameterValues["name"] = "Server"; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.push_back(serverInstance); - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing parameter - //cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ServerInfo serverBefore = admin->getServerInfo("Server"); - ApplicationDescriptor origApp = admin->getApplicationInfo("TestApp").descriptor; - - update = empty; - update.variables["nodevar"] = "appoverride"; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node1"; - nodeUpdate.variables["serverparamvar"] = "nodeoverride"; - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ServerInfo serverAfter = admin->getServerInfo("Server"); - test(serverBefore.descriptor->propertySet == serverAfter.descriptor->propertySet); - - update = empty; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node1"; - nodeUpdate.variables["appvar"] = "nodeoverride"; - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - serverAfter = admin->getServerInfo("Server"); - PropertyDescriptorSeq newProps = serverAfter.descriptor->propertySet.properties; - test(getProperty(serverAfter.descriptor->propertySet.properties, "ApplicationVar") == "nodeoverride"); - test(getProperty(serverAfter.descriptor->propertySet.properties, "NodeVar") == "NodeValue"); - test(getProperty(serverAfter.descriptor->propertySet.properties, "ServerParamVar") == "ServerParamValue"); - admin->removeApplication("TestApp"); - cout << "ok" << endl; + cout << "testing variable update... " << flush; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "${name}"; + server->exe = "server"; + server->pwd = "."; + + addProperty(server, "ApplicationVar", "${appvar}"); + addProperty(server, "NodeVar", "${nodevar}"); + addProperty(server, "ServerParamVar", "${serverparamvar}"); + + TemplateDescriptor templ; + templ.parameters.push_back("name"); + templ.parameters.push_back("serverparamvar"); + templ.descriptor = server; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + testApp.variables["appvar"] = "AppValue"; + testApp.serverTemplates["ServerTemplate"] = templ; + + NodeDescriptor node; + node.variables["nodevar"] = "NodeValue"; + + ServerInstanceDescriptor serverInstance; + serverInstance._cpp_template = "ServerTemplate"; + serverInstance.parameterValues["name"] = "Server"; + serverInstance.parameterValues["serverparamvar"] = "ServerParamValue"; + node.serverInstances.push_back(serverInstance); + + testApp.nodes["node1"] = node; + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + ApplicationUpdateDescriptor update = empty; + update.removeVariables.push_back("appvar"); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing app variable + //cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node1"; + nodeUpdate.removeVariables.push_back("nodevar"); + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing node variable + //cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + serverInstance = ServerInstanceDescriptor(); + serverInstance._cpp_template = "ServerTemplate"; + serverInstance.parameterValues["name"] = "Server"; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node1"; + nodeUpdate.serverInstances.push_back(serverInstance); + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing parameter + //cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ServerInfo serverBefore = admin->getServerInfo("Server"); + ApplicationDescriptor origApp = admin->getApplicationInfo("TestApp").descriptor; + + update = empty; + update.variables["nodevar"] = "appoverride"; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node1"; + nodeUpdate.variables["serverparamvar"] = "nodeoverride"; + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ServerInfo serverAfter = admin->getServerInfo("Server"); + test(serverBefore.descriptor->propertySet == serverAfter.descriptor->propertySet); + + update = empty; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node1"; + nodeUpdate.variables["appvar"] = "nodeoverride"; + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + serverAfter = admin->getServerInfo("Server"); + PropertyDescriptorSeq newProps = serverAfter.descriptor->propertySet.properties; + test(getProperty(serverAfter.descriptor->propertySet.properties, "ApplicationVar") == "nodeoverride"); + test(getProperty(serverAfter.descriptor->propertySet.properties, "NodeVar") == "NodeValue"); + test(getProperty(serverAfter.descriptor->propertySet.properties, "ServerParamVar") == "ServerParamValue"); + admin->removeApplication("TestApp"); + cout << "ok" << endl; } { - cout << "testing property set update... " << flush; - - ServiceDescriptorPtr service = new ServiceDescriptor(); - service->name = "${name}"; - service->entry = "dummy"; - addProperty(service, "ServiceProp", "test"); - - TemplateDescriptor svcTempl; - svcTempl.parameters.push_back("name"); - svcTempl.descriptor = service; - - ServiceInstanceDescriptor serviceInstance; - serviceInstance._cpp_template = "ServiceTemplate"; - serviceInstance.parameterValues["name"] = "Service"; - serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "test")); - - IceBoxDescriptorPtr server = new IceBoxDescriptor(); - server->id = "${name}"; - server->exe = "server"; - server->pwd = "."; - server->propertySet.references.push_back("ApplicationPropertySet"); - server->propertySet.references.push_back("NodePropertySet"); - addProperty(server, "ServerProp", "test"); - server->services.push_back(serviceInstance); - - TemplateDescriptor templ; - templ.parameters.push_back("name"); - templ.descriptor = server; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - testApp.variables["appvar"] = "AppValue"; - testApp.serverTemplates["ServerTemplate"] = templ; - testApp.serviceTemplates["ServiceTemplate"] = svcTempl; - testApp.propertySets["ApplicationPropertySet"].properties.push_back(createProperty("ApplicationProp","test")); - testApp.propertySets["ApplicationPropertySet1"].properties.push_back(createProperty("ApplicationProp", "d")); - - NodeDescriptor node; - node.variables["nodevar"] = "NodeValue"; - node.propertySets["NodePropertySet"].properties.push_back(createProperty("NodeProp", "test")); - node.propertySets["NodePropertySet1"].properties.push_back(createProperty("NodeProp", "test")); - - ServerInstanceDescriptor serverInstance; - serverInstance._cpp_template = "ServerTemplate"; - serverInstance.parameterValues["name"] = "Server"; - serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "test")); - node.serverInstances.push_back(serverInstance); - - testApp.nodes["node1"] = node; - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ServerInfo info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ServerProp", "test")); - test(hasProperty(info.descriptor, "NodeProp", "test")); - test(hasProperty(info.descriptor, "ApplicationProp", "test")); - test(hasProperty(info.descriptor, "ServerInstanceProp", "test")); - - ServiceDescriptorPtr svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; - test(hasProperty(svc, "ServiceProp", "test")); - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - ApplicationUpdateDescriptor update; - - update = empty; - service->propertySet.properties.clear(); - addProperty(service, "ServiceProp", "updated"); - svcTempl.descriptor = service; - update.serviceTemplates["ServiceTemplate"] = svcTempl; - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; - test(hasProperty(svc, "ServiceProp", "updated")); - - update = empty; - serviceInstance.propertySet.properties.clear(); - serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "updated")); - server->services.clear(); - server->services.push_back(serviceInstance); - templ.descriptor = server; - update.serverTemplates["ServerTemplate"] = templ; - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; - test(hasProperty(svc, "ServiceInstanceProp", "updated")); - - update = empty; - server->propertySet.properties.clear(); - addProperty(server, "ServerProp", "updated"); - templ.descriptor = server; - update.serverTemplates["ServerTemplate"] = templ; - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ServerProp", "updated")); - - update = empty; - serverInstance.propertySet.properties.clear(); - serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "updated")); - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.push_back(serverInstance); - update.nodes.push_back(nodeUpdate); - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ServerInstanceProp", "updated")); - - update = empty; - nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.clear(); - nodeUpdate.propertySets["NodePropertySet"].properties.clear(); - nodeUpdate.propertySets["NodePropertySet"].properties.push_back( - createProperty("NodeProp", "updated")); - nodeUpdate.removePropertySets.push_back("NodePropertySet1"); - update.nodes.push_back(nodeUpdate); - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "NodeProp", "updated")); - ApplicationDescriptor updatedApplication = admin->getApplicationInfo("TestApp").descriptor; - test(updatedApplication.nodes["node1"].propertySets.find("NodePropertySet1") == - updatedApplication.nodes["node1"].propertySets.end()); - - update = empty; - update.propertySets["ApplicationPropertySet"].properties.clear(); - update.propertySets["ApplicationPropertySet"].properties.push_back( - createProperty("ApplicationProp", "updated")); - update.removePropertySets.push_back("ApplicationPropertySet1"); - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ApplicationProp", "updated")); - updatedApplication = admin->getApplicationInfo("TestApp").descriptor; - test(updatedApplication.propertySets.find("ApplicationPropertySet1") == - updatedApplication.propertySets.end()); - - admin->removeApplication("TestApp"); - cout << "ok" << endl; + cout << "testing property set update... " << flush; + + ServiceDescriptorPtr service = new ServiceDescriptor(); + service->name = "${name}"; + service->entry = "dummy"; + addProperty(service, "ServiceProp", "test"); + + TemplateDescriptor svcTempl; + svcTempl.parameters.push_back("name"); + svcTempl.descriptor = service; + + ServiceInstanceDescriptor serviceInstance; + serviceInstance._cpp_template = "ServiceTemplate"; + serviceInstance.parameterValues["name"] = "Service"; + serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "test")); + + IceBoxDescriptorPtr server = new IceBoxDescriptor(); + server->id = "${name}"; + server->exe = "server"; + server->pwd = "."; + server->propertySet.references.push_back("ApplicationPropertySet"); + server->propertySet.references.push_back("NodePropertySet"); + addProperty(server, "ServerProp", "test"); + server->services.push_back(serviceInstance); + + TemplateDescriptor templ; + templ.parameters.push_back("name"); + templ.descriptor = server; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + testApp.variables["appvar"] = "AppValue"; + testApp.serverTemplates["ServerTemplate"] = templ; + testApp.serviceTemplates["ServiceTemplate"] = svcTempl; + testApp.propertySets["ApplicationPropertySet"].properties.push_back(createProperty("ApplicationProp","test")); + testApp.propertySets["ApplicationPropertySet1"].properties.push_back(createProperty("ApplicationProp", "d")); + + NodeDescriptor node; + node.variables["nodevar"] = "NodeValue"; + node.propertySets["NodePropertySet"].properties.push_back(createProperty("NodeProp", "test")); + node.propertySets["NodePropertySet1"].properties.push_back(createProperty("NodeProp", "test")); + + ServerInstanceDescriptor serverInstance; + serverInstance._cpp_template = "ServerTemplate"; + serverInstance.parameterValues["name"] = "Server"; + serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "test")); + node.serverInstances.push_back(serverInstance); + + testApp.nodes["node1"] = node; + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ServerInfo info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ServerProp", "test")); + test(hasProperty(info.descriptor, "NodeProp", "test")); + test(hasProperty(info.descriptor, "ApplicationProp", "test")); + test(hasProperty(info.descriptor, "ServerInstanceProp", "test")); + + ServiceDescriptorPtr svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + test(hasProperty(svc, "ServiceProp", "test")); + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + ApplicationUpdateDescriptor update; + + update = empty; + service->propertySet.properties.clear(); + addProperty(service, "ServiceProp", "updated"); + svcTempl.descriptor = service; + update.serviceTemplates["ServiceTemplate"] = svcTempl; + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + test(hasProperty(svc, "ServiceProp", "updated")); + + update = empty; + serviceInstance.propertySet.properties.clear(); + serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "updated")); + server->services.clear(); + server->services.push_back(serviceInstance); + templ.descriptor = server; + update.serverTemplates["ServerTemplate"] = templ; + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + test(hasProperty(svc, "ServiceInstanceProp", "updated")); + + update = empty; + server->propertySet.properties.clear(); + addProperty(server, "ServerProp", "updated"); + templ.descriptor = server; + update.serverTemplates["ServerTemplate"] = templ; + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ServerProp", "updated")); + + update = empty; + serverInstance.propertySet.properties.clear(); + serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "updated")); + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node1"; + nodeUpdate.serverInstances.push_back(serverInstance); + update.nodes.push_back(nodeUpdate); + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ServerInstanceProp", "updated")); + + update = empty; + nodeUpdate.name = "node1"; + nodeUpdate.serverInstances.clear(); + nodeUpdate.propertySets["NodePropertySet"].properties.clear(); + nodeUpdate.propertySets["NodePropertySet"].properties.push_back( + createProperty("NodeProp", "updated")); + nodeUpdate.removePropertySets.push_back("NodePropertySet1"); + update.nodes.push_back(nodeUpdate); + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "NodeProp", "updated")); + ApplicationDescriptor updatedApplication = admin->getApplicationInfo("TestApp").descriptor; + test(updatedApplication.nodes["node1"].propertySets.find("NodePropertySet1") == + updatedApplication.nodes["node1"].propertySets.end()); + + update = empty; + update.propertySets["ApplicationPropertySet"].properties.clear(); + update.propertySets["ApplicationPropertySet"].properties.push_back( + createProperty("ApplicationProp", "updated")); + update.removePropertySets.push_back("ApplicationPropertySet1"); + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ApplicationProp", "updated")); + updatedApplication = admin->getApplicationInfo("TestApp").descriptor; + test(updatedApplication.propertySets.find("ApplicationPropertySet1") == + updatedApplication.propertySets.end()); + + admin->removeApplication("TestApp"); + cout << "ok" << endl; } { - cout << "testing description update... " << flush; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - testApp.description = "Description"; - try - { - admin->addApplication(testApp); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == "Description"); - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == "Description"); - - update.description = new BoxedString("updatedDescription"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == "updatedDescription"); - - update.description = new BoxedString(""); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == ""); - - admin->removeApplication("TestApp"); - - cout << "ok" << endl; + cout << "testing description update... " << flush; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + testApp.description = "Description"; + try + { + admin->addApplication(testApp); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == "Description"); + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == "Description"); + + update.description = new BoxedString("updatedDescription"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == "updatedDescription"); + + update.description = new BoxedString(""); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == ""); + + admin->removeApplication("TestApp"); + + cout << "ok" << endl; } { - cout << "testing server node move... " << flush; - - ApplicationDescriptor nodeApp; - nodeApp.name = "NodeApp"; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "node-${index}"; - server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; - server->pwd = "."; - server->options.push_back("--nowarn"); - AdapterDescriptor adapter; - adapter.name = "IceGrid.Node"; - adapter.id = "IceGrid.Node.node-${index}"; - adapter.registerProcess = true; - adapter.serverLifetime = false; - server->adapters.push_back(adapter); - - addProperty(server, "IceGrid.Node.Name", "node-${index}"); - addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-${index}"); - addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); - addProperty(server, "IceGrid.Node.PropertiesOverride", properties->getProperty("NodePropertiesOverride")); - - nodeApp.serverTemplates["nodeTemplate"].descriptor = server; - nodeApp.serverTemplates["nodeTemplate"].parameters.push_back("index"); - - ServerInstanceDescriptor instance; - instance._cpp_template = "nodeTemplate"; - instance.parameterValues["index"] = "1"; - nodeApp.nodes["localnode"].serverInstances.push_back(instance); - instance.parameterValues["index"] = "2"; - nodeApp.nodes["localnode"].serverInstances.push_back(instance); - - try - { - admin->addApplication(nodeApp); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - admin->startServer("node-1"); - admin->startServer("node-2"); - - // - // We need to wait because the node might not be fully started - // here (the node adapter isn't indirect, so we can't use the - // wait-for-activation feature here.) - // - int retry = 0; - while(retry < 20) - { - try - { - if(admin->pingNode("node-1") && admin->pingNode("node-2")) - { - break; - } - } - catch(const NodeNotExistException&) - { - } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++retry; - } - test(admin->pingNode("node-1")); - test(admin->pingNode("node-2")); - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - server = new ServerDescriptor(); - server->id = "Server"; - server->exe = properties->getProperty("TestDir") + "/server"; - server->pwd = "."; - adapter.name = "Server"; - adapter.id = "ServerAdapter"; - adapter.registerProcess = true; - adapter.serverLifetime = true; - server->adapters.push_back(adapter); - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - testApp.nodes["node-1"].servers.push_back(server); - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - - try - { - admin->startServer("Server"); - test(admin->getServerState("Server") == Active); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node-1"; - nodeUpdate.removeServers.push_back("Server"); - update.nodes.push_back(nodeUpdate); - nodeUpdate.name = "node-2"; - nodeUpdate.servers.push_back(server); - nodeUpdate.removeServers.clear(); - update.nodes.push_back(nodeUpdate); - - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - test(admin->getServerInfo("Server").node == "node-2" && admin->getServerState("Server") == Inactive); - - admin->startServer("Server"); - test(admin->getServerState("Server") == Active); - - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); - - update = ApplicationUpdateDescriptor(); - update.name = "TestApp"; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node-2"; - nodeUpdate.removeServers.push_back("Server"); - update.nodes.push_back(nodeUpdate); - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "unknownNode"; - nodeUpdate.servers.push_back(server); - update.nodes.push_back(nodeUpdate); - - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - - try - { - admin->getServerState("Server"); - test(false); - } - catch(const NodeUnreachableException&) - { - } - - try - { - admin->removeApplication("TestApp"); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - - admin->stopServer("node-1"); - admin->stopServer("node-2"); - - try - { - admin->removeApplication("NodeApp"); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - cout << "ok" << endl; + cout << "testing server node move... " << flush; + + ApplicationDescriptor nodeApp; + nodeApp.name = "NodeApp"; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "node-${index}"; + server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; + server->pwd = "."; + server->options.push_back("--nowarn"); + AdapterDescriptor adapter; + adapter.name = "IceGrid.Node"; + adapter.id = "IceGrid.Node.node-${index}"; + adapter.registerProcess = true; + adapter.serverLifetime = false; + server->adapters.push_back(adapter); + + addProperty(server, "IceGrid.Node.Name", "node-${index}"); + addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-${index}"); + addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); + addProperty(server, "IceGrid.Node.PropertiesOverride", properties->getProperty("NodePropertiesOverride")); + + nodeApp.serverTemplates["nodeTemplate"].descriptor = server; + nodeApp.serverTemplates["nodeTemplate"].parameters.push_back("index"); + + ServerInstanceDescriptor instance; + instance._cpp_template = "nodeTemplate"; + instance.parameterValues["index"] = "1"; + nodeApp.nodes["localnode"].serverInstances.push_back(instance); + instance.parameterValues["index"] = "2"; + nodeApp.nodes["localnode"].serverInstances.push_back(instance); + + try + { + admin->addApplication(nodeApp); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + admin->startServer("node-1"); + admin->startServer("node-2"); + + // + // We need to wait because the node might not be fully started + // here (the node adapter isn't indirect, so we can't use the + // wait-for-activation feature here.) + // + int retry = 0; + while(retry < 20) + { + try + { + if(admin->pingNode("node-1") && admin->pingNode("node-2")) + { + break; + } + } + catch(const NodeNotExistException&) + { + } + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++retry; + } + test(admin->pingNode("node-1")); + test(admin->pingNode("node-2")); + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + server = new ServerDescriptor(); + server->id = "Server"; + server->exe = properties->getProperty("TestDir") + "/server"; + server->pwd = "."; + adapter.name = "Server"; + adapter.id = "ServerAdapter"; + adapter.registerProcess = true; + adapter.serverLifetime = true; + server->adapters.push_back(adapter); + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + testApp.nodes["node-1"].servers.push_back(server); + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + + try + { + admin->startServer("Server"); + test(admin->getServerState("Server") == Active); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node-1"; + nodeUpdate.removeServers.push_back("Server"); + update.nodes.push_back(nodeUpdate); + nodeUpdate.name = "node-2"; + nodeUpdate.servers.push_back(server); + nodeUpdate.removeServers.clear(); + update.nodes.push_back(nodeUpdate); + + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + test(admin->getServerInfo("Server").node == "node-2" && admin->getServerState("Server") == Inactive); + + admin->startServer("Server"); + test(admin->getServerState("Server") == Active); + + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + + update = ApplicationUpdateDescriptor(); + update.name = "TestApp"; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node-2"; + nodeUpdate.removeServers.push_back("Server"); + update.nodes.push_back(nodeUpdate); + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "unknownNode"; + nodeUpdate.servers.push_back(server); + update.nodes.push_back(nodeUpdate); + + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + + try + { + admin->getServerState("Server"); + test(false); + } + catch(const NodeUnreachableException&) + { + } + + try + { + admin->removeApplication("TestApp"); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + + admin->stopServer("node-1"); + admin->stopServer("node-2"); + + try + { + admin->removeApplication("NodeApp"); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + cout << "ok" << endl; } keepAlive->destroy(); diff --git a/cpp/test/IceGrid/update/Client.cpp b/cpp/test/IceGrid/update/Client.cpp index 47f910e24da..940ae6bec73 100644 --- a/cpp/test/IceGrid/update/Client.cpp +++ b/cpp/test/IceGrid/update/Client.cpp @@ -27,28 +27,28 @@ main(int argc, char* argv[]) int status; Ice::CommunicatorPtr communicator; try - { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/update/run.py b/cpp/test/IceGrid/update/run.py index 1d4fee7324c..ffc218efb4b 100755 --- a/cpp/test/IceGrid/update/run.py +++ b/cpp/test/IceGrid/update/run.py @@ -39,7 +39,7 @@ else: nodeOverrideOptions = "--IceDir=\"" + toplevel + "\" --TestDir=\"" + testdir + "\"" + \ ' --NodePropertiesOverride="' + \ TestUtil.clientServerOptions.replace("--", "") + \ - ' Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0' + '"' + ' Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0' + '"' IceGridAdmin.iceGridTest(name, "", nodeOverrideOptions) sys.exit(0) diff --git a/cpp/test/IceSSL/configuration/AllTests.cpp b/cpp/test/IceSSL/configuration/AllTests.cpp index b5ae334bcd5..bb8430472ab 100644 --- a/cpp/test/IceSSL/configuration/AllTests.cpp +++ b/cpp/test/IceSSL/configuration/AllTests.cpp @@ -25,13 +25,13 @@ public: virtual string getPassword() { - ++_count; - return _password; + ++_count; + return _password; } int count() const { - return _count; + return _count; } private: @@ -47,59 +47,59 @@ public: CertificateVerifierI() { - reset(); + reset(); } virtual bool verify(const IceSSL::ConnectionInfo& info) { - if(info.certs.size() > 0) - { - vector<pair<int, string> > subjectAltNames = info.certs[0]->getSubjectAlternativeNames(); - vector<string> ipAddresses; - vector<string> dnsNames; - for(vector<pair<int, string> >::const_iterator p = subjectAltNames.begin(); - p != subjectAltNames.end(); ++p) - { - if(p->first == 7) - { - ipAddresses.push_back(p->second); - } - else if(p->first == 2) - { - dnsNames.push_back(p->second); - } - } - - test(find(dnsNames.begin(), dnsNames.end(), "server") != dnsNames.end()); - test(find(ipAddresses.begin(), ipAddresses.end(), "127.0.0.1") != ipAddresses.end()); - } - - _hadCert = info.certs.size() != 0; - _invoked = true; - return _returnValue; + if(info.certs.size() > 0) + { + vector<pair<int, string> > subjectAltNames = info.certs[0]->getSubjectAlternativeNames(); + vector<string> ipAddresses; + vector<string> dnsNames; + for(vector<pair<int, string> >::const_iterator p = subjectAltNames.begin(); + p != subjectAltNames.end(); ++p) + { + if(p->first == 7) + { + ipAddresses.push_back(p->second); + } + else if(p->first == 2) + { + dnsNames.push_back(p->second); + } + } + + test(find(dnsNames.begin(), dnsNames.end(), "server") != dnsNames.end()); + test(find(ipAddresses.begin(), ipAddresses.end(), "127.0.0.1") != ipAddresses.end()); + } + + _hadCert = info.certs.size() != 0; + _invoked = true; + return _returnValue; } void reset() { - _returnValue = true; - _invoked = false; - _hadCert = false; + _returnValue = true; + _invoked = false; + _hadCert = false; } void returnValue(bool b) { - _returnValue = b; + _returnValue = b; } bool invoked() const { - return _invoked; + return _invoked; } bool hadCert() const { - return _hadCert; + return _hadCert; } private: @@ -118,7 +118,7 @@ createClientProps(const string& defaultDir, const string& defaultHost) result->setProperty("IceSSL.DefaultDir", defaultDir); if(!defaultHost.empty()) { - result->setProperty("Ice.Default.Host", defaultHost); + result->setProperty("Ice.Default.Host", defaultHost); } return result; } @@ -131,7 +131,7 @@ createServerProps(const string& defaultDir, const string& defaultHost) result["IceSSL.DefaultDir"] = defaultDir; if(!defaultHost.empty()) { - result["Ice.Default.Host"] = defaultHost; + result["Ice.Default.Host"] = defaultHost; } return result; } @@ -155,1316 +155,1316 @@ allTests(const CommunicatorPtr& communicator, const string& testDir) cout << "testing manual initialization... " << flush; { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("Ice.InitPlugins", "0"); - CommunicatorPtr comm = initialize(initData); - ObjectPrx p = comm->stringToProxy("dummy:ssl -p 9999"); - try - { - p->ice_ping(); - test(false); - } - catch(const PluginInitializationException&) - { - // Expected. - } - catch(const LocalException&) - { - test(false); - } - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("Ice.InitPlugins", "0"); + CommunicatorPtr comm = initialize(initData); + ObjectPrx p = comm->stringToProxy("dummy:ssl -p 9999"); + try + { + p->ice_ping(); + test(false); + } + catch(const PluginInitializationException&) + { + // Expected. + } + catch(const LocalException&) + { + test(false); + } + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("Ice.InitPlugins", "0"); - initData.properties->setProperty("IceSSL.Ciphers", "ADH"); - initData.properties->setProperty("IceSSL.VerifyPeer", "0"); - CommunicatorPtr comm = initialize(initData); - PluginManagerPtr pm = comm->getPluginManager(); - pm->initializePlugins(); - ObjectPrx obj = comm->stringToProxy(factoryRef); - test(obj); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(obj); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.Ciphers"] = "ADH"; - d["IceSSL.VerifyPeer"] = "0"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("Ice.InitPlugins", "0"); + initData.properties->setProperty("IceSSL.Ciphers", "ADH"); + initData.properties->setProperty("IceSSL.VerifyPeer", "0"); + CommunicatorPtr comm = initialize(initData); + PluginManagerPtr pm = comm->getPluginManager(); + pm->initializePlugins(); + ObjectPrx obj = comm->stringToProxy(factoryRef); + test(obj); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(obj); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.Ciphers"] = "ADH"; + d["IceSSL.VerifyPeer"] = "0"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing certificate verification... " << flush; { - // - // Test IceSSL.VerifyPeer=0. Client does not have a certificate, - // but it still verifies the server's. - // + // + // Test IceSSL.VerifyPeer=0. Client does not have a certificate, + // but it still verifies the server's. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.VerifyPeer", "0"); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "0"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->noCert(); - } - catch(const LocalException&) - { - test(false); - } - // - // Validate that we can get the connection info. - // - try - { - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); - test(info.certs.size() == 2); - } - catch(const IceSSL::ConnectionInvalidException&) - { - test(false); - } - fact->destroyServer(server); - - // - // Test IceSSL.VerifyPeer=1. Client does not have a certificate. - // - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "1"; - server = fact->createServer(d); - try - { - server->noCert(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - - // - // Test IceSSL.VerifyPeer=2. This should fail because the client - // does not supply a certificate. - // - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "2"; - server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.VerifyPeer", "0"); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "0"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->noCert(); + } + catch(const LocalException&) + { + test(false); + } + // + // Validate that we can get the connection info. + // + try + { + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); + test(info.certs.size() == 2); + } + catch(const IceSSL::ConnectionInvalidException&) + { + test(false); + } + fact->destroyServer(server); + + // + // Test IceSSL.VerifyPeer=1. Client does not have a certificate. + // + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "1"; + server = fact->createServer(d); + try + { + server->noCert(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + + // + // Test IceSSL.VerifyPeer=2. This should fail because the client + // does not supply a certificate. + // + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "2"; + server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } #ifdef _WIN32 - catch(const ConnectionLostException&) - { - // Expected. - } + catch(const ConnectionLostException&) + { + // Expected. + } #endif - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - - comm->destroy(); - - // - // Test IceSSL.VerifyPeer=1. Client has a certificate. - // - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "1"; - server = fact->createServer(d); - try - { - IceSSL::CertificatePtr clientCert = - IceSSL::Certificate::load(defaultDir + "/c_rsa_nopass_ca1_pub.pem"); - server->checkCert(clientCert->getSubjectDN(), clientCert->getIssuerDN()); - - // - // Validate that we can get the connection info. Validate - // that the certificates have the same DN. - // - // Validate some aspects of the Certificate class. - // - IceSSL::CertificatePtr serverCert = - IceSSL::Certificate::load(defaultDir + "/s_rsa_nopass_ca1_pub.pem"); - test(IceSSL::Certificate::decode(serverCert->encode()) == serverCert); - test(serverCert == serverCert); - test(serverCert->checkValidity()); - test(!serverCert->checkValidity(IceUtil::Time::seconds(0))); - - IceSSL::CertificatePtr caCert = IceSSL::Certificate::load(defaultDir + "/cacert1.pem"); - test(caCert == caCert); - test(caCert->checkValidity()); - test(!caCert->checkValidity(IceUtil::Time::seconds(0))); - - test(!serverCert->verify(serverCert->getPublicKey())); - test(serverCert->verify(caCert->getPublicKey())); - test(caCert->verify(caCert->getPublicKey())); - - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); - - test(info.certs.size() == 2); - - test(caCert == info.certs[1]); - test(serverCert == info.certs[0]); - - test(serverCert != info.certs[1]); - test(caCert != info.certs[0]); - - test(info.certs[0]->checkValidity() && info.certs[1]->checkValidity()); - test(!info.certs[0]->checkValidity(IceUtil::Time::seconds(0)) && - !info.certs[1]->checkValidity(IceUtil::Time::seconds(0))); - test(info.certs[0]->verify(info.certs[1]->getPublicKey())); - test(info.certs.size() == 2 && - info.certs[0]->getSubjectDN() == serverCert->getSubjectDN() && - info.certs[0]->getIssuerDN() == serverCert->getIssuerDN()); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - - // - // Test IceSSL.VerifyPeer=2. Client has a certificate. - // - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "2"; - server = fact->createServer(d); - try - { - IceSSL::CertificatePtr clientCert = - IceSSL::Certificate::load(defaultDir + "/c_rsa_nopass_ca1_pub.pem"); - server->checkCert(clientCert->getSubjectDN(), clientCert->getIssuerDN()); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - - comm->destroy(); - - // - // Test IceSSL.VerifyPeer=1. This should fail because the - // client doesn't trust the server's CA. - // - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert2.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca2_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca2_priv.pem"); - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "1"; - server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + + comm->destroy(); + + // + // Test IceSSL.VerifyPeer=1. Client has a certificate. + // + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "1"; + server = fact->createServer(d); + try + { + IceSSL::CertificatePtr clientCert = + IceSSL::Certificate::load(defaultDir + "/c_rsa_nopass_ca1_pub.pem"); + server->checkCert(clientCert->getSubjectDN(), clientCert->getIssuerDN()); + + // + // Validate that we can get the connection info. Validate + // that the certificates have the same DN. + // + // Validate some aspects of the Certificate class. + // + IceSSL::CertificatePtr serverCert = + IceSSL::Certificate::load(defaultDir + "/s_rsa_nopass_ca1_pub.pem"); + test(IceSSL::Certificate::decode(serverCert->encode()) == serverCert); + test(serverCert == serverCert); + test(serverCert->checkValidity()); + test(!serverCert->checkValidity(IceUtil::Time::seconds(0))); + + IceSSL::CertificatePtr caCert = IceSSL::Certificate::load(defaultDir + "/cacert1.pem"); + test(caCert == caCert); + test(caCert->checkValidity()); + test(!caCert->checkValidity(IceUtil::Time::seconds(0))); + + test(!serverCert->verify(serverCert->getPublicKey())); + test(serverCert->verify(caCert->getPublicKey())); + test(caCert->verify(caCert->getPublicKey())); + + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); + + test(info.certs.size() == 2); + + test(caCert == info.certs[1]); + test(serverCert == info.certs[0]); + + test(serverCert != info.certs[1]); + test(caCert != info.certs[0]); + + test(info.certs[0]->checkValidity() && info.certs[1]->checkValidity()); + test(!info.certs[0]->checkValidity(IceUtil::Time::seconds(0)) && + !info.certs[1]->checkValidity(IceUtil::Time::seconds(0))); + test(info.certs[0]->verify(info.certs[1]->getPublicKey())); + test(info.certs.size() == 2 && + info.certs[0]->getSubjectDN() == serverCert->getSubjectDN() && + info.certs[0]->getIssuerDN() == serverCert->getIssuerDN()); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + + // + // Test IceSSL.VerifyPeer=2. Client has a certificate. + // + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "2"; + server = fact->createServer(d); + try + { + IceSSL::CertificatePtr clientCert = + IceSSL::Certificate::load(defaultDir + "/c_rsa_nopass_ca1_pub.pem"); + server->checkCert(clientCert->getSubjectDN(), clientCert->getIssuerDN()); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + + comm->destroy(); + + // + // Test IceSSL.VerifyPeer=1. This should fail because the + // client doesn't trust the server's CA. + // + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert2.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca2_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca2_priv.pem"); + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "1"; + server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } #ifdef _WIN32 - catch(const ConnectionLostException&) - { - // Expected. - } + catch(const ConnectionLostException&) + { + // Expected. + } #endif - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - - comm->destroy(); - - // - // Test IceSSL.VerifyPeer=1. This should fail because the - // server doesn't trust the client's CA. - // - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca2_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca2_priv.pem"); - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "1"; - server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + + comm->destroy(); + + // + // Test IceSSL.VerifyPeer=1. This should fail because the + // server doesn't trust the client's CA. + // + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca2_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca2_priv.pem"); + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "1"; + server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } #ifdef _WIN32 - catch(const ConnectionLostException&) - { - // Expected. - } + catch(const ConnectionLostException&) + { + // Expected. + } #endif - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - - comm->destroy(); - - // - // Verify that IceSSL.CheckCertName has no effect in a server. - // - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - comm = initialize(initData); - - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.CheckCertName"] = "1"; - server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + + comm->destroy(); + + // + // Verify that IceSSL.CheckCertName has no effect in a server. + // + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + comm = initialize(initData); + + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.CheckCertName"] = "1"; + server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing custom certificate verifier... " << flush; { - // - // ADH is allowed but will not have a certificate. - // + // + // ADH is allowed but will not have a certificate. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.Ciphers", "ADH"); - initData.properties->setProperty("IceSSL.VerifyPeer", "0"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - CertificateVerifierIPtr verifier = new CertificateVerifierI; - plugin->setCertificateVerifier(verifier); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.Ciphers"] = "ADH"; - d["IceSSL.VerifyPeer"] = "0"; - Test::ServerPrx server = fact->createServer(d); - try - { - string cipherSub = "ADH-"; - server->checkCipher(cipherSub); - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); - test(info.cipher.compare(0, cipherSub.size(), cipherSub) == 0); - } - catch(const LocalException&) - { - test(false); - } - test(verifier->invoked()); - test(!verifier->hadCert()); - - // - // Have the verifier return false. Close the connection explicitly - // to force a new connection to be established. - // - verifier->reset(); - verifier->returnValue(false); - server->ice_getConnection()->close(false); - try - { - server->ice_ping(); - test(false); - } - catch(const SecurityException&) - { - // Expected. - } - catch(const LocalException&) - { - test(false); - } - test(verifier->invoked()); - test(!verifier->hadCert()); - - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.Ciphers", "ADH"); + initData.properties->setProperty("IceSSL.VerifyPeer", "0"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + CertificateVerifierIPtr verifier = new CertificateVerifierI; + plugin->setCertificateVerifier(verifier); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.Ciphers"] = "ADH"; + d["IceSSL.VerifyPeer"] = "0"; + Test::ServerPrx server = fact->createServer(d); + try + { + string cipherSub = "ADH-"; + server->checkCipher(cipherSub); + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); + test(info.cipher.compare(0, cipherSub.size(), cipherSub) == 0); + } + catch(const LocalException&) + { + test(false); + } + test(verifier->invoked()); + test(!verifier->hadCert()); + + // + // Have the verifier return false. Close the connection explicitly + // to force a new connection to be established. + // + verifier->reset(); + verifier->returnValue(false); + server->ice_getConnection()->close(false); + try + { + server->ice_ping(); + test(false); + } + catch(const SecurityException&) + { + // Expected. + } + catch(const LocalException&) + { + test(false); + } + test(verifier->invoked()); + test(!verifier->hadCert()); + + fact->destroyServer(server); + comm->destroy(); } { - // - // Verify that a server certificate is present. - // + // + // Verify that a server certificate is present. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.VerifyPeer", "0"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - CertificateVerifierIPtr verifier = new CertificateVerifierI; - plugin->setCertificateVerifier(verifier); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.VerifyPeer"] = "2"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - test(verifier->invoked()); - test(verifier->hadCert()); - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.VerifyPeer", "0"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + CertificateVerifierIPtr verifier = new CertificateVerifierI; + plugin->setCertificateVerifier(verifier); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.VerifyPeer"] = "2"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + test(verifier->invoked()); + test(verifier->hadCert()); + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing protocols... " << flush; { - // - // This should fail because the client and server have no protocol - // in common. - // + // + // This should fail because the client and server have no protocol + // in common. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.Ciphers", "ADH"); - initData.properties->setProperty("IceSSL.VerifyPeer", "0"); - initData.properties->setProperty("IceSSL.Protocols", "ssl3"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.Ciphers"] = "ADH"; - d["IceSSL.VerifyPeer"] = "0"; - d["IceSSL.Protocols"] = "tls1"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected on some platforms. - } - catch(const ConnectionLostException&) - { - // Expected on some platforms. - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); - - // - // This should succeed. - // - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.Ciphers"] = "ADH"; - d["IceSSL.VerifyPeer"] = "0"; - d["IceSSL.Protocols"] = "tls1, ssl3"; - server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.Ciphers", "ADH"); + initData.properties->setProperty("IceSSL.VerifyPeer", "0"); + initData.properties->setProperty("IceSSL.Protocols", "ssl3"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.Ciphers"] = "ADH"; + d["IceSSL.VerifyPeer"] = "0"; + d["IceSSL.Protocols"] = "tls1"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected on some platforms. + } + catch(const ConnectionLostException&) + { + // Expected on some platforms. + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); + + // + // This should succeed. + // + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.Ciphers"] = "ADH"; + d["IceSSL.VerifyPeer"] = "0"; + d["IceSSL.Protocols"] = "tls1, ssl3"; + server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing expired certificates... " << flush; { - // - // This should fail because the server's certificate is expired. - // - { - IceSSL::CertificatePtr cert = - IceSSL::Certificate::load(defaultDir + "/s_rsa_nopass_ca1_exp_pub.pem"); - test(!cert->checkValidity()); - } + // + // This should fail because the server's certificate is expired. + // + { + IceSSL::CertificatePtr cert = + IceSSL::Certificate::load(defaultDir + "/s_rsa_nopass_ca1_exp_pub.pem"); + test(!cert->checkValidity()); + } InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_exp_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_exp_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_exp_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_exp_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } #ifdef _WIN32 - catch(const ConnectionLostException&) - { - // Expected. - } + catch(const ConnectionLostException&) + { + // Expected. + } #endif - catch(const LocalException& ex) - { - cerr << ex << endl; - test(false); - } - fact->destroyServer(server); - comm->destroy(); - - // - // This should fail because the client's certificate is expired. - // - { - IceSSL::CertificatePtr cert = - IceSSL::Certificate::load(defaultDir + "/c_rsa_nopass_ca1_exp_pub.pem"); - test(!cert->checkValidity()); - } - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_exp_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_exp_priv.pem"); - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } + catch(const LocalException& ex) + { + cerr << ex << endl; + test(false); + } + fact->destroyServer(server); + comm->destroy(); + + // + // This should fail because the client's certificate is expired. + // + { + IceSSL::CertificatePtr cert = + IceSSL::Certificate::load(defaultDir + "/c_rsa_nopass_ca1_exp_pub.pem"); + test(!cert->checkValidity()); + } + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_exp_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_exp_priv.pem"); + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } #ifdef _WIN32 - catch(const ConnectionLostException&) - { - // Expected. - } + catch(const ConnectionLostException&) + { + // Expected. + } #endif - catch(const LocalException& ex) - { - cerr << ex << endl; - test(false); - } - fact->destroyServer(server); - comm->destroy(); + catch(const LocalException& ex) + { + cerr << ex << endl; + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing CA certificate directory... " << flush; { - // - // Don't specify CertAuthFile explicitly; we let OpenSSL find the CA - // certificate in the default directory. - // + // + // Don't specify CertAuthFile explicitly; we let OpenSSL find the CA + // certificate in the default directory. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException& ex) - { - cerr << ex << endl; - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException& ex) + { + cerr << ex << endl; + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing password prompt... " << flush; { - // - // Use the correct password. - // + // + // Use the correct password. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_pass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_pass_ca1_priv.pem"); - initData.properties->setProperty("Ice.InitPlugins", "0"); - CommunicatorPtr comm = initialize(initData); - PluginManagerPtr pm = comm->getPluginManager(); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(pm->getPlugin("IceSSL")); - test(plugin); - PasswordPromptIPtr prompt = new PasswordPromptI("client"); - plugin->setPasswordPrompt(prompt); - pm->initializePlugins(); - test(prompt->count() == 1); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException& ex) - { - cerr << ex << endl; - test(false); - } - fact->destroyServer(server); - comm->destroy(); - - // - // Use an incorrect password and check that retries are attempted. - // - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_pass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_pass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.PasswordRetryMax", "4"); - initData.properties->setProperty("Ice.InitPlugins", "0"); - comm = initialize(initData); - pm = comm->getPluginManager(); - plugin = IceSSL::PluginPtr::dynamicCast(pm->getPlugin("IceSSL")); - test(plugin); - prompt = new PasswordPromptI("invalid"); - plugin->setPasswordPrompt(prompt); - try - { - pm->initializePlugins(); - } - catch(const PluginInitializationException&) - { - // Expected. - } - catch(const LocalException& ex) - { - cerr << ex << endl; - test(false); - } - test(prompt->count() == 4); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_pass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_pass_ca1_priv.pem"); + initData.properties->setProperty("Ice.InitPlugins", "0"); + CommunicatorPtr comm = initialize(initData); + PluginManagerPtr pm = comm->getPluginManager(); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(pm->getPlugin("IceSSL")); + test(plugin); + PasswordPromptIPtr prompt = new PasswordPromptI("client"); + plugin->setPasswordPrompt(prompt); + pm->initializePlugins(); + test(prompt->count() == 1); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException& ex) + { + cerr << ex << endl; + test(false); + } + fact->destroyServer(server); + comm->destroy(); + + // + // Use an incorrect password and check that retries are attempted. + // + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_pass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_pass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.PasswordRetryMax", "4"); + initData.properties->setProperty("Ice.InitPlugins", "0"); + comm = initialize(initData); + pm = comm->getPluginManager(); + plugin = IceSSL::PluginPtr::dynamicCast(pm->getPlugin("IceSSL")); + test(plugin); + prompt = new PasswordPromptI("invalid"); + plugin->setPasswordPrompt(prompt); + try + { + pm->initializePlugins(); + } + catch(const PluginInitializationException&) + { + // Expected. + } + catch(const LocalException& ex) + { + cerr << ex << endl; + test(false); + } + test(prompt->count() == 4); + comm->destroy(); } cout << "ok" << endl; cout << "testing ciphers... " << flush; { - // - // The server has a certificate but the client doesn't. They should - // negotiate to use ADH since we explicitly enable it. - // + // + // The server has a certificate but the client doesn't. They should + // negotiate to use ADH since we explicitly enable it. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.Ciphers", "ADH"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.Ciphers"] = "RSA:ADH"; - d["IceSSL.VerifyPeer"] = "1"; - Test::ServerPrx server = fact->createServer(d); - try - { - string cipherSub = "ADH-"; - server->checkCipher(cipherSub); - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); - test(info.cipher.compare(0, cipherSub.size(), cipherSub) == 0); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.Ciphers", "ADH"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.Ciphers"] = "RSA:ADH"; + d["IceSSL.VerifyPeer"] = "1"; + Test::ServerPrx server = fact->createServer(d); + try + { + string cipherSub = "ADH-"; + server->checkCipher(cipherSub); + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(server->ice_getConnection()); + test(info.cipher.compare(0, cipherSub.size(), cipherSub) == 0); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { - // - // Configure a server with RSA and DSA certificates. - // - // First try a client with a DSA certificate. - // + // + // Configure a server with RSA and DSA certificates. + // + // First try a client with a DSA certificate. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertFile", "c_dsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_dsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.Ciphers", "DEFAULT:DSS"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem" + sep + "s_dsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem" + sep + "s_dsa_nopass_ca1_priv.pem"; - d["IceSSL.Ciphers"] = "DEFAULT:DSS"; - d["IceSSL.VerifyPeer"] = "1"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); - - // - // Next try a client with an RSA certificate. - // - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem" + sep + "s_dsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem" + sep + "s_dsa_nopass_ca1_priv.pem"; - d["IceSSL.Ciphers"] = "DEFAULT:DSS"; - d["IceSSL.VerifyPeer"] = "1"; - server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); - - // - // Next try a client with ADH. This should fail. - // - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.Ciphers", "ADH"); - comm = initialize(initData); - fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem" + sep + "s_dsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem" + sep + "s_dsa_nopass_ca1_priv.pem"; - d["IceSSL.Ciphers"] = "DEFAULT:DSS"; - d["IceSSL.VerifyPeer"] = "1"; - server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertFile", "c_dsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_dsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.Ciphers", "DEFAULT:DSS"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem" + sep + "s_dsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem" + sep + "s_dsa_nopass_ca1_priv.pem"; + d["IceSSL.Ciphers"] = "DEFAULT:DSS"; + d["IceSSL.VerifyPeer"] = "1"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); + + // + // Next try a client with an RSA certificate. + // + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem" + sep + "s_dsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem" + sep + "s_dsa_nopass_ca1_priv.pem"; + d["IceSSL.Ciphers"] = "DEFAULT:DSS"; + d["IceSSL.VerifyPeer"] = "1"; + server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); + + // + // Next try a client with ADH. This should fail. + // + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.Ciphers", "ADH"); + comm = initialize(initData); + fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem" + sep + "s_dsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem" + sep + "s_dsa_nopass_ca1_priv.pem"; + d["IceSSL.Ciphers"] = "DEFAULT:DSS"; + d["IceSSL.VerifyPeer"] = "1"; + server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { - // - // Configure a server with RSA and a client with DSA. This should fail. - // + // + // Configure a server with RSA and a client with DSA. This should fail. + // InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertFile", "c_dsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_dsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.Ciphers", "DSS"); - CommunicatorPtr comm = initialize(initData); - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const ProtocolException&) - { - // Expected. - } + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertFile", "c_dsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_dsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.Ciphers", "DSS"); + CommunicatorPtr comm = initialize(initData); + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const ProtocolException&) + { + // Expected. + } #ifdef _WIN32 - catch(const ConnectionLostException&) - { - // Expected. - } + catch(const ConnectionLostException&) + { + // Expected. + } #endif - catch(const LocalException& ex) - { - cerr << ex << endl; - test(false); - } - fact->destroyServer(server); - comm->destroy(); + catch(const LocalException& ex) + { + cerr << ex << endl; + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing IceSSL.TrustOnly... " << flush; { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly", "C=US, ST=Florida, O=ZeroC\\, Inc.," - "OU=Ice, emailAddress=info@zeroc.com, CN=Server"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly", "C=US, ST=Florida, O=ZeroC\\, Inc.," + "OU=Ice, emailAddress=info@zeroc.com, CN=Server"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly", "C=US, ST=Florida, O=\"ZeroC, Inc.\"," - "OU=Ice, emailAddress=info@zeroc.com, CN=Server"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly", "C=US, ST=Florida, O=\"ZeroC, Inc.\"," + "OU=Ice, emailAddress=info@zeroc.com, CN=Server"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly"] = "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com," - "CN=Client"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly"] = "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com," + "CN=Client"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly", "CN=Server"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly", "CN=Server"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly"] = "CN=Client"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly"] = "CN=Client"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly", "CN=Client"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const LocalException&) - { - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly", "CN=Client"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const LocalException&) + { + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly"] = "CN=Server"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const LocalException&) - { - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly"] = "CN=Server"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const LocalException&) + { + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly", "C=Canada,CN=Server"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const LocalException&) - { - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly", "C=Canada,CN=Server"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const LocalException&) + { + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly", "C=Canada;CN=Server"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly", "C=Canada;CN=Server"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing IceSSL.TrustOnly.Client... " << flush; { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly.Client", "C=US, ST=Florida, O=ZeroC\\, Inc.," - "OU=Ice, emailAddress=info@zeroc.com, CN=Server"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - // Should have no effect. - d["IceSSL.TrustOnly.Client"] = "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com," - "CN=Client"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly.Client", "C=US, ST=Florida, O=ZeroC\\, Inc.," + "OU=Ice, emailAddress=info@zeroc.com, CN=Server"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + // Should have no effect. + d["IceSSL.TrustOnly.Client"] = "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com," + "CN=Client"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - initData.properties->setProperty("IceSSL.TrustOnly.Client", "CN=Client"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const LocalException&) - { - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + initData.properties->setProperty("IceSSL.TrustOnly.Client", "CN=Client"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const LocalException&) + { + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing IceSSL.TrustOnly.Server... " << flush; { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - // Should have no effect. - initData.properties->setProperty("IceSSL.TrustOnly.Server", "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice," - "emailAddress=info@zeroc.com,CN=Client"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly.Server"] = "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com," - "CN=Client"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + // Should have no effect. + initData.properties->setProperty("IceSSL.TrustOnly.Server", "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice," + "emailAddress=info@zeroc.com,CN=Client"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly.Server"] = "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com," + "CN=Client"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly.Server"] = "CN=Server"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const LocalException&) - { - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly.Server"] = "CN=Server"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const LocalException&) + { + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; cout << "testing IceSSL.TrustOnly.Server.<AdapterName>... " << flush; { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly.Server"] = "CN=bogus"; - d["IceSSL.TrustOnly.Server.ServerAdapter"] = - "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com,CN=Client"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - } - catch(const LocalException&) - { - test(false); - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly.Server"] = "CN=bogus"; + d["IceSSL.TrustOnly.Server.ServerAdapter"] = + "C=US, ST=Florida, O=ZeroC\\, Inc., OU=Ice, emailAddress=info@zeroc.com,CN=Client"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + } + catch(const LocalException&) + { + test(false); + } + fact->destroyServer(server); + comm->destroy(); } { InitializationData initData; - initData.properties = createClientProps(defaultDir, defaultHost); - initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); - initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); - initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); - CommunicatorPtr comm = initialize(initData); - IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); - test(plugin); - - Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); - test(fact); - Test::Properties d = createServerProps(defaultDir, defaultHost); - d["IceSSL.CertAuthFile"] = "cacert1.pem"; - d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; - d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; - d["IceSSL.TrustOnly.Server.ServerAdapter"] = "CN=bogus"; - Test::ServerPrx server = fact->createServer(d); - try - { - server->ice_ping(); - test(false); - } - catch(const LocalException&) - { - } - fact->destroyServer(server); - comm->destroy(); + initData.properties = createClientProps(defaultDir, defaultHost); + initData.properties->setProperty("IceSSL.CertAuthFile", "cacert1.pem"); + initData.properties->setProperty("IceSSL.CertFile", "c_rsa_nopass_ca1_pub.pem"); + initData.properties->setProperty("IceSSL.KeyFile", "c_rsa_nopass_ca1_priv.pem"); + CommunicatorPtr comm = initialize(initData); + IceSSL::PluginPtr plugin = IceSSL::PluginPtr::dynamicCast(comm->getPluginManager()->getPlugin("IceSSL")); + test(plugin); + + Test::ServerFactoryPrx fact = Test::ServerFactoryPrx::checkedCast(comm->stringToProxy(factoryRef)); + test(fact); + Test::Properties d = createServerProps(defaultDir, defaultHost); + d["IceSSL.CertAuthFile"] = "cacert1.pem"; + d["IceSSL.CertFile"] = "s_rsa_nopass_ca1_pub.pem"; + d["IceSSL.KeyFile"] = "s_rsa_nopass_ca1_priv.pem"; + d["IceSSL.TrustOnly.Server.ServerAdapter"] = "CN=bogus"; + Test::ServerPrx server = fact->createServer(d); + try + { + server->ice_ping(); + test(false); + } + catch(const LocalException&) + { + } + fact->destroyServer(server); + comm->destroy(); } cout << "ok" << endl; diff --git a/cpp/test/IceSSL/configuration/Client.cpp b/cpp/test/IceSSL/configuration/Client.cpp index 4a60e4a9be4..be76b51b598 100644 --- a/cpp/test/IceSSL/configuration/Client.cpp +++ b/cpp/test/IceSSL/configuration/Client.cpp @@ -16,8 +16,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { if(argc < 2) { - cerr << "Usage: " << argv[0] << " testdir" << endl; - return 1; + cerr << "Usage: " << argv[0] << " testdir" << endl; + return 1; } void allTests(const Ice::CommunicatorPtr&, const string&); @@ -35,26 +35,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceSSL/configuration/Server.cpp b/cpp/test/IceSSL/configuration/Server.cpp index e1e5ef05071..b9978ab4b31 100644 --- a/cpp/test/IceSSL/configuration/Server.cpp +++ b/cpp/test/IceSSL/configuration/Server.cpp @@ -33,26 +33,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceSSL/configuration/TestI.cpp b/cpp/test/IceSSL/configuration/TestI.cpp index 0f3a1b49a3f..dd36b125080 100644 --- a/cpp/test/IceSSL/configuration/TestI.cpp +++ b/cpp/test/IceSSL/configuration/TestI.cpp @@ -26,12 +26,12 @@ ServerI::noCert(const Ice::Current& c) { try { - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(c.con); - test(info.certs.size() == 0); + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(c.con); + test(info.certs.size() == 0); } catch(const IceSSL::ConnectionInvalidException&) { - test(false); + test(false); } } @@ -40,14 +40,14 @@ ServerI::checkCert(const string& subjectDN, const string& issuerDN, const Ice::C { try { - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(c.con); - test(info.certs.size() == 2 && - info.certs[0]->getSubjectDN() == IceSSL::DistinguishedName(subjectDN) && - info.certs[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN)); + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(c.con); + test(info.certs.size() == 2 && + info.certs[0]->getSubjectDN() == IceSSL::DistinguishedName(subjectDN) && + info.certs[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN)); } catch(const IceSSL::ConnectionInvalidException&) { - test(false); + test(false); } } @@ -56,12 +56,12 @@ ServerI::checkCipher(const string& cipher, const Ice::Current& c) { try { - IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(c.con); - test(info.cipher.compare(0, cipher.size(), cipher) == 0); + IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(c.con); + test(info.cipher.compare(0, cipher.size(), cipher) == 0); } catch(const IceSSL::ConnectionInvalidException&) { - test(false); + test(false); } } @@ -78,7 +78,7 @@ ServerFactoryI::createServer(const Test::Properties& props, const Current& curre initData.properties = createProperties(); for(Test::Properties::const_iterator p = props.begin(); p != props.end(); ++p) { - initData.properties->setProperty(p->first, p->second); + initData.properties->setProperty(p->first, p->second); } CommunicatorPtr communicator = initialize(initData); @@ -97,8 +97,8 @@ ServerFactoryI::destroyServer(const Test::ServerPrx& srv, const Ice::Current&) map<Identity, ServerIPtr>::iterator p = _servers.find(srv->ice_getIdentity()); if(p != _servers.end()) { - p->second->destroy(); - _servers.erase(p); + p->second->destroy(); + _servers.erase(p); } } diff --git a/cpp/test/IceStorm/federation/Publisher.cpp b/cpp/test/IceStorm/federation/Publisher.cpp index d9ee2935453..d5273b081be 100644 --- a/cpp/test/IceStorm/federation/Publisher.cpp +++ b/cpp/test/IceStorm/federation/Publisher.cpp @@ -24,52 +24,52 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } TopicPrx fed1; try { - fed1 = manager->retrieve("fed1"); + fed1 = manager->retrieve("fed1"); } catch(const NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; + } TopicPrx fed2; try { - fed2 = manager->retrieve("fed2"); + fed2 = manager->retrieve("fed2"); } catch(const NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; + } TopicPrx fed3; try { - fed3 = manager->retrieve("fed3"); + fed3 = manager->retrieve("fed3"); } catch(const NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; + } EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway()); @@ -82,37 +82,37 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) context["cost"] = "0"; for(i = 0; i < 10; ++i) { - eventFed1->pub("fed1:0", context); + eventFed1->pub("fed1:0", context); } context["cost"] = "10"; for(i = 0; i < 10; ++i) { - eventFed1->pub("fed1:10", context); + eventFed1->pub("fed1:10", context); } context["cost"] = "15"; for(i = 0; i < 10; ++i) { - eventFed1->pub("fed1:15", context); + eventFed1->pub("fed1:15", context); } context["cost"] = "0"; for(i = 0; i < 10; ++i) { - eventFed2->pub("fed2:0", context); + eventFed2->pub("fed2:0", context); } context["cost"] = "5"; for(i = 0; i < 10; ++i) { - eventFed2->pub("fed2:5", context); + eventFed2->pub("fed2:5", context); } context["cost"] = "0"; for(i = 0; i < 10; ++i) { - eventFed3->pub("fed3:0", context); + eventFed3->pub("fed3:0", context); } // @@ -134,26 +134,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index c6c3efc8578..876a09686fe 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -24,19 +24,19 @@ class EventI : public Event public: EventI(const CommunicatorPtr& communicator) : - _communicator(communicator) + _communicator(communicator) { } virtual void pub(const string& data, const Ice::Current&) { - IceUtil::StaticMutex::Lock sync(_countMutex); + IceUtil::StaticMutex::Lock sync(_countMutex); - if(++_count == 30 + 40 + 30) - { - _communicator->shutdown(); - } + if(++_count == 30 + 40 + 30) + { + _communicator->shutdown(); + } } private: @@ -56,11 +56,11 @@ void usage(const char* appName) { cerr << "Usage: " << appName << " [options]\n"; - cerr << - "Options:\n" - "-h, --help Show this message.\n" - "-b Use batch reliability.\n" - ; + cerr << + "Options:\n" + "-h, --help Show this message.\n" + "-b Use batch reliability.\n" + ; } int @@ -71,27 +71,27 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) int idx = 1; while(idx < argc) { - if(strcmp(argv[idx], "-b") == 0) - { + if(strcmp(argv[idx], "-b") == 0) + { batch = true; - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } - else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - else if(argv[idx][0] == '-') - { - cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + else if(argv[idx][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } } PropertiesPtr properties = communicator->getProperties(); @@ -99,16 +99,16 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); @@ -128,15 +128,15 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) IceStorm::QoS qos; if(batch) { - objFed1 = objFed1->ice_batchOneway(); - objFed2 = objFed1->ice_batchOneway(); - objFed3 = objFed1->ice_batchOneway(); + objFed1 = objFed1->ice_batchOneway(); + objFed2 = objFed1->ice_batchOneway(); + objFed3 = objFed1->ice_batchOneway(); } else { - objFed1 = objFed1->ice_oneway(); - objFed2 = objFed1->ice_oneway(); - objFed3 = objFed1->ice_oneway(); + objFed1 = objFed1->ice_oneway(); + objFed2 = objFed1->ice_oneway(); + objFed3 = objFed1->ice_oneway(); } TopicPrx fed1; @@ -151,8 +151,8 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceStorm::NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; } fed1->subscribeAndGetPublisher(qos, objFed1); @@ -176,26 +176,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/federation/run.py b/cpp/test/IceStorm/federation/run.py index eb8998394b5..36f479fb2b3 100755 --- a/cpp/test/IceStorm/federation/run.py +++ b/cpp/test/IceStorm/federation/run.py @@ -53,7 +53,7 @@ def doTest(batch): command = subscriber + batchOptions + TestUtil.clientServerOptions + iceStormReference if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", subscriberPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(subscriberPipe) TestUtil.getAdapterReady(subscriberPipe) @@ -64,7 +64,7 @@ def doTest(batch): # command = publisher + TestUtil.clientOptions + iceStormReference if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", publisherPipe = os.popen(command + " 2>&1") TestUtil.printOutputFromPipe(publisherPipe) diff --git a/cpp/test/IceStorm/federation2/Publisher.cpp b/cpp/test/IceStorm/federation2/Publisher.cpp index 6dc8a216ba9..0b5484f20fe 100644 --- a/cpp/test/IceStorm/federation2/Publisher.cpp +++ b/cpp/test/IceStorm/federation2/Publisher.cpp @@ -24,35 +24,35 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } TopicPrx fed1; try { - fed1 = manager->retrieve("fed1"); + fed1 = manager->retrieve("fed1"); } catch(const NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; + } EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway()); for(int i = 0; i < 10; ++i) { - eventFed1->pub("fed1"); + eventFed1->pub("fed1"); } // @@ -72,26 +72,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/federation2/Subscriber.cpp b/cpp/test/IceStorm/federation2/Subscriber.cpp index 88a4408c54d..2afdc080189 100644 --- a/cpp/test/IceStorm/federation2/Subscriber.cpp +++ b/cpp/test/IceStorm/federation2/Subscriber.cpp @@ -32,19 +32,19 @@ class EventI : public Event public: EventI(const CommunicatorPtr& communicator) : - _communicator(communicator) + _communicator(communicator) { } virtual void pub(const string& data, const Ice::Current&) { - IceUtil::StaticMutex::Lock sync(_countMutex); + IceUtil::StaticMutex::Lock sync(_countMutex); - if(++_count == 10) - { - _communicator->shutdown(); - } + if(++_count == 10) + { + _communicator->shutdown(); + } } private: @@ -64,11 +64,11 @@ void usage(const char* appName) { cerr << "Usage: " << appName << " [options]\n"; - cerr << - "Options:\n" - "-h, --help Show this message.\n" - "-b Use batch reliability.\n" - ; + cerr << + "Options:\n" + "-h, --help Show this message.\n" + "-b Use batch reliability.\n" + ; } int @@ -79,27 +79,27 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) int idx = 1; while(idx < argc) { - if(strcmp(argv[idx], "-b") == 0) - { + if(strcmp(argv[idx], "-b") == 0) + { batch = true; - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } - else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - else if(argv[idx][0] == '-') - { - cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + else if(argv[idx][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } } PropertiesPtr properties = communicator->getProperties(); @@ -107,16 +107,16 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); @@ -132,11 +132,11 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) IceStorm::QoS qos; if(batch) { - obj = obj->ice_batchOneway(); + obj = obj->ice_batchOneway(); } else { - obj = obj->ice_oneway(); + obj = obj->ice_oneway(); } TopicPrx fed1; @@ -147,8 +147,8 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceStorm::NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; } fed1->subscribeAndGetPublisher(qos, obj); @@ -168,26 +168,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/federation2/run.py b/cpp/test/IceStorm/federation2/run.py index 2d5ba98bebb..36d520fb274 100755 --- a/cpp/test/IceStorm/federation2/run.py +++ b/cpp/test/IceStorm/federation2/run.py @@ -35,8 +35,8 @@ iceStormService = " --IceBox.Service.IceStorm=IceStormService," + TestUtil.getIc ' --Ice.OA.IceStorm.TopicManager.Endpoints="default -p 12011"' + \ ' --Ice.OA.IceStorm.Publish.Endpoints="default -p 12012"' + \ ' --IceStorm.InstanceName=TestIceStorm1 ' + \ - ' --IceStorm.Discard.Interval=2' + \ - ' --IceBox.PrintServicesReady=IceStorm' + \ + ' --IceStorm.Discard.Interval=2' + \ + ' --IceBox.PrintServicesReady=IceStorm' + \ " --IceBox.InheritContainerProperties=1" iceStormReference = ' --IceStorm.TopicManager.Proxy="TestIceStorm1/TopicManager: default -p 12011"' @@ -46,8 +46,8 @@ iceStormService2 = " --IceBox.Service.IceStorm=IceStormService," + TestUtil.getI ' --Ice.OA.IceStorm.TopicManager.Endpoints="default -p 12021"' + \ ' --Ice.OA.IceStorm.Publish.Endpoints="default -p 12022"' + \ ' --IceStorm.InstanceName=TestIceStorm2 ' + \ - ' --IceStorm.Discard.Interval=2' + \ - ' --IceBox.PrintServicesReady=IceStorm' + \ + ' --IceStorm.Discard.Interval=2' + \ + ' --IceBox.PrintServicesReady=IceStorm' + \ " --IceBox.InheritContainerProperties=1" iceStormReference2 = ' --IceStorm.TopicManager.Proxy="TestIceStorm2/TopicManager: default -p 12021"' @@ -70,11 +70,11 @@ def doTest(batch, subscriberRef = None): batchOptions = "" if subscriberRef == None: - subscriberRef = iceStormReference2 + subscriberRef = iceStormReference2 command = subscriber + batchOptions + TestUtil.clientServerOptions + subscriberRef if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", subscriberPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(subscriberPipe) TestUtil.getAdapterReady(subscriberPipe) @@ -85,7 +85,7 @@ def doTest(batch, subscriberRef = None): # command = publisher + TestUtil.clientOptions + iceStormReference if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", publisherPipe = os.popen(command + " 2>&1") TestUtil.printOutputFromPipe(publisherPipe) @@ -105,13 +105,13 @@ def startServers(): global iceStormDBEnv2 command = iceBox + TestUtil.clientServerOptions + iceBoxEndpoints + iceStormService + iceStormDBEnv if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", iceBoxPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceBoxPipe) TestUtil.waitServiceReady(iceBoxPipe, "IceStorm") command = iceBox + TestUtil.clientServerOptions + iceBoxEndpoints2 + iceStormService2 + iceStormDBEnv2 if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", iceBoxPipe2 = os.popen(command + " 2>&1") TestUtil.getServerPid(iceBoxPipe2) TestUtil.waitServiceReady(iceBoxPipe2, "IceStorm") @@ -125,21 +125,21 @@ def stopServers(p1, p2 = None): global iceBoxEndpoints2 command = iceBoxAdmin + TestUtil.clientOptions + iceBoxEndpoints + r' shutdown' if TestUtil.debug: - print "(" + command + ")", + print "(" + command + ")", pipe = os.popen(command + " 2>&1") status = TestUtil.closePipe(pipe) if status or TestUtil.specificServerStatus(p1): - TestUtil.killServers() - sys.exit(1) + TestUtil.killServers() + sys.exit(1) if p2: - command = iceBoxAdmin + TestUtil.clientOptions + iceBoxEndpoints2 + r' shutdown' - if TestUtil.debug: - print "(" + command + ")", - pipe = os.popen(command + " 2>&1") - status = TestUtil.closePipe(pipe) - if status or TestUtil.specificServerStatus(p2): - TestUtil.killServers() - sys.exit(1) + command = iceBoxAdmin + TestUtil.clientOptions + iceBoxEndpoints2 + r' shutdown' + if TestUtil.debug: + print "(" + command + ")", + pipe = os.popen(command + " 2>&1") + status = TestUtil.closePipe(pipe) + if status or TestUtil.specificServerStatus(p2): + TestUtil.killServers() + sys.exit(1) dbHome = os.path.join(testdir, "db") TestUtil.cleanDbDir(dbHome) @@ -241,9 +241,9 @@ stopServers(iceBoxPipe1, iceBoxPipe2) # class ExpectorThread(threading.Thread): def __init__(self, pipe): - self.mutex = threading.Lock() + self.mutex = threading.Lock() self.pipe = pipe - # Suppress "adapter ready" messages. Under windows the eol isn't \n. + # Suppress "adapter ready" messages. Under windows the eol isn't \n. self.re = [ [ re.compile(" ready\r?\n$"), 0 ] ] threading.Thread.__init__(self) @@ -252,41 +252,41 @@ class ExpectorThread(threading.Thread): while 1: line = self.pipe.readline() if not line: break - found = False; - self.mutex.acquire() - for item in self.re: - if item[0].search(line): - found = True - item[1] = item[1] + 1 - break - self.mutex.release() - if not found: - print line, + found = False; + self.mutex.acquire() + for item in self.re: + if item[0].search(line): + found = True + item[1] = item[1] + 1 + break + self.mutex.release() + if not found: + print line, except IOError: pass - self.status = TestUtil.closePipe(self.pipe) + self.status = TestUtil.closePipe(self.pipe) # To comply with the ReaderThread protocol. def getPipe(self): - return self.pipe + return self.pipe # To comply with the ReaderThread protocol. def getStatus(self): - return self.status + return self.status def matches(self, index): - self.mutex.acquire() - m = self.re[index][1] - self.mutex.release() - return m + self.mutex.acquire() + m = self.re[index][1] + self.mutex.release() + return m def expect(self, r): - self.mutex.acquire() - self.re.append([r, 0]) - l = len(self.re)-1 - self.mutex.release() - return l + self.mutex.acquire() + self.re.append([r, 0]) + l = len(self.re)-1 + self.mutex.release() + return l # # Test #3: @@ -430,8 +430,8 @@ iceStormAdminPipe = os.popen(command + " 2>&1") line = iceStormAdminPipe.readline() try: if line and len(line) > 0: - TestUtil.killServers() - sys.exit(1) + TestUtil.killServers() + sys.exit(1) except IOError: pass iceStormAdminStatus = TestUtil.closePipe(iceStormAdminPipe) diff --git a/cpp/test/IceStorm/single/Publisher.cpp b/cpp/test/IceStorm/single/Publisher.cpp index 0dab4de5ffd..454973b1d05 100644 --- a/cpp/test/IceStorm/single/Publisher.cpp +++ b/cpp/test/IceStorm/single/Publisher.cpp @@ -24,28 +24,28 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( - communicator->stringToProxy(managerProxy)); + communicator->stringToProxy(managerProxy)); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } TopicPrx topic; try { - topic = manager->retrieve("single"); + topic = manager->retrieve("single"); } catch(const NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; + } assert(topic); @@ -56,7 +56,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway()); for(int i = 0; i < 1000; ++i) { - single->event(i); + single->event(i); } return EXIT_SUCCESS; @@ -70,26 +70,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index b1857119707..88d28a4e21e 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -23,10 +23,10 @@ class SingleI : public Single, public IceUtil::Monitor<IceUtil::Mutex> public: SingleI(const CommunicatorPtr& communicator, const string& name) : - _communicator(communicator), - _name(name), - _count(0), - _last(0) + _communicator(communicator), + _name(name), + _count(0), + _last(0) { } @@ -34,64 +34,64 @@ public: event(int i, const Current& current) { - if((_name == "default" || _name == "oneway" || _name == "batch" || _name == "datagram" || - _name == "batch datagram") && current.requestId != 0) - { - cerr << endl << "expected oneway request"; - test(false); - } - else if((_name == "twoway" || _name == "twoway ordered") && current.requestId == 0) - { - cerr << endl << "expected twoway request"; - } - if(_name == "twoway ordered" && i != _last) - { - cerr << endl << "received unordered event for `" << _name << "': " << i << " " << _last; - test(false); - } - if((_name == "datagram" || _name == "batch datagram") && current.con->type() != "udp") - { - cerr << endl << "expected datagram to be received over udp"; - test(false); - } - Lock sync(*this); - ++_last; - if(++_count == 1000) - { - notify(); - } + if((_name == "default" || _name == "oneway" || _name == "batch" || _name == "datagram" || + _name == "batch datagram") && current.requestId != 0) + { + cerr << endl << "expected oneway request"; + test(false); + } + else if((_name == "twoway" || _name == "twoway ordered") && current.requestId == 0) + { + cerr << endl << "expected twoway request"; + } + if(_name == "twoway ordered" && i != _last) + { + cerr << endl << "received unordered event for `" << _name << "': " << i << " " << _last; + test(false); + } + if((_name == "datagram" || _name == "batch datagram") && current.con->type() != "udp") + { + cerr << endl << "expected datagram to be received over udp"; + test(false); + } + Lock sync(*this); + ++_last; + if(++_count == 1000) + { + notify(); + } } virtual void waitForEvents() { - Lock sync(*this); - cout << "testing " << _name << " reliability... " << flush; - bool datagram = _name == "datagram" || _name == "batch datagram"; - IceUtil::Time timeout = (datagram) ? IceUtil::Time::seconds(5) : IceUtil::Time::seconds(20); - while(_count < 1000) - { - if(!timedWait(timeout)) - { - if(datagram && _count > 0) - { - if(_count < 100) - { - cout << "[" << _count << "/1000: This may be an error!!]"; - } - else - { - cout << "[" << _count << "/1000] "; - } - break; - } - else - { - test(false); - } - } - } - cout << "ok" << endl; + Lock sync(*this); + cout << "testing " << _name << " reliability... " << flush; + bool datagram = _name == "datagram" || _name == "batch datagram"; + IceUtil::Time timeout = (datagram) ? IceUtil::Time::seconds(5) : IceUtil::Time::seconds(20); + while(_count < 1000) + { + if(!timedWait(timeout)) + { + if(datagram && _count > 0) + { + if(_count < 100) + { + cout << "[" << _count << "/1000: This may be an error!!]"; + } + else + { + cout << "[" << _count << "/1000] "; + } + break; + } + else + { + test(false); + } + } + } + cout << "ok" << endl; } private: @@ -112,16 +112,16 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:udp"); @@ -133,8 +133,8 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceStorm::NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; } // @@ -145,84 +145,84 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) // First we use the old deprecated API. // { - subscribers.push_back(new SingleI(communicator, "default")); - topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "default")); + topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "oneway")); - IceStorm::QoS qos; - qos["reliability"] = "oneway"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "oneway")); + IceStorm::QoS qos; + qos["reliability"] = "oneway"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "twoway")); - IceStorm::QoS qos; - qos["reliability"] = "twoway"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway")); + IceStorm::QoS qos; + qos["reliability"] = "twoway"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "batch")); - IceStorm::QoS qos; - qos["reliability"] = "batch"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "batch")); + IceStorm::QoS qos; + qos["reliability"] = "batch"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered - IceStorm::QoS qos; - qos["reliability"] = "twoway ordered"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered + IceStorm::QoS qos; + qos["reliability"] = "twoway ordered"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "datagram")); - IceStorm::QoS qos; - qos["reliability"] = "oneway"; - topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); + subscribers.push_back(new SingleI(communicator, "datagram")); + IceStorm::QoS qos; + qos["reliability"] = "oneway"; + topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); } { - subscribers.push_back(new SingleI(communicator, "batch datagram")); - IceStorm::QoS qos; - qos["reliability"] = "batch"; - topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); + subscribers.push_back(new SingleI(communicator, "batch datagram")); + IceStorm::QoS qos; + qos["reliability"] = "batch"; + topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); } // // Next we use the new API call with the new proxy semantics. // { - subscribers.push_back(new SingleI(communicator, "default")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); + subscribers.push_back(new SingleI(communicator, "default")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); } { - subscribers.push_back(new SingleI(communicator, "oneway")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); + subscribers.push_back(new SingleI(communicator, "oneway")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); } { - subscribers.push_back(new SingleI(communicator, "twoway")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "batch")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchOneway()); + subscribers.push_back(new SingleI(communicator, "batch")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchOneway()); } { - subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered - IceStorm::QoS qos; - qos["reliability"] = "ordered"; - topic->subscribeAndGetPublisher(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered + IceStorm::QoS qos; + qos["reliability"] = "ordered"; + topic->subscribeAndGetPublisher(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "datagram")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); + subscribers.push_back(new SingleI(communicator, "datagram")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); } { - subscribers.push_back(new SingleI(communicator, "batch datagram")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchDatagram()); + subscribers.push_back(new SingleI(communicator, "batch datagram")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchDatagram()); } adapter->activate(); for(vector<SingleIPtr>::const_iterator p = subscribers.begin(); p != subscribers.end(); ++p) { - (*p)->waitForEvents(); + (*p)->waitForEvents(); } return EXIT_SUCCESS; @@ -236,26 +236,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/stress/Publisher.cpp b/cpp/test/IceStorm/stress/Publisher.cpp index ad0fb64ed85..0be735c52c6 100644 --- a/cpp/test/IceStorm/stress/Publisher.cpp +++ b/cpp/test/IceStorm/stress/Publisher.cpp @@ -30,20 +30,20 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceUtil::BadOptException& e) { - cerr << argv[0] << ": " << e.reason << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": " << e.reason << endl; + return EXIT_FAILURE; } int events = 1000; string s = opts.optArg("events"); if(!s.empty()) { - events = atoi(s.c_str()); + events = atoi(s.c_str()); } if(events <= 0) { - cerr << argv[0] << ": events must be > 0." << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": events must be > 0." << endl; + return EXIT_FAILURE; } bool oneway = opts.isSet("oneway"); @@ -53,53 +53,53 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( - communicator->stringToProxy(managerProxy)); + communicator->stringToProxy(managerProxy)); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } TopicPrx topic; try { - topic = manager->retrieve("fed1"); + topic = manager->retrieve("fed1"); } catch(const NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; + } EventPrx twowayProxy = EventPrx::uncheckedCast(topic->getPublisher()->ice_twoway()); EventPrx proxy; if(oneway) { - proxy = EventPrx::uncheckedCast(twowayProxy->ice_oneway()); + proxy = EventPrx::uncheckedCast(twowayProxy->ice_oneway()); } else { - proxy = twowayProxy; + proxy = twowayProxy; } for(int i = 0; i < events; ++i) { - proxy->pub(i); + proxy->pub(i); } if(oneway) { - // - // Before we exit, we ping all proxies as twoway, to make sure - // that all oneways are delivered. - // - twowayProxy->ice_ping(); + // + // Before we exit, we ping all proxies as twoway, to make sure + // that all oneways are delivered. + // + twowayProxy->ice_ping(); } return EXIT_SUCCESS; @@ -113,26 +113,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index 0a10931b223..01590e4702f 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -28,14 +28,14 @@ class EventI : public Event, public IceUtil::Mutex public: EventI(const CommunicatorPtr& communicator, int total) : - _communicator(communicator), _total(total), _count(0) + _communicator(communicator), _total(total), _count(0) { } int count() const { - Lock sync(*this); - return _count; + Lock sync(*this); + return _count; } protected: @@ -51,24 +51,24 @@ class OrderEventI : public EventI public: OrderEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total) + EventI(communicator, total) { } virtual void pub(int counter, const Ice::Current&) { - Lock sync(*this); - - if(counter != _count || counter == _total-1) - { - if(counter != _count) - { - cerr << "failed! expected event: " << _count << " received event: " << counter << endl; - } - _communicator->shutdown(); - } - _count++; + Lock sync(*this); + + if(counter != _count || counter == _total-1) + { + if(counter != _count) + { + cerr << "failed! expected event: " << _count << " received event: " << counter << endl; + } + _communicator->shutdown(); + } + _count++; } }; @@ -77,19 +77,19 @@ class CountEventI : public EventI public: CountEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total) + EventI(communicator, total) { } virtual void pub(int, const Ice::Current&) { - Lock sync(*this); + Lock sync(*this); - if(++_count == _total) - { - _communicator->shutdown(); - } + if(++_count == _total) + { + _communicator->shutdown(); + } } }; @@ -98,28 +98,28 @@ class SlowEventI : public EventI public: SlowEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total) + EventI(communicator, total) { } virtual void pub(int, const Ice::Current&) { - Lock sync(*this); - - // - // Ignore events over and above the expected. - // - if(_count >= _total) - { - return; - } - // Sleep for 3 seconds - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(3)); - if(++_count == _total) - { - _communicator->shutdown(); - } + Lock sync(*this); + + // + // Ignore events over and above the expected. + // + if(_count >= _total) + { + return; + } + // Sleep for 3 seconds + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(3)); + if(++_count == _total) + { + _communicator->shutdown(); + } } }; @@ -128,32 +128,32 @@ class ErraticEventI : public EventI public: ErraticEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total), _done(false) + EventI(communicator, total), _done(false) { - IceUtil::StaticMutex::Lock sync(_remainingMutex); - ++_remaining; + IceUtil::StaticMutex::Lock sync(_remainingMutex); + ++_remaining; } virtual void pub(int, const Ice::Current& current) { - Lock sync(*this); - - // Randomly close the connection. - if(!_done && (IceUtil::random(10) == 1 || ++_count == _total)) - { - _done = true; - current.con->close(true); - _count = _total; - { - IceUtil::StaticMutex::Lock sync(_remainingMutex); - --_remaining; - if(_remaining == 0) - { - _communicator->shutdown(); - } - } - } + Lock sync(*this); + + // Randomly close the connection. + if(!_done && (IceUtil::random(10) == 1 || ++_count == _total)) + { + _done = true; + current.con->close(true); + _count = _total; + { + IceUtil::StaticMutex::Lock sync(_remainingMutex); + --_remaining; + if(_remaining == 0) + { + _communicator->shutdown(); + } + } + } } private: @@ -189,20 +189,20 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceUtil::BadOptException& e) { - cerr << argv[0] << ": " << e.reason << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": " << e.reason << endl; + return EXIT_FAILURE; } int events = 1000; string s = opts.optArg("events"); if(!s.empty()) { - events = atoi(s.c_str()); + events = atoi(s.c_str()); } if(events <= 0) { - cerr << argv[0] << ": events must be > 0." << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": events must be > 0." << endl; + return EXIT_FAILURE; } IceStorm::QoS qos; @@ -210,13 +210,13 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) vector<string> sqos = opts.argVec("qos"); for(vector<string>::const_iterator q = sqos.begin(); q != sqos.end(); ++q) { - string::size_type off = q->find(","); - if(off == string::npos) - { - cerr << argv[0] << ": parse error: no , in QoS" << endl; - return EXIT_FAILURE; - } - qos[q->substr(0, off)] = q->substr(off+1); + string::size_type off = q->find(","); + if(off == string::npos) + { + cerr << argv[0] << ": parse error: no , in QoS" << endl; + return EXIT_FAILURE; + } + qos[q->substr(0, off)] = q->substr(off+1); } bool slow = opts.isSet("slow"); @@ -225,13 +225,13 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) s = opts.optArg("erratic"); if(!s.empty()) { - erratic = true; - erraticNum = atoi(s.c_str()); + erratic = true; + erraticNum = atoi(s.c_str()); } if(events <= 0) { - cerr << argv[0] << ": events must be > 0." << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": events must be > 0." << endl; + return EXIT_FAILURE; } PropertiesPtr properties = communicator->getProperties(); @@ -239,16 +239,16 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( - communicator->stringToProxy(managerProxy)); + communicator->stringToProxy(managerProxy)); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } vector<Subscription> subs; @@ -259,40 +259,40 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) EventIPtr servant; if(erratic) { - for(int i = 0 ; i< erraticNum; ++i) - { - ostringstream os; - os << "SubscriberAdapter" << i; - Subscription item; - item.adapter = communicator->createObjectAdapterWithEndpoints(os.str(), "default"); - item.servant = new ErraticEventI(communicator, events); - item.qos["reliability"] = "twoway"; - subs.push_back(item); - } + for(int i = 0 ; i< erraticNum; ++i) + { + ostringstream os; + os << "SubscriberAdapter" << i; + Subscription item; + item.adapter = communicator->createObjectAdapterWithEndpoints(os.str(), "default"); + item.servant = new ErraticEventI(communicator, events); + item.qos["reliability"] = "twoway"; + subs.push_back(item); + } } else if(slow) { - servant = new SlowEventI(communicator, events); + servant = new SlowEventI(communicator, events); } else { - map<string, string>::iterator p = qos.find("reliability"); - if(p != qos.end()) - { - reliability = p->second; - if(reliability != "ordered") - { - qos.erase(p); - } - } - if(reliability == "ordered") - { - servant = new OrderEventI(communicator, events); - } - else - { - servant = new CountEventI(communicator, events); - } + map<string, string>::iterator p = qos.find("reliability"); + if(p != qos.end()) + { + reliability = p->second; + if(reliability != "ordered") + { + qos.erase(p); + } + } + if(reliability == "ordered") + { + servant = new OrderEventI(communicator, events); + } + else + { + servant = new CountEventI(communicator, events); + } } // @@ -300,11 +300,11 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) // if(subs.empty()) { - Subscription item; - item.adapter = adapter; - item.servant = servant; - item.qos = qos; - subs.push_back(item); + Subscription item; + item.adapter = adapter; + item.servant = servant; + item.qos = qos; + subs.push_back(item); } TopicPrx topic; @@ -314,43 +314,43 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceStorm::NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; } { - for(vector<Subscription>::iterator p = subs.begin(); p != subs.end(); ++p) - { - p->obj = p->adapter->addWithUUID(p->servant); - if(reliability == "twoway" || reliability == "ordered") - { - // Do nothing. - } - else if(reliability == "batch") - { - p->obj = p->obj->ice_batchOneway(); - } - else //if(reliability == "oneway") - { - p->obj = p->obj->ice_oneway(); - } - p->adapter->activate(); - topic->subscribeAndGetPublisher(qos, p->obj); - } + for(vector<Subscription>::iterator p = subs.begin(); p != subs.end(); ++p) + { + p->obj = p->adapter->addWithUUID(p->servant); + if(reliability == "twoway" || reliability == "ordered") + { + // Do nothing. + } + else if(reliability == "batch") + { + p->obj = p->obj->ice_batchOneway(); + } + else //if(reliability == "oneway") + { + p->obj = p->obj->ice_oneway(); + } + p->adapter->activate(); + topic->subscribeAndGetPublisher(qos, p->obj); + } } communicator->waitForShutdown(); { - for(vector<Subscription>::const_iterator p = subs.begin(); p != subs.end(); ++p) - { - topic->unsubscribe(p->obj); - if(p->servant->count() != events) - { - cerr << "expected " << events << " events but got " << p->servant->count() << " events." << endl; - return EXIT_FAILURE; - } - } + for(vector<Subscription>::const_iterator p = subs.begin(); p != subs.end(); ++p) + { + topic->unsubscribe(p->obj); + if(p->servant->count() != events) + { + cerr << "expected " << events << " events but got " << p->servant->count() << " events." << endl; + return EXIT_FAILURE; + } + } } return EXIT_SUCCESS; @@ -364,26 +364,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceStorm/stress/run.py b/cpp/test/IceStorm/stress/run.py index 7fc3b952ac0..0bf39f16d9c 100755 --- a/cpp/test/IceStorm/stress/run.py +++ b/cpp/test/IceStorm/stress/run.py @@ -35,8 +35,8 @@ iceStormService = " --IceBox.Service.IceStorm=IceStormService," + TestUtil.getIc ' --Ice.OA.IceStorm.TopicManager.Endpoints="default -p 12011"' + \ ' --Ice.OA.IceStorm.Publish.Endpoints="default -p 12012"' + \ ' --IceStorm.InstanceName=TestIceStorm1 ' + \ - ' --IceStorm.Discard.Interval=2' + \ - ' --IceBox.PrintServicesReady=IceStorm' + \ + ' --IceStorm.Discard.Interval=2' + \ + ' --IceBox.PrintServicesReady=IceStorm' + \ " --IceBox.InheritContainerProperties=1" iceStormReference = ' --IceStorm.TopicManager.Proxy="TestIceStorm1/TopicManager: default -p 12011"' @@ -46,8 +46,8 @@ iceStormService2 = " --IceBox.Service.IceStorm=IceStormService," + TestUtil.getI ' --Ice.OA.IceStorm.TopicManager.Endpoints="default -p 12021"' + \ ' --Ice.OA.IceStorm.Publish.Endpoints="default -p 12022"' + \ ' --IceStorm.InstanceName=TestIceStorm2 ' + \ - ' --IceStorm.Discard.Interval=2' + \ - ' --IceBox.PrintServicesReady=IceStorm' + \ + ' --IceStorm.Discard.Interval=2' + \ + ' --IceBox.PrintServicesReady=IceStorm' + \ " --IceBox.InheritContainerProperties=1" iceStormReference2 = ' --IceStorm.TopicManager.Proxy="TestIceStorm2/TopicManager: default -p 12021"' @@ -64,39 +64,39 @@ def doTest(subOpts, pubOpts): subscriberPipes = [] if type(subOpts) != type([]): - subOpts = [ subOpts ] + subOpts = [ subOpts ] for opts in subOpts: - command = subscriber + TestUtil.clientServerOptions + r' ' + opts - if TestUtil.debug: - print "(" + command + ")", - sys.stdout.flush() - pipe = os.popen(command + " 2>&1") - TestUtil.getServerPid(pipe) - TestUtil.getAdapterReady(pipe) - subscriberPipes.append(pipe) + command = subscriber + TestUtil.clientServerOptions + r' ' + opts + if TestUtil.debug: + print "(" + command + ")", + sys.stdout.flush() + pipe = os.popen(command + " 2>&1") + TestUtil.getServerPid(pipe) + TestUtil.getAdapterReady(pipe) + subscriberPipes.append(pipe) command = publisher + TestUtil.clientOptions + iceStormReference + r' ' + pubOpts if TestUtil.debug: - print "(" + command + ")", - sys.stdout.flush() + print "(" + command + ")", + sys.stdout.flush() publisherPipe = os.popen(command + " 2>&1") TestUtil.printOutputFromPipe(publisherPipe) publisherStatus = TestUtil.closePipe(publisherPipe) if publisherStatus: - print "(publisher failed)", - return publisherStatus + print "(publisher failed)", + return publisherStatus for p in subscriberPipes: - try: - sys.stdout.flush() - subscriberStatus = TestUtil.specificServerStatus(p, 30) - except: - print "(subscriber failed)", - return 1 - if subscriberStatus: - print "(subscriber failed)", - return subscriberStatus + try: + sys.stdout.flush() + subscriberStatus = TestUtil.specificServerStatus(p, 30) + except: + print "(subscriber failed)", + return 1 + if subscriberStatus: + print "(subscriber failed)", + return subscriberStatus return 0 @@ -113,15 +113,15 @@ def startServers(): # Clear the idle timeout otherwise the IceBox ThreadPool will timeout. command = iceBox + TestUtil.clientServerOptions + iceBoxEndpoints + iceStormService + iceStormDBEnv + ' --Ice.ServerIdleTime=0' if TestUtil.debug: - print "(" + command + ")", - sys.stdout.flush() + print "(" + command + ")", + sys.stdout.flush() iceBoxPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceBoxPipe) TestUtil.waitServiceReady(iceBoxPipe, "IceStorm") command = iceBox + TestUtil.clientServerOptions + iceBoxEndpoints2 + iceStormService2 + iceStormDBEnv2 + ' --Ice.ServerIdleTime=0' if TestUtil.debug: - print "(" + command + ")", - sys.stdout.flush() + print "(" + command + ")", + sys.stdout.flush() iceBoxPipe2 = os.popen(command + " 2>&1") TestUtil.getServerPid(iceBoxPipe2) TestUtil.waitServiceReady(iceBoxPipe2, "IceStorm") @@ -138,23 +138,23 @@ def stopServers(p1, p2 = None): sys.stdout.flush() command = iceBoxAdmin + TestUtil.clientOptions + iceBoxEndpoints + r' shutdown' if TestUtil.debug: - print "(" + command + ")", - sys.stdout.flush() + print "(" + command + ")", + sys.stdout.flush() pipe = os.popen(command + " 2>&1") status = TestUtil.closePipe(pipe) if status or TestUtil.specificServerStatus(p1): - TestUtil.killServers() - sys.exit(1) + TestUtil.killServers() + sys.exit(1) if p2: - command = iceBoxAdmin + TestUtil.clientOptions + iceBoxEndpoints2 + r' shutdown' - if TestUtil.debug: - print "(" + command + ")", - sys.stdout.flush() - pipe = os.popen(command + " 2>&1") - status = TestUtil.closePipe(pipe) - if status or TestUtil.specificServerStatus(p2): - TestUtil.killServers() - sys.exit(1) + command = iceBoxAdmin + TestUtil.clientOptions + iceBoxEndpoints2 + r' shutdown' + if TestUtil.debug: + print "(" + command + ")", + sys.stdout.flush() + pipe = os.popen(command + " 2>&1") + status = TestUtil.closePipe(pipe) + if status or TestUtil.specificServerStatus(p2): + TestUtil.killServers() + sys.exit(1) print "ok" dbHome = os.path.join(testdir, "db") @@ -271,8 +271,8 @@ print "ok" print "Sending 20000 unordered events with erratic subscriber across a link... ", status = doTest(['--erratic 10 --events 20000' + iceStormReference, '--events 20000 ' + iceStormReference, \ - '--erratic 10 --events 20000' + iceStormReference2, '--events 20000 ' + iceStormReference2], \ - '--events 20000 --oneway') + '--erratic 10 --events 20000' + iceStormReference2, '--events 20000 ' + iceStormReference2], \ + '--events 20000 --oneway') if status: print "failed!" TestUtil.killServers() diff --git a/cpp/test/IceUtil/ctrlCHandler/Client.cpp b/cpp/test/IceUtil/ctrlCHandler/Client.cpp index 7f838b69eee..a71a95dba6c 100644 --- a/cpp/test/IceUtil/ctrlCHandler/Client.cpp +++ b/cpp/test/IceUtil/ctrlCHandler/Client.cpp @@ -23,13 +23,13 @@ void callback(int signal) int main() { { - cout << "First ignore CTRL+C and the like for 10 seconds (try it!)" << endl; - CtrlCHandler handler; - ThreadControl::sleep(Time::seconds(10)); - - cout << "Then handling them for another 30 seconds (try it)" << endl; - handler.setCallback(callback); - ThreadControl::sleep(Time::seconds(10)); + cout << "First ignore CTRL+C and the like for 10 seconds (try it!)" << endl; + CtrlCHandler handler; + ThreadControl::sleep(Time::seconds(10)); + + cout << "Then handling them for another 30 seconds (try it)" << endl; + handler.setCallback(callback); + ThreadControl::sleep(Time::seconds(10)); } cout << "And another 10 seconds after ~CtrlCHandler" << endl; ThreadControl::sleep(Time::seconds(10)); diff --git a/cpp/test/IceUtil/inputUtil/Client.cpp b/cpp/test/IceUtil/inputUtil/Client.cpp index 0bec2c0317e..5a7ef96bc28 100644 --- a/cpp/test/IceUtil/inputUtil/Client.cpp +++ b/cpp/test/IceUtil/inputUtil/Client.cpp @@ -178,14 +178,14 @@ main(int, char**) badQuoteCommands.push_back("-Dir=$'test"); for(vector<string>::const_iterator p = badQuoteCommands.begin(); p != badQuoteCommands.end(); ++p) { - try - { - IceUtil::Options::split(*p); - test(false); - } - catch(const IceUtil::BadOptException&) - { - } + try + { + IceUtil::Options::split(*p); + test(false); + } + catch(const IceUtil::BadOptException&) + { + } } cout << "ok" << endl; diff --git a/cpp/test/IceUtil/thread/AliveTest.cpp b/cpp/test/IceUtil/thread/AliveTest.cpp index efb8ed26c6b..e1c526d2b54 100644 --- a/cpp/test/IceUtil/thread/AliveTest.cpp +++ b/cpp/test/IceUtil/thread/AliveTest.cpp @@ -21,24 +21,24 @@ class CondVar : public IceUtil::Monitor<IceUtil::RecMutex> public: CondVar() : - _done(false) + _done(false) { } void waitForSignal() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock lock(*this); - while(!_done) - { - wait(); - } + IceUtil::Monitor<IceUtil::RecMutex>::Lock lock(*this); + while(!_done) + { + wait(); + } } void signal() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock lock(*this); - _done = true; - notify(); + IceUtil::Monitor<IceUtil::RecMutex>::Lock lock(*this); + _done = true; + notify(); } private: @@ -51,20 +51,20 @@ class AliveTestThread : public Thread public: AliveTestThread(CondVar& childCreated, CondVar& parentReady) : - _childCreated(childCreated), _parentReady(parentReady) + _childCreated(childCreated), _parentReady(parentReady) { } virtual void run() { - try - { - _childCreated.signal(); - _parentReady.waitForSignal(); - } - catch(IceUtil::ThreadLockedException &) - { - } + try + { + _childCreated.signal(); + _parentReady.waitForSignal(); + } + catch(IceUtil::ThreadLockedException &) + { + } } private: diff --git a/cpp/test/IceUtil/thread/Client.cpp b/cpp/test/IceUtil/thread/Client.cpp index da04fabc81a..bea92fa446f 100644 --- a/cpp/test/IceUtil/thread/Client.cpp +++ b/cpp/test/IceUtil/thread/Client.cpp @@ -21,17 +21,17 @@ main(int argc, char** argv) { try { - initializeTestSuite(); + initializeTestSuite(); - for(list<TestBasePtr>::const_iterator p = allTests.begin(); p != allTests.end(); ++p) - { - (*p)->start(); - } + for(list<TestBasePtr>::const_iterator p = allTests.begin(); p != allTests.end(); ++p) + { + (*p)->start(); + } } catch(const TestFailed& e) { - cout << "test " << e.name << " failed" << endl; - return EXIT_FAILURE; + cout << "test " << e.name << " failed" << endl; + return EXIT_FAILURE; } return EXIT_SUCCESS; } diff --git a/cpp/test/IceUtil/thread/CountDownLatchTest.cpp b/cpp/test/IceUtil/thread/CountDownLatchTest.cpp index ea30c1aa721..3a26c9349cd 100644 --- a/cpp/test/IceUtil/thread/CountDownLatchTest.cpp +++ b/cpp/test/IceUtil/thread/CountDownLatchTest.cpp @@ -24,28 +24,28 @@ class CountDownLatchTestThread : public Thread public: CountDownLatchTestThread(CountDownLatch& latch, int& val, bool takeOne) : - _latch(latch), - _val(val), - _takeOne(takeOne) + _latch(latch), + _val(val), + _takeOne(takeOne) { } virtual void run() { - if(_takeOne) - { - _latch.countDown(); - } - - if(_latch.getCount() == 0) - { - test(_val == magic); - } - - _latch.await(); - test(_latch.getCount() == 0); - test(_val == magic); + if(_takeOne) + { + _latch.countDown(); + } + + if(_latch.getCount() == 0) + { + test(_val == magic); + } + + _latch.await(); + test(_latch.getCount() == 0); + test(_val == magic); } private: @@ -76,8 +76,8 @@ CountDownLatchTest::run() ThreadPtr t1[wave1Count]; for(i = 0; i < wave1Count; i++) { - t1[i] = new CountDownLatchTestThread(latch, val, false); - t1[i]->start(); + t1[i] = new CountDownLatchTestThread(latch, val, false); + t1[i]->start(); } // @@ -92,8 +92,8 @@ CountDownLatchTest::run() ThreadPtr t2[fullCount - 1]; for(i = 0; i < fullCount - 1; i++) { - t2[i] = new CountDownLatchTestThread(latch, val, true); - t2[i]->start(); + t2[i] = new CountDownLatchTestThread(latch, val, true); + t2[i]->start(); } // @@ -101,17 +101,17 @@ CountDownLatchTest::run() // do { - ThreadControl::sleep(Time::milliSeconds(100)); - - for(i = 0; i < wave1Count; i++) - { - test(t1[i]->isAlive()); - } - - for(i = 0; i < fullCount - 1; i++) - { - test(t2[i]->isAlive()); - } + ThreadControl::sleep(Time::milliSeconds(100)); + + for(i = 0; i < wave1Count; i++) + { + test(t1[i]->isAlive()); + } + + for(i = 0; i < fullCount - 1; i++) + { + test(t2[i]->isAlive()); + } } while(latch.getCount() > 1); @@ -127,12 +127,12 @@ CountDownLatchTest::run() // for(i = 0; i < wave1Count; i++) { - t1[i]->getThreadControl().join(); + t1[i]->getThreadControl().join(); } for(i = 0; i < fullCount - 1; i++) { - t2[i]->getThreadControl().join(); + t2[i]->getThreadControl().join(); } test(latch.getCount() == 0); @@ -141,14 +141,14 @@ CountDownLatchTest::run() ThreadPtr t3[wave2Count]; for(i = 0; i < wave2Count; i++) { - t3[i] = new CountDownLatchTestThread(latch, val, true); - t3[i]->start(); + t3[i] = new CountDownLatchTestThread(latch, val, true); + t3[i]->start(); } test(latch.getCount() == 0); for(i = 0; i < wave2Count; i++) { - t3[i]->getThreadControl().join(); + t3[i]->getThreadControl().join(); } test(latch.getCount() == 0); } diff --git a/cpp/test/IceUtil/thread/CreateTest.cpp b/cpp/test/IceUtil/thread/CreateTest.cpp index a1ea843fb5a..04f9dc2ad42 100644 --- a/cpp/test/IceUtil/thread/CreateTest.cpp +++ b/cpp/test/IceUtil/thread/CreateTest.cpp @@ -25,13 +25,13 @@ class CreateTestThread : public Thread public: CreateTestThread() : - threadran(false) + threadran(false) { } virtual void run() { - threadran = true; + threadran = true; } bool threadran; @@ -49,16 +49,16 @@ CreateTest::run() { for(int i = 0; i < 4096 ; ++i) { - CreateTestThreadPtr t = new CreateTestThread(); - ThreadControl control = t->start(); - control.join(); - test(t->threadran); - if((i % 256) == 0) - { - char buf[5]; - sprintf(buf, "%04d", i); - cout << buf << "" << flush; - } + CreateTestThreadPtr t = new CreateTestThread(); + ThreadControl control = t->start(); + control.join(); + test(t->threadran); + if((i % 256) == 0) + { + char buf[5]; + sprintf(buf, "%04d", i); + cout << buf << "" << flush; + } } cout << " " << flush; } diff --git a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp index a993e661348..6cfc32d2cd6 100644 --- a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp @@ -20,33 +20,33 @@ class MonitorMutexTestThread : public Thread public: MonitorMutexTestThread(Monitor<Mutex>& m) : - _monitor(m), - _tryLock(false) + _monitor(m), + _tryLock(false) { } virtual void run() { - Monitor<Mutex>::TryLock tlock(_monitor); - test(!tlock.acquired()); - - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); - - Monitor<Mutex>::Lock lock(_monitor); + Monitor<Mutex>::TryLock tlock(_monitor); + test(!tlock.acquired()); + + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); + + Monitor<Mutex>::Lock lock(_monitor); } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } private: @@ -67,16 +67,16 @@ class MonitorMutexTestThread2 : public Thread public: MonitorMutexTestThread2(Monitor<Mutex>& monitor) : - finished(false), - _monitor(monitor) + finished(false), + _monitor(monitor) { } virtual void run() { - Monitor<Mutex>::Lock lock(_monitor); - _monitor.wait(); - finished = true; + Monitor<Mutex>::Lock lock(_monitor); + _monitor.wait(); + finished = true; } bool finished; @@ -106,27 +106,27 @@ MonitorMutexTest::run() ThreadControl control2; { - Monitor<Mutex>::Lock lock(monitor); - - try - { - Monitor<Mutex>::TryLock tlock(monitor); - test(!tlock.acquired()); - } - catch(const ThreadLockedException&) - { - // - // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation - // as well as in Fedora Core 5. - // - } - - // TEST: Start thread, try to acquire the mutex. - t = new MonitorMutexTestThread(monitor); - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + Monitor<Mutex>::Lock lock(monitor); + + try + { + Monitor<Mutex>::TryLock tlock(monitor); + test(!tlock.acquired()); + } + catch(const ThreadLockedException&) + { + // + // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation + // as well as in Fedora Core 5. + // + } + + // TEST: Start thread, try to acquire the mutex. + t = new MonitorMutexTestThread(monitor); + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // @@ -145,8 +145,8 @@ MonitorMutexTest::run() ThreadControl::sleep(Time::seconds(1)); { - Monitor<Mutex>::Lock lock(monitor); - monitor.notify(); + Monitor<Mutex>::Lock lock(monitor); + monitor.notify(); } // Give one thread time to terminate @@ -155,8 +155,8 @@ MonitorMutexTest::run() test((t2->finished && !t3->finished) || (t3->finished && !t2->finished)); { - Monitor<Mutex>::Lock lock(monitor); - monitor.notify(); + Monitor<Mutex>::Lock lock(monitor); + monitor.notify(); } control.join(); control2.join(); @@ -171,8 +171,8 @@ MonitorMutexTest::run() ThreadControl::sleep(Time::seconds(1)); { - Monitor<Mutex>::Lock lock(monitor); - monitor.notifyAll(); + Monitor<Mutex>::Lock lock(monitor); + monitor.notifyAll(); } control.join(); @@ -180,7 +180,7 @@ MonitorMutexTest::run() // TEST: timedWait { - Monitor<Mutex>::Lock lock(monitor); - test(!monitor.timedWait(Time::milliSeconds(500))); + Monitor<Mutex>::Lock lock(monitor); + test(!monitor.timedWait(Time::milliSeconds(500))); } } diff --git a/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp index a2f24fa5630..79731b02849 100644 --- a/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp @@ -20,34 +20,34 @@ class MonitorRecMutexTestThread : public Thread public: MonitorRecMutexTestThread(Monitor<RecMutex>& m) : - _monitor(m), - _tryLock(false) + _monitor(m), + _tryLock(false) { } virtual void run() { - - Monitor<RecMutex>::TryLock tlock(_monitor); - test(!tlock.acquired()); - - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); - - Monitor<RecMutex>::Lock lock(_monitor); + + Monitor<RecMutex>::TryLock tlock(_monitor); + test(!tlock.acquired()); + + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); + + Monitor<RecMutex>::Lock lock(_monitor); } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } private: @@ -68,16 +68,16 @@ class MonitorRecMutexTestThread2 : public Thread, public Monitor<RecMutex> public: MonitorRecMutexTestThread2(Monitor<RecMutex>& monitor) : - finished(false), - _monitor(monitor) + finished(false), + _monitor(monitor) { } virtual void run() { - Monitor<RecMutex>::Lock lock(_monitor); - _monitor.wait(); - finished = true; + Monitor<RecMutex>::Lock lock(_monitor); + _monitor.wait(); + finished = true; } bool finished; @@ -108,22 +108,22 @@ MonitorRecMutexTest::run() { - Monitor<RecMutex>::Lock lock(monitor); - - Monitor<RecMutex>::TryLock lock2(monitor); - test(lock2.acquired()); - - // TEST: TryLock - - Monitor<RecMutex>::TryLock tlock(monitor); - test(tlock.acquired()); - - // TEST: Start thread, try to acquire the mutex. - t = new MonitorRecMutexTestThread(monitor); - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + Monitor<RecMutex>::Lock lock(monitor); + + Monitor<RecMutex>::TryLock lock2(monitor); + test(lock2.acquired()); + + // TEST: TryLock + + Monitor<RecMutex>::TryLock tlock(monitor); + test(tlock.acquired()); + + // TEST: Start thread, try to acquire the mutex. + t = new MonitorRecMutexTestThread(monitor); + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // @@ -142,8 +142,8 @@ MonitorRecMutexTest::run() ThreadControl::sleep(Time::seconds(1)); { - Monitor<RecMutex>::Lock lock(monitor); - monitor.notify(); + Monitor<RecMutex>::Lock lock(monitor); + monitor.notify(); } // Give one thread time to terminate @@ -152,8 +152,8 @@ MonitorRecMutexTest::run() test((t2->finished && !t3->finished) || (t3->finished && !t2->finished)); { - Monitor<RecMutex>::Lock lock(monitor); - monitor.notify(); + Monitor<RecMutex>::Lock lock(monitor); + monitor.notify(); } control.join(); control2.join(); @@ -168,8 +168,8 @@ MonitorRecMutexTest::run() ThreadControl::sleep(Time::seconds(1)); { - Monitor<RecMutex>::Lock lock(monitor); - monitor.notifyAll(); + Monitor<RecMutex>::Lock lock(monitor); + monitor.notifyAll(); } control.join(); @@ -177,7 +177,7 @@ MonitorRecMutexTest::run() // TEST: timedWait { - Monitor<RecMutex>::Lock lock(monitor); - test(!monitor.timedWait(Time::milliSeconds(500))); + Monitor<RecMutex>::Lock lock(monitor); + test(!monitor.timedWait(Time::milliSeconds(500))); } } diff --git a/cpp/test/IceUtil/thread/MutexTest.cpp b/cpp/test/IceUtil/thread/MutexTest.cpp index 0ae62305bd8..3c6f6d18fac 100644 --- a/cpp/test/IceUtil/thread/MutexTest.cpp +++ b/cpp/test/IceUtil/thread/MutexTest.cpp @@ -22,33 +22,33 @@ class MutexTestThread : public Thread public: MutexTestThread(Mutex& m) : - _mutex(m), - _tryLock(false) + _mutex(m), + _tryLock(false) { } virtual void run() - { - Mutex::TryLock tlock(_mutex); - test(!tlock.acquired()); + { + Mutex::TryLock tlock(_mutex); + test(!tlock.acquired()); - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); - Mutex::Lock lock(_mutex); + Mutex::Lock lock(_mutex); } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } private: @@ -77,80 +77,80 @@ MutexTest::run() ThreadControl control; { - Mutex::Lock lock(mutex); - - // LockT testing: - // - - test(lock.acquired()); - - try - { - lock.acquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - try - { - lock.tryAcquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(lock.acquired()); - lock.release(); - test(!lock.acquired()); - - try - { - lock.release(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - Mutex::TryLock lock2(mutex); - try - { - test(lock.tryAcquire() == false); - } - catch(const ThreadLockedException&) - { - } - lock2.release(); - test(lock.tryAcquire() == true); - test(lock.acquired()); - - // Deadlock testing - // + Mutex::Lock lock(mutex); + + // LockT testing: + // + + test(lock.acquired()); + + try + { + lock.acquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + try + { + lock.tryAcquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(lock.acquired()); + lock.release(); + test(!lock.acquired()); + + try + { + lock.release(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + Mutex::TryLock lock2(mutex); + try + { + test(lock.tryAcquire() == false); + } + catch(const ThreadLockedException&) + { + } + lock2.release(); + test(lock.tryAcquire() == true); + test(lock.acquired()); + + // Deadlock testing + // #if !defined(NDEBUG) && !defined(_WIN32) - try - { - Mutex::Lock lock3(mutex); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } + try + { + Mutex::Lock lock3(mutex); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } #endif - // TEST: Start thread, try to acquire the mutex. - t = new MutexTestThread(mutex); - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + // TEST: Start thread, try to acquire the mutex. + t = new MutexTestThread(mutex); + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // diff --git a/cpp/test/IceUtil/thread/RWRecMutexTest.cpp b/cpp/test/IceUtil/thread/RWRecMutexTest.cpp index af3180c8d80..72834b254f0 100644 --- a/cpp/test/IceUtil/thread/RWRecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/RWRecMutexTest.cpp @@ -22,19 +22,19 @@ class RWRecMutexTestThread : public Thread public: RWRecMutexTestThread(RWRecMutex& m) : - _mutex(m), - _tryLock(false) + _mutex(m), + _tryLock(false) { } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } protected: @@ -54,23 +54,23 @@ class RWRecMutexReadTestThread : public RWRecMutexTestThread public: RWRecMutexReadTestThread(RWRecMutex& m) : - RWRecMutexTestThread(m) + RWRecMutexTestThread(m) { } virtual void run() { - RWRecMutex::TryRLock tlock(_mutex); - test(tlock.acquired()); - - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); + RWRecMutex::TryRLock tlock(_mutex); + test(tlock.acquired()); + + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); - RWRecMutex::RLock lock(_mutex); + RWRecMutex::RLock lock(_mutex); } }; @@ -79,24 +79,24 @@ class RWRecMutexReadTestThread2 : public RWRecMutexTestThread public: RWRecMutexReadTestThread2(RWRecMutex& m) : - RWRecMutexTestThread(m) + RWRecMutexTestThread(m) { } virtual void run() { - - RWRecMutex::TryRLock tlock(_mutex); - test(!tlock.acquired()); + + RWRecMutex::TryRLock tlock(_mutex); + test(!tlock.acquired()); - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); - RWRecMutex::RLock lock(_mutex); + RWRecMutex::RLock lock(_mutex); } }; @@ -105,54 +105,54 @@ class RWRecMutexUpgradeReadThread : public Thread public: RWRecMutexUpgradeReadThread(RWRecMutex& m) : - _mutex(m), - _unlock(false), - _lock(false) + _mutex(m), + _unlock(false), + _lock(false) { } virtual void run() { - RWRecMutex::RLock lock(_mutex); + RWRecMutex::RLock lock(_mutex); - signalLock(); - waitUnlock(); + signalLock(); + waitUnlock(); } void waitUnlock() { - Mutex::Lock lock(_unlockMutex); - while(!_unlock) - { - _unlockCond.wait(lock); - } + Mutex::Lock lock(_unlockMutex); + while(!_unlock) + { + _unlockCond.wait(lock); + } } void signalUnlock() { - Mutex::Lock lock(_unlockMutex); - _unlock = true; - _unlockCond.signal(); + Mutex::Lock lock(_unlockMutex); + _unlock = true; + _unlockCond.signal(); } void signalLock() { - Mutex::Lock lock(_lockMutex); - _lock = true; - _lockCond.signal(); + Mutex::Lock lock(_lockMutex); + _lock = true; + _lockCond.signal(); } void waitLock() { - Mutex::Lock lock(_lockMutex); - while(!_lock) - { - _lockCond.wait(lock); - } + Mutex::Lock lock(_lockMutex); + while(!_lock) + { + _lockCond.wait(lock); + } } private: @@ -177,45 +177,45 @@ class RWRecMutexUpgradeTestThread : public Thread public: RWRecMutexUpgradeTestThread(RWRecMutex& m) : - _mutex(m), - _lock(false), - _upgradeAcquired(false) + _mutex(m), + _lock(false), + _upgradeAcquired(false) { } virtual void run() { - RWRecMutex::RLock lock(_mutex); + RWRecMutex::RLock lock(_mutex); - signalLock(); - lock.upgrade(); + signalLock(); + lock.upgrade(); - _upgradeAcquired = true; + _upgradeAcquired = true; } void signalLock() { - Mutex::Lock lock(_lockMutex); - _lock = true; - _lockCond.signal(); + Mutex::Lock lock(_lockMutex); + _lock = true; + _lockCond.signal(); } void waitLock() { - Mutex::Lock lock(_lockMutex); - while(!_lock) - { - _lockCond.wait(lock); - } + Mutex::Lock lock(_lockMutex); + while(!_lock) + { + _lockCond.wait(lock); + } } bool upgradeAcquired() const { - return _upgradeAcquired; + return _upgradeAcquired; } private: @@ -238,24 +238,24 @@ class RWRecMutexWriteTestThread : public RWRecMutexTestThread public: RWRecMutexWriteTestThread(RWRecMutex& m) : - RWRecMutexTestThread(m) + RWRecMutexTestThread(m) { } virtual void run() { - - RWRecMutex::TryWLock tlock(_mutex); - test(!tlock.acquired()); + + RWRecMutex::TryWLock tlock(_mutex); + test(!tlock.acquired()); - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); - RWRecMutex::WLock lock(_mutex); + RWRecMutex::WLock lock(_mutex); } }; typedef Handle<RWRecMutexTestThread> RWRecMutexTestThreadPtr; @@ -266,79 +266,79 @@ public: RWRecMutexUpgradeThread(RWRecMutex& m, bool timed = false) : _m(m), - _timed(timed), - _destroyed(false), - _upgrading(false), - _hasWriteLock(false), - _failed(false) + _timed(timed), + _destroyed(false), + _upgrading(false), + _hasWriteLock(false), + _failed(false) { } virtual void run() { - // - // Acquire a read lock. - // - RWRecMutex::RLock tlock(_m); - - { - Lock sync(*this); - _upgrading = true; - notify(); - } - - try - { - if(_timed) - { - if(!_m.timedUpgrade(IceUtil::Time::seconds(10))) - { - _failed = true; - } - } - else - { - _m.upgrade(); - } - } - catch(DeadlockException&) - { - _failed = true; - } - - { - Lock sync(*this); - _hasWriteLock = true; - notify(); - - while(!_destroyed) - { - wait(); - } - } + // + // Acquire a read lock. + // + RWRecMutex::RLock tlock(_m); + + { + Lock sync(*this); + _upgrading = true; + notify(); + } + + try + { + if(_timed) + { + if(!_m.timedUpgrade(IceUtil::Time::seconds(10))) + { + _failed = true; + } + } + else + { + _m.upgrade(); + } + } + catch(DeadlockException&) + { + _failed = true; + } + + { + Lock sync(*this); + _hasWriteLock = true; + notify(); + + while(!_destroyed) + { + wait(); + } + } } void waitUpgrade() { - Lock sync(*this); + Lock sync(*this); - // - // Wait for the _upgrading flag to be set. - // - while(!_upgrading) - { - wait(); - } + // + // Wait for the _upgrading flag to be set. + // + while(!_upgrading) + { + wait(); + } } void destroy() { - Lock sync(*this); - _destroyed = true; - notify(); + Lock sync(*this); + _destroyed = true; + notify(); } // @@ -349,18 +349,18 @@ public: bool waitHasWriteLock() { - Lock sync(*this); - if(!_hasWriteLock) - { - timedWait(Time::seconds(10)); - } - return _hasWriteLock; + Lock sync(*this); + if(!_hasWriteLock) + { + timedWait(Time::seconds(10)); + } + return _hasWriteLock; } bool failed() const { - return _failed; + return _failed; } private: @@ -380,70 +380,70 @@ public: RWRecMutexWriteThread(RWRecMutex& m) : _m(m), - _destroyed(false), - _waitWrite(false), - _hasWriteLock(false) + _destroyed(false), + _waitWrite(false), + _hasWriteLock(false) { } virtual void run() { - { - Lock sync(*this); - _waitWrite = true; - notify(); - } - // - // Acquire a read lock. - // - RWRecMutex::WLock sync(_m); + { + Lock sync(*this); + _waitWrite = true; + notify(); + } + // + // Acquire a read lock. + // + RWRecMutex::WLock sync(_m); - { - Lock sync(*this); - _hasWriteLock = true; - notify(); + { + Lock sync(*this); + _hasWriteLock = true; + notify(); - while(!_destroyed) - { - wait(); - } - } + while(!_destroyed) + { + wait(); + } + } } void waitWrite() { - Lock sync(*this); + Lock sync(*this); - // - // Wait for the _upgrading flag to be set. - // - while(!_waitWrite) - { - wait(); - } + // + // Wait for the _upgrading flag to be set. + // + while(!_waitWrite) + { + wait(); + } - // - // Its necessary to sleep for 1 second to ensure that the - // thread is actually IN the upgrade and waiting. - // - ThreadControl::sleep(Time::seconds(1)); + // + // Its necessary to sleep for 1 second to ensure that the + // thread is actually IN the upgrade and waiting. + // + ThreadControl::sleep(Time::seconds(1)); } void destroy() { - Lock sync(*this); - _destroyed = true; - notify(); + Lock sync(*this); + _destroyed = true; + notify(); } bool hasWriteLock() { - Lock sync(*this); - return _hasWriteLock; + Lock sync(*this); + return _hasWriteLock; } // @@ -454,12 +454,12 @@ public: bool waitHasWriteLock() { - Lock sync(*this); - if(!_hasWriteLock) - { - timedWait(Time::seconds(10)); - } - return _hasWriteLock; + Lock sync(*this); + if(!_hasWriteLock) + { + timedWait(Time::seconds(10)); + } + return _hasWriteLock; } private: @@ -485,127 +485,127 @@ RWRecMutexTest::run() // TEST: TryLock (read) { - RWRecMutex::RLock rlock(mutex); - - // RLock testing - test(rlock.acquired()); - - try - { - rlock.acquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - try - { - rlock.tryAcquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(rlock.acquired()); - rlock.release(); - test(!rlock.acquired()); - - try - { - rlock.release(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(rlock.tryAcquire() == true); - test(rlock.acquired()); - - RWRecMutex::RLock rlock2(mutex); - - RWRecMutex::TryRLock trlock(mutex); - test(trlock.acquired()); - - RWRecMutex::TryWLock twlock(mutex); - test(!twlock.acquired()); - - RWRecMutex::TryWLock twlock2(mutex, Time::milliSeconds(10)); - test(!twlock2.acquired()); + RWRecMutex::RLock rlock(mutex); + + // RLock testing + test(rlock.acquired()); + + try + { + rlock.acquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + try + { + rlock.tryAcquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(rlock.acquired()); + rlock.release(); + test(!rlock.acquired()); + + try + { + rlock.release(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(rlock.tryAcquire() == true); + test(rlock.acquired()); + + RWRecMutex::RLock rlock2(mutex); + + RWRecMutex::TryRLock trlock(mutex); + test(trlock.acquired()); + + RWRecMutex::TryWLock twlock(mutex); + test(!twlock.acquired()); + + RWRecMutex::TryWLock twlock2(mutex, Time::milliSeconds(10)); + test(!twlock2.acquired()); } // TEST: TryLock (write) { - RWRecMutex::WLock wlock(mutex); - - // WLock testing - test(wlock.acquired()); - - try - { - wlock.acquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - try - { - wlock.tryAcquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(wlock.acquired()); - wlock.release(); - test(!wlock.acquired()); - - try - { - wlock.release(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(wlock.tryAcquire() == true); - test(wlock.acquired()); - - RWRecMutex::TryRLock trlock(mutex); - test(!trlock.acquired()); - - RWRecMutex::TryRLock trlock2(mutex, Time::milliSeconds(10)); - test(!trlock2.acquired()); - - RWRecMutex::TryWLock twlock(mutex); - test(twlock.acquired()); - - RWRecMutex::TryWLock twlock2(mutex, Time::milliSeconds(10)); - test(twlock2.acquired()); + RWRecMutex::WLock wlock(mutex); + + // WLock testing + test(wlock.acquired()); + + try + { + wlock.acquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + try + { + wlock.tryAcquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(wlock.acquired()); + wlock.release(); + test(!wlock.acquired()); + + try + { + wlock.release(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(wlock.tryAcquire() == true); + test(wlock.acquired()); + + RWRecMutex::TryRLock trlock(mutex); + test(!trlock.acquired()); + + RWRecMutex::TryRLock trlock2(mutex, Time::milliSeconds(10)); + test(!trlock2.acquired()); + + RWRecMutex::TryWLock twlock(mutex); + test(twlock.acquired()); + + RWRecMutex::TryWLock twlock2(mutex, Time::milliSeconds(10)); + test(twlock2.acquired()); } // TEST: read lock { - RWRecMutex::RLock rlock(mutex); + RWRecMutex::RLock rlock(mutex); - // TEST: Start thread, try to acquire the mutex. - t = new RWRecMutexReadTestThread(mutex); - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + // TEST: Start thread, try to acquire the mutex. + t = new RWRecMutexReadTestThread(mutex); + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // @@ -616,14 +616,14 @@ RWRecMutexTest::run() // TEST: write lock { - RWRecMutex::WLock wlock(mutex); + RWRecMutex::WLock wlock(mutex); - // TEST: Start thread, try to acquire the mutex. - t = new RWRecMutexWriteTestThread(mutex); - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + // TEST: Start thread, try to acquire the mutex. + t = new RWRecMutexWriteTestThread(mutex); + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // @@ -634,22 +634,22 @@ RWRecMutexTest::run() // TEST: Lock precedence. Writers have precedence over readers. { - RWRecMutex::RLock rlock(mutex); + RWRecMutex::RLock rlock(mutex); - // Start thread that tries to acquire write lock - t = new RWRecMutexWriteTestThread(mutex); - control = t->start(); + // Start thread that tries to acquire write lock + t = new RWRecMutexWriteTestThread(mutex); + control = t->start(); - // TEST: Wait until the tryLock has been tested. The thread is - // now waiting on a write lock. - t->waitTryLock(); + // TEST: Wait until the tryLock has been tested. The thread is + // now waiting on a write lock. + t->waitTryLock(); - // It's necessary for a small sleep here to ensure that the - // thread is actually waiting on a write lock. - ThreadControl::sleep(Time::seconds(1)); + // It's necessary for a small sleep here to ensure that the + // thread is actually waiting on a write lock. + ThreadControl::sleep(Time::seconds(1)); - RWRecMutex::TryRLock trlock(mutex); - test(!trlock.acquired()); + RWRecMutex::TryRLock trlock(mutex); + test(!trlock.acquired()); } // @@ -660,24 +660,24 @@ RWRecMutexTest::run() // TEST: Lock upgrading. { - RWRecMutex::RLock rlock(mutex); + RWRecMutex::RLock rlock(mutex); - // - // Mutex now holds a write lock. - // - mutex.upgrade(); + // + // Mutex now holds a write lock. + // + mutex.upgrade(); - // Start thread that tries to acquire write lock - t = new RWRecMutexReadTestThread2(mutex); - control = t->start(); + // Start thread that tries to acquire write lock + t = new RWRecMutexReadTestThread2(mutex); + control = t->start(); - // TEST: Wait until the tryLock has been tested. The thread is - // now waiting on a read lock. - t->waitTryLock(); + // TEST: Wait until the tryLock has been tested. The thread is + // now waiting on a read lock. + t->waitTryLock(); - // It's necessary for a small sleep here to ensure that the - // thread is actually waiting on a read lock. - ThreadControl::sleep(Time::seconds(1)); + // It's necessary for a small sleep here to ensure that the + // thread is actually waiting on a read lock. + ThreadControl::sleep(Time::seconds(1)); } // @@ -696,182 +696,182 @@ RWRecMutexTest::run() // TEST: Lock upgrading. This time a reader thread is started // first. { - RWRecMutexUpgradeReadThreadPtr t1 = new RWRecMutexUpgradeReadThread(mutex); - control = t1->start(); - - // Wait for the thread to acquire the read lock. - t1->waitLock(); - - // Spawn a thread to try acquiring the lock - RWRecMutexUpgradeTestThreadPtr t2 = new RWRecMutexUpgradeTestThread(mutex); - ThreadControl control2 = t2->start(); - t2->waitLock(); - - // - // Small sleep to find out whether the thread actually - // terminates (which means that the write lock upgrade was - // mistakenly acquired). - // - ThreadControl::sleep(Time::seconds(1)); - - test(!t2->upgradeAcquired()); - - // - // A read lock at this point should fail. - // - RWRecMutex::TryRLock trlock(mutex); - test(!trlock.acquired()); - - // - // As should a write lock. - // - RWRecMutex::TryWLock twlock(mutex); - test(!twlock.acquired()); - - // - // Once the read lock is released then the upgrade should - // succeed & the thread should terminate. - // - t1->signalUnlock(); - - control2.join(); - control.join(); - - // - // Now both a read & write lock should be available. - // - { - RWRecMutex::WLock rlock2(mutex); - } - { - RWRecMutex::RLock rlock2(mutex); - } + RWRecMutexUpgradeReadThreadPtr t1 = new RWRecMutexUpgradeReadThread(mutex); + control = t1->start(); + + // Wait for the thread to acquire the read lock. + t1->waitLock(); + + // Spawn a thread to try acquiring the lock + RWRecMutexUpgradeTestThreadPtr t2 = new RWRecMutexUpgradeTestThread(mutex); + ThreadControl control2 = t2->start(); + t2->waitLock(); + + // + // Small sleep to find out whether the thread actually + // terminates (which means that the write lock upgrade was + // mistakenly acquired). + // + ThreadControl::sleep(Time::seconds(1)); + + test(!t2->upgradeAcquired()); + + // + // A read lock at this point should fail. + // + RWRecMutex::TryRLock trlock(mutex); + test(!trlock.acquired()); + + // + // As should a write lock. + // + RWRecMutex::TryWLock twlock(mutex); + test(!twlock.acquired()); + + // + // Once the read lock is released then the upgrade should + // succeed & the thread should terminate. + // + t1->signalUnlock(); + + control2.join(); + control.join(); + + // + // Now both a read & write lock should be available. + // + { + RWRecMutex::WLock rlock2(mutex); + } + { + RWRecMutex::RLock rlock2(mutex); + } } #endif // TEST: Ensure that only one reader can upgrade to a writer. // Other readers get a DeadlockException. { - mutex.readLock(); + mutex.readLock(); - RWRecMutexUpgradeThreadPtr t1 = new RWRecMutexUpgradeThread(mutex); - ThreadControl control1 = t1->start(); + RWRecMutexUpgradeThreadPtr t1 = new RWRecMutexUpgradeThread(mutex); + ThreadControl control1 = t1->start(); - // - // Wait for the thread to get into the upgrade call. The - // upgrade will hang since the readLock is held by this thread - // and therefore cannot succeed until we release our read - // lock. - // - t1->waitUpgrade(); + // + // Wait for the thread to get into the upgrade call. The + // upgrade will hang since the readLock is held by this thread + // and therefore cannot succeed until we release our read + // lock. + // + t1->waitUpgrade(); - // - // Its necessary to sleep for 1 second to ensure that the - // thread is actually IN the upgrade and waiting. - // - ThreadControl::sleep(Time::seconds(1)); + // + // Its necessary to sleep for 1 second to ensure that the + // thread is actually IN the upgrade and waiting. + // + ThreadControl::sleep(Time::seconds(1)); - try - { - mutex.upgrade(); - test(false); - } - catch(const DeadlockException&) - { - } + try + { + mutex.upgrade(); + test(false); + } + catch(const DeadlockException&) + { + } - // - // Release the waiting thread, join. - // - mutex.unlock(); - t1->destroy(); - control1.join(); + // + // Release the waiting thread, join. + // + mutex.unlock(); + t1->destroy(); + control1.join(); - test(!t1->failed()); + test(!t1->failed()); } // TEST: Same as previous test, but for a timedUpgrade. { - mutex.readLock(); + mutex.readLock(); - RWRecMutexUpgradeThreadPtr t1 = new RWRecMutexUpgradeThread(mutex, true); - ThreadControl control1 = t1->start(); + RWRecMutexUpgradeThreadPtr t1 = new RWRecMutexUpgradeThread(mutex, true); + ThreadControl control1 = t1->start(); - t1->waitUpgrade(); - // - // Its necessary to sleep for 1 second to ensure that the - // thread is actually IN the upgrade and waiting. - // - ThreadControl::sleep(Time::seconds(1)); + t1->waitUpgrade(); + // + // Its necessary to sleep for 1 second to ensure that the + // thread is actually IN the upgrade and waiting. + // + ThreadControl::sleep(Time::seconds(1)); - try - { - mutex.upgrade(); - test(false); - } - catch(const DeadlockException&) - { - } + try + { + mutex.upgrade(); + test(false); + } + catch(const DeadlockException&) + { + } - // - // Release the waiting thread, join. - // - mutex.unlock(); - t1->destroy(); - control1.join(); + // + // Release the waiting thread, join. + // + mutex.unlock(); + t1->destroy(); + control1.join(); - test(!t1->failed()); + test(!t1->failed()); } // TEST: Check that an upgrader is given preference over a writer. { - mutex.readLock(); + mutex.readLock(); - RWRecMutexUpgradeThreadPtr t1 = new RWRecMutexUpgradeThread(mutex); - - ThreadControl control1 = t1->start(); + RWRecMutexUpgradeThreadPtr t1 = new RWRecMutexUpgradeThread(mutex); + + ThreadControl control1 = t1->start(); - // - // Its not necessary to sleep here, since the upgrade thread - // acquires the read lock before signalling. Therefore the - // write thread cannot get the write lock. - // - t1->waitUpgrade(); + // + // Its not necessary to sleep here, since the upgrade thread + // acquires the read lock before signalling. Therefore the + // write thread cannot get the write lock. + // + t1->waitUpgrade(); - RWRecMutexWriteThreadPtr t2 = new RWRecMutexWriteThread(mutex);
- ThreadControl control2 = t2->start();
- t2->waitWrite(); - //
- // Its necessary to sleep for 1 second to ensure that the
- // thread is actually IN the write lock and waiting.
- //
- ThreadControl::sleep(Time::seconds(1));
- - // - // Unlocking the read mutex lets the upgrade continue. At this - // point t1 should have the write-lock, and t2 should not. - // - test(!t2->hasWriteLock()); - mutex.unlock(); - - // - // Wait for t1 to get the write lock. It will not release it - // until the thread is destroyed. t2 should not have the write - // lock. - // - test(!t1->failed()); - test(t1->waitHasWriteLock()); - test(!t2->hasWriteLock()); - t1->destroy(); - t2->destroy(); - - // - // After the thread has terminated the thread must have - // acquired the write lock. - // - test(t2->waitHasWriteLock()); - - control1.join(); - control2.join(); + RWRecMutexWriteThreadPtr t2 = new RWRecMutexWriteThread(mutex);
+ ThreadControl control2 = t2->start();
+ t2->waitWrite(); + //
+ // Its necessary to sleep for 1 second to ensure that the
+ // thread is actually IN the write lock and waiting.
+ //
+ ThreadControl::sleep(Time::seconds(1));
+ + // + // Unlocking the read mutex lets the upgrade continue. At this + // point t1 should have the write-lock, and t2 should not. + // + test(!t2->hasWriteLock()); + mutex.unlock(); + + // + // Wait for t1 to get the write lock. It will not release it + // until the thread is destroyed. t2 should not have the write + // lock. + // + test(!t1->failed()); + test(t1->waitHasWriteLock()); + test(!t2->hasWriteLock()); + t1->destroy(); + t2->destroy(); + + // + // After the thread has terminated the thread must have + // acquired the write lock. + // + test(t2->waitHasWriteLock()); + + control1.join(); + control2.join(); } } diff --git a/cpp/test/IceUtil/thread/RecMutexTest.cpp b/cpp/test/IceUtil/thread/RecMutexTest.cpp index e4bad16fc22..0668f565383 100644 --- a/cpp/test/IceUtil/thread/RecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/RecMutexTest.cpp @@ -22,34 +22,34 @@ class RecMutexTestThread : public Thread public: RecMutexTestThread(RecMutex& m) : - _mutex(m), - _tryLock(false) + _mutex(m), + _tryLock(false) { } virtual void run() { - - RecMutex::TryLock tlock(_mutex); - test(!tlock.acquired()); - - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); - - RecMutex::Lock lock(_mutex); + + RecMutex::TryLock tlock(_mutex); + test(!tlock.acquired()); + + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); + + RecMutex::Lock lock(_mutex); } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } private: @@ -78,22 +78,22 @@ RecMutexTest::run() ThreadControl control; { - RecMutex::Lock lock(mutex); - - // TEST: lock twice - RecMutex::Lock lock2(mutex); - - // TEST: TryLock - RecMutex::TryLock lock3(mutex); - test(lock3.acquired()); - - // TEST: Start thread, try to acquire the mutex. - t = new RecMutexTestThread(mutex); - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); - + RecMutex::Lock lock(mutex); + + // TEST: lock twice + RecMutex::Lock lock2(mutex); + + // TEST: TryLock + RecMutex::TryLock lock3(mutex); + test(lock3.acquired()); + + // TEST: Start thread, try to acquire the mutex. + t = new RecMutexTestThread(mutex); + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); + } // diff --git a/cpp/test/IceUtil/thread/StartTest.cpp b/cpp/test/IceUtil/thread/StartTest.cpp index a07f7e1804e..1f1af376ea1 100644 --- a/cpp/test/IceUtil/thread/StartTest.cpp +++ b/cpp/test/IceUtil/thread/StartTest.cpp @@ -50,8 +50,8 @@ StartTest::run() control.join(); try { - t->start(); - test(false); + t->start(); + test(false); } catch(const ThreadStartedException&) { @@ -62,11 +62,11 @@ StartTest::run() // for(int i = 0; i < 50; i++) { - for(int j = 0; j < 50; j++) - { - Thread* t = new StartTestThread; - t->start().detach(); - } - ThreadControl::sleep(Time::milliSeconds(5)); + for(int j = 0; j < 50; j++) + { + Thread* t = new StartTestThread; + t->start().detach(); + } + ThreadControl::sleep(Time::milliSeconds(5)); } } diff --git a/cpp/test/IceUtil/thread/StaticMutexTest.cpp b/cpp/test/IceUtil/thread/StaticMutexTest.cpp index 7868b2a4b32..f42b7c4345a 100644 --- a/cpp/test/IceUtil/thread/StaticMutexTest.cpp +++ b/cpp/test/IceUtil/thread/StaticMutexTest.cpp @@ -24,32 +24,32 @@ class StaticMutexTestThread : public Thread public: StaticMutexTestThread() : - _tryLock(false) + _tryLock(false) { } virtual void run() - { - StaticMutex::TryLock tlock(staticMutex); - test(!tlock.acquired()); + { + StaticMutex::TryLock tlock(staticMutex); + test(!tlock.acquired()); - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); - StaticMutex::Lock lock(staticMutex); + StaticMutex::Lock lock(staticMutex); } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } private: @@ -76,65 +76,65 @@ StaticMutexTest::run() ThreadControl control; { - StaticMutex::Lock lock(staticMutex); - - // LockT testing: - // - - test(lock.acquired()); - - try - { - lock.acquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - try - { - lock.tryAcquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(lock.acquired()); - lock.release(); - test(!lock.acquired()); - - try - { - lock.release(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - StaticMutex::TryLock lock2(staticMutex); - try - { - test(lock.tryAcquire() == false); - } - catch(const ThreadLockedException&) - { - } - lock2.release(); - test(lock.tryAcquire() == true); - test(lock.acquired()); - - // TEST: Start thread, try to acquire the mutex. - t = new StaticMutexTestThread; - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + StaticMutex::Lock lock(staticMutex); + + // LockT testing: + // + + test(lock.acquired()); + + try + { + lock.acquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + try + { + lock.tryAcquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(lock.acquired()); + lock.release(); + test(!lock.acquired()); + + try + { + lock.release(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + StaticMutex::TryLock lock2(staticMutex); + try + { + test(lock.tryAcquire() == false); + } + catch(const ThreadLockedException&) + { + } + lock2.release(); + test(lock.tryAcquire() == true); + test(lock.acquired()); + + // TEST: Start thread, try to acquire the mutex. + t = new StaticMutexTestThread; + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // diff --git a/cpp/test/IceUtil/thread/TestBase.cpp b/cpp/test/IceUtil/thread/TestBase.cpp index 54b565d9bb0..71bf59cce24 100644 --- a/cpp/test/IceUtil/thread/TestBase.cpp +++ b/cpp/test/IceUtil/thread/TestBase.cpp @@ -35,12 +35,12 @@ TestBase::start() cout << "running " << _name << " test... " << flush; try { - run(); + run(); } catch(const IceUtil::Exception& e) { - cout << e << " failed" << endl; - throw TestFailed(_name); + cout << e << " failed" << endl; + throw TestFailed(_name); } cout << "ok" << endl; } diff --git a/cpp/test/IceUtil/unicode/Client.cpp b/cpp/test/IceUtil/unicode/Client.cpp index 475d6ee4aac..da91e03fee1 100644 --- a/cpp/test/IceUtil/unicode/Client.cpp +++ b/cpp/test/IceUtil/unicode/Client.cpp @@ -25,12 +25,12 @@ main(int argc, char** argv) if(argc > 1) { - dir = argv[1]; + dir = argv[1]; #ifdef _WIN32 - dir += "\\"; + dir += "\\"; #else - dir += "/"; -#endif + dir += "/"; +#endif } @@ -45,119 +45,119 @@ main(int argc, char** argv) string wcoeurFile = string("coeur.") + wstringEncoding; { - cout << "testing UTF-8 to wstring (" << wstringEncoding << ") conversion..."; - - ifstream is((dir + "coeur.utf8").c_str()); - test(is.good()); - ifstream bis((dir + wcoeurFile).c_str(), ios_base::binary); - test(bis.good()); - - int lineNumber = 0; - - do - { - string line; - getline(is, line, '\n'); - test(isLegalUTF8Sequence(reinterpret_cast<const Byte*>(line.data()), - reinterpret_cast<const Byte*>(line.data() + line.size()))); - lineNumber++; - wstring wline = stringToWstring(line); - - for(size_t i = 0; i < wline.length(); ++i) - { - wchar_t wc = wline[i]; - const char* buffer = reinterpret_cast<char*>(&wc); - for(size_t j = 0; j < sizeof(wchar_t); ++j) - { - test(bis.good()); - char c; - bis.get(c); - if(buffer[j] != c) - { - cerr << "Error at line " << lineNumber << " column " << i << endl; - cerr << "buffer[j] == " << hex << (int)static_cast<unsigned char>(buffer[j]) << endl; - cerr << "c == " << hex << (int)static_cast<unsigned char>(c) << endl; - } - test(buffer[j] == c); - } - } - // - // Skip newline character (Unix-style newline) - // - if(is.good()) - { - for(size_t j = 0; j < sizeof(wchar_t); ++j) - { - test(bis.good()); - char c; - bis.get(c); - } - } - else - { - char c; - bis.get(c); - test(bis.eof()); - } - } while(is.good()); + cout << "testing UTF-8 to wstring (" << wstringEncoding << ") conversion..."; + + ifstream is((dir + "coeur.utf8").c_str()); + test(is.good()); + ifstream bis((dir + wcoeurFile).c_str(), ios_base::binary); + test(bis.good()); + + int lineNumber = 0; + + do + { + string line; + getline(is, line, '\n'); + test(isLegalUTF8Sequence(reinterpret_cast<const Byte*>(line.data()), + reinterpret_cast<const Byte*>(line.data() + line.size()))); + lineNumber++; + wstring wline = stringToWstring(line); + + for(size_t i = 0; i < wline.length(); ++i) + { + wchar_t wc = wline[i]; + const char* buffer = reinterpret_cast<char*>(&wc); + for(size_t j = 0; j < sizeof(wchar_t); ++j) + { + test(bis.good()); + char c; + bis.get(c); + if(buffer[j] != c) + { + cerr << "Error at line " << lineNumber << " column " << i << endl; + cerr << "buffer[j] == " << hex << (int)static_cast<unsigned char>(buffer[j]) << endl; + cerr << "c == " << hex << (int)static_cast<unsigned char>(c) << endl; + } + test(buffer[j] == c); + } + } + // + // Skip newline character (Unix-style newline) + // + if(is.good()) + { + for(size_t j = 0; j < sizeof(wchar_t); ++j) + { + test(bis.good()); + char c; + bis.get(c); + } + } + else + { + char c; + bis.get(c); + test(bis.eof()); + } + } while(is.good()); - cout << "ok" << endl; + cout << "ok" << endl; } { - cout << "wstring (" << wstringEncoding << ") to UTF-8 conversion..."; + cout << "wstring (" << wstringEncoding << ") to UTF-8 conversion..."; - ifstream bis((dir + wcoeurFile).c_str(), ios_base::binary); - test(bis.good()); + ifstream bis((dir + wcoeurFile).c_str(), ios_base::binary); + test(bis.good()); - wstring ws; - char c; + wstring ws; + char c; - do - { - wchar_t wc; - char* buffer = reinterpret_cast<char*>(&wc); - - for(size_t j = 0; j < sizeof(wchar_t); ++j) - { - if(!bis.good()) - { - break; - } - bis.get(c); - buffer[j] = c; - } + do + { + wchar_t wc; + char* buffer = reinterpret_cast<char*>(&wc); + + for(size_t j = 0; j < sizeof(wchar_t); ++j) + { + if(!bis.good()) + { + break; + } + bis.get(c); + buffer[j] = c; + } - if(bis.good()) - { - ws.push_back(wc); - } - } while(bis.good()); - - string s = wstringToString(ws); - - ifstream nbis((dir + "coeur.utf8").c_str(), ios_base::binary); - test(nbis.good()); - - for(size_t i = 0; i < s.size(); ++i) - { - test(nbis.good()); - nbis.get(c); - char ci = s[i]; + if(bis.good()) + { + ws.push_back(wc); + } + } while(bis.good()); + + string s = wstringToString(ws); + + ifstream nbis((dir + "coeur.utf8").c_str(), ios_base::binary); + test(nbis.good()); + + for(size_t i = 0; i < s.size(); ++i) + { + test(nbis.good()); + nbis.get(c); + char ci = s[i]; - if(c != ci) - { - cerr << "i == " << i << endl; - cerr << "ci == " << hex << (int)static_cast<unsigned char>(ci) << endl; - cerr << "c == " << hex << (int)static_cast<unsigned char>(c) << endl; - } - test(c == s[i]); - } - test(!nbis.eof()); - nbis.get(c); - test(nbis.eof()); + if(c != ci) + { + cerr << "i == " << i << endl; + cerr << "ci == " << hex << (int)static_cast<unsigned char>(ci) << endl; + cerr << "c == " << hex << (int)static_cast<unsigned char>(c) << endl; + } + test(c == s[i]); + } + test(!nbis.eof()); + nbis.get(c); + test(nbis.eof()); - cout << "ok" << endl; + cout << "ok" << endl; } return EXIT_SUCCESS; diff --git a/cpp/test/IceUtil/uuid/Client.cpp b/cpp/test/IceUtil/uuid/Client.cpp index e405ae74939..bda63c8795d 100644 --- a/cpp/test/IceUtil/uuid/Client.cpp +++ b/cpp/test/IceUtil/uuid/Client.cpp @@ -34,35 +34,35 @@ public: typedef set<T> ItemSet; InsertThread(int threadId, ItemSet& itemSet, GenerateFunc func, long howMany, bool verbose) - : _threadId(threadId), _itemSet(itemSet), _func(func), _howMany(howMany), _verbose(verbose) + : _threadId(threadId), _itemSet(itemSet), _func(func), _howMany(howMany), _verbose(verbose) { } void run() { - for(long i = 0; i < _howMany; i++) - { - T item = _func(); + for(long i = 0; i < _howMany; i++) + { + T item = _func(); - StaticMutex::Lock lock(staticMutex); + StaticMutex::Lock lock(staticMutex); #if defined(_MSC_VER) && (_MSC_VER < 1300) - pair<ItemSet::iterator, bool> ok = _itemSet.insert(item); + pair<ItemSet::iterator, bool> ok = _itemSet.insert(item); #else - pair<typename ItemSet::iterator, bool> ok = _itemSet.insert(item); + pair<typename ItemSet::iterator, bool> ok = _itemSet.insert(item); #endif - if(!ok.second) - { - cerr << "******* iteration " << i << endl; - cerr << "******* Duplicate item: " << *ok.first << endl; - } - - test(ok.second); - - if(_verbose && i > 0 && (i % 100000 == 0)) - { - cout << "Thread " << _threadId << ": generated " << i << " UUIDs." << endl; - } - } + if(!ok.second) + { + cerr << "******* iteration " << i << endl; + cerr << "******* Duplicate item: " << *ok.first << endl; + } + + test(ok.second); + + if(_verbose && i > 0 && (i % 100000 == 0)) + { + cout << "Thread " << _threadId << ": generated " << i << " UUIDs." << endl; + } + } } @@ -80,7 +80,7 @@ struct GenerateUUID string operator()() { - return generateUUID(); + return generateUUID(); } }; @@ -89,15 +89,15 @@ struct GenerateRandomString string operator()() { - string s; - s.resize(20); - char buf[20]; - IceUtil::generateRandom(buf, static_cast<int>(sizeof(buf))); - for(unsigned int i = 0; i < sizeof(buf); ++i) - { - s[i] = 33 + buf[i] % (127-33); // We use ASCII 33-126 (from ! to ~, w/o space). - } - return s; + string s; + s.resize(20); + char buf[20]; + IceUtil::generateRandom(buf, static_cast<int>(sizeof(buf))); + for(unsigned int i = 0; i < sizeof(buf); ++i) + { + s[i] = 33 + buf[i] % (127-33); // We use ASCII 33-126 (from ! to ~, w/o space). + } + return s; } }; IceUtil::StaticMutex lock; @@ -108,7 +108,7 @@ public: int operator()() { - return IceUtil::random(); + return IceUtil::random(); } }; @@ -119,17 +119,17 @@ runTest(int threadCount, GenerateFunc func, long howMany, bool verbose, string n cout << "Generating " << howMany << " " << name << "s using " << threadCount << " thread"; if(threadCount > 1) { - cout << "s"; + cout << "s"; } cout << "... "; if(verbose) { - cout << endl; + cout << endl; } else { - cout << flush; + cout << flush; } set<T> itemSet; @@ -139,12 +139,12 @@ runTest(int threadCount, GenerateFunc func, long howMany, bool verbose, string n Time start = Time::now(); for(int i = 0; i < threadCount; i++) { - ThreadPtr t = new InsertThread<T, GenerateFunc>(i, itemSet, func, howMany / threadCount, verbose); - threads.push_back(t->start()); + ThreadPtr t = new InsertThread<T, GenerateFunc>(i, itemSet, func, howMany / threadCount, verbose); + threads.push_back(t->start()); } for(vector<ThreadControl>::iterator p = threads.begin(); p != threads.end(); ++p) { - p->join(); + p->join(); } Time finish = Time::now(); @@ -153,9 +153,9 @@ runTest(int threadCount, GenerateFunc func, long howMany, bool verbose, string n if(verbose) { cout << "Each " << name << " took an average of " - << (double) ((finish - start).toMicroSeconds()) / howMany - << " micro seconds to generate and insert into a set." - << endl; + << (double) ((finish - start).toMicroSeconds()) / howMany + << " micro seconds to generate and insert into a set." + << endl; } } @@ -167,33 +167,33 @@ int main(int argc, char* argv[]) if(argc > 3) { - usage(argv[0]); - return EXIT_FAILURE; + usage(argv[0]); + return EXIT_FAILURE; } else if(argc == 3) { - howMany = atol(argv[1]); - if (howMany == 0) - { - usage(argv[0]); - return EXIT_FAILURE; - } - threadCount = atoi(argv[2]); - if(threadCount <= 0) - { - usage(argv[0]); - return EXIT_FAILURE; - } - verbose = true; + howMany = atol(argv[1]); + if (howMany == 0) + { + usage(argv[0]); + return EXIT_FAILURE; + } + threadCount = atoi(argv[2]); + if(threadCount <= 0) + { + usage(argv[0]); + return EXIT_FAILURE; + } + verbose = true; } else if(argc == 2) { - howMany = atol(argv[1]); - if (howMany == 0) - { - usage(argv[0]); - return EXIT_FAILURE; - } + howMany = atol(argv[1]); + if (howMany == 0) + { + usage(argv[0]); + return EXIT_FAILURE; + } } runTest<string, GenerateUUID>(threadCount, GenerateUUID(), howMany, verbose, "UUID"); diff --git a/cpp/test/Slice/errorDetection/CaseInsensitive.ice b/cpp/test/Slice/errorDetection/CaseInsensitive.ice index 74f30d56e36..0760387509f 100644 --- a/cpp/test/Slice/errorDetection/CaseInsensitive.ice +++ b/cpp/test/Slice/errorDetection/CaseInsensitive.ice @@ -263,12 +263,12 @@ module CI { interface base1 { - void op(); + void op(); }; interface base2 { - void OP(); + void OP(); }; interface derived extends base1, base2 diff --git a/cpp/test/Slice/errorDetection/ChangedMeaning.ice b/cpp/test/Slice/errorDetection/ChangedMeaning.ice index e853190070e..0286ec8e3f4 100644 --- a/cpp/test/Slice/errorDetection/ChangedMeaning.ice +++ b/cpp/test/Slice/errorDetection/ChangedMeaning.ice @@ -16,24 +16,24 @@ sequence<long> ls; struct s00 { - ls ls; // Changed meaning + ls ls; // Changed meaning }; struct s0 { - Test::ls ls; // OK + Test::ls ls; // OK }; struct s1 { ls mem; - long ls; // Changed meaning + long ls; // Changed meaning }; struct s2 { Test::ls mem; - long ls; // OK + long ls; // OK }; module M @@ -46,21 +46,21 @@ sequence<long> ls; interface i1 { M::ls op(); - void M(); // Changed meaning + void M(); // Changed meaning }; interface i2 { M::ls op(); - long M(); // Changed meaning + long M(); // Changed meaning }; module N { interface n1 extends i1 {}; - interface i1 {}; // Changed meaning - interface i2 extends i2 {}; // Changed meaning + interface i1 {}; // Changed meaning + interface i2 extends i2 {}; // Changed meaning }; @@ -68,8 +68,8 @@ module O { interface n1 extends ::Test::i1 {}; - interface i1 {}; // OK - interface i2 extends ::Test::i2 {}; // OK + interface i1 {}; // OK + interface i2 extends ::Test::i2 {}; // OK }; @@ -81,8 +81,8 @@ module E { exception ee1 extends e1 {}; - exception e1 {}; // Changed meaning - exception e2 extends e2 {}; // Changed meaning + exception e1 {}; // Changed meaning + exception e2 extends e2 {}; // Changed meaning }; @@ -94,8 +94,8 @@ module C { class cc1 implements c1 {}; - class c1 {}; // Changed meaning - class c2 extends c2 {}; // Changed meaning + class c1 {}; // Changed meaning + class c2 extends c2 {}; // Changed meaning }; @@ -106,7 +106,7 @@ module B const color fc = blue; - interface blue {}; // Changed meaning + interface blue {}; // Changed meaning }; @@ -123,40 +123,40 @@ interface ParamTest { void op(long param); void op2(counter param); - void param(counter counter); // Changed meaning - void op3(long counter, counter x); // Second "counter" is not a type + void param(counter counter); // Changed meaning + void op3(long counter, counter x); // Second "counter" is not a type void op4(long param, long param); }; sequence<int> IS; struct x { - IS is; // Changed meaning (case-insensitive) + IS is; // Changed meaning (case-insensitive) }; struct y { - ::Test::IS is; // OK, nothing introduced + ::Test::IS is; // OK, nothing introduced }; interface Blah { - void op1() throws ::Test::E::ee1; // Nothing introduced - void E(); // OK - void op2() throws E; // Changed meaning + void op1() throws ::Test::E::ee1; // Nothing introduced + void E(); // OK + void op2() throws E; // Changed meaning }; interface Blah2 { - void op3() throws ::Test::E::ee1; // Nothing introduced - void E(); // OK - void op4() throws E::ee1; // Changed meaning + void op3() throws ::Test::E::ee1; // Nothing introduced + void E(); // OK + void op4() throws E::ee1; // Changed meaning }; interface Blah3 { - void op5() throws E::ee1; // Introduces E - void E(); // Changed meaning + void op5() throws E::ee1; // Introduces E + void E(); // Changed meaning }; module M1 @@ -165,7 +165,7 @@ module M1 struct smnpStruct { - smnpEnum e; + smnpEnum e; }; exception smnpException diff --git a/cpp/test/Slice/errorDetection/ConstDef.ice b/cpp/test/Slice/errorDetection/ConstDef.ice index 1f92f5a92d1..0af93184258 100644 --- a/cpp/test/Slice/errorDetection/ConstDef.ice +++ b/cpp/test/Slice/errorDetection/ConstDef.ice @@ -72,57 +72,57 @@ const float nf9 = -1E+1; const float nf10 = -1E+1f; const float nf11 = -1E1F; -const XXX ic1 = 1; // no such type -const long f11 = 1; // redefinition -const long F10 = 1; // case-insensitive redefinition +const XXX ic1 = 1; // no such type +const long f11 = 1; // redefinition +const long F10 = 1; // case-insensitive redefinition sequence<long> LS; -const LS ic2 = 1; // illegal constant type -const Object ic3 = 0; // illegal constant type +const LS ic2 = 1; // illegal constant type +const Object ic3 = 0; // illegal constant type -const bool ic4 = 0; // type mismatch -const byte ic5 = "hello"; // type mismatch -const short ic6 = 1.1; // type mismatch -const int ic7 = blue; // type mismatch -const long ic8 = false; // type mismatch +const bool ic4 = 0; // type mismatch +const byte ic5 = "hello"; // type mismatch +const short ic6 = 1.1; // type mismatch +const int ic7 = blue; // type mismatch +const long ic8 = false; // type mismatch -const long = 0; // missing identifier +const long = 0; // missing identifier enum digit { one, two }; -const color ic9 = two; // wrong enumerator type -const color ic10 = 0; // wrong initializer type +const color ic9 = two; // wrong enumerator type +const color ic10 = 0; // wrong initializer type // // Range checks // -const long r1 = 9223372036854775807; // LLONG_MAX, OK -const long r2 = -9223372036854775807; // -LLONG_MAX, OK +const long r1 = 9223372036854775807; // LLONG_MAX, OK +const long r2 = -9223372036854775807; // -LLONG_MAX, OK // // TODO: This should work, but doesn't. STLport can't handle inserting // LLONG_MIN onto a stream and inserts garbage. We can periodically try // this again as new versions of STLport come out... // -// const long r3 = -9223372036854775808; // LLONG_MIN, OK +// const long r3 = -9223372036854775808; // LLONG_MIN, OK // -const long r4 = -9223372036854775809; // underflow -const long r5 = +9223372036854775808; // overflow +const long r4 = -9223372036854775809; // underflow +const long r5 = +9223372036854775808; // overflow -const int i1 = -2147483648; // INT_MIN, OK -const int i2 = +2147483647; // INT_MAX, OK -const int i3 = -2147483649; // underflow -const int i4 = +2147483648; // overflow +const int i1 = -2147483648; // INT_MIN, OK +const int i2 = +2147483647; // INT_MAX, OK +const int i3 = -2147483649; // underflow +const int i4 = +2147483648; // overflow -const short s1 = -32768; // SHORT_MIN, OK -const short s2 = +32767; // SHORT_MAX, OK -const short s3 = -32769; // underflow -const short s4 = +32768; // overflow +const short s1 = -32768; // SHORT_MIN, OK +const short s2 = +32767; // SHORT_MAX, OK +const short s3 = -32769; // underflow +const short s4 = +32768; // overflow -const byte b1 = 0; // OK -const byte b2 = 255; // OK -const byte b3 = -1; // underflow -const byte b4 = 256; // overflow +const byte b1 = 0; // OK +const byte b2 = 255; // OK +const byte b3 = -1; // underflow +const byte b4 = 256; // overflow const string nullstring1 = "a\000"; const string nullstring2 = "a\x000"; diff --git a/cpp/test/Slice/errorDetection/DerivedRedefinition.ice b/cpp/test/Slice/errorDetection/DerivedRedefinition.ice index 483d8483fb8..dc99aca5084 100644 --- a/cpp/test/Slice/errorDetection/DerivedRedefinition.ice +++ b/cpp/test/Slice/errorDetection/DerivedRedefinition.ice @@ -20,8 +20,8 @@ interface Base1 interface Derived1 extends Base1 { - void op(); // error - long op(); // error + void op(); // error + long op(); // error void foo(); }; @@ -32,22 +32,22 @@ interface Base2 interface D1 extends Base1 { - void foo(); // OK + void foo(); // OK }; interface D2 extends D1 { - void op(); // error, op() in Base1 + void op(); // error, op() in Base1 }; interface D3 extends D1, Base2 { - void bar(); // error, op() in Base1 and Base2 + void bar(); // error, op() in Base1 and Base2 }; class c1 { long l; }; -class c2 extends c1 { double l; }; // error -class c3 extends c1 { double d; }; // OK -class c4 extends c3 { short l; }; // error, l in c1 +class c2 extends c1 { double l; }; // error +class c3 extends c1 { double d; }; // OK +class c4 extends c3 { short l; }; // error, l in c1 }; diff --git a/cpp/test/Slice/errorDetection/IdentAsKeyword.ice b/cpp/test/Slice/errorDetection/IdentAsKeyword.ice index 44a5e50e424..6e940706bb4 100644 --- a/cpp/test/Slice/errorDetection/IdentAsKeyword.ice +++ b/cpp/test/Slice/errorDetection/IdentAsKeyword.ice @@ -83,14 +83,14 @@ interface i8 { void op(double BYTE); }; interface i9 { void op(out double byte); }; interface i10 { void op(out double BYTE); }; -interface \true {}; // OK, escaped keyword +interface \true {}; // OK, escaped keyword -interface _a; // Illegal leading underscore -interface _true; // Illegal leading underscore -interface \_true; // Illegal leading underscore +interface _a; // Illegal leading underscore +interface _true; // Illegal leading underscore +interface \_true; // Illegal leading underscore -interface b_; // Illegal underscore -interface tr_ue; // Illegal underscore -interface \tr_ue; // Illegal underscore +interface b_; // Illegal underscore +interface tr_ue; // Illegal underscore +interface \tr_ue; // Illegal underscore }; diff --git a/cpp/test/Slice/errorDetection/IllegalDictionary.ice b/cpp/test/Slice/errorDetection/IllegalDictionary.ice index e7863ef7b62..18b59a7a812 100644 --- a/cpp/test/Slice/errorDetection/IllegalDictionary.ice +++ b/cpp/test/Slice/errorDetection/IllegalDictionary.ice @@ -12,48 +12,48 @@ module Test { -dictionary<bool, long> d1; // OK -dictionary<byte, long> d2; // OK -dictionary<short, long> d3; // OK -dictionary<int, long> d4; // OK -dictionary<long, long> d5; // OK -dictionary<string, long> d6; // OK - -dictionary<float, long> b1; // Bad -dictionary<double, long> b2; // Bad -dictionary<Object, long> b3; // Bad -dictionary<Object*, long> b4; // Bad -dictionary<LocalObject, long> b5; // Bad +dictionary<bool, long> d1; // OK +dictionary<byte, long> d2; // OK +dictionary<short, long> d3; // OK +dictionary<int, long> d4; // OK +dictionary<long, long> d5; // OK +dictionary<string, long> d6; // OK + +dictionary<float, long> b1; // Bad +dictionary<double, long> b2; // Bad +dictionary<Object, long> b3; // Bad +dictionary<Object*, long> b4; // Bad +dictionary<LocalObject, long> b5; // Bad sequence<byte> s1; -dictionary<s1, long> d7; // OK +dictionary<s1, long> d7; // OK sequence<float> s2; -dictionary<s2, long> b6; // Bad +dictionary<s2, long> b6; // Bad sequence<s1> s3; -dictionary<s3, long> b7; // OK +dictionary<s3, long> b7; // OK struct st1 { long x; long y; }; -dictionary<st1, long> d8; // OK +dictionary<st1, long> d8; // OK struct st2 { long x; float y; }; -dictionary<st2, long> b8; // Bad +dictionary<st2, long> b8; // Bad enum e { e1, e2 }; -dictionary<e, long> d9; // OK +dictionary<e, long> d9; // OK sequence<e> s4; -dictionary<s4, long> d10; // OK +dictionary<s4, long> d10; // OK -dictionary<d9, long> b9; // Bad +dictionary<d9, long> b9; // Bad }; diff --git a/cpp/test/Slice/errorDetection/IllegalLocal.ice b/cpp/test/Slice/errorDetection/IllegalLocal.ice index 44fad05de27..8ab2d9b63a8 100644 --- a/cpp/test/Slice/errorDetection/IllegalLocal.ice +++ b/cpp/test/Slice/errorDetection/IllegalLocal.ice @@ -14,51 +14,51 @@ module Test interface i1 {}; -local interface i2 extends i1 {}; // error +local interface i2 extends i1 {}; // error -interface i3 extends i2 {}; // error +interface i3 extends i2 {}; // error -local interface i4 extends i2 {}; // OK +local interface i4 extends i2 {}; // OK -class c1 implements i1 {}; // OK +class c1 implements i1 {}; // OK -class c2 implements i2 {}; // error +class c2 implements i2 {}; // error local exception le {}; interface i { - void op() throws le; // error + void op() throws le; // error }; -exception le2 extends le {}; // error +exception le2 extends le {}; // error local sequence<long> lls; class c3 { - LocalObject lo1; // error - i2* lo2; // error - i2 lo3; // error - lls ls; // error + LocalObject lo1; // error + i2* lo2; // error + i2 lo3; // error + lls ls; // error }; struct s1 { - lls ls; // error + lls ls; // error }; exception e3 { - lls ls; // error + lls ls; // error }; -sequence<LocalObject> los; // error +sequence<LocalObject> los; // error local sequence<byte> bs; -dictionary<bs, long> d1; // error -dictionary<long, bs> d2; // error -dictionary<bs, bs> d3; // error +dictionary<bs, long> d1; // error +dictionary<long, bs> d2; // error +dictionary<bs, bs> d3; // error local interface i4; struct s2 @@ -84,12 +84,12 @@ exception E local interface i6 { - void op() throws E; // error + void op() throws E; // error }; local class c7 { - void op() throws E; // error + void op() throws E; // error }; }; diff --git a/cpp/test/Slice/errorDetection/IllegalMI.ice b/cpp/test/Slice/errorDetection/IllegalMI.ice index 4dc2d4bd731..395a4b0b7c5 100644 --- a/cpp/test/Slice/errorDetection/IllegalMI.ice +++ b/cpp/test/Slice/errorDetection/IllegalMI.ice @@ -59,7 +59,7 @@ module M2 void op(); }; - interface A3 extends A2, B2 // Error + interface A3 extends A2, B2 // Error { void ia3(); }; @@ -200,7 +200,7 @@ module M7 void ic1(); }; - interface A2 extends A1, B1, C1 // Error + interface A2 extends A1, B1, C1 // Error { void ia2(); }; @@ -228,7 +228,7 @@ module M8 void op(); }; - interface A2 extends A1, B1, C1 // Error + interface A2 extends A1, B1, C1 // Error { void ia2(); }; @@ -256,7 +256,7 @@ module M9 void op(); }; - interface A2 extends A1, B1, C1 // Error + interface A2 extends A1, B1, C1 // Error { void ia2(); }; @@ -286,7 +286,7 @@ module M10 void op(); }; - interface A2 extends A1, B1, C1 // Error + interface A2 extends A1, B1, C1 // Error { void ia2(); }; @@ -350,7 +350,7 @@ module M12 void id1(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -384,7 +384,7 @@ module M13 void id1(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -417,7 +417,7 @@ module M14 void op(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -451,7 +451,7 @@ module M15 void id1(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -485,7 +485,7 @@ module M16 void op(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -519,7 +519,7 @@ module M17 void op(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -554,7 +554,7 @@ module M18 void id1(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -624,7 +624,7 @@ module M20 void op(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -659,7 +659,7 @@ module M21 void op(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -695,7 +695,7 @@ module M22 void op(); }; - interface A2 extends A1, B1, C1, D1 // Error + interface A2 extends A1, B1, C1, D1 // Error { void ia2(); }; @@ -737,7 +737,7 @@ module M23 void id1(); }; - interface A2 extends A1, B1, C1, D1 // OK + interface A2 extends A1, B1, C1, D1 // OK { void ia2(); }; @@ -899,7 +899,7 @@ module M26 void ib3(); }; - interface A4 extends A3, B3 // OK + interface A4 extends A3, B3 // OK { void ia4(); }; @@ -973,7 +973,7 @@ module M27 void ib3(); }; - interface A4 extends A3, B3 // Error + interface A4 extends A3, B3 // Error { void ia4(); }; @@ -1047,7 +1047,7 @@ module M28 void ib3(); }; - interface A4 extends A3, B3 // Error + interface A4 extends A3, B3 // Error { void ia4(); }; @@ -1121,7 +1121,7 @@ module M29 void ib3(); }; - interface A4 extends A3, B3 // Error + interface A4 extends A3, B3 // Error { void ia4(); }; @@ -1193,7 +1193,7 @@ module M30 void ib3(); }; - interface A4 extends A3, B3 // Error + interface A4 extends A3, B3 // Error { void ia4(); }; @@ -1265,7 +1265,7 @@ module M31 void ib3(); }; - interface A4 extends A3, B3 // Error + interface A4 extends A3, B3 // Error { void ia4(); }; diff --git a/cpp/test/Slice/errorDetection/Reserved.ice b/cpp/test/Slice/errorDetection/Reserved.ice index c14a5a449a7..b1519bbcbe8 100644 --- a/cpp/test/Slice/errorDetection/Reserved.ice +++ b/cpp/test/Slice/errorDetection/Reserved.ice @@ -12,7 +12,7 @@ -#include <include/IcePrefix.ice> // No error should be caused by this file +#include <include/IcePrefix.ice> // No error should be caused by this file module OK { diff --git a/cpp/test/Slice/errorDetection/SelfContainment.ice b/cpp/test/Slice/errorDetection/SelfContainment.ice index 9e7ddde676d..0b256b7fce0 100644 --- a/cpp/test/Slice/errorDetection/SelfContainment.ice +++ b/cpp/test/Slice/errorDetection/SelfContainment.ice @@ -15,13 +15,13 @@ module Test struct x { int i; - x j; // Error + x j; // Error }; class y { int i; - y j; // OK + y j; // OK }; }; diff --git a/cpp/test/Slice/errorDetection/StructMembers.ice b/cpp/test/Slice/errorDetection/StructMembers.ice index 86429390781..89c5a2799ca 100644 --- a/cpp/test/Slice/errorDetection/StructMembers.ice +++ b/cpp/test/Slice/errorDetection/StructMembers.ice @@ -12,41 +12,41 @@ module Test { -struct s1 // Illegal empty struct +struct s1 // Illegal empty struct { }; struct s2 { - long l; // One member, OK + long l; // One member, OK }; struct s4 { - [ "Hi" ] long l; // One member with metadata, OK + [ "Hi" ] long l; // One member with metadata, OK }; -struct s5 // Two members, OK +struct s5 // Two members, OK { long l; byte b; }; struct s6 -{ // Two members with metadata, OK - [ "Hi" ] long l; - byte b; +{ // Two members with metadata, OK + [ "Hi" ] long l; + byte b; }; -struct s7 // Two members with metadata, OK +struct s7 // Two members with metadata, OK { - [ "Hi" ] long l; - [ "there" ] byte b; + [ "Hi" ] long l; + [ "there" ] byte b; }; struct s8 { - [ "hi" ] long ; // Missing data member name + [ "hi" ] long ; // Missing data member name }; struct s9 @@ -56,12 +56,12 @@ struct s9 struct s10 { - long ; // Missing data member name + long ; // Missing data member name }; struct s11 { - long // Missing data member name + long // Missing data member name }; }; diff --git a/cpp/test/Slice/errorDetection/run.py b/cpp/test/Slice/errorDetection/run.py index 70e7550f1d6..52b20f94051 100755 --- a/cpp/test/Slice/errorDetection/run.py +++ b/cpp/test/Slice/errorDetection/run.py @@ -39,9 +39,9 @@ for file in files: print file + "...", if file == "CaseSensitive.ice": - command = slice2cpp + " --case-sensitive -I. " + os.path.join(directory, file); + command = slice2cpp + " --case-sensitive -I. " + os.path.join(directory, file); else: - command = slice2cpp + " -I. " + os.path.join(directory, file); + command = slice2cpp + " -I. " + os.path.join(directory, file); stdin, stdout, stderr = os.popen3(command) lines1 = stdout.readlines() lines2 = open(os.path.join(directory, regex1.sub(".err", file)), "r").readlines() |