Author: julien(a)jboss.com
Date: 2007-04-05 11:09:59 -0400 (Thu, 05 Apr 2007)
New Revision: 6926
Added:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestLayoutServiceImpl.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestThemeServiceImpl.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/
Removed:
trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java
trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java
trunk/theme/src/main/org/jboss/portal/test/theme/metadata/
trunk/theme/src/main/org/jboss/portal/test/theme/render/
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestPortalLayoutMetaData.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestPortalThemeMetaData.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestRenderSetMetaData.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/TestAJAXServlet.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/TestThemeServlet.java
trunk/theme/src/resources/test/theme-test-war/WEB-INF/web.xml
Log:
moved existing theme test to a tmp package in order to make the cleanup after
Deleted: trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-05 14:14:24
UTC (rev 6925)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-05 15:09:59
UTC (rev 6926)
@@ -1,799 +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 org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.portlet.Properties;
-import org.jboss.portal.server.ServerRequest;
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.RuntimeContext;
-import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.deployment.jboss.PortalLayoutMetaDataFactory;
-import org.jboss.portal.theme.deployment.jboss.RenderSetMetaDataFactory;
-import org.jboss.portal.theme.impl.LayoutServiceImpl;
-import org.jboss.portal.theme.impl.ThemeServiceImpl;
-import org.jboss.portal.theme.impl.PageServiceImpl;
-import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
-import org.jboss.portal.theme.metadata.RenderSetMetaData;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.PageService;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.xml.sax.SAXException;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.Principal;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public class TestHelper
-{
- public static PageService createPageService() throws Exception
- {
- LayoutService layoutService = new LayoutServiceImpl();
- ((ServiceMBeanSupport)layoutService).create();
- ((ServiceMBeanSupport)layoutService).start();
-
- ThemeService themeService = new ThemeServiceImpl();
- ((ServiceMBeanSupport)themeService).create();
- ((ServiceMBeanSupport)themeService).start();
-
- PageService pageService = new PageServiceImpl();
- pageService.setLayoutService(layoutService);
- pageService.setThemeService(themeService);
- ((ServiceMBeanSupport)pageService).create();
- ((ServiceMBeanSupport)pageService).start();
-
- return pageService;
- }
-
- public static void destroyPageService(PageService pageService)
- {
- ((ServiceMBeanSupport)pageService.getLayoutService()).stop();
- ((ServiceMBeanSupport)pageService.getThemeService()).stop();
- ((ServiceMBeanSupport)pageService).stop();
- ((ServiceMBeanSupport)pageService.getLayoutService()).destroy();
- ((ServiceMBeanSupport)pageService.getThemeService()).destroy();
- ((ServiceMBeanSupport)pageService).destroy();
- }
-
- public static RuntimeContext createRuntimeContext()
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return new RuntimeContext("TestAppId", new TestContext(),
"TestContextPath", loader);
- }
-
- public static WindowResult createWindowResult(String windowTitle, String content)
- {
- // setup the window result
- return createWindowResult(windowTitle, content, Collections.EMPTY_MAP);
- }
-
- public static WindowResult createWindowResult(String title, String content, Map
windowProps)
- {
- // setup the window result
- Map actionsMap = Collections.EMPTY_MAP;
- Properties responseProps = null;
- String headerChars = null;
- return new WindowResult(title, content, actionsMap, windowProps, responseProps,
headerChars, null, null);
- }
-
- public static RenderSetMetaData createRenderSetMD() throws Exception
- {
- List renderSets =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(createRenderSetDescriptor(),
new RenderSetMetaDataFactory(), null);
- return (RenderSetMetaData)renderSets.get(0);
- }
-
- public static List createRenderSetMDList() throws Exception
- {
- List renderSets =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(createRenderSetDescriptor(),
new RenderSetMetaDataFactory(), null);
- return renderSets;
- }
-
- private static Reader createRenderSetDescriptor()
- throws IOException, SAXException, ParserConfigurationException
- {
- StringBuffer testString = new StringBuffer();
- testString.append("<portal-renderSet>");
- testString.append("<renderSet name=\"emptyRenderer\">");
- testString.append("<set content-type=\"text/html\">");
-
testString.append("<region-renderer>org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer</region-renderer>");
-
testString.append("<window-renderer>org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer</window-renderer>");
-
testString.append("<portlet-renderer>org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer</portlet-renderer>");
-
testString.append("<decoration-renderer>org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer</decoration-renderer>");
- testString.append("</set>");
- testString.append("</renderSet>");
-
- testString.append("<renderSet name=\"divRenderer\">");
- testString.append("<set content-type=\"text/html\">");
-
testString.append("<region-renderer>org.jboss.portal.theme.impl.render.div.DivRegionRenderer</region-renderer>");
-
testString.append("<window-renderer>org.jboss.portal.theme.impl.render.div.DivWindowRenderer</window-renderer>");
-
testString.append("<portlet-renderer>org.jboss.portal.theme.impl.render.div.DivPortletRenderer</portlet-renderer>");
-
testString.append("<decoration-renderer>org.jboss.portal.theme.impl.render.div.DivDecorationRenderer</decoration-renderer>");
- testString.append("</set>");
- testString.append("</renderSet>");
-
- testString.append("</portal-renderSet>");
-
- return new StringReader(testString.toString());
- }
-
- public static PortalLayoutMetaData createLayoutMD() throws Exception
- {
- // create a descriptor for the tests
- StringBuffer testString = new StringBuffer();
- testString.append("<layouts>");
- testString.append("<layout>");
- testString.append("<name>TestLayout</name>");
- testString.append("<uri>/test/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>");
- List layoutMDList =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new
StringReader(testString.toString()), new PortalLayoutMetaDataFactory(), null);
- return (PortalLayoutMetaData)layoutMDList.get(0);
- }
-
- public static PageResult createPageResult(AttributeResolver navCtx, String pageName,
- Map pageProperties, Map portalProperties,
WindowContext[] windows)
- {
- PageResult pageResult = new PageResult(pageName, pageProperties,
portalProperties);
- for (int i = 0; i < windows.length; i++)
- {
- pageResult.addWindowContext(windows[i]);
- }
- return pageResult;
- }
-
- public static ServerRequest createServerRequest()
- {
- final HttpServletRequest clientRequest = new TestHttpServletRequest();
- return new ServerRequest(null);
- }
-
- public static class TestContext implements ServletContext
- {
- public TestContext()
- {
-
- }
-
- public ServletContext getContext(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public int getMajorVersion()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public int getMinorVersion()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getMimeType(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Set getResourcePaths(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public URL getResource(String string) throws MalformedURLException
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public InputStream getResourceAsStream(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public RequestDispatcher getRequestDispatcher(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public RequestDispatcher getNamedDispatcher(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Servlet getServlet(String string) throws ServletException
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getServlets()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getServletNames()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public void log(String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void log(Exception exception, String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void log(String string, Throwable throwable)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public String getRealPath(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getServerInfo()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getInitParameter(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getInitParameterNames()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Object getAttribute(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getAttributeNames()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public void setAttribute(String string, Object object)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void removeAttribute(String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public String getServletContextName()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
- }
-
-
- // request
- public static class TestHttpServletRequest implements HttpServletRequest
- {
- private Map attributes;
-
- public TestHttpServletRequest()
- {
- attributes = new HashMap();
- }
-
- public String getAuthType()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Cookie[] getCookies()
- {
- return new Cookie[0]; //To change body of implemented methods use File |
Settings | File Templates.
- }
-
- public long getDateHeader(String string)
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getHeader(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getHeaders(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getHeaderNames()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public int getIntHeader(String string)
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getMethod()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getPathInfo()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getPathTranslated()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getContextPath()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getQueryString()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getRemoteUser()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public boolean isUserInRole(String string)
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public Principal getUserPrincipal()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getRequestedSessionId()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getRequestURI()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public StringBuffer getRequestURL()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getServletPath()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public HttpSession getSession(boolean b)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public HttpSession getSession()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public boolean isRequestedSessionIdValid()
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public boolean isRequestedSessionIdFromCookie()
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public boolean isRequestedSessionIdFromURL()
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public boolean isRequestedSessionIdFromUrl()
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public Object getAttribute(String key)
- {
- return attributes.get(key);
- }
-
- public Enumeration getAttributeNames()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getCharacterEncoding()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public void setCharacterEncoding(String string) throws
UnsupportedEncodingException
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public int getContentLength()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getContentType()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public ServletInputStream getInputStream() throws IOException
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getParameter(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getParameterNames()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String[] getParameterValues(String string)
- {
- return new String[0]; //To change body of implemented methods use File |
Settings | File Templates.
- }
-
- public Map getParameterMap()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getProtocol()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getScheme()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getServerName()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public int getServerPort()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public BufferedReader getReader() throws IOException
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getRemoteAddr()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getRemoteHost()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public void setAttribute(String key, Object value)
- {
- attributes.put(key, value);
- }
-
- public void removeAttribute(String key)
- {
- attributes.remove(key);
- }
-
- public Locale getLocale()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public Enumeration getLocales()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public boolean isSecure()
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public RequestDispatcher getRequestDispatcher(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getRealPath(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public int getRemotePort()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getLocalName()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getLocalAddr()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public int getLocalPort()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
- }
-
- // response
- public static class TestHttpServletResponse implements HttpServletResponse
- {
- private StringWriter writer;
-
- public TestHttpServletResponse()
- {
-
- }
-
- public void addCookie(Cookie cookie)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean containsHeader(String string)
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public String encodeURL(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String encodeRedirectURL(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String encodeUrl(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String encodeRedirectUrl(String string)
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public void sendError(int i, String string) throws IOException
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void sendError(int i) throws IOException
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void sendRedirect(String string) throws IOException
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setDateHeader(String string, long l)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void addDateHeader(String string, long l)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setHeader(String string, String string1)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void addHeader(String string, String string1)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setIntHeader(String string, int i)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void addIntHeader(String string, int i)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setStatus(int i)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setStatus(int i, String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public String getCharacterEncoding()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getContentType()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public ServletOutputStream getOutputStream() throws IOException
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public PrintWriter getWriter() throws IOException
- {
- writer = new StringWriter();
- return new PrintWriter(writer);
- }
-
- public String getResult()
- {
- return writer.toString();
- }
-
- public void setCharacterEncoding(String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setContentLength(int i)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setContentType(String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setBufferSize(int i)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public int getBufferSize()
- {
- return 0; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public void flushBuffer() throws IOException
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void resetBuffer()
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean isCommitted()
- {
- return false; //To change body of implemented methods use File | Settings |
File Templates.
- }
-
- public void reset()
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setLocale(Locale locale)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Locale getLocale()
- {
- return null; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public String getResponseMarkup()
- {
- return null; //To change body of created methods use File | Settings | File
Templates.
- }
- }
-
-}
Deleted: trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java 2007-04-05
14:14:24 UTC (rev 6925)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -1,206 +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.common.util.MediaType;
-import org.jboss.portal.common.util.CLResourceLoader;
-import org.jboss.portal.common.util.LoaderResource;
-import org.jboss.portal.theme.LayoutException;
-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.deployment.jboss.RenderSetMetaDataFactory;
-import org.jboss.portal.theme.impl.LayoutServiceImpl;
-import org.jboss.portal.theme.impl.render.div.DivDecorationRenderer;
-import org.jboss.portal.theme.impl.render.div.DivPortletRenderer;
-import org.jboss.portal.theme.impl.render.div.DivRegionRenderer;
-import org.jboss.portal.theme.impl.render.div.DivWindowRenderer;
-import org.jboss.portal.theme.impl.render.dynamic.DynaDecorationRenderer;
-import org.jboss.portal.theme.impl.render.dynamic.DynaPortletRenderer;
-import org.jboss.portal.theme.impl.render.dynamic.DynaRegionRenderer;
-import org.jboss.portal.theme.impl.render.dynamic.DynaWindowRenderer;
-import org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer;
-import org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer;
-import org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer;
-import org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer;
-import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
-import org.jboss.portal.theme.metadata.RenderSetMetaData;
-import org.jboss.portal.theme.render.PortalRenderSet;
-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@novell.com">Martin Holzner</a>
- * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
- * @version $Revision$
- */
-public class TestLayoutServiceImpl extends TestCase
-{
- private LayoutServiceImpl layoutService;
- private RuntimeContext runtimeContext;
- private List portalLayouts;
- private List renderSets;
-
- protected void setUp() throws Exception
- {
- layoutService = new LayoutServiceImpl();
-
- layoutService.create();
- layoutService.start();
-
- runtimeContext = TestHelper.createRuntimeContext();
-
- LoaderResource res = new
CLResourceLoader().getResource("xml/portal-layouts.xml");
- assertNotNull("Layout xml could not be loaded", res);
- Unmarshaller unmarshaller = null;
- unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- portalLayouts = (List)unmarshaller.unmarshal(res.asInputStream(), new
PortalLayoutMetaDataFactory(), null);
-
- for (Iterator i = portalLayouts.iterator(); i.hasNext();)
- {
- PortalLayoutMetaData layoutMD = (PortalLayoutMetaData)i.next();
- layoutService.addLayout(runtimeContext, layoutMD);
- }
-
- res = new CLResourceLoader().getResource("xml/portal-renderSet.xml");
- unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- renderSets = (List)unmarshaller.unmarshal(res.asInputStream(), new
RenderSetMetaDataFactory(), null);
- for (Iterator i = renderSets.iterator(); i.hasNext();)
- {
- RenderSetMetaData renderSetMD = (RenderSetMetaData)i.next();
- layoutService.addRenderSet(runtimeContext, renderSetMD);
- }
- }
-
- protected void tearDown() throws Exception
- {
- layoutService = null;
- renderSets = null;
- }
-
- public void testCreateLayouts()
- {
- try
- {
- 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)
- {
- assertFalse("unexpected exception occured", true);
- e.printStackTrace();
- }
- }
-
- public void testGetLayoutInfos()
- {
- PortalLayout layout = layoutService.getLayout("nodesk", true);
- assertTrue(layout.getLayoutInfo().getName().equals("nodesk"));
- assertTrue(layout.getLayoutInfo().getURI().equals("/nodesk/index.jsp"));
- assertTrue(layout.getLayoutInfo().getRegionNames().size() == 2);
-
- layout = layoutService.getLayout("phalanx", true);
- assertTrue(layout.getLayoutInfo().getName().equals("phalanx"));
- assertNotNull(layout.getLayoutInfo().getURI());
-
- layout = layoutService.getLayout("generic", true);
- assertTrue(layout.getLayoutInfo().getName().equals("generic"));
- assertTrue(layout.getLayoutInfo().getRegionNames().size() == 3);
- List regions = layout.getLayoutInfo().getRegionNames();
- assertTrue(regions.get(0).equals("left"));
- assertTrue(regions.get(1).equals("center"));
- assertTrue(regions.get(2).equals("navigation"));
- }
-
- public void testRemoveLayouts()
- {
- try
- {
- assertNotNull(layoutService.getLayout("generic", false));
- layoutService.removeLayouts(runtimeContext.getAppId());
- assertNull(layoutService.getLayout("generic", 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)
- {
- assertFalse("unexpected exception occured", true);
- e.printStackTrace();
- }
- }
-
- public void testCreateRenderSets()
- {
- PortalRenderSet renderSet = layoutService.getRenderSet("divRenderer",
MediaType.HTML);
- assertEquals(renderSet.getName(), "divRenderer");
-
- renderSet = layoutService.getRenderSet("emptyRenderer", MediaType.HTML);
- assertEquals(renderSet.getName(), "emptyRenderer");
- }
-
- public void testGetRenderSetInfos() throws Exception
- {
- PortalRenderSet renderSet = layoutService.getRenderSet("divRenderer",
MediaType.HTML);
- assertEquals(renderSet.getName(), "divRenderer");
- assertTrue(renderSet.isAjaxEnabled());
- assertEquals(renderSet.getDecorationRenderer().getClass(), new
DynaDecorationRenderer(new DivDecorationRenderer()).getClass());
- assertEquals(renderSet.getPortletRenderer().getClass(), new DynaPortletRenderer(new
DivPortletRenderer()).getClass());
- assertEquals(renderSet.getRegionRenderer().getClass(), new DynaRegionRenderer(new
DivRegionRenderer()).getClass());
- assertEquals(renderSet.getWindowRenderer().getClass(), new DynaWindowRenderer(new
DivWindowRenderer()).getClass());
-
- renderSet = layoutService.getRenderSet("emptyRenderer", MediaType.HTML);
- assertEquals(renderSet.getName(), "emptyRenderer");
- assertFalse(renderSet.isAjaxEnabled());
- assertEquals(renderSet.getDecorationRenderer().getClass(), new
EmptyDecorationRenderer().getClass());
- assertEquals(renderSet.getPortletRenderer().getClass(), new
EmptyPortletRenderer().getClass());
- assertEquals(renderSet.getRegionRenderer().getClass(), new
EmptyRegionRenderer().getClass());
- assertEquals(renderSet.getWindowRenderer().getClass(), new
EmptyWindowRenderer().getClass());
- }
-
- public void testRemoveRenderSets() throws LayoutException
- {
- assertNotNull(layoutService.getRenderSet("divRenderer",
MediaType.HTML));
- ServerRegistrationID id =
ServerRegistrationID.createPortalLayoutID(runtimeContext.getAppId(),
"divRenderer");
- layoutService.removeRenderSets(id.getName(0));
- assertNull(layoutService.getRenderSet("divRenderer", MediaType.HTML));
- }
-}
Deleted: trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java 2007-04-05
14:14:24 UTC (rev 6925)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -1,118 +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.common.util.CLResourceLoader;
-import org.jboss.portal.common.util.LoaderResource;
-import org.jboss.portal.theme.PortalTheme;
-import org.jboss.portal.theme.RuntimeContext;
-import org.jboss.portal.theme.ThemeException;
-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@novell.com">Martin Holzner</a>
- * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
- * @version $Revision$
- */
-public class TestThemeServiceImpl extends TestCase
-{
- private ThemeService themeService;
- private RuntimeContext runtimeContext;
- List themes;
-
- protected void setUp() throws Exception
- {
- themeService = new ThemeServiceImpl();
-
- runtimeContext = TestHelper.createRuntimeContext();
- LoaderResource res = new
CLResourceLoader().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()
- {
- PortalTheme theme = themeService.getTheme("industrial", false);
- assertEquals(theme.getThemeInfo().getName(), "industrial");
- assertTrue(theme.getThemeInfo().getScripts().size() == 0);
- assertTrue(theme.getThemeInfo().getLinks().size() == 2);
-
- theme = themeService.getTheme("Nphalanx", false);
- assertEquals(theme.getThemeInfo().getName(), "Nphalanx");
- assertTrue(theme.getThemeInfo().getScripts().size() == 0);
- assertTrue(theme.getThemeInfo().getLinks().size() == 1);
- }
-
- public void testRemoveTheme() throws ThemeException
- {
- assertNotNull(themeService.getTheme("industrial", false));
- themeService.removeTheme(themeService.getTheme("industrial", false));
- assertNull(themeService.getTheme("industrial", false));
- }
-}
\ No newline at end of file
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java (from rev
6924, trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -0,0 +1,799 @@
+/******************************************************************************
+ * 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.tmp;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.portlet.Properties;
+import org.jboss.portal.server.ServerRequest;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.RuntimeContext;
+import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.deployment.jboss.PortalLayoutMetaDataFactory;
+import org.jboss.portal.theme.deployment.jboss.RenderSetMetaDataFactory;
+import org.jboss.portal.theme.impl.LayoutServiceImpl;
+import org.jboss.portal.theme.impl.ThemeServiceImpl;
+import org.jboss.portal.theme.impl.PageServiceImpl;
+import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
+import org.jboss.portal.theme.metadata.RenderSetMetaData;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.PageService;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.xml.sax.SAXException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $Revision$
+ */
+public class TestHelper
+{
+ public static PageService createPageService() throws Exception
+ {
+ LayoutService layoutService = new LayoutServiceImpl();
+ ((ServiceMBeanSupport)layoutService).create();
+ ((ServiceMBeanSupport)layoutService).start();
+
+ ThemeService themeService = new ThemeServiceImpl();
+ ((ServiceMBeanSupport)themeService).create();
+ ((ServiceMBeanSupport)themeService).start();
+
+ PageService pageService = new PageServiceImpl();
+ pageService.setLayoutService(layoutService);
+ pageService.setThemeService(themeService);
+ ((ServiceMBeanSupport)pageService).create();
+ ((ServiceMBeanSupport)pageService).start();
+
+ return pageService;
+ }
+
+ public static void destroyPageService(PageService pageService)
+ {
+ ((ServiceMBeanSupport)pageService.getLayoutService()).stop();
+ ((ServiceMBeanSupport)pageService.getThemeService()).stop();
+ ((ServiceMBeanSupport)pageService).stop();
+ ((ServiceMBeanSupport)pageService.getLayoutService()).destroy();
+ ((ServiceMBeanSupport)pageService.getThemeService()).destroy();
+ ((ServiceMBeanSupport)pageService).destroy();
+ }
+
+ public static RuntimeContext createRuntimeContext()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return new RuntimeContext("TestAppId", new TestContext(),
"TestContextPath", loader);
+ }
+
+ public static WindowResult createWindowResult(String windowTitle, String content)
+ {
+ // setup the window result
+ return createWindowResult(windowTitle, content, Collections.EMPTY_MAP);
+ }
+
+ public static WindowResult createWindowResult(String title, String content, Map
windowProps)
+ {
+ // setup the window result
+ Map actionsMap = Collections.EMPTY_MAP;
+ Properties responseProps = null;
+ String headerChars = null;
+ return new WindowResult(title, content, actionsMap, windowProps, responseProps,
headerChars, null, null);
+ }
+
+ public static RenderSetMetaData createRenderSetMD() throws Exception
+ {
+ List renderSets =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(createRenderSetDescriptor(),
new RenderSetMetaDataFactory(), null);
+ return (RenderSetMetaData)renderSets.get(0);
+ }
+
+ public static List createRenderSetMDList() throws Exception
+ {
+ List renderSets =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(createRenderSetDescriptor(),
new RenderSetMetaDataFactory(), null);
+ return renderSets;
+ }
+
+ private static Reader createRenderSetDescriptor()
+ throws IOException, SAXException, ParserConfigurationException
+ {
+ StringBuffer testString = new StringBuffer();
+ testString.append("<portal-renderSet>");
+ testString.append("<renderSet name=\"emptyRenderer\">");
+ testString.append("<set content-type=\"text/html\">");
+
testString.append("<region-renderer>org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer</region-renderer>");
+
testString.append("<window-renderer>org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer</window-renderer>");
+
testString.append("<portlet-renderer>org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer</portlet-renderer>");
+
testString.append("<decoration-renderer>org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer</decoration-renderer>");
+ testString.append("</set>");
+ testString.append("</renderSet>");
+
+ testString.append("<renderSet name=\"divRenderer\">");
+ testString.append("<set content-type=\"text/html\">");
+
testString.append("<region-renderer>org.jboss.portal.theme.impl.render.div.DivRegionRenderer</region-renderer>");
+
testString.append("<window-renderer>org.jboss.portal.theme.impl.render.div.DivWindowRenderer</window-renderer>");
+
testString.append("<portlet-renderer>org.jboss.portal.theme.impl.render.div.DivPortletRenderer</portlet-renderer>");
+
testString.append("<decoration-renderer>org.jboss.portal.theme.impl.render.div.DivDecorationRenderer</decoration-renderer>");
+ testString.append("</set>");
+ testString.append("</renderSet>");
+
+ testString.append("</portal-renderSet>");
+
+ return new StringReader(testString.toString());
+ }
+
+ public static PortalLayoutMetaData createLayoutMD() throws Exception
+ {
+ // create a descriptor for the tests
+ StringBuffer testString = new StringBuffer();
+ testString.append("<layouts>");
+ testString.append("<layout>");
+ testString.append("<name>TestLayout</name>");
+ testString.append("<uri>/test/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>");
+ List layoutMDList =
(List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new
StringReader(testString.toString()), new PortalLayoutMetaDataFactory(), null);
+ return (PortalLayoutMetaData)layoutMDList.get(0);
+ }
+
+ public static PageResult createPageResult(AttributeResolver navCtx, String pageName,
+ Map pageProperties, Map portalProperties,
WindowContext[] windows)
+ {
+ PageResult pageResult = new PageResult(pageName, pageProperties,
portalProperties);
+ for (int i = 0; i < windows.length; i++)
+ {
+ pageResult.addWindowContext(windows[i]);
+ }
+ return pageResult;
+ }
+
+ public static ServerRequest createServerRequest()
+ {
+ final HttpServletRequest clientRequest = new TestHttpServletRequest();
+ return new ServerRequest(null);
+ }
+
+ public static class TestContext implements ServletContext
+ {
+ public TestContext()
+ {
+
+ }
+
+ public ServletContext getContext(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public int getMajorVersion()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public int getMinorVersion()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getMimeType(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Set getResourcePaths(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public URL getResource(String string) throws MalformedURLException
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public InputStream getResourceAsStream(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public RequestDispatcher getRequestDispatcher(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public RequestDispatcher getNamedDispatcher(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Servlet getServlet(String string) throws ServletException
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getServlets()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getServletNames()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void log(String string)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void log(Exception exception, String string)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void log(String string, Throwable throwable)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getRealPath(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getServerInfo()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getInitParameter(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Object getAttribute(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void setAttribute(String string, Object object)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeAttribute(String string)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getServletContextName()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+ }
+
+
+ // request
+ public static class TestHttpServletRequest implements HttpServletRequest
+ {
+ private Map attributes;
+
+ public TestHttpServletRequest()
+ {
+ attributes = new HashMap();
+ }
+
+ public String getAuthType()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Cookie[] getCookies()
+ {
+ return new Cookie[0]; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public long getDateHeader(String string)
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getHeader(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getHeaders(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getHeaderNames()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public int getIntHeader(String string)
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getMethod()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getPathInfo()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getPathTranslated()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getContextPath()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getQueryString()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getRemoteUser()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public boolean isUserInRole(String string)
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getRequestedSessionId()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getRequestURI()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public StringBuffer getRequestURL()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getServletPath()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public HttpSession getSession(boolean b)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public HttpSession getSession()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public boolean isRequestedSessionIdValid()
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public boolean isRequestedSessionIdFromCookie()
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public boolean isRequestedSessionIdFromURL()
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public boolean isRequestedSessionIdFromUrl()
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public Object getAttribute(String key)
+ {
+ return attributes.get(key);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getCharacterEncoding()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void setCharacterEncoding(String string) throws
UnsupportedEncodingException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public int getContentLength()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getContentType()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public ServletInputStream getInputStream() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getParameter(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getParameterNames()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String[] getParameterValues(String string)
+ {
+ return new String[0]; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public Map getParameterMap()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getProtocol()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getScheme()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getServerName()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public int getServerPort()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getRemoteAddr()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getRemoteHost()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void setAttribute(String key, Object value)
+ {
+ attributes.put(key, value);
+ }
+
+ public void removeAttribute(String key)
+ {
+ attributes.remove(key);
+ }
+
+ public Locale getLocale()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public Enumeration getLocales()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public boolean isSecure()
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public RequestDispatcher getRequestDispatcher(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getRealPath(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public int getRemotePort()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getLocalName()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getLocalAddr()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public int getLocalPort()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+ }
+
+ // response
+ public static class TestHttpServletResponse implements HttpServletResponse
+ {
+ private StringWriter writer;
+
+ public TestHttpServletResponse()
+ {
+
+ }
+
+ public void addCookie(Cookie cookie)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean containsHeader(String string)
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public String encodeURL(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String encodeRedirectURL(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String encodeUrl(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String encodeRedirectUrl(String string)
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void sendError(int i, String string) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void sendError(int i) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void sendRedirect(String string) throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setDateHeader(String string, long l)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addDateHeader(String string, long l)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setHeader(String string, String string1)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addHeader(String string, String string1)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setIntHeader(String string, int i)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addIntHeader(String string, int i)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setStatus(int i)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setStatus(int i, String string)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getCharacterEncoding()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getContentType()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ writer = new StringWriter();
+ return new PrintWriter(writer);
+ }
+
+ public String getResult()
+ {
+ return writer.toString();
+ }
+
+ public void setCharacterEncoding(String string)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setContentLength(int i)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setContentType(String string)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setBufferSize(int i)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public int getBufferSize()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void resetBuffer()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isCommitted()
+ {
+ return false; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public void reset()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setLocale(Locale locale)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Locale getLocale()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public String getResponseMarkup()
+ {
+ return null; //To change body of created methods use File | Settings | File
Templates.
+ }
+ }
+
+}
Property changes on: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestLayoutServiceImpl.java
(from rev 6924,
trunk/theme/src/main/org/jboss/portal/test/theme/TestLayoutServiceImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestLayoutServiceImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestLayoutServiceImpl.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * 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.tmp;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.common.util.CLResourceLoader;
+import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.portal.theme.LayoutException;
+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.deployment.jboss.RenderSetMetaDataFactory;
+import org.jboss.portal.theme.impl.LayoutServiceImpl;
+import org.jboss.portal.theme.impl.render.div.DivDecorationRenderer;
+import org.jboss.portal.theme.impl.render.div.DivPortletRenderer;
+import org.jboss.portal.theme.impl.render.div.DivRegionRenderer;
+import org.jboss.portal.theme.impl.render.div.DivWindowRenderer;
+import org.jboss.portal.theme.impl.render.dynamic.DynaDecorationRenderer;
+import org.jboss.portal.theme.impl.render.dynamic.DynaPortletRenderer;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRegionRenderer;
+import org.jboss.portal.theme.impl.render.dynamic.DynaWindowRenderer;
+import org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer;
+import org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer;
+import org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer;
+import org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer;
+import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
+import org.jboss.portal.theme.metadata.RenderSetMetaData;
+import org.jboss.portal.theme.render.PortalRenderSet;
+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@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
+ * @version $Revision$
+ */
+public class TestLayoutServiceImpl extends TestCase
+{
+ private LayoutServiceImpl layoutService;
+ private RuntimeContext runtimeContext;
+ private List portalLayouts;
+ private List renderSets;
+
+ protected void setUp() throws Exception
+ {
+ layoutService = new LayoutServiceImpl();
+
+ layoutService.create();
+ layoutService.start();
+
+ runtimeContext = TestHelper.createRuntimeContext();
+
+ LoaderResource res = new
CLResourceLoader().getResource("xml/portal-layouts.xml");
+ assertNotNull("Layout xml could not be loaded", res);
+ Unmarshaller unmarshaller = null;
+ unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ portalLayouts = (List)unmarshaller.unmarshal(res.asInputStream(), new
PortalLayoutMetaDataFactory(), null);
+
+ for (Iterator i = portalLayouts.iterator(); i.hasNext();)
+ {
+ PortalLayoutMetaData layoutMD = (PortalLayoutMetaData)i.next();
+ layoutService.addLayout(runtimeContext, layoutMD);
+ }
+
+ res = new CLResourceLoader().getResource("xml/portal-renderSet.xml");
+ unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ renderSets = (List)unmarshaller.unmarshal(res.asInputStream(), new
RenderSetMetaDataFactory(), null);
+ for (Iterator i = renderSets.iterator(); i.hasNext();)
+ {
+ RenderSetMetaData renderSetMD = (RenderSetMetaData)i.next();
+ layoutService.addRenderSet(runtimeContext, renderSetMD);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ layoutService = null;
+ renderSets = null;
+ }
+
+ public void testCreateLayouts()
+ {
+ try
+ {
+ 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)
+ {
+ assertFalse("unexpected exception occured", true);
+ e.printStackTrace();
+ }
+ }
+
+ public void testGetLayoutInfos()
+ {
+ PortalLayout layout = layoutService.getLayout("nodesk", true);
+ assertTrue(layout.getLayoutInfo().getName().equals("nodesk"));
+ assertTrue(layout.getLayoutInfo().getURI().equals("/nodesk/index.jsp"));
+ assertTrue(layout.getLayoutInfo().getRegionNames().size() == 2);
+
+ layout = layoutService.getLayout("phalanx", true);
+ assertTrue(layout.getLayoutInfo().getName().equals("phalanx"));
+ assertNotNull(layout.getLayoutInfo().getURI());
+
+ layout = layoutService.getLayout("generic", true);
+ assertTrue(layout.getLayoutInfo().getName().equals("generic"));
+ assertTrue(layout.getLayoutInfo().getRegionNames().size() == 3);
+ List regions = layout.getLayoutInfo().getRegionNames();
+ assertTrue(regions.get(0).equals("left"));
+ assertTrue(regions.get(1).equals("center"));
+ assertTrue(regions.get(2).equals("navigation"));
+ }
+
+ public void testRemoveLayouts()
+ {
+ try
+ {
+ assertNotNull(layoutService.getLayout("generic", false));
+ layoutService.removeLayouts(runtimeContext.getAppId());
+ assertNull(layoutService.getLayout("generic", 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)
+ {
+ assertFalse("unexpected exception occured", true);
+ e.printStackTrace();
+ }
+ }
+
+ public void testCreateRenderSets()
+ {
+ PortalRenderSet renderSet = layoutService.getRenderSet("divRenderer",
MediaType.HTML);
+ assertEquals(renderSet.getName(), "divRenderer");
+
+ renderSet = layoutService.getRenderSet("emptyRenderer", MediaType.HTML);
+ assertEquals(renderSet.getName(), "emptyRenderer");
+ }
+
+ public void testGetRenderSetInfos() throws Exception
+ {
+ PortalRenderSet renderSet = layoutService.getRenderSet("divRenderer",
MediaType.HTML);
+ assertEquals(renderSet.getName(), "divRenderer");
+ assertTrue(renderSet.isAjaxEnabled());
+ assertEquals(renderSet.getDecorationRenderer().getClass(), new
DynaDecorationRenderer(new DivDecorationRenderer()).getClass());
+ assertEquals(renderSet.getPortletRenderer().getClass(), new DynaPortletRenderer(new
DivPortletRenderer()).getClass());
+ assertEquals(renderSet.getRegionRenderer().getClass(), new DynaRegionRenderer(new
DivRegionRenderer()).getClass());
+ assertEquals(renderSet.getWindowRenderer().getClass(), new DynaWindowRenderer(new
DivWindowRenderer()).getClass());
+
+ renderSet = layoutService.getRenderSet("emptyRenderer", MediaType.HTML);
+ assertEquals(renderSet.getName(), "emptyRenderer");
+ assertFalse(renderSet.isAjaxEnabled());
+ assertEquals(renderSet.getDecorationRenderer().getClass(), new
EmptyDecorationRenderer().getClass());
+ assertEquals(renderSet.getPortletRenderer().getClass(), new
EmptyPortletRenderer().getClass());
+ assertEquals(renderSet.getRegionRenderer().getClass(), new
EmptyRegionRenderer().getClass());
+ assertEquals(renderSet.getWindowRenderer().getClass(), new
EmptyWindowRenderer().getClass());
+ }
+
+ public void testRemoveRenderSets() throws LayoutException
+ {
+ assertNotNull(layoutService.getRenderSet("divRenderer",
MediaType.HTML));
+ ServerRegistrationID id =
ServerRegistrationID.createPortalLayoutID(runtimeContext.getAppId(),
"divRenderer");
+ layoutService.removeRenderSets(id.getName(0));
+ assertNull(layoutService.getRenderSet("divRenderer", MediaType.HTML));
+ }
+}
Property changes on:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestLayoutServiceImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestThemeServiceImpl.java
(from rev 6924,
trunk/theme/src/main/org/jboss/portal/test/theme/TestThemeServiceImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestThemeServiceImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestThemeServiceImpl.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * 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.tmp;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CLResourceLoader;
+import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.portal.theme.PortalTheme;
+import org.jboss.portal.theme.RuntimeContext;
+import org.jboss.portal.theme.ThemeException;
+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@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
+ * @version $Revision$
+ */
+public class TestThemeServiceImpl extends TestCase
+{
+ private ThemeService themeService;
+ private RuntimeContext runtimeContext;
+ List themes;
+
+ protected void setUp() throws Exception
+ {
+ themeService = new ThemeServiceImpl();
+
+ runtimeContext = TestHelper.createRuntimeContext();
+ LoaderResource res = new
CLResourceLoader().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()
+ {
+ PortalTheme theme = themeService.getTheme("industrial", false);
+ assertEquals(theme.getThemeInfo().getName(), "industrial");
+ assertTrue(theme.getThemeInfo().getScripts().size() == 0);
+ assertTrue(theme.getThemeInfo().getLinks().size() == 2);
+
+ theme = themeService.getTheme("Nphalanx", false);
+ assertEquals(theme.getThemeInfo().getName(), "Nphalanx");
+ assertTrue(theme.getThemeInfo().getScripts().size() == 0);
+ assertTrue(theme.getThemeInfo().getLinks().size() == 1);
+ }
+
+ public void testRemoveTheme() throws ThemeException
+ {
+ assertNotNull(themeService.getTheme("industrial", false));
+ themeService.removeTheme(themeService.getTheme("industrial", false));
+ assertNull(themeService.getTheme("industrial", false));
+ }
+}
\ No newline at end of file
Property changes on:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestThemeServiceImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata (from rev 6924,
trunk/theme/src/main/org/jboss/portal/test/theme/metadata)
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestPortalLayoutMetaData.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/metadata/TestPortalLayoutMetaData.java 2007-04-05
14:12:12 UTC (rev 6924)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestPortalLayoutMetaData.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -20,7 +20,7 @@
* 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.metadata;
+package org.jboss.portal.test.theme.tmp.metadata;
import junit.framework.TestCase;
import org.jboss.portal.theme.deployment.jboss.PortalLayoutMetaDataFactory;
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestPortalThemeMetaData.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/metadata/TestPortalThemeMetaData.java 2007-04-05
14:12:12 UTC (rev 6924)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestPortalThemeMetaData.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -20,7 +20,7 @@
* 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.metadata;
+package org.jboss.portal.test.theme.tmp.metadata;
import junit.framework.TestCase;
import org.jboss.portal.theme.deployment.jboss.PortalThemeMetaDataFactory;
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestRenderSetMetaData.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/metadata/TestRenderSetMetaData.java 2007-04-05
14:12:12 UTC (rev 6924)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/metadata/TestRenderSetMetaData.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -20,7 +20,7 @@
* 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.metadata;
+package org.jboss.portal.test.theme.tmp.metadata;
import junit.framework.TestCase;
import org.jboss.portal.common.util.MediaType;
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render (from rev 6924,
trunk/theme/src/main/org/jboss/portal/test/theme/render)
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-05
14:12:12 UTC (rev 6924)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -19,7 +19,7 @@
* 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.render;
+package org.jboss.portal.test.theme.tmp.render;
import junit.framework.TestCase;
import org.jboss.portal.common.util.MediaType;
@@ -27,7 +27,7 @@
import org.jboss.portal.common.util.LoaderResource;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.server.ServerRequest;
-import org.jboss.portal.test.theme.TestHelper;
+import org.jboss.portal.test.theme.tmp.TestHelper;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
Copied: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet (from rev 6924,
trunk/theme/src/main/org/jboss/portal/test/theme/servlet)
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/TestAJAXServlet.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestAJAXServlet.java 2007-04-05
14:12:12 UTC (rev 6924)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/TestAJAXServlet.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -21,7 +21,7 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.test.theme.servlet;
+package org.jboss.portal.test.theme.tmp.servlet;
import org.jboss.logging.Logger;
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/TestThemeServlet.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-05
14:12:12 UTC (rev 6924)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/servlet/TestThemeServlet.java 2007-04-05
15:09:59 UTC (rev 6926)
@@ -21,7 +21,7 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.test.theme.servlet;
+package org.jboss.portal.test.theme.tmp.servlet;
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanServerLocator;
Modified: trunk/theme/src/resources/test/theme-test-war/WEB-INF/web.xml
===================================================================
--- trunk/theme/src/resources/test/theme-test-war/WEB-INF/web.xml 2007-04-05 14:14:24 UTC
(rev 6925)
+++ trunk/theme/src/resources/test/theme-test-war/WEB-INF/web.xml 2007-04-05 15:09:59 UTC
(rev 6926)
@@ -32,13 +32,13 @@
<description>Handles test xmlhttprequests and callbacks from content rendered
by the
TestThemeServlet</description>
<servlet-name>TestAJAXServlet</servlet-name>
-
<servlet-class>org.jboss.portal.test.theme.servlet.TestAJAXServlet</servlet-class>
+
<servlet-class>org.jboss.portal.test.theme.tmp.servlet.TestAJAXServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<description>Renders a theme for testing</description>
<servlet-name>TestThemeServlet</servlet-name>
-
<servlet-class>org.jboss.portal.test.theme.servlet.TestThemeServlet</servlet-class>
+
<servlet-class>org.jboss.portal.test.theme.tmp.servlet.TestThemeServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>