summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/slice/IceGrid/Descriptor.ice12
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp27
-rw-r--r--cpp/test/IceGrid/update/AllTests.cpp63
3 files changed, 92 insertions, 10 deletions
diff --git a/cpp/slice/IceGrid/Descriptor.ice b/cpp/slice/IceGrid/Descriptor.ice
index 959469eefa8..96fe3fbfb51 100644
--- a/cpp/slice/IceGrid/Descriptor.ice
+++ b/cpp/slice/IceGrid/Descriptor.ice
@@ -478,6 +478,11 @@ class ApplicationDescriptor
};
["java:type:java.util.LinkedList"] sequence<ApplicationDescriptor> ApplicationDescriptorSeq;
+class BoxedComment
+{
+ string value;
+};
+
struct ApplicationUpdateDescriptor
{
/**
@@ -489,6 +494,13 @@ struct ApplicationUpdateDescriptor
/**
*
+ * The updated comment (or null if the comment doesn't need to be updated).
+ *
+ **/
+ BoxedComment comment;
+
+ /**
+ *
* The variables to update.
*
**/
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index a14c0ccba90..fe972055156 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -659,34 +659,41 @@ ApplicationDescriptorHelper::update(const ApplicationUpdateDescriptor& update)
_templates->setDescriptor(newApp);
newApp->name = oldApp->name;
- newApp->comment = oldApp->comment;
+ newApp->comment = newUpdate.comment ? newUpdate.comment->value : oldApp->comment;
newApp->targets = oldApp->targets;
newApp->variables = oldApp->variables;
- for(map<string, string>::const_iterator q = newUpdate.variables.begin(); q != newUpdate.variables.end(); ++q)
- {
- newApp->variables[q->first] = q->second;
- _variables->addVariable(q->first, q->second);
- }
Ice::StringSeq::const_iterator p;
for(p = newUpdate.removeVariables.begin(); p != newUpdate.removeVariables.end(); ++p)
{
newApp->variables.erase(*p);
_variables->remove(*p);
}
+ for(map<string, string>::const_iterator q = newUpdate.variables.begin(); q != newUpdate.variables.end(); ++q)
+ {
+ newApp->variables[q->first] = q->second;
+ _variables->addVariable(q->first, q->second);
+ }
- newApp->serverTemplates = newUpdate.serverTemplates;
- newApp->serverTemplates.insert(oldApp->serverTemplates.begin(), oldApp->serverTemplates.end());
+ newApp->serverTemplates = oldApp->serverTemplates;
for(p = newUpdate.removeServerTemplates.begin(); p != newUpdate.removeServerTemplates.end(); ++p)
{
newApp->serverTemplates.erase(*p);
}
+ TemplateDescriptorDict::const_iterator t;
+ for(t = newUpdate.serverTemplates.begin(); t != newUpdate.serverTemplates.end(); ++t)
+ {
+ newApp->serverTemplates[t->first] = t->second;
+ }
- newApp->serviceTemplates = newUpdate.serviceTemplates;
- newApp->serviceTemplates.insert(oldApp->serviceTemplates.begin(), oldApp->serviceTemplates.end());
+ newApp->serviceTemplates = oldApp->serviceTemplates;
for(p = newUpdate.removeServiceTemplates.begin(); p != newUpdate.removeServiceTemplates.end(); ++p)
{
newApp->serviceTemplates.erase(*p);
}
+ for(t = newUpdate.serviceTemplates.begin(); t != newUpdate.serviceTemplates.end(); ++t)
+ {
+ newApp->serviceTemplates[t->first] = t->second;
+ }
newApp->nodes = newUpdate.nodes;
set<string> removed(newUpdate.removeNodes.begin(), newUpdate.removeNodes.end());
diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp
index 0cd35b4571c..e1c7b8030a3 100644
--- a/cpp/test/IceGrid/update/AllTests.cpp
+++ b/cpp/test/IceGrid/update/AllTests.cpp
@@ -718,7 +718,70 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(false);
}
}
+ admin->removeApplication("TestApp");
+ cout << "ok" << endl;
+ }
+
+ {
+ cout << "testing comment update..." << flush;
+
+ ApplicationDescriptorPtr testApp = new ApplicationDescriptor();
+ testApp->name = "TestApp";
+ testApp->comment = "Comment";
+ try
+ {
+ admin->addApplication(testApp);
+ }
+ catch(const Ice::UserException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+ testApp = admin->getApplicationDescriptor("TestApp");
+ test(testApp->comment == "Comment");
+
+ ApplicationUpdateDescriptor update;
+ update.name = "TestApp";
+ try
+ {
+ admin->updateApplication(update);
+ }
+ catch(const Ice::UserException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+ testApp = admin->getApplicationDescriptor("TestApp");
+ test(testApp->comment == "Comment");
+ update.comment = new BoxedComment("updatedComment");
+ try
+ {
+ admin->updateApplication(update);
+ }
+ catch(const Ice::UserException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+ testApp = admin->getApplicationDescriptor("TestApp");
+ test(testApp->comment == "updatedComment");
+
+ update.comment = new BoxedComment("");
+ try
+ {
+ admin->updateApplication(update);
+ }
+ catch(const Ice::UserException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+ testApp = admin->getApplicationDescriptor("TestApp");
+ test(testApp->comment == "");
+
+ admin->removeApplication("TestApp");
+
cout << "ok" << endl;
}
}