Author: nscavell
Date: 2011-05-23 13:56:55 -0400 (Mon, 23 May 2011)
New Revision: 6528
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/PortalConfigStAXParser.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.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/ContainerStAXParser.java
===================================================================
---
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)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java 2011-05-23
17:56:55 UTC (rev 6528)
@@ -50,7 +50,6 @@
}
container.setId(elementNavigator.getAttribute("id"));
- container.setDecorator(elementNavigator.getAttribute("decorator"));
container.setWidth(elementNavigator.getAttribute("width"));
container.setHeight(elementNavigator.getAttribute("height"));
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-23
16:01:18 UTC (rev 6527)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java 2011-05-23
17:56:55 UTC (rev 6528)
@@ -52,8 +52,6 @@
if(elementNavigator.next(StAXElement.properties))
{
Properties properties = new Properties();
- StaxNavigator<StAXElement> propertiesElement = elementNavigator.fork();
-
while(elementNavigator.next(StAXElement.entry))
{
String propertyName = elementNavigator.getAttribute("key");
@@ -69,6 +67,7 @@
final Set<StAXElement> modelElementSet = new HashSet<StAXElement>();
modelElementSet.add(StAXElement.container);
modelElementSet.add(StAXElement.portlet_application);
+ modelElementSet.add(StAXElement.gadget_application);
modelElementSet.add(StAXElement.page_body);
elementNavigator.next(modelElementSet);
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java 2011-05-23
16:01:18 UTC (rev 6527)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java 2011-05-23
17:56:55 UTC (rev 6528)
@@ -24,8 +24,10 @@
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.PageBody;
import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.model.Properties;
import org.exoplatform.portal.config.stax.PortalConfigStAXParser;
import org.exoplatform.portal.config.stax.StAXElement;
+import org.exoplatform.portal.pom.config.Utils;
import org.json.XML;
import org.staxnav.Naming;
import org.staxnav.StaxNavigator;
@@ -39,25 +41,26 @@
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
* @date 5/20/11
*/
-public class TestParsingPortalConfig extends TestCase
+public class TestParsingPortalConfig extends AbstractStaxTestCase
{
- private StaxNavigator<StAXElement> elementNavigator;
-
- protected void setUp() throws Exception
- {
- InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/portal.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 testPortalConfig()
{
- PortalConfigStAXParser portalConfigParser = new
PortalConfigStAXParser(elementNavigator);
+ PortalConfigStAXParser portalConfigParser = new
PortalConfigStAXParser(createNavigator("/stax/portal.xml"));
PortalConfig portalConfig = portalConfigParser.parseXML();
+ assertNotNull(portalConfig);
+ assertEquals("classic", portalConfig.getName());
+ assertEquals("en", portalConfig.getLocale());
+ assertEquals("Everyone", Utils.join(";",
portalConfig.getAccessPermissions()));
+ assertEquals("*:/platform/administrators",
portalConfig.getEditPermission());
+ assertNotNull(portalConfig.getProperties());
+
+ Properties properties = new Properties();
+ properties.put("sessionAlive", "onDemand");
+ properties.put("foo", "bar");
+ assertEquals(properties, portalConfig.getProperties());
+
Container layout = portalConfig.getPortalLayout();
List<ModelObject> children = layout.getChildren();
Modified:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml 2011-05-23
16:01:18 UTC (rev 6527)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml 2011-05-23
17:56:55 UTC (rev 6528)
@@ -30,6 +30,7 @@
<edit-permission>*:/platform/administrators</edit-permission>
<properties>
<entry key="sessionAlive">onDemand</entry>
+ <entry key="foo">bar</entry>
</properties>
<portal-layout>
Show replies by date