Author: hoang_to
Date: 2010-04-13 07:09:15 -0400 (Tue, 13 Apr 2010)
New Revision: 2601
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
Log:
GTNPORTAL-1007: Update test case on node name immutability
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-04-13
08:01:36 UTC (rev 2600)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-04-13
11:09:15 UTC (rev 2601)
@@ -30,6 +30,7 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PageBody;
import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.pom.config.POMDataStorage;
import org.exoplatform.portal.pom.config.POMSession;
@@ -704,6 +705,71 @@
}.execute(null);
}
+ public void testNodeNameImmutability()
+ {
+ new UnitTest()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ String ownerType = "group";
+ String ownerId = "/platform/administrators";
+ String formerName = "testtest";
+ String updatedName = "updatedupdated";
+
+ PageNavigation pageNav = new PageNavigation();
+ pageNav.setOwnerType(ownerType);
+ pageNav.setOwnerId(ownerId);
+
+ storage_.remove(pageNav);
+ storage_.create(pageNav);
+
+ pageNav = storage_.getPageNavigation(ownerType, ownerId);
+ assertNotNull("Could not create navigation!", pageNav);
+ PageNode pageNode = new PageNode();
+ pageNode.setName(formerName);
+ pageNode.setUri(formerName + "_uri");
+ pageNode.setLabel(formerName + "_label");
+ pageNav.addNode(pageNode);
+
+ storage_.save(pageNav);
+
+ pageNav = storage_.getPageNavigation(ownerType, ownerId);
+ pageNode = pageNav.getNode(formerName);
+ //Check if the node with name containing '_' has been created
+ assertNotNull("Could not create page node!", pageNode);
+ assertEquals(formerName, pageNode.getName());
+ assertEquals(formerName + "_uri", pageNode.getUri());
+ assertEquals(formerName + "_label", pageNode.getLabel());
+
+ pageNode.setName(updatedName);
+ pageNode.setUri(updatedName + "_uri");
+ pageNode.setLabel(updatedName + "_label");
+
+ storage_.save(pageNav);
+
+ pageNav = storage_.getPageNavigation(ownerType, ownerId);
+ pageNode = pageNav.getNode(updatedName);
+ assertNull("Node name has been updated", pageNode);
+
+ pageNode = pageNav.getNode(formerName);
+ assertNotNull("Could not find node " + formerName, pageNode);
+ assertEquals(formerName, pageNode.getName());
+ assertEquals(updatedName + "_uri", pageNode.getUri());
+ assertEquals(updatedName + "_label", pageNode.getLabel());
+
+ for(PageNode node : pageNav.getNodes())
+ {
+ StringBuffer message = new StringBuffer("Current node metadata:
\n");
+ message.append("Name: " + node.getName() + "\n");
+ message.append("Label: " + node.getLabel() + "\n");
+ message.append("Uri: " + node.getUri() + "\n");
+ System.out.println(message.toString());
+ }
+ }
+ }.execute(null);
+ }
+
public void testRenewPage()
{
new UnitTest()