Author: nscavell
Date: 2011-05-22 19:14:08 -0400 (Sun, 22 May 2011)
New Revision: 6525
Added:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/AbstractStaxTestCase.java
portal/branches/stax-integration/component/portal/src/test/resources/stax/gadget-application.xml
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application1.xml
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application2.xml
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-preferences.xml
Removed:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.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/PageStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.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/TestParsingContainer.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.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
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml
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/AbstractStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.java 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -55,7 +55,7 @@
}
else if(isOptional(staxElement))
{
- return "";
+ return null;
}
else
{
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-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -20,6 +20,7 @@
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.pom.config.Utils;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
import java.util.HashSet;
@@ -48,13 +49,14 @@
container.setTemplate(templateName);
}
+ container.setId(elementNavigator.getAttribute("id"));
container.setDecorator(elementNavigator.getAttribute("decorator"));
container.setWidth(elementNavigator.getAttribute("width"));
container.setHeight(elementNavigator.getAttribute("height"));
container.setTitle(getContent(elementNavigator, StAXElement.title));
container.setIcon(getContent(elementNavigator, StAXElement.icon));
- container.setAccessPermissions(getContent(elementNavigator,
StAXElement.access_permissions).split(","));
+ container.setAccessPermissions(Utils.split(";",
getContent(elementNavigator, StAXElement.access_permissions)));
container.setFactoryId(getContent(elementNavigator, StAXElement.factory_id));
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -20,6 +20,7 @@
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.pom.config.Utils;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
import java.util.ArrayList;
@@ -46,19 +47,8 @@
page.setName(getContent(elementNavigator, StAXElement.name));
page.setTitle(getContent(elementNavigator, StAXElement.title));
-
- String factoryID = getContent(elementNavigator, StAXElement.factory_id);
- if(factoryID.length() > 0)
- {
- page.setFactoryId(factoryID);
- }
-
- String accessPermissions = getContent(elementNavigator,
StAXElement.access_permissions);
- if(accessPermissions.length() > 0)
- {
- page.setAccessPermissions(accessPermissions.split(","));
- }
-
+ page.setFactoryId(getContent(elementNavigator, StAXElement.factory_id));
+ page.setAccessPermissions(Utils.split(";", getContent(elementNavigator,
StAXElement.access_permissions)));
page.setEditPermission(getContent(elementNavigator, StAXElement.edit_permission));
page.setShowMaxWindow("true".equals(getContent(elementNavigator,
StAXElement.show_max_window)));
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -21,6 +21,7 @@
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.Properties;
+import org.exoplatform.portal.pom.config.Utils;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
import java.util.HashSet;
@@ -45,7 +46,7 @@
portalConfig.setName(getContent(elementNavigator, StAXElement.portal_name));
portalConfig.setLocale(getContent(elementNavigator, StAXElement.locale));
- portalConfig.setAccessPermissions(getContent(elementNavigator,
StAXElement.access_permissions).split(","));
+ portalConfig.setAccessPermissions(Utils.split(";",
getContent(elementNavigator, StAXElement.access_permissions)));
portalConfig.setEditPermission(getContent(elementNavigator,
StAXElement.edit_permission));
if(elementNavigator.next(StAXElement.properties))
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-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -21,11 +21,17 @@
import org.exoplatform.portal.config.model.Application;
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
@@ -55,10 +61,24 @@
while(elementNavigator.next(StAXElement.preference))
{
String preferenceName = getContent(elementNavigator, StAXElement.name);
- String preferenceValue = getContent(elementNavigator, StAXElement.value);
+ List<String> preferenceValues = new ArrayList<String>();
+ while (elementNavigator.sibling(StAXElement.value))
+ {
+ String content = elementNavigator.getContent();
+ if (content != null)
+ {
+ preferenceValues.add(content);
+ }
+ }
boolean readOnly = "true".equals(getContent(elementNavigator,
StAXElement.read_only));
-
- builder.add(preferenceName, preferenceValue, readOnly);
+ if (preferenceValues.isEmpty())
+ {
+ builder.add(preferenceName, (String) null, readOnly);
+ }
+ else
+ {
+ builder.add(preferenceName, preferenceValues, readOnly);
+ }
}
state = new TransientApplicationState<Portlet>(applicationName +
"/" + portletName, builder.build());
@@ -71,12 +91,12 @@
Application<Portlet> application = Application.createPortletApplication();
application.setState(state);
+ application.setTheme(getContent(elementNavigator, StAXElement.theme));
application.setTitle(getContent(elementNavigator, StAXElement.title));
- application.setTheme(getContent(elementNavigator, StAXElement.theme));
- application.setAccessPermissions(getContent(elementNavigator,
StAXElement.access_permissions).split(","));
+ 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_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));
@@ -93,10 +113,12 @@
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;
Added:
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
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/AbstractStaxTestCase.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -0,0 +1,33 @@
+package org.exoplatform.portal.stax;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.stax.StAXElement;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavigator;
+import org.staxnav.StaxNavigatorImpl;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class AbstractStaxTestCase extends TestCase
+{
+ protected StaxNavigator<StAXElement> createNavigator(String resource) throws
RuntimeException
+ {
+ try
+ {
+ InputStream in = getClass().getResourceAsStream(resource);
+ XMLStreamReader streamReader =
XMLInputFactory.newInstance().createXMLStreamReader(in);
+
+ return new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple<StAXElement>(StAXElement.class,
StAXElement.NO_SUCH_ELEMENT), streamReader);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -18,54 +18,51 @@
*/
package org.exoplatform.portal.stax;
-import junit.framework.TestCase;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.stax.ContainerStAXParser;
import org.exoplatform.portal.config.stax.StAXElement;
-import org.staxnav.Naming;
import org.staxnav.StaxNavigator;
-import org.staxnav.StaxNavigatorImpl;
-import java.io.InputStream;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/20/11
*/
-public class TestParsingContainer extends TestCase
+public class TestParsingContainer extends AbstractStaxTestCase
{
- private StaxNavigator<StAXElement> elementNavigator;
-
- protected void setUp() throws Exception
- {
- InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/container.xml");
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-
- XMLStreamReader streamReader = inputFactory.createXMLStreamReader(in);
- elementNavigator = new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamReader);
- }
-
public void testContainer()
{
+ StaxNavigator<StAXElement> elementNavigator =
createNavigator("/stax/container.xml");
+
ContainerStAXParser containerParser = new ContainerStAXParser(elementNavigator);
Container rootContainer = containerParser.parseXML();
+ assertEquals("root", rootContainer.getId());
assertEquals(4, rootContainer.getChildren().size());
Container firstChild = (Container)rootContainer.getChildren().get(0);
assertEquals("system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl",
firstChild.getTemplate());
+ assertEquals("c0", firstChild.getId());
+ int j = 1;
for(ModelObject descendant : firstChild.getChildren())
{
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
((Container)descendant).getTemplate());
+ assertEquals("c0-" + j++, ((Container)descendant).getId());
}
for(int i = 1; i < 4; i++)
{
- assertEquals("system:/groovy/portal/webui/container/UIContainer" + i +
".gtmpl", ((Container)rootContainer.getChildren().get(i)).getTemplate());
+ Container container = (Container) rootContainer.getChildren().get(i);
+ assertEquals("system:/groovy/portal/webui/container/UIContainer" + i +
".gtmpl", container.getTemplate());
+ assertEquals("c" + i, container.getId());
+ String[] ap = container.getAccessPermissions();
+ assertEquals(i, ap.length);
+ for (j=0; j<ap.length; j++)
+ {
+ assertEquals("*:/platform/administrators" + j, ap[j]);
+ }
}
}
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -19,11 +19,22 @@
package org.exoplatform.portal.stax;
import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.config.stax.GadgetWindowStAXParer;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/20/11
*/
-public class TestParsingGadgetWindow extends TestCase
+public class TestParsingGadgetWindow extends AbstractStaxTestCase
{
+ public void testGadget() throws Exception
+ {
+ GadgetWindowStAXParer parser = new
GadgetWindowStAXParer(createNavigator("/stax/gadget-application.xml"));
+ Application<Gadget> gadget = parser.parseXML();
+ assertNotNull(gadget);
+ assertEquals("Calendar", ((TransientApplicationState<Gadget>)
gadget.getState()).getContentId());
+ }
}
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-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPage.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -18,51 +18,36 @@
*/
package org.exoplatform.portal.stax;
-import junit.framework.TestCase;
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.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.config.stax.StAXElement;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavigator;
-import org.staxnav.StaxNavigatorImpl;
-import java.io.InputStream;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/11/11
*/
-public class TestParsingPage extends TestCase
+public class TestParsingPage extends AbstractStaxTestCase
{
- private StaxNavigator<StAXElement> pageMetadata;
-
- protected void setUp() throws Exception
- {
- InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/test-page.xml");
- XMLInputFactory factory = XMLInputFactory.newInstance();
-
- XMLStreamReader streamReader = factory.createXMLStreamReader(in);
-
- pageMetadata = new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple<StAXElement>(StAXElement.class,
StAXElement.NO_SUCH_ELEMENT), streamReader);
- }
-
public void testConvertXML() throws Exception
{
- PageStAXParser pageStAXParser = new PageStAXParser(pageMetadata);
+ PageStAXParser pageStAXParser = new
PageStAXParser(createNavigator("/stax/test-page.xml"));
Page page = pageStAXParser.parseXML();
assertNotNull(page);
assertEquals("homepage", page.getName());
assertEquals("Home Page", page.getTitle());
-
- Application application = (Application)page.getChildren().get(0);
-
- assertEquals(ApplicationType.PORTLET, application.getType());
- assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
page.getAccessPermissions()));
+ assertEquals("*:/platform/administrators", page.getEditPermission());
+ assertNotNull(page.getChildren());
+ assertEquals(1, page.getChildren().size());
}
}
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-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java 2011-05-22
23:14:08 UTC (rev 6525)
@@ -18,36 +18,111 @@
*/
package org.exoplatform.portal.stax;
-import junit.framework.TestCase;
-import org.exoplatform.portal.config.stax.StAXElement;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavigator;
-import org.staxnav.StaxNavigatorImpl;
-import java.io.InputStream;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
+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.stax.PortletWindowStAXParser;
+import org.exoplatform.portal.pom.config.Utils;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
+import java.util.Arrays;
+import java.util.List;
+
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/20/11
*/
-public class TestParsingPortletWindow extends TestCase
+public class TestParsingPortletWindow extends AbstractStaxTestCase
{
- private StaxNavigator<StAXElement> elementNavigator;
+ public void testPortletApplication1()
+ {
+ PortletWindowStAXParser parser = new
PortletWindowStAXParser(createNavigator("/stax/portlet-application1.xml"));
+ Application<Portlet> application = parser.parseXML();
- protected void setUp() throws Exception
+ assertNotNull(application);
+ assertEquals(ApplicationType.PORTLET, application.getType());
+ 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());
+
+ assertNull(application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
+ assertFalse(application.getShowInfoBar());
+ assertFalse(application.getShowApplicationState());
+ assertFalse(application.getShowApplicationMode());
+ assertNull(application.getDescription());
+ assertNull(application.getIcon());
+ assertNull(application.getWidth());
+ assertNull(application.getHeight());
+ }
+
+ public void testPortletApplication2()
{
- InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/portlet-application.xml");
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ PortletWindowStAXParser parser = new
PortletWindowStAXParser(createNavigator("/stax/portlet-application2.xml"));
+ Application<Portlet> application = parser.parseXML();
- XMLStreamReader streamReader = inputFactory.createXMLStreamReader(in);
- elementNavigator = new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamReader);
+ assertNotNull(application);
+ assertEquals(ApplicationType.PORTLET, application.getType());
+ 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());
+
+ assertEquals("Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme",
application.getTheme());
+ assertEquals("Home Page portlet", application.getTitle());
+ assertEquals("Everyone", Utils.join(";",
application.getAccessPermissions()));
+ assertTrue(application.getShowInfoBar());
+ assertTrue(application.getShowApplicationState());
+ assertTrue(application.getShowApplicationMode());
+ assertEquals("Home Page", application.getDescription());
+ assertEquals("PortletIcon", application.getIcon());
+ assertEquals("300px", application.getWidth());
+ assertEquals("200px", application.getHeight());
}
- public void testPortletApplication()
+ public void testPreferences()
{
+ PortletWindowStAXParser parser = new
PortletWindowStAXParser(createNavigator("/stax/portlet-preferences.xml"));
+ Application<Portlet> application = parser.parseXML();
+ TransientApplicationState<Portlet> state =
(TransientApplicationState<Portlet>) application.getState();
+ Portlet portlet = state.getContentState();
+ int count = 0;
+ for (Preference preference : portlet)
+ {
+ count++;
+ }
+ 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);
+ }
+ private void assertPreference(Portlet portlet, String name, String...values)
+ {
+ assertNotNull(portlet.getPreference(name));
+ if (values == null)
+ {
+ assertNull(portlet.getValue(name));
+ }
+ else if (values.length == 1)
+ {
+ assertEquals(values[0], portlet.getValue(name));
+ }
+ else if (values.length > 0)
+ {
+ List<String> list = Arrays.asList(values);
+ assertEquals(list, portlet.getValues(name));
+ }
}
}
Modified:
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml 2011-05-22
23:14:08 UTC (rev 6525)
@@ -19,25 +19,25 @@
02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
-<container>
-<container
template='system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl'>
- <access-permissions>Everyone</access-permissions>
- <container
template='system:/groovy/portal/webui/container/UIContainer.gtmpl'>
- <access-permissions>Everyone</access-permissions>
- </container>
- <container
template='system:/groovy/portal/webui/container/UIContainer.gtmpl'>
- <access-permissions>Everyone</access-permissions>
- </container>
-</container>
+<container id="root">
+ <container id="c0"
template='system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl'>
+ <access-permissions>Everyone</access-permissions>
+ <container id="c0-1"
template='system:/groovy/portal/webui/container/UIContainer.gtmpl'>
+ <access-permissions>Everyone</access-permissions>
+ </container>
+ <container id="c0-2"
template='system:/groovy/portal/webui/container/UIContainer.gtmpl'>
+ <access-permissions>Everyone</access-permissions>
+ </container>
+ </container>
-<container
template="system:/groovy/portal/webui/container/UIContainer1.gtmpl">
- <access-permissions>Everyone</access-permissions>
+ <container id="c1"
template="system:/groovy/portal/webui/container/UIContainer1.gtmpl">
+ <access-permissions>*:/platform/administrators0</access-permissions>
+ </container>
+ <container id="c2"
template="system:/groovy/portal/webui/container/UIContainer2.gtmpl">
+
<access-permissions>*:/platform/administrators0;*:/platform/administrators1</access-permissions>
+ </container>
+ <container id="c3"
template="system:/groovy/portal/webui/container/UIContainer3.gtmpl">
+
<access-permissions>*:/platform/administrators0;*:/platform/administrators1;*:/platform/administrators2</access-permissions>
+ </container>
</container>
-<container
template="system:/groovy/portal/webui/container/UIContainer2.gtmpl">
- <access-permissions>Everyone</access-permissions>
-</container>
-<container
template="system:/groovy/portal/webui/container/UIContainer3.gtmpl">
- <access-permissions>Everyone</access-permissions>
-</container>
-</container>
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/gadget-application.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/gadget-application.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/gadget-application.xml 2011-05-22
23:14:08 UTC (rev 6525)
@@ -0,0 +1,32 @@
+<!--
+ ~ 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.
+ -->
+
+<gadget-application>
+ <gadget>
+ <gadget-ref>Calendar</gadget-ref>
+ </gadget>
+ <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>
+</gadget-application>
\ No newline at end of file
Deleted:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml 2011-05-22
20:38:54 UTC (rev 6524)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml 2011-05-22
23:14:08 UTC (rev 6525)
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- 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.
-
--->
-
-<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>false</read-only>
- </preference>
- </preferences>
- </portlet>
- <title>Home Page portlet</title>
- <access-permissions>Everyone</access-permissions>
- <show-info-bar>false</show-info-bar>
- <show-application-state>false</show-application-state>
- <show-application-mode>false</show-application-mode>
-</portlet-application>
-
-
Copied:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application1.xml
(from rev 6521,
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml)
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application1.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application1.xml 2011-05-22
23:14:08 UTC (rev 6525)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ 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.
+
+-->
+
+<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>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+</portlet-application>
+
+
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application2.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application2.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application2.xml 2011-05-22
23:14:08 UTC (rev 6525)
@@ -0,0 +1,45 @@
+<!--
+ ~ 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.
+ -->
+
+<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>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <theme>Vista:VistaTheme::Mac:MacTheme::Default:DefaultTheme</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>
+ <description>Home Page</description>
+ <icon>PortletIcon</icon>
+ <width>300px</width>
+ <height>200px</height>
+</portlet-application>
\ No newline at end of file
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-preferences.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-preferences.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-preferences.xml 2011-05-22
23:14:08 UTC (rev 6525)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ 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.
+
+-->
+
+<portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>single-value</name>
+ <value>value1</value>
+ </preference>
+ <preference>
+ <name>multi-value</name>
+ <value>multi-value1</value>
+ <value>multi-value2</value>
+ <value>multi-value3</value>
+ </preference>
+ <preference>
+ <name>empty-value</name>
+ <value></value>
+ </preference>
+ <preference>
+ <name>no-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>
+
+