Author: nscavell
Date: 2011-05-23 12:01:18 -0400 (Mon, 23 May 2011)
New Revision: 6527
Added:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java
portal/branches/stax-integration/component/portal/src/test/resources/stax/loaded-page.xml
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/AbstractStaxTestCase.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPage.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java
Log:
GTNPORTAL-1905: Commit GateIn object StAX parser and JUnit tests
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.portal.config.stax;
+import org.exoplatform.portal.config.model.ModelObject;
import org.staxnav.StaxNavigator;
/**
@@ -27,25 +28,25 @@
public class AbstractStAXParserFactory
{
- public static AbstractStAXParser getParser(StAXElement element,
StaxNavigator<StAXElement> elementNavigator)
+ @SuppressWarnings("unchecked")
+ public static <T extends ModelObject> AbstractStAXParser<T>
getParser(StAXElement element, StaxNavigator<StAXElement> elementNavigator)
{
switch(element)
{
case page:
- return new PageStAXParser(elementNavigator);
+ return (AbstractStAXParser<T>) new PageStAXParser(elementNavigator);
case page_body:
- return new PageBodyStAXParser(elementNavigator);
+ return (AbstractStAXParser<T>) new
PageBodyStAXParser(elementNavigator);
case portal_config:
- return new PortalConfigStAXParser(elementNavigator);
+ return (AbstractStAXParser<T>) new
PortalConfigStAXParser(elementNavigator);
case portlet_application:
- return new PortletWindowStAXParser(elementNavigator);
+ return (AbstractStAXParser<T>) new
PortletWindowStAXParser(elementNavigator);
case gadget_application:
- return new GadgetWindowStAXParer(elementNavigator);
+ return (AbstractStAXParser<T>) new
GadgetWindowStAXParer(elementNavigator);
case container:
- return new ContainerStAXParser(elementNavigator);
+ return (AbstractStAXParser<T>) new
ContainerStAXParser(elementNavigator);
default:
throw new IllegalArgumentException("StAXElement " + element +
" is not associated with any subclass of ModelObject");
}
-
}
}
Added:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ApplicationStAXParser.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.stax;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.pom.config.Utils;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public abstract class ApplicationStAXParser<S> extends
AbstractStAXParser<Application<S>>
+{
+ private Application<S> application;
+
+ public ApplicationStAXParser(ApplicationType<S> applicationType,
StaxNavigator<StAXElement> elementNavigator) throws IllegalArgumentException
+ {
+ super(elementNavigator);
+ application = new Application<S>(applicationType);
+ }
+
+ @Override
+ public final Application<S> parseXML() throws StaxNavException
+ {
+ application.setState(parseApplicationState());
+
+ application.setTheme(getContent(elementNavigator, StAXElement.theme));
+ application.setTitle(getContent(elementNavigator, StAXElement.title));
+ application.setAccessPermissions(Utils.split(";",
getContent(elementNavigator, StAXElement.access_permissions)));
+ application.setShowInfoBar("true".equals(getContent(elementNavigator,
StAXElement.show_info_bar)));
+
application.setShowApplicationState("true".equals(getContent(elementNavigator,
StAXElement.show_application_state)));
+
application.setShowApplicationMode("true".equals(getContent(elementNavigator,
StAXElement.show_application_mode)));
+ application.setDescription(getContent(elementNavigator, StAXElement.description));
+ application.setIcon(getContent(elementNavigator, StAXElement.icon));
+ application.setWidth(getContent(elementNavigator, StAXElement.width));
+ application.setHeight(getContent(elementNavigator, StAXElement.height));
+
+ return application;
+ }
+
+ public abstract ApplicationState<S> parseApplicationState() throws
StaxNavException;
+
+ public abstract boolean isElementOptional(StAXElement stAXElement) throws
StaxNavException;
+
+ @Override
+ public final boolean isOptional(StAXElement staxElement)
+ {
+ switch (staxElement)
+ {
+ case theme:
+ case title:
+ case show_application_state:
+ case show_application_mode:
+ case description:
+ case icon:
+ case width:
+ case height:
+ return true;
+
+ default:
+ return isElementOptional(staxElement);
+ }
+ }
+}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -62,6 +62,7 @@
final Set<StAXElement> childElementSet = new HashSet<StAXElement>();
childElementSet.add(StAXElement.portlet_application);
+ childElementSet.add(StAXElement.gadget_application);
childElementSet.add(StAXElement.container);
elementNavigator.next(childElementSet);
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -18,9 +18,9 @@
*/
package org.exoplatform.portal.config.stax;
-import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.config.serialize.GadgetApplication;
import org.exoplatform.portal.pom.spi.gadget.Gadget;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
@@ -29,36 +29,26 @@
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/19/11
*/
-public class GadgetWindowStAXParer extends
AbstractStAXParser<Application<Gadget>>
+public class GadgetWindowStAXParer extends ApplicationStAXParser<Gadget>
{
public GadgetWindowStAXParer(StaxNavigator<StAXElement> elementNavigator)
{
- super(elementNavigator);
+ super(ApplicationType.GADGET, elementNavigator);
}
@Override
- public Application<Gadget> parseXML() throws StaxNavException
+ public ApplicationState<Gadget> parseApplicationState() throws StaxNavException
{
elementNavigator.next(StAXElement.gadget);
String gadgetName = getContent(elementNavigator, StAXElement.gadget_ref);
- TransientApplicationState<Gadget> state = new
TransientApplicationState<Gadget>(gadgetName, null);
- Application<Gadget> app = Application.createGadgetApplication();
- app.setState(state);
-
- return app;
+ return new TransientApplicationState<Gadget>(gadgetName, null);
}
@Override
- public boolean isOptional(StAXElement staxElement)
+ public boolean isElementOptional(StAXElement staxElement)
{
- switch(staxElement)
- {
- case gadget_ref:
- return false;
- default:
- return true;
- }
+ return false;
}
}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -18,42 +18,37 @@
*/
package org.exoplatform.portal.config.stax;
-import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationState;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.config.serialize.PortletApplication;
-import org.exoplatform.portal.pom.config.Utils;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
-import org.omg.CORBA.NamedValue;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/9/11
*/
-public class PortletWindowStAXParser extends
AbstractStAXParser<Application<Portlet>>
+public class PortletWindowStAXParser extends ApplicationStAXParser<Portlet>
{
public PortletWindowStAXParser(StaxNavigator<StAXElement> elementNavigator)
{
- super(elementNavigator);
+ super(ApplicationType.PORTLET, elementNavigator);
}
@Override
- public Application<Portlet> parseXML() throws StaxNavException
+ public ApplicationState<Portlet> parseApplicationState() throws
StaxNavException
{
elementNavigator.next(StAXElement.portlet);
String applicationName = getContent(elementNavigator,
StAXElement.application_ref);
String portletName = getContent(elementNavigator, StAXElement.portlet_ref);
- TransientApplicationState<Portlet> state;
-
if(elementNavigator.next(StAXElement.preferences))
{
PortletBuilder builder = new PortletBuilder();
@@ -81,46 +76,22 @@
}
}
- state = new TransientApplicationState<Portlet>(applicationName +
"/" + portletName, builder.build());
+ return new TransientApplicationState<Portlet>(applicationName +
"/" + portletName, builder.build());
}
else
{
- state = new TransientApplicationState<Portlet>(applicationName +
"/" + portletName, null);
+ return new TransientApplicationState<Portlet>(applicationName +
"/" + portletName, null);
}
-
- Application<Portlet> application = Application.createPortletApplication();
- application.setState(state);
-
- application.setTheme(getContent(elementNavigator, StAXElement.theme));
- application.setTitle(getContent(elementNavigator, StAXElement.title));
- application.setAccessPermissions(Utils.split(";",
getContent(elementNavigator, StAXElement.access_permissions)));
- application.setShowInfoBar("true".equals(getContent(elementNavigator,
StAXElement.show_info_bar)));
-
application.setShowApplicationState("true".equals(getContent(elementNavigator,
StAXElement.show_application_state)));
-
application.setShowApplicationMode("true".equals(getContent(elementNavigator,
StAXElement.show_application_mode)));
- application.setDescription(getContent(elementNavigator, StAXElement.description));
- application.setIcon(getContent(elementNavigator, StAXElement.icon));
- application.setWidth(getContent(elementNavigator, StAXElement.width));
- application.setHeight(getContent(elementNavigator, StAXElement.height));
-
- return application;
}
@Override
- public boolean isOptional(StAXElement staxElement)
+ public boolean isElementOptional(StAXElement staxElement)
{
switch(staxElement)
{
case preferences:
- case theme:
- case show_application_state:
- case show_application_mode:
- case description:
- case icon:
- case width:
- case height:
case value:
case read_only:
- case title:
return true;
default:
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/AbstractStaxTestCase.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/AbstractStaxTestCase.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/AbstractStaxTestCase.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
package org.exoplatform.portal.stax;
import junit.framework.TestCase;
@@ -14,7 +36,7 @@
* @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
* @version $Revision$
*/
-public class AbstractStaxTestCase extends TestCase
+public abstract class AbstractStaxTestCase extends TestCase
{
protected StaxNavigator<StAXElement> createNavigator(String resource) throws
RuntimeException
{
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPage.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPage.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPage.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -21,14 +21,18 @@
import org.exoplatform.portal.config.model.Application;
import org.exoplatform.portal.config.model.ApplicationState;
import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.config.stax.PageStAXParser;
import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.Preference;
+import java.util.List;
+
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/11/11
@@ -50,4 +54,220 @@
assertNotNull(page.getChildren());
assertEquals(1, page.getChildren().size());
}
+
+ public void testLoadedPage() throws Exception
+ {
+ PageStAXParser parser = new
PageStAXParser(createNavigator("/stax/loaded-page.xml"));
+ Page page = parser.parseXML();
+
+ assertNotNull(page);
+
+ // Verify page properties
+ assertEquals("loaded-page", page.getName());
+ assertEquals("Loaded Page", page.getTitle());
+ assertEquals("manager:/platform/administrators;manager:/platform/users",
Utils.join(";", page.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", page.getEditPermission());
+
+ // Verify page children
+ assertNotNull(page.getChildren());
+ assertEquals(1, page.getChildren().size());
+ ModelObject component = page.getChildren().get(0);
+ assertTrue(component instanceof Container);
+
+ // Verify root container
+ Container rootContainer = (Container) component;
+ assertEquals("rootContainer", rootContainer.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
rootContainer.getTemplate());
+ assertEquals("Everyone", Utils.join(";",
rootContainer.getAccessPermissions()));
+
+ // Verify root container children
+ List<ModelObject> rootChildren = rootContainer.getChildren();
+ assertNotNull(rootChildren);
+ assertEquals(3, rootChildren.size());
+
+ // Verify container 1
+ ModelObject c1 = rootChildren.get(0);
+ assertNotNull(c1);
+ assertTrue(c1 instanceof Container);
+ Container container1 = (Container) c1;
+ assertEquals("c1", container1.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
container1.getTemplate());
+ assertEquals("*:/platform/users", Utils.join(";",
container1.getAccessPermissions()));
+ {
+ // Verify homepage application
+ assertNotNull(container1.getChildren());
+ assertEquals(1, container1.getChildren().size());
+ ModelObject homeComponent = container1.getChildren().get(0);
+ assertTrue(homeComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
homeComponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/HomePagePortlet", tas.getContentId());
+ Portlet portlet = tas.getContentState();
+ int count = 0;
+ for (Preference pref : portlet)
+ {
+ count++;
+ }
+ assertEquals(3, count);
+ Preference pref = portlet.getPreference("template");
+ assertNotNull(pref);
+ assertEquals("template", pref.getName());
+
assertEquals("system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl",
pref.getValue());
+ assertTrue(pref.isReadOnly());
+
+ pref = portlet.getPreference("empty-preference-value");
+ assertNotNull(pref);
+ assertEquals("empty-preference-value", pref.getName());
+ assertNull(pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ pref = portlet.getPreference("no-preference-value");
+ assertNotNull(pref);
+ assertEquals("no-preference-value", pref.getName());
+ assertNull(pref.getValue());
+ assertFalse(pref.isReadOnly());
+
+ assertEquals("Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme",
application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertTrue(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+
+ // Verify container 2
+ ModelObject c2 = rootChildren.get(1);
+ assertNotNull(c2);
+ assertTrue(c2 instanceof Container);
+ Container container2 = (Container) c2;
+ assertEquals("c2", container2.getId());
+
assertEquals("system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl",
container2.getTemplate());
+ assertEquals("*:/platform/guests", Utils.join(";",
container2.getAccessPermissions()));
+ assertEquals("TableColumnContainer", container2.getFactoryId());
+ assertNotNull(container2.getChildren());
+ assertEquals(2, container2.getChildren().size());
+
+ {
+ // Verify column 1 of container 2
+ ModelObject appregComp = container2.getChildren().get(0);
+ assertTrue(appregComp instanceof Container);
+ Container appregContainer = (Container) appregComp;
+ assertEquals("c2-1", appregContainer.getId());
+
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
appregContainer.getTemplate());
+ assertEquals("300px", appregContainer.getWidth());
+ assertEquals("400px", appregContainer.getHeight());
+ assertEquals("Everyone", Utils.join(";",
appregContainer.getAccessPermissions()));
+ {
+ // Verify app registry application
+ assertNotNull(appregContainer.getChildren());
+ assertEquals(1, appregContainer.getChildren().size());
+ ModelObject appregComponent = appregContainer.getChildren().get(0);
+ assertTrue(appregComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
appregComponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("exoadmin/ApplicationRegistryPortlet",
tas.getContentId());
+ assertNull(tas.getContentState());
+
+
assertEquals("Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme",
application.getTheme());
+ assertEquals("Application Registry", application.getTitle());
+
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Application Registry",
application.getDescription());
+ assertEquals("PortletIcon", application.getIcon());
+ assertEquals("250px", application.getWidth());
+ assertEquals("350px", application.getHeight());
+ }
+
+ // Verify column 2 of container 2
+ ModelObject orgComp = container2.getChildren().get(1);
+ assertTrue(orgComp instanceof Container);
+ Container orgContainer = (Container) orgComp;
+ assertEquals("c2-2", orgContainer.getId());
+
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
orgContainer.getTemplate());
+ assertEquals("200px", orgContainer.getWidth());
+ assertEquals("300px", orgContainer.getHeight());
+ assertEquals("/platform/users", Utils.join(";",
orgContainer.getAccessPermissions()));
+ {
+ // Verify calendar gadget application
+ assertNotNull(orgContainer.getChildren());
+ assertEquals(1, orgContainer.getChildren().size());
+ ModelObject gadgetComponent = orgContainer.getChildren().get(0);
+ assertTrue(gadgetComponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Gadget> application = (Application<Gadget>)
gadgetComponent;
+ assertTrue(application.getType() == ApplicationType.GADGET);
+ ApplicationState<Gadget> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Gadget> tas =
(TransientApplicationState<Gadget>) state;
+ assertEquals("Calendar", tas.getContentId());
+ assertNull(tas.getContentState());
+
+
assertEquals("Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme",
application.getTheme());
+ assertEquals("Calendar Title", application.getTitle());
+
assertEquals("*:/platform/administrators;*:/organization/management/executive-board",
Utils.join(";", application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertFalse(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("Calendar Description",
application.getDescription());
+ assertEquals("StarAwardIcon", application.getIcon());
+ assertEquals("100px", application.getWidth());
+ assertEquals("200px", application.getHeight());
+ }
+ }
+
+ // Verify container 3
+ ModelObject c3 = rootChildren.get(2);
+ assertNotNull(c3);
+ assertTrue(c3 instanceof Container);
+ Container container3 = (Container) c3;
+ assertEquals("c3", container3.getId());
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
container3.getTemplate());
+ assertEquals(container3.getTemplate(),
"system:/groovy/portal/webui/container/UIContainer.gtmpl");
+ assertEquals("Everyone", Utils.join(";",
container3.getAccessPermissions()));
+ assertNull(container3.getFactoryId());
+ {
+ // Verify site map application
+ assertNotNull(container3.getChildren());
+ assertEquals(1, container3.getChildren().size());
+ ModelObject sitemapcomponent = container3.getChildren().get(0);
+ assertTrue(sitemapcomponent instanceof Application);
+ @SuppressWarnings("unchecked")
+ Application<Portlet> application = (Application<Portlet>)
sitemapcomponent;
+ assertTrue(application.getType() == ApplicationType.PORTLET);
+ ApplicationState<Portlet> state = application.getState();
+ assertNotNull(state);
+ assertTrue(state instanceof TransientApplicationState);
+ TransientApplicationState<Portlet> tas =
(TransientApplicationState<Portlet>) state;
+ assertEquals("web/SiteMapPortlet", tas.getContentId());
+ assertNull(tas.getContentState());
+
+ assertEquals("Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme",
application.getTheme());
+ assertEquals("SiteMap", application.getTitle());
+ assertEquals("*:/platform/users", Utils.join(";",
application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertEquals("SiteMap", application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+ }
}
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java 2011-05-23
03:46:39 UTC (rev 6526)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java 2011-05-23
16:01:18 UTC (rev 6527)
@@ -103,8 +103,8 @@
assertEquals(4, count);
assertPreference(portlet, "single-value", "value1");
assertPreference(portlet, "multi-value", "multi-value1",
"multi-value2", "multi-value3");
- assertPreference(portlet, "empty-value", null);
- assertPreference(portlet, "no-value", null);
+ assertPreference(portlet, "empty-value", (String) null);
+ assertPreference(portlet, "no-value", (String) null);
}
private void assertPreference(Portlet portlet, String name, String...values)
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/loaded-page.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/loaded-page.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/loaded-page.xml 2011-05-23
16:01:18 UTC (rev 6527)
@@ -0,0 +1,118 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+<page>
+ <name>loaded-page</name>
+ <title>Loaded Page</title>
+
<access-permissions>manager:/platform/administrators;manager:/platform/users</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <show-max-window>false</show-max-window>
+ <container id="rootContainer"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+ <container id="c1"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>*:/platform/users</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
+ <read-only>true</read-only>
+ </preference>
+ <preference>
+ <name>empty-preference-value</name>
+ <value></value>
+ </preference>
+ <preference>
+ <name>no-preference-value</name>
+ </preference>
+ </preferences>
+ </portlet>
+
<theme>Mac:MacTheme::Default:DefaultTheme::Vista:VistaTheme</theme>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>true</show-application-mode>
+ </portlet-application>
+ </container>
+ <container id="c2"
template="system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl">
+ <access-permissions>*:/platform/guests</access-permissions>
+ <factory-id>TableColumnContainer</factory-id>
+ <container id="c2-1"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl"
width="300px" height="400px">
+ <access-permissions>Everyone</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>exoadmin</application-ref>
+ <portlet-ref>ApplicationRegistryPortlet</portlet-ref>
+ </portlet>
+
<theme>Default:DefaultTheme::Mac:MacTheme::Vista:VistaTheme</theme>
+ <title>Application Registry</title>
+
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Application Registry</description>
+ <icon>PortletIcon</icon>
+ <width>250px</width>
+ <height>350px</height>
+ </portlet-application>
+ </container>
+ <container id="c2-2"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl"
width="200px" height="300px">
+ <access-permissions>/platform/users</access-permissions>
+ <gadget-application>
+ <gadget>
+ <gadget-ref>Calendar</gadget-ref>
+ </gadget>
+
<theme>Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme</theme>
+ <title>Calendar Title</title>
+
<access-permissions>*:/platform/administrators;*:/organization/management/executive-board</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>Calendar Description</description>
+ <icon>StarAwardIcon</icon>
+ <width>100px</width>
+ <height>200px</height>
+ </gadget-application>
+ </container>
+ </container>
+ <container id="c3"
template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>SiteMapPortlet</portlet-ref>
+ </portlet>
+
<theme>Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme</theme>
+ <title>SiteMap</title>
+ <access-permissions>*:/platform/users</access-permissions>
+ <show-info-bar>true</show-info-bar>
+ <show-application-state>true</show-application-state>
+ <show-application-mode>false</show-application-mode>
+ <description>SiteMap</description>
+ </portlet-application>
+ </container>
+ </container>
+</page>
\ No newline at end of file