[jboss-svn-commits] JBoss Portal SVN: r5567 - in trunk/theme: . src/main/org/jboss/portal/test/theme src/resources/test src/resources/test/xml
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 2 17:40:14 EST 2006
Author: roy.russo at jboss.com
Date: 2006-11-02 17:39:59 -0500 (Thu, 02 Nov 2006)
New Revision: 5567
Added:
trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java
trunk/theme/src/resources/test/xml/
trunk/theme/src/resources/test/xml/portal-layouts.xml
trunk/theme/src/resources/test/xml/portal-themes.xml
Removed:
trunk/theme/src/main/org/jboss/portal/test/theme/TestPortalThemeImpl.java
Modified:
trunk/theme/build.xml
trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java
Log:
JBPORTAL-1099 - Expanded theme/layout service tests.
Modified: trunk/theme/build.xml
===================================================================
--- trunk/theme/build.xml 2006-11-02 22:29:56 UTC (rev 5566)
+++ trunk/theme/build.xml 2006-11-02 22:39:59 UTC (rev 5567)
@@ -262,7 +262,7 @@
<x-test>
<!-- theme tests -->
<test todir="${test.reports}" name="org.jboss.portal.test.theme.TestLayoutServiceImpl"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.theme.TestPortalThemeImpl"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.theme.TestThemeServiceImpl"/>
<!-- theme metadata tests -->
<test todir="${test.reports}" name="org.jboss.portal.test.theme.metadata.TestLayoutStrategySetMetaData"/>
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java 2006-11-02 22:29:56 UTC (rev 5566)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java 2006-11-02 22:39:59 UTC (rev 5567)
@@ -23,68 +23,67 @@
package org.jboss.portal.test.theme;
import junit.framework.TestCase;
+import org.jboss.portal.common.util.CLLoader;
+import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.RuntimeContext;
import org.jboss.portal.theme.ServerRegistrationID;
+import org.jboss.portal.theme.deployment.jboss.PortalLayoutMetaDataFactory;
import org.jboss.portal.theme.impl.LayoutServiceImpl;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import java.util.Iterator;
+import java.util.List;
+
/**
* @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
* @version $Revision$
*/
public class TestLayoutServiceImpl extends TestCase
{
private LayoutServiceImpl layoutService;
+ private RuntimeContext runtimeContext;
+ private List portalLayouts;
protected void setUp() throws Exception
{
layoutService = new LayoutServiceImpl();
- }
- protected void tearDown() throws Exception
- {
- layoutService = null;
- }
+ layoutService.create();
+ layoutService.start();
- public void testCreate()
- {
- try
+ runtimeContext = TestHelper.createRuntimeContext();
+ LoaderResource res = new CLLoader().getResource("xml/portal-layouts.xml");
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ portalLayouts = (List)unmarshaller.unmarshal(res.asInputStream(), new PortalLayoutMetaDataFactory(), null);
+ for (Iterator i = portalLayouts.iterator(); i.hasNext();)
{
- layoutService.create();
- assertNotNull(layoutService.getLayouts());
- assertNotNull(layoutService.getRenderSets());
- assertNotNull(layoutService.getStrategies());
+ PortalLayoutMetaData layoutMD = (PortalLayoutMetaData)i.next();
+ layoutService.addLayout(runtimeContext, layoutMD);
}
- catch (Exception e)
- {
- assertFalse("unexpected exception occured", true);
- e.printStackTrace();
- }
}
- public void testStart()
+ protected void tearDown() throws Exception
{
- try
- {
- layoutService.create();
- layoutService.start();
- }
- catch (Exception e)
- {
- assertFalse("unexpected exception occured", true);
- e.printStackTrace();
- }
+ layoutService = null;
}
- public void testAddLayout()
+ public void testCreateLayouts()
{
try
{
- layoutService.create();
- layoutService.start();
- RuntimeContext runtimeContext = TestHelper.createRuntimeContext();
- PortalLayoutMetaData meta = TestHelper.createLayoutMD();
- layoutService.addLayout(runtimeContext, meta);
+ assertTrue(layoutService.getLayouts().size() == 3);
+
+ PortalLayout layout = layoutService.getLayout("generic", true);
+ assertTrue(layout.getLayoutInfo().getName().equals("generic"));
+ layout = layoutService.getLayout("nodesk", true);
+ assertTrue(layout.getLayoutInfo().getName().equals("nodesk"));
+ layout = layoutService.getLayout("phalanx", true);
+ assertTrue(layout.getLayoutInfo().getName().equals("phalanx"));
}
catch (Exception e)
{
@@ -93,44 +92,28 @@
}
}
- public void testGetLayout()
+ public void testGetLayoutInfos()
{
- try
- {
- layoutService.create();
- layoutService.start();
- RuntimeContext runtimeContext = TestHelper.createRuntimeContext();
- PortalLayoutMetaData meta = TestHelper.createLayoutMD();
- layoutService.addLayout(runtimeContext, meta);
- assertNotNull(layoutService.getLayout("TestLayout", false));
- assertNotNull(layoutService.getLayout(runtimeContext.getAppId() + "." + "TestLayout", false));
- }
- catch (Exception e)
- {
- assertFalse("unexpected exception occured", true);
- e.printStackTrace();
- }
+ // TODO
}
-
+
public void testRemoveLayouts()
{
try
{
- layoutService.create();
- layoutService.start();
- RuntimeContext runtimeContext = TestHelper.createRuntimeContext();
- PortalLayoutMetaData meta = TestHelper.createLayoutMD();
- layoutService.addLayout(runtimeContext, meta);
- assertNotNull(layoutService.getLayout("TestLayout", false));
+ assertNotNull(layoutService.getLayout("generic", false));
layoutService.removeLayouts(runtimeContext.getAppId());
- assertNull(layoutService.getLayout("TestLayout", false));
+ assertNull(layoutService.getLayout("generic", false));
- layoutService.addLayout(runtimeContext, meta);
- assertNotNull(layoutService.getLayout("TestLayout", false));
- ServerRegistrationID id = ServerRegistrationID.createPortalLayoutID(runtimeContext.getAppId(), "TestLayout");
- layoutService.removeLayout(id);
- assertNull(layoutService.getLayout("TestLayout", false));
+ for (Iterator i = portalLayouts.iterator(); i.hasNext();)
+ {
+ PortalLayoutMetaData layoutMD = (PortalLayoutMetaData)i.next();
+ layoutService.addLayout(runtimeContext, layoutMD);
+ }
+ ServerRegistrationID id = ServerRegistrationID.createPortalLayoutID(runtimeContext.getAppId(), "generic");
+ layoutService.removeLayout(id);
+ assertNull(layoutService.getLayout("generic", false));
}
catch (Exception e)
{
@@ -138,7 +121,4 @@
e.printStackTrace();
}
}
-
- //TODO: add more for failure cases
- //TODO: add more for render sets and strategies
}
Deleted: trunk/theme/src/main/org/jboss/portal/test/theme/TestPortalThemeImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestPortalThemeImpl.java 2006-11-02 22:29:56 UTC (rev 5566)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestPortalThemeImpl.java 2006-11-02 22:39:59 UTC (rev 5567)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * 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.test.theme;
-
-import junit.framework.TestCase;
-import org.jboss.portal.theme.deployment.jboss.PortalThemeMetaDataFactory;
-import org.jboss.portal.theme.metadata.PortalThemeMetaData;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.List;
-
-/**
- * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public class TestPortalThemeImpl extends TestCase
-{
-
- public void testTheme() throws IOException, ParserConfigurationException, SAXException
- {
- 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>");
-
- List portalThemes = (List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new StringReader(testString.toString()), new PortalThemeMetaDataFactory(), null);
- assertTrue(portalThemes.size() == 2);
-
- PortalThemeMetaData themeMD = (PortalThemeMetaData)portalThemes.get(0);
-
- assertEquals("industrial", themeMD.getName());
- assertTrue(themeMD.getScripts().size() == 0);
- assertTrue(themeMD.getLinks().size() == 2);
- }
- catch (Exception e)
- {
- assertTrue("unexpected exception occured", false);
- }
- }
-
- // todo: test <theme-implementation>
-}
\ No newline at end of file
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java (from rev 5556, trunk/theme/src/main/org/jboss/portal/test/theme/TestPortalThemeImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestPortalThemeImpl.java 2006-11-02 00:21:18 UTC (rev 5556)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java 2006-11-02 22:39:59 UTC (rev 5567)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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.test.theme;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CLLoader;
+import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.portal.theme.PortalTheme;
+import org.jboss.portal.theme.RuntimeContext;
+import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.deployment.jboss.PortalThemeMetaDataFactory;
+import org.jboss.portal.theme.impl.ThemeServiceImpl;
+import org.jboss.portal.theme.metadata.PortalThemeMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:mholzner at novell.com">Martin Holzner</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ * @version $Revision$
+ */
+public class TestThemeServiceImpl extends TestCase
+{
+ private ThemeService themeService;
+ List themes;
+
+ protected void setUp() throws Exception
+ {
+ themeService = new ThemeServiceImpl();
+
+ RuntimeContext runtimeContext = TestHelper.createRuntimeContext();
+ LoaderResource res = new CLLoader().getResource("xml/portal-themes.xml");
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ themes = (List)unmarshaller.unmarshal(res.asInputStream(), new PortalThemeMetaDataFactory(), null);
+ for (Iterator i = themes.iterator(); i.hasNext();)
+ {
+ PortalThemeMetaData themeMD = (PortalThemeMetaData)i.next();
+ themeService.addTheme(runtimeContext, themeMD);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ themeService = null;
+ }
+
+ public void testCreateTheme() throws IOException, ParserConfigurationException, SAXException
+ {
+ try
+ {
+ assertTrue(themeService.getThemes().size() == 5);
+
+ PortalTheme theme = themeService.getTheme("industrial", false);
+ assertTrue(theme.getThemeInfo().getName().equals("industrial"));
+ theme = themeService.getTheme("Nphalanx", false);
+ assertTrue(theme.getThemeInfo().getName().equals("Nphalanx"));
+ theme = themeService.getTheme("mission-critical", false);
+ assertTrue(theme.getThemeInfo().getName().equals("mission-critical"));
+ theme = themeService.getTheme("Maple", false);
+ assertTrue(theme.getThemeInfo().getName().equals("Maple"));
+ theme = themeService.getTheme("renaissance", false);
+ assertTrue(theme.getThemeInfo().getName().equals("renaissance"));
+ }
+ catch (Exception e)
+ {
+ assertTrue("unexpected exception occured", false);
+ }
+ }
+
+ public void testGetThemeInfos()
+ {
+ // TODO
+ /*
+ assertEquals("industrial", themeMD.getName());
+ assertTrue(themeMD.getScripts().size() == 0);
+ assertTrue(themeMD.getLinks().size() == 2);
+ */
+ }
+
+ public void testRemoveTheme()
+ {
+ // TODO
+ }
+}
\ No newline at end of file
Property changes on: trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/theme/src/resources/test/xml/portal-layouts.xml
===================================================================
--- trunk/theme/src/resources/test/xml/portal-layouts.xml 2006-11-02 22:29:56 UTC (rev 5566)
+++ trunk/theme/src/resources/test/xml/portal-layouts.xml 2006-11-02 22:39:59 UTC (rev 5567)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<layouts>
+ <layout>
+ <name>nodesk</name>
+ <uri>/nodesk/index.jsp</uri>
+ <uri state="maximized">/nodesk/index.jsp</uri>
+ <regions>
+ <region name="left"/>
+ <region name="center"/>
+ </regions>
+ </layout>
+ <layout>
+ <name>phalanx</name>
+ <uri>/phalanx/index.jsp</uri>
+ <uri state="maximized">/phalanx/index.jsp</uri>
+ <regions>
+ <region name="left"/>
+ <region name="center"/>
+ </regions>
+ </layout>
+ <layout>
+ <name>generic</name>
+ <uri>/layouts/generic/index.jsp</uri>
+ <uri state="maximized">/layouts/generic/maximized.jsp</uri>
+ <regions>
+ <region name="left"/>
+ <region name="center"/>
+ <region name="navigation"/>
+ </regions>
+ </layout>
+</layouts>
Added: trunk/theme/src/resources/test/xml/portal-themes.xml
===================================================================
--- trunk/theme/src/resources/test/xml/portal-themes.xml 2006-11-02 22:29:56 UTC (rev 5566)
+++ trunk/theme/src/resources/test/xml/portal-themes.xml 2006-11-02 22:39:59 UTC (rev 5567)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<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>
+ <theme>
+ <name>renaissance</name>
+ <link rel="stylesheet" id="main_css" href="/themes/renaissance/portal_style.css" type="text/css"/>
+ <link rel="shortcut icon" href="/themes/renaissance/images/favicon.ico"/>
+ <link rel="icon" href="/themes/renaissance/images/animated_favicon1.gif" type="image/gif"/>
+ </theme>
+</themes>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list