Author: mwringe
Date: 2009-04-02 16:35:03 -0400 (Thu, 02 Apr 2009)
New Revision: 13124
Added:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalLayoutMetaData.java
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalThemeMetaData.java
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestRenderSetMetaData.java
Log:
Add theme metadata tests.
Added:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalLayoutMetaData.java
===================================================================
---
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalLayoutMetaData.java
(rev 0)
+++
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalLayoutMetaData.java 2009-04-02
20:35:03 UTC (rev 13124)
@@ -0,0 +1,198 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.jboss.portal.deployer.theme;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.deployer.portal.PortalUnmarshallerFactory;
+import org.jboss.portal.metadata.layout.PortalLayoutMetaData;
+import org.jboss.portal.metadata.layout.PortalLayoutsMetaData;
+import org.jboss.portal.metadata.layout.URIMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+
+import java.io.StringReader;
+import java.util.List;
+
+/**
+ * Test all aspects of the portal layout meta data.
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $Revision: 8784 $
+ */
+public class TestPortalLayoutMetaData extends TestCase
+{
+ public void testBuildLayoutMetaDataList() throws Exception
+ {
+ try
+ {
+ // create a descriptor for the tests
+ StringBuffer testString = new StringBuffer();
+ testString.append("<layouts>");
+ testString.append("<layout>");
+ testString.append("<name>nodesk</name>");
+ testString.append("<uri>/nodesk/index.jsp</uri>");
+ testString.append("<regions>");
+ testString.append("<region name=\"left\"/>");
+ testString.append("<region name=\"center\"/>");
+ testString.append("</regions>");
+ testString.append("</layout>");
+ testString.append("<layout>");
+ testString.append("<name>generic</name>");
+
testString.append("<uri>/layouts/generic/index.jsp</uri>");
+ testString.append("<uri
state=\"maximized\">/layouts/generic/maximized.jsp</uri>");
+ testString.append("<regions>");
+ testString.append("<region name=\"left\"/>");
+ testString.append("<region name=\"center\"/>");
+ testString.append("<region name=\"navigation\"/>");
+ testString.append("</regions>");
+ testString.append("</layout>");
+ testString.append("</layouts>");
+
+ PortalLayoutsMetaData layoutsMD = getLayoutMetaData(testString);
+
+ assertNotNull(layoutsMD);
+ assertTrue(layoutsMD.getLayouts().size() == 2);
+
+ PortalLayoutMetaData layoutMD =
(PortalLayoutMetaData)layoutsMD.getLayouts().get(0);
+ assertEquals("nodesk", layoutMD.getName());
+ assertEquals("/nodesk/index.jsp",
layoutMD.getUris().get(0).getUri());
+ assertNotNull(layoutMD.getUris());
+ assertEquals(1, layoutMD.getUris().size());
+ assertNotNull(layoutMD.getClassName());
+ assertNotNull(layoutMD.getRegions());
+ String foo = layoutMD.getRegions().get(0);
+
+ assertEquals(2, layoutMD.getRegions().size());
+ assertTrue(layoutMD.getRegions().contains("left"));
+ assertTrue(layoutMD.getRegions().contains("center"));
+
+ layoutMD = (PortalLayoutMetaData)layoutsMD.getLayouts().get(1);
+ URIMetaData uriMetaData1 = new URIMetaData (null,
"/layouts/generic/index.jsp");
+ URIMetaData uriMetaData2 = new URIMetaData ("maximized",
"/layouts/generic/maximized.jsp");
+ assertEquals("generic", layoutMD.getName());
+ assertTrue(layoutMD.getUris().contains(uriMetaData1));
+ assertTrue(layoutMD.getUris().contains(uriMetaData2));
+ assertNotNull(layoutMD.getUris());
+ assertEquals(2, layoutMD.getUris().size());
+ assertNotNull(layoutMD.getClassName());
+ assertNotNull(layoutMD.getRegions());
+ assertEquals(3, layoutMD.getRegions().size());
+ assertTrue(layoutMD.getRegions().contains("left"));
+ assertTrue(layoutMD.getRegions().contains("center"));
+ assertTrue(layoutMD.getRegions().contains("navigation"));
+ }
+ catch (IllegalArgumentException e)
+ {
+ // the layout meta needs the portal web app to be not null and have an id
+ assertTrue("expected exception did occur", true);
+ }
+ }
+
+ public void testLayoutMetaDataNoName() throws Exception
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<layouts>");
+
+ // no name
+ testString.append("<layout>");
+// testString.append("<name>nodesk</name>");
+ testString.append("<uri>/nodesk/index.jsp</uri>");
+ testString.append("<regions>");
+ testString.append("<region name=\"left\"/>");
+ testString.append("<region name=\"center\"/>");
+ testString.append("</regions>");
+ testString.append("</layout>");
+
+ testString.append("</layouts>");
+
+ PortalLayoutsMetaData layoutsMD = getLayoutMetaData(testString);
+ PortalLayoutMetaData layoutMD =
(PortalLayoutMetaData)layoutsMD.getLayouts().get(0);
+ assertTrue(layoutMD.getName() == null);
+ }
+
+ public void testLayoutMetaDataNoURI() throws JBossXBException
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<layouts>");
+
+ // no uri
+ testString.append("<layout>");
+ testString.append("<name>nodesk</name>");
+ testString.append("</layout>");
+// testString.append("<uri>/nodesk/index.jsp</uri>");
+ testString.append("</layouts>");
+
+ PortalLayoutsMetaData layoutsMD = getLayoutMetaData(testString);
+ PortalLayoutMetaData layoutMD =
(PortalLayoutMetaData)layoutsMD.getLayouts().get(0);
+ assertTrue(layoutMD.getUris().size() == 0);
+ }
+
+ public void testLayoutMetaDataNoRegions() throws Exception
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<layouts>");
+ // no regions
+ testString.append("<layout>");
+ testString.append("<name>nodesk</name>");
+ testString.append("<uri>/nodesk/index.jsp</uri>");
+ testString.append("</layout>");
+ testString.append("</layouts>");
+ PortalLayoutsMetaData layoutsMD = getLayoutMetaData(testString);
+ assertNotNull(layoutsMD);
+ PortalLayoutMetaData layoutMD =
(PortalLayoutMetaData)layoutsMD.getLayouts().get(0);
+ assertNotNull(layoutMD.getRegions());
+ assertTrue(layoutMD.getRegions().size() == 0);
+ }
+
+ // What in the world does this do?
+/*
+ public void testLayoutMetaData4() throws Exception
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<layouts>");
+ // fragment assembler class specified
+ testString.append("<layout>");
+ testString.append("<name>nodesk</name>");
+ testString.append("<uri>/nodesk/index.jsp</uri>");
+
testString.append("<fragment-assembler-implementation>TestFragmentAssembler</fragment-assembler-implementation>");
+ testString.append("</layout>");
+ testString.append("</layouts>");
+ List layoutMDList =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new
StringReader(testString.toString()), new PortalLayoutMetaDataFactory(), null);
+ assertNotNull(layoutMDList);
+ PortalLayoutMetaData layoutMD = (PortalLayoutMetaData)layoutMDList.get(0);
+ assertNotNull(layoutMD.getClassName());
+ assertEquals("org.jboss.portal.theme.impl.JSPLayout",
layoutMD.getClassName());
+ }
+*/
+
+ private PortalLayoutsMetaData getLayoutMetaData(StringBuffer testString) throws
JBossXBException
+ {
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addClassBindingForLocation("layouts",
PortalLayoutsMetaData.class);
+ return (PortalLayoutsMetaData) PortalUnmarshallerFactory.getInstance()
+ .getUnmarshaller().unmarshal(new StringReader(testString.toString()),
resolver);
+ }
+
+}
\ No newline at end of file
Property changes on:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalLayoutMetaData.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalThemeMetaData.java
===================================================================
---
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalThemeMetaData.java
(rev 0)
+++
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalThemeMetaData.java 2009-04-02
20:35:03 UTC (rev 13124)
@@ -0,0 +1,167 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.jboss.portal.deployer.theme;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.deployer.portal.PortalUnmarshallerFactory;
+import org.jboss.portal.metadata.theme.PortalThemeMetaData;
+import org.jboss.portal.metadata.theme.PortalThemesMetaData;
+import org.jboss.portal.metadata.theme.ThemeLinkMetaData;
+import org.jboss.portal.metadata.theme.ThemeScriptMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+
+import java.io.StringReader;
+import java.util.List;
+
+/**
+ * Testcase for the portal theme meta data parsing from the descriptor
+ * <p/>
+ * example descriptor:
+ * <p/>
+ * <themes> <theme> <name>industrial</name> <link
rel="stylesheet" id="main_css"
href="/themes/industrial/portal_style.css"
+ * type="text/css" /> <link rel="shortcut icon"
href="/themes/industrial/images/favicon.ico" /> </theme> <theme>
+ * <name>Nphalanx</name> <link rel="stylesheet"
id="main_css" href="/themes/phalanx/portal_style.css"
type="text/css" />
+ * <link rel="shortcut icon"
href="/themes/phalanx/images/favicon.ico" /> </theme> <theme>
<name>mission-critical</name>
+ * <link rel="stylesheet" id="main_css"
href="/themes/mission-critical/portal_style.css" type="text/css" />
<link
+ * rel="shortcut icon"
href="/themes/mission-critical/images/favicon.ico" /> </theme>
<theme> <name>Maple</name> <link
+ * rel="stylesheet" id="main_css"
href="/themes/maple/portal_style.css" type="text/css"/> <link
rel="shortcut icon"
+ * href="/themes/maple/images/favicon.ico"/> </theme> </themes>
*
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $Revision: 8784 $
+ */
+public class TestPortalThemeMetaData extends TestCase
+{
+
+ public void testBuildThemeMetaDataList() throws JBossXBException
+ {
+ try
+ {
+ // create a descriptor for the tests
+ StringBuffer testString = new StringBuffer();
+ testString.append("<themes>");
+
+ testString.append("<theme>");
+ testString.append("<name>industrial</name>");
+ testString.append("<link rel=\"stylesheet\"
id=\"main_css\" href=\"/themes/industrial/portal_style.css\"
type=\"text/css\" />");
+ testString.append("<link rel=\"shortcut icon\"
href=\"/themes/industrial/images/favicon.ico\" />");
+ testString.append("</theme>");
+
+ testString.append("<theme>");
+ testString.append("<name>mission-critical</name>");
+ testString.append("<link rel=\"stylesheet\"
id=\"main_css\" href=\"/themes/mission-critical/portal_style.css\"
type=\"text/css\" />");
+ testString.append("<link rel=\"shortcut icon\"
href=\"/themes/mission-critical/images/favicon.ico\" />");
+ testString.append("<script id=\"scriptWithBody\"
type=\"text/javascript\">some script content here...</script>");
+ testString.append("<script src=\"srcURL\"
id=\"scriptWithNoBody\" type=\"text/javascript\"/>");
+ testString.append("</theme>");
+
+ testString.append("</themes>");
+
+ PortalThemesMetaData themes= getThemeMetaData(testString);
+
+ assertTrue(themes.getThemes().size() == 2);
+
+ PortalThemeMetaData meta = (PortalThemeMetaData)themes.getThemes().get(0);
+ assertEquals("industrial", meta.getName());
+ assertTrue(meta.getLinks().size() == 2);
+ assertTrue(meta.getScripts().size() == 0);
+
+ List links = meta.getLinks();
+ ThemeLinkMetaData link = (ThemeLinkMetaData)links.get(0);
+ assertEquals("/themes/industrial/portal_style.css", link.getHref());
+ assertEquals("text/css", link.getType());
+
+ // second link
+ link = (ThemeLinkMetaData)links.get(1);
+ assertEquals("/themes/industrial/images/favicon.ico",
link.getHref());
+ assertEquals("shortcut icon", link.getRel());
+
+ // test the second theme
+ meta = (PortalThemeMetaData)themes.getThemes().get(1);
+ assertEquals("mission-critical", meta.getName());
+ assertTrue(meta.getLinks().size() == 2);
+ assertTrue(meta.getScripts().size() == 2);
+
+ ThemeScriptMetaData script = (ThemeScriptMetaData)meta.getScripts().get(0);
+ assertTrue(script.getSrc() == null);
+ assertEquals("scriptWithBody", script.getId());
+ assertEquals("text/javascript", script.getType());
+
+ script = (ThemeScriptMetaData)meta.getScripts().get(1);
+ assertEquals("srcURL", script.getSrc());
+ assertEquals("scriptWithNoBody", script.getId());
+ }
+ catch (Exception e)
+ {
+ assertFalse("unexpected exception occured", true);
+ }
+ }
+
+ public void testThemeMetaDataNoName() throws JBossXBException
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<themes>");
+
+ // no name defined
+ testString.append("<theme>");
+// testString.append("<name>industrial</name>");
+ testString.append("<link rel=\"stylesheet\"
id=\"main_css\" href=\"/themes/industrial/portal_style.css\"
type=\"text/css\" />");
+ testString.append("<link rel=\"shortcut icon\"
href=\"/themes/industrial/images/favicon.ico\" />");
+ testString.append("</theme>");
+
+ testString.append("</themes>");
+
+ PortalThemesMetaData themes= getThemeMetaData(testString);
+ PortalThemeMetaData meta = (PortalThemeMetaData)themes.getThemes().get(0);
+ assertTrue(meta.getName() == null);
+ }
+
+ public void testThemeMetaDataNoLinks() throws JBossXBException
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<themes>");
+
+ // no link, no script defined
+ testString.append("<theme>");
+ testString.append("<name>industrial</name>");
+ testString.append("</theme>");
+
+ testString.append("</themes>");
+
+ PortalThemesMetaData themes= getThemeMetaData(testString);
+ PortalThemeMetaData meta = (PortalThemeMetaData)themes.getThemes().get(0);
+ assertTrue(meta.getLinks().size() == 0);
+ assertTrue(meta.getScripts().size() == 0);
+ }
+
+ private PortalThemesMetaData getThemeMetaData(StringBuffer testString) throws
JBossXBException
+ {
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addClassBindingForLocation("themes",
PortalThemesMetaData.class);
+ return (PortalThemesMetaData) PortalUnmarshallerFactory.getInstance()
+ .getUnmarshaller().unmarshal(new StringReader(testString.toString()),
resolver);
+ }
+}
Property changes on:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestPortalThemeMetaData.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestRenderSetMetaData.java
===================================================================
---
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestRenderSetMetaData.java
(rev 0)
+++
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestRenderSetMetaData.java 2009-04-02
20:35:03 UTC (rev 13124)
@@ -0,0 +1,205 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.jboss.portal.deployer.theme;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.deployer.portal.PortalUnmarshallerFactory;
+import org.jboss.portal.metadata.renderset.PortalRenderSetsMetaData;
+import org.jboss.portal.metadata.renderset.RenderSetMetaData;
+import org.jboss.portal.metadata.renderset.SetMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.xml.sax.SAXException;
+
+/**
+ * Test cases for the render set meta data <p/> <p/> exmaple of a render set
descriptor: <p/> <portal-renderSet>
+ * <renderSet name="divRenderer"> <set
content-type="text/html">
<region-renderer>org.jboss.portal.theme.impl.render.div.DivRegionRenderer</region-renderer>
+ *
<window-renderer>org.jboss.portal.theme.impl.render.div.DivWindowRenderer</window-renderer>
+ *
<portlet-renderer>org.jboss.portal.theme.impl.render.div.DivPortletRenderer</portlet-renderer>
+ *
<decoration-renderer>org.jboss.portal.theme.impl.render.div.DivDecorationRenderer</decoration-renderer>
</set>
+ * </renderSet> <renderSet name="emptyRenderer"> <set
content-type="text/html">
<region-renderer>org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer</region-renderer>
+ *
<window-renderer>org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer</window-renderer>
+ *
<portlet-renderer>org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer</portlet-renderer>
+ *
<decoration-renderer>org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer</decoration-renderer>
</set>
+ * </renderSet> </portal-renderSet> <p/> </p>
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $Revision: 10337 $
+ */
+public class TestRenderSetMetaData extends TestCase
+{
+
+ public void testBuildRenderSetMD() throws IOException, ParserConfigurationException,
SAXException
+ {
+ try
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<portal-renderSet>");
+
+ testString.append("<renderSet
name=\"divRenderer\">");
+
+ testString.append("<set
content-type=\"text/html\">");
+
testString.append("<region-renderer>DivRegionRenderer</region-renderer>");
+
testString.append("<window-renderer>DivWindowRenderer</window-renderer>");
+
testString.append("<portlet-renderer>DivPortletRenderer</portlet-renderer>");
+
testString.append("<decoration-renderer>DivDecorationRenderer</decoration-renderer>");
+ testString.append("</set>");
+
+ testString.append("</renderSet>");
+
+
+ testString.append("<renderSet
name=\"emptyRenderer\">");
+
+ testString.append("<set
content-type=\"text/html\">");
+
testString.append("<region-renderer>EmptyRegionRendererHTML</region-renderer>");
+
testString.append("<window-renderer>EmptyWindowRendererHTML</window-renderer>");
+
testString.append("<portlet-renderer>EmptyPortletRendererHTML</portlet-renderer>");
+
testString.append("<decoration-renderer>EmptyDecorationRendererHTML</decoration-renderer>");
+ testString.append("</set>");
+
+ testString.append("<set
content-type=\"application/xhtml+xml\">");
+
testString.append("<region-renderer>EmptyRegionRendererXHTML</region-renderer>");
+
testString.append("<window-renderer>EmptyWindowRendererXHTML</window-renderer>");
+
testString.append("<portlet-renderer>EmptyPortletRendererXHTML</portlet-renderer>");
+
testString.append("<decoration-renderer>EmptyDecorationRendererXHTML</decoration-renderer>");
+ testString.append("</set>");
+
+ testString.append("</renderSet>");
+
+ testString.append("</portal-renderSet>");
+
+ PortalRenderSetsMetaData setList = getRenderSetMetaData(testString);
+
+ assertNotNull(setList);
+ assertTrue(setList.getRenderSets().size() == 2);
+
+ RenderSetMetaData renderSetMD =
(RenderSetMetaData)setList.getRenderSets().get(0);
+ assertEquals("divRenderer", renderSetMD.getName());
+ assertNotNull(renderSetMD.getSet());
+ assertTrue(renderSetMD.getSet().size() == 1);
+ SetMetaData rendererSetMD = (SetMetaData)renderSetMD.getSet().get(0);
+ assertEquals("text/html", rendererSetMD.getContentType());
+ assertEquals("DivPortletRenderer",
rendererSetMD.getPortletRenderer());
+
+ renderSetMD = (RenderSetMetaData)setList.getRenderSets().get(1);
+ assertEquals("emptyRenderer", renderSetMD.getName());
+ assertNotNull(renderSetMD.getSet());
+ assertTrue(renderSetMD.getSet().size() == 2);
+
+ rendererSetMD = (SetMetaData)renderSetMD.getSet().get(0);
+ assertEquals("text/html", rendererSetMD.getContentType());
+ assertEquals("EmptyPortletRendererHTML",
rendererSetMD.getPortletRenderer());
+
+ rendererSetMD = (SetMetaData)renderSetMD.getSet().get(1);
+ assertEquals("application/xhtml+xml",
rendererSetMD.getContentType());
+ assertEquals("EmptyDecorationRendererXHTML",
rendererSetMD.getDecorationRenderer());
+ }
+ catch (Exception e)
+ {
+ assertFalse("unexpected exception occured" + e.getMessage(), true);
+ }
+ }
+
+// TODO: reenable this test later once it determined how to throw the XBException
properly
+// public void testRenderSetMetaDataNoMime() throws JBossXBException
+// {
+// StringBuffer testString = new StringBuffer();
+// // no content type attribute in the set
+// testString.append("<portal-renderSet>");
+// testString.append("<renderSet name=\"divRenderer\">");
+// testString.append("<set>");
+//
testString.append("<region-renderer>DivRegionRenderer</region-renderer>");
+//
testString.append("<window-renderer>DivWindowRenderer</window-renderer>");
+//
testString.append("<portlet-renderer>DivPortletRenderer</portlet-renderer>");
+//
testString.append("<decoration-renderer>DivDecorationRenderer</decoration-renderer>");
+// testString.append("</set>");
+// testString.append("</renderSet>");
+// testString.append("</portal-renderSet>");
+// try
+// {
+// PortalRenderSetsMetaData setList = getRenderSetMetaData(testString);
+// RenderSetMetaData renderSetMD =
(RenderSetMetaData)setList.getRenderSets().get(0);
+// SetMetaData rendererSetMD = (SetMetaData)renderSetMD.getSet().get(0);
+// assertFalse("expected exception did not occur", true);
+// }
+// catch (JBossXBException e)
+// {
+// // expected
+// }
+// }
+
+ public void testRenderSetMetaDataNoWindowRenderer() throws JBossXBException
+ {
+ StringBuffer testString = new StringBuffer();
+ // no window renderer defined in the set
+ testString.append("<portal-renderSet>");
+ testString.append("<renderSet name=\"divRenderer\">");
+ testString.append("<set content-type=\"text/html\">");
+
testString.append("<region-renderer>DivRegionRenderer</region-renderer>");
+//
testString.append("<window-renderer>DivWindowRenderer</window-renderer>");
+
testString.append("<portlet-renderer>DivPortletRenderer</portlet-renderer>");
+
testString.append("<decoration-renderer>DivDecorationRenderer</decoration-renderer>");
+ testString.append("</set>");
+ testString.append("</renderSet>");
+ testString.append("</portal-renderSet>");
+
+ PortalRenderSetsMetaData setList = getRenderSetMetaData(testString);
+ RenderSetMetaData renderSetMD = (RenderSetMetaData)setList.getRenderSets().get(0);
+ SetMetaData rendererSetMD = (SetMetaData)renderSetMD.getSet().get(0);
+ assertTrue(rendererSetMD.getWindowRenderer() == null);
+ }
+
+ public void testRenderSetMetaDataEmpty() throws JBossXBException
+ {
+ StringBuffer testString = new StringBuffer();
+ // empty render set descriptor
+ testString.append("<portal-renderSet>");
+ testString.append("</portal-renderSet>");
+
+ PortalRenderSetsMetaData setList = getRenderSetMetaData(testString);
+ try
+ {
+ RenderSetMetaData renderSetMD =
(RenderSetMetaData)setList.getRenderSets().get(0);
+ assertFalse("expected exception did not occur", true);
+ }
+ catch (IndexOutOfBoundsException ioe)
+ {
+ // expected
+ }
+ }
+
+ private PortalRenderSetsMetaData getRenderSetMetaData(StringBuffer testString) throws
JBossXBException
+ {
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addClassBindingForLocation("portal-renderSet",
PortalRenderSetsMetaData.class);
+ Unmarshaller unmarshaller =
PortalUnmarshallerFactory.getInstance().getUnmarshaller();
+ return (PortalRenderSetsMetaData) unmarshaller.unmarshal(new
StringReader(testString.toString()), resolver);
+ }
+}
Property changes on:
modules/deployer/trunk/theme/src/test/java/org/jboss/portal/deployer/theme/TestRenderSetMetaData.java
___________________________________________________________________
Name: svn:executable
+ *