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

📄 alltests.cpp

📁 ICE-3.2 一个开源的中间件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            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, "${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 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}";

⌨️ 快捷键说明

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