⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alltests.cpp

📁 ICE-3.2 一个开源的中间件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    test(obj->getProperty("Service1.Type") == "standard");    test(obj->getProperty("Service1.ServiceName") == "Service1");    test(obj->getProperty("TestService1Identity") == "IceBox1-Service1");    test(obj->getProperty("LogFilePath") == "test-Service1.log");    test(obj->getProperty("LogFilePath-Service1") == "test.log");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter"));    test(obj->getProperty("Service2.Type") == "freeze");    test(obj->getProperty("Service2.ServiceName") == "Service2");    test(obj->getProperty("Service2.DebugProperty") == "");    test(obj->getProperty("Service1.DebugProperty") == "");    cout << "ok" << endl;    cout << "testing server options... " << flush;    obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server"));    test(obj->getProperty("Test.Test") == "2");    test(obj->getProperty("Test.Test1") == "0");    cout << "ok" << endl;    cout << "testing variables... " << flush;    vector<TestIntfPrx> proxies;    obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server"));    proxies.push_back(obj);    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1"));    proxies.push_back(obj);    obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server"));    proxies.push_back(obj);    obj = TestIntfPrx::checkedCast(        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");    }    cout << "ok" << endl;    cout << "testing parameters... " << flush;    obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server"));    test(obj->getProperty("Param1Prop") == "Param1");    test(obj->getProperty("Param2Prop") == "AppVar");    test(obj->getProperty("ParamEscapedProp") == "${escaped}");    test(obj->getProperty("ParamDoubleEscapedProp") == "$escapedvalue");    test(obj->getProperty("AppVarOverridedByParamProp") == "Overrided");    test(obj->getProperty("NodeVarOverridedByParamProp") == "Test");    test(obj->getProperty("DefaultParamProp") == "VALUE");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server2@Server2.Server"));    test(obj->getProperty("Param1Prop") == "Param12");    test(obj->getProperty("Param2Prop") == "OverridedInNode");    test(obj->getProperty("ParamEscapedProp") == "${escaped}");    test(obj->getProperty("ParamDoubleEscapedProp") == "$escapedvalue");    test(obj->getProperty("AppVarOverridedByParamProp") == "Overrided");    test(obj->getProperty("NodeVarOverridedByParamProp") == "Test");    test(obj->getProperty("DefaultParamProp") == "OTHERVALUE");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1"));    test(obj->getProperty("AppVarOverridedByParamProp") == "Test");    test(obj->getProperty("NodeVarOverridedByParamProp") == "Overrided");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service2@IceBox1Service2Adapter"));    test(obj->getProperty("AppVarOverridedByParamProp") == "Test");    test(obj->getProperty("NodeVarOverridedByParamProp") == "Test");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1"));    test(obj->getProperty("AppVarOverridedByParamProp") == "Test");    test(obj->getProperty("NodeVarOverridedByParamProp") == "Overrided");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter"));    test(obj->getProperty("AppVarOverridedByParamProp") == "Test");    test(obj->getProperty("NodeVarOverridedByParamProp") == "Test");        cout << "ok" << endl;    cout << "testing descriptions... " << flush;    //    // NOTE: We can't test the following since    // getApplicationDescriptor doesn't return the instantiated    // application descriptor...    ////     ApplicationDescriptor desc = admin->getApplicationDescriptor("test");//     test(desc.description == "APP AppVar");//     test(desc.nodes["localnode"].description == "NODE NodeVar");//     test(desc.replicaGroups[0].description == "REPLICA GROUP AppVar");//     test(desc.nodes["localnode"].servers.size() == 2);//    const int idx = desc.nodes["localnode"].servers[0]->id == "SimpleServer" ? 0 : 1;    ServerInfo info = admin->getServerInfo("SimpleServer");    test(info.descriptor->id == "SimpleServer");    test(info.descriptor->description == "SERVER NodeVar");    test(info.descriptor->adapters[0].description == "ADAPTER NodeVar");    test(info.descriptor->dbEnvs[0].description == "DBENV NodeVar");    cout << "ok" << endl;        cout << "testing property sets..." << flush;    obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server"));    test(obj->getProperty("AppProperty") == "AppVar");    test(obj->getProperty("AppProperty2") == "OverrideMe");    test(obj->getProperty("AppProperty21") == "Override");    test(obj->getProperty("NodeProperty") == "NodeVar");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server2@Server2.Server"));    test(obj->getProperty("AppProperty") == "AppVar");    test(obj->getProperty("AppProperty2") == "OverrideMe");    test(obj->getProperty("AppProperty21") == "Override");    test(obj->getProperty("NodeProperty") == "NodeVar");    test(obj->getProperty("ServerInstanceProperty") == "Server2");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1"));    test(obj->getProperty("AppProperty") == ""); // IceBox server properties aren't inherited for IceBox1    test(obj->getProperty("AppProperty2") == "");    test(obj->getProperty("AppProperty21") == "");    test(obj->getProperty("NodeProperty") == "");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1"));    test(obj->getProperty("AppProperty") == "AppVar");    test(obj->getProperty("AppProperty2") == "OverrideMe");    test(obj->getProperty("AppProperty21") == "Override");    test(obj->getProperty("NodeProperty") == "NodeVar");    test(obj->getProperty("IceBoxInstanceProperty") == "IceBox2");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter"));        test(obj->getProperty("AppProperty") == "AppVar");    test(obj->getProperty("AppProperty2") == "OverrideMe");    test(obj->getProperty("AppProperty21") == "Override");    test(obj->getProperty("NodeProperty") == "NodeVar");    test(obj->getProperty("IceBoxInstanceProperty") == "IceBox2");    test(obj->getProperty("ServiceInstanceProperty") == "Service2");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server"));    test(obj->getProperty("AppProperty") == "AppVar");    test(obj->getProperty("AppProperty2") == "OverrideMe");    test(obj->getProperty("AppProperty21") == "Override");    test(obj->getProperty("NodeProperty") == "NodeVar");         obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1"));    test(obj->getProperty("ServerInstanceServiceProperty") == "service1");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service4@IceBox1.Service4.Service4"));    test(obj->getProperty("ServerInstanceServiceProperty") == "service4");    obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service4@IceBox2.Service4.Service4"));    test(obj->getProperty("IceBoxInstanceProperty") == "overriden");    cout << "ok" << endl;    cout << "testing validation... " << flush;    TemplateDescriptor templ;    templ.parameters.push_back("name");    templ.parameters.push_back("nam3");    templ.parameters.push_back("nam2");    templ.parameters.push_back("nam3");    templ.descriptor = new ServerDescriptor();    ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(templ.descriptor);    server->id = "test";    server->exe = "${test.dir}/server";    ApplicationDescriptor desc;    desc.name = "App";    desc.serverTemplates["ServerTemplate"] = templ;    try    {        admin->addApplication(desc);        test(false);    }    catch(const DeploymentException& ex)    {        test(ex.reason.find("duplicate parameters") != string::npos);    }    catch(const Ice::Exception& ex)    {        cerr << ex << endl;        test(false);    }    cout << "ok" << endl;    cout << "testing stderr/stdout/log files... " << flush;    string testDir = comm->getProperties()->getProperty("TestDir");    assert(!testDir.empty());    try    {        session->openServerStdErr("LogServer", -1);        test(false);    }    catch(const FileNotAvailableException&)    {    }    try    {        session->openServerStdOut("LogServer", -1);        test(false);    }    catch(const FileNotAvailableException&)    {    }    try    {        session->openServerLog("LogServer", "unknown.txt", -1);        test(false);    }    catch(const FileNotAvailableException&)    {    }    obj = TestIntfPrx::checkedCast(comm->stringToProxy("LogServer"));    try    {        session->openServerStdErr("LogServer", -1)->destroy();        session->openServerStdOut("LogServer", -1)->destroy();    }    catch(const FileNotAvailableException& ex)    {        cerr << ex.reason << endl;        test(false);    }    FileIteratorPrx it;    Ice::StringSeq lines;    try    {        //        // Test with empty file.        //         ofstream os((testDir + "/log1.txt").c_str());        os.close();        it = session->openServerLog("LogServer", testDir + "/log1.txt", -1);        test(it->read(1024, lines) && lines.empty());        test(it->read(1024, lines) && lines.empty());        it->destroy();        it = session->openServerLog("LogServer", testDir + "/log1.txt", 0);        test(it->read(1024, lines) && lines.empty());        test(it->read(1024, lines) && lines.empty());        it->destroy();        it = session->openServerLog("LogServer", testDir + "/log1.txt", 100);        test(it->read(1024, lines) && lines.empty());        test(it->read(1024, lines) && lines.empty());        it->destroy();    }    catch(const FileNotAvailableException& ex)    {        cerr << ex.reason << endl;        test(false);    }    try    {        //        // Test with log file with one line with no EOL on last line.        // 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -