You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2005/07/27 22:34:48 UTC

svn commit: r225618 - in /portals/jetspeed-2/trunk/components/portal: ./ src/java/org/apache/jetspeed/ src/test/org/apache/jetspeed/ src/test/org/apache/jetspeed/container/ src/test/org/apache/jetspeed/container/state/ src/test/org/apache/jetspeed/engi...

Author: weaver
Date: Wed Jul 27 13:34:42 2005
New Revision: 225618

URL: http://svn.apache.org/viewcvs?rev=225618&view=rev
Log:
Refactoring/fixing of test cases.

Added:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/PortalContext.java   (with props)
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java   (with props)
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortalTestConstants.java   (with props)
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/SpringEngineHelper.java
      - copied unchanged from r225527, portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/SpringEngineHelper.java
Modified:
    portals/jetspeed-2/trunk/components/portal/project.xml
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/Jetspeed.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/JetspeedPortalContext.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/AbstractEngineTest.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/test/JetspeedTestSuite.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/tools/TestWebXML.java

Modified: portals/jetspeed-2/trunk/components/portal/project.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/project.xml?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/project.xml (original)
+++ portals/jetspeed-2/trunk/components/portal/project.xml Wed Jul 27 13:34:42 2005
@@ -40,15 +40,9 @@
     <sourceDirectory>src/java</sourceDirectory>
     <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
     <unitTest>
-       <excludes>
-            <exclude>**/TestSpring*</exclude>                        
-            <exclude>**/TestPipeline*</exclude>                        
-            <exclude>**/TestNavigationalState*</exclude>                        
-            <exclude>**/TestWebXML*</exclude>                                                
-            <exclude>**/JetspeedTest*</exclude>                        
-            <exclude>**/PortalTestConstants*</exclude>                                                
-            <exclude>**/Abstract*</exclude>                                                
-       </excludes>
+       <includes>
+         <include>**/Test*</include>  
+       </includes>
       <resources>
       <resource>
         <directory>${basedir}/src/java</directory>

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/Jetspeed.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/Jetspeed.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/Jetspeed.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/Jetspeed.java Wed Jul 27 13:34:42 2005
@@ -42,42 +42,6 @@
     private static final Log log = LogFactory.getLog(Jetspeed.class);
 
     /**
-     * Creates a Jetspeed Engine
-     * 
-     * @param configuration a configuration associated with this Jetspeed instance
-     * @param applicationRoot the root of the servlet application
-     * @param config the servlet configuration, this parameter can be null for unit tests or utilities
-     * @return the newly created Engine
-     * @throws JetspeedException
-     */
-    public static Engine createEngine(Configuration configuration, String applicationRoot, ServletConfig config, Class engineClass)
-        throws JetspeedException
-    {
-        try
-        {
-            synchronized(Jetspeed.class)
-            {
-                if(engine == null)
-                {
-                    log.info("Jetspeed environment attempting to initialize portal Engine...");
-                    engine = (Engine) engineClass.newInstance();
-                    engine.init(configuration, applicationRoot, config);
-                    log.info("JetspeedEngine successfuly intialized.");
-                    log.info("Jetspeed environment successfuly intialized.");
-                }
-                return engine;
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            String msg = "Unable to create Engine";
-            log.error(msg, e);
-            throw new JetspeedException(msg, e);
-        }
-    }
-
-    /**
      * Shuts down the currently running instance of the portal
      * Engine.
      * @throws JetspeedException
@@ -138,4 +102,10 @@
     {
         return engine.getComponentManager();
     }
+
+    public static void setEngine(Engine engine)
+    {
+        Jetspeed.engine = engine;
+    }
+    
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/JetspeedPortalContext.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/JetspeedPortalContext.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/JetspeedPortalContext.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/JetspeedPortalContext.java Wed Jul 27 13:34:42 2005
@@ -15,12 +15,16 @@
  */
 package org.apache.jetspeed;
 
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
 import org.apache.commons.configuration.Configuration;
 import org.apache.jetspeed.engine.Engine;
-import org.apache.jetspeed.engine.core.PortalContextProviderImpl;
-import org.apache.pluto.services.information.PortalContextProvider;
 import org.apache.pluto.util.Enumerator;
 
 /**
@@ -31,6 +35,10 @@
  */
 public class JetspeedPortalContext implements PortalContext
 {
+    private static final String SUPPORTED_WINDOWSTATE_ATTR = "supported.windowstate";
+    private static final String SUPPORTED_PORTLETMODE_ATTR = "supported.portletmode";
+    private static final String PORTAL_VERSION_ATTR = "portal.version";
+    private static final String PORTAL_NAME_ATTR = "portal.name";
     /**
      * The engine associated with this context.
      */
@@ -50,15 +58,43 @@
      * The base from which the Jetspped application will operate.
      */
     private String applicationRoot;
+    
+      /** Portlet Modes */
+    private final List portletModes;
+    
+    /** Window States */
+    private final List windowStates;
 
+    private final String portalName;
+
+    private final String portalVersion;
 
-    public JetspeedPortalContext(Engine engine)
-    {
-        this.engine = engine;
-    }
 
-    private JetspeedPortalContext()
+    public JetspeedPortalContext(Engine engine, Configuration configuration, String applicationRoot)
     {
+        this.engine = engine;
+        this.configuration = configuration;
+        this.applicationRoot = applicationRoot;
+             
+        
+        portalName = configuration.getString(PORTAL_NAME_ATTR);
+        portalVersion = configuration.getString(PORTAL_VERSION_ATTR);
+        
+        // Inititalize supported portlet modes 
+        String[] supportedModes = configuration.getStringArray(SUPPORTED_PORTLETMODE_ATTR);
+        portletModes = new ArrayList(supportedModes.length);        
+        for (int i=0; i<supportedModes.length; i++) 
+        {
+            portletModes.add(new PortletMode(supportedModes[i].toString().toLowerCase()));
+        }
+        
+        // Initialize supported window states         
+        String[] supportedStates = configuration.getStringArray(SUPPORTED_WINDOWSTATE_ATTR);
+        windowStates = new ArrayList(supportedStates.length);
+        for (int i=0; i<supportedStates.length; i++) 
+        {
+            windowStates.add(new WindowState(supportedStates[i].toString().toLowerCase()));
+        }       
     }
 
     // ------------------------------------------------------------------------
@@ -152,7 +188,11 @@
      */
     public String getProperty(String name)
     {
-        return getPortalContextProvider().getProperty(name);
+        if (name == null) 
+        {
+            throw new IllegalArgumentException("Property name == null");
+        }
+        return(String) configuration.getProperty(name);
     }
 
     /* (non-Javadoc)
@@ -160,7 +200,7 @@
      */
     public Enumeration getPropertyNames()
     {
-        return new Enumerator(getPortalContextProvider().getPropertyNames());
+        return new Enumerator(configuration.getKeys());
     }
 
     /* (non-Javadoc)
@@ -168,7 +208,7 @@
      */
     public Enumeration getSupportedPortletModes()
     {
-        return new Enumerator(getPortalContextProvider().getSupportedPortletModes());
+        return new Enumerator(portletModes);
     }
 
     /* (non-Javadoc)
@@ -176,7 +216,7 @@
      */
     public Enumeration getSupportedWindowStates()
     {
-        return new Enumerator(getPortalContextProvider().getSupportedWindowStates());
+        return new Enumerator(windowStates);
     }
 
     /* (non-Javadoc)
@@ -184,26 +224,6 @@
      */
     public String getPortalInfo()
     {
-        return getPortalContextProvider().getPortalInfo();
-    }
-
-    /**
-     * TODO: need to refactor context provider, move implementation directly into here since it comes back here anyway
-     * @return
-     */
-    private PortalContextProvider getPortalContextProvider()
-    {
-        javax.servlet.ServletContext context = engine.getServletConfig().getServletContext();
-
-        PortalContextProvider provider =
-            (PortalContextProvider) context.getAttribute("org.apache.jetspeed.engine.core.PortalContextProvider");
-
-        if (provider == null)
-        {
-            provider = new PortalContextProviderImpl();
-            context.setAttribute("org.apache.jetspeed.engine.core.PortalContextProvider", provider);
-        }
-
-        return provider;
+        return portalName + "/" + portalVersion;
     }
 }

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/PortalContext.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/PortalContext.java?rev=225618&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/PortalContext.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/PortalContext.java Wed Jul 27 13:34:42 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.jetspeed.engine.Engine;
+
+/**
+ * Portal Context associated with running thread of the engine
+ *
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+ * @version $Id: PortalContext.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public interface PortalContext extends javax.portlet.PortalContext
+{
+    public Engine getEngine();
+
+    public Configuration getConfiguration();
+    public void setConfiguration(Configuration configuration);
+
+    public String getConfigurationProperty(String key);
+    public String getConfigurationProperty(String key, String defaultValue);
+
+    public void setAttribute(String name, Object value);
+    public Object getAttribute(String name);
+
+    /**
+     * Returns the application root for this Jetspeed engine context.
+     *
+     * @return a <code>String</code> containing the application root path for this Jetspeed context.
+     */
+    public String getApplicationRoot();
+
+    /**
+     * Sets the application root path for this Jetspeed engine context.
+     *
+     * @param applicationRoot - the applicationRoot path on the file system.
+     */
+    public void setApplicationRoot(String applicationRoot);
+
+}

Propchange: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/PortalContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java?rev=225618&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java Wed Jul 27 13:34:42 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed;
+
+import org.apache.jetspeed.components.util.RegistrySupportedTestCase;
+import org.apache.jetspeed.container.JetspeedPortletContainerWrapper;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.container.window.impl.PortletWindowAccessorImpl;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerImpl;
+
+/**
+ * @author <a href="mailto:sweaver@einnovation.com">Scott T. Weaver</a>
+ *
+ */
+public class AbstractPortalContainerTestCase extends RegistrySupportedTestCase
+{
+
+    protected PortletWindowAccessor windowAccessor;
+    protected PortletContainer portletContainer;
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        windowAccessor = new PortletWindowAccessorImpl(entityAccess, true);
+       //  portletContainer = new JetspeedPortletContainerWrapper(new PortletContainerImpl());
+    }
+}

Propchange: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortalTestConstants.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortalTestConstants.java?rev=225618&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortalTestConstants.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortalTestConstants.java Wed Jul 27 13:34:42 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed;
+
+/**
+ * <p>
+ * Constants used for test cases.
+ * </p>
+ * 
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
+ */
+public class PortalTestConstants
+{
+    public final static String JETSPEED_PROPERTIES_PATH = "../../portal-webapp/src/webapp/WEB-INF/conf/jetspeed.properties";
+    
+    public final static String PORTAL_WEBAPP_PATH = "../../portal-webapp/src/webapp";
+    
+    public static final String JETSPEED_APPLICATION_ROOT = "../../portal-webapp/src/webapp";
+}

Propchange: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortalTestConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java Wed Jul 27 13:34:42 2005
@@ -57,7 +57,7 @@
     {
         super.setUp();
         
-        portletContainer = new JetspeedPortletContainerWrapper(new PortletContainerImpl());
+      //  portletContainer = new JetspeedPortletContainerWrapper(new PortletContainerImpl());
     }
 
    public static Test suite()

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java Wed Jul 27 13:34:42 2005
@@ -15,34 +15,38 @@
  */
 package org.apache.jetspeed.container.state;
 
-import java.io.FileInputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.jetspeed.Jetspeed;
-import org.apache.jetspeed.PortalTestConstants;
-import org.apache.jetspeed.container.state.NavigationalState;
-import org.apache.jetspeed.container.state.NavigationalStateComponent;
+import org.apache.jetspeed.JetspeedPortalContext;
+import org.apache.jetspeed.PortalContext;
+import org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateCodec;
 import org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateComponent;
+import org.apache.jetspeed.container.state.impl.NavigationalStateCodec;
+import org.apache.jetspeed.container.state.impl.PathNavigationalState;
+import org.apache.jetspeed.container.state.impl.SessionFullNavigationalState;
+import org.apache.jetspeed.container.state.impl.SessionNavigationalState;
 import org.apache.jetspeed.container.url.PortalURL;
 import org.apache.jetspeed.container.url.impl.AbstractPortalURL;
+import org.apache.jetspeed.container.url.impl.PathInfoEncodingPortalURL;
+import org.apache.jetspeed.container.url.impl.QueryStringEncodingPortalURL;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
-import org.apache.jetspeed.engine.AbstractEngine;
 import org.apache.jetspeed.engine.Engine;
-import org.apache.jetspeed.engine.SpringEngine;
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
 import org.apache.jetspeed.request.JetspeedRequestContext;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.testhelpers.SpringEngineHelper;
 import org.apache.pluto.om.entity.PortletEntity;
 import org.apache.pluto.om.window.PortletWindow;
 import org.apache.pluto.om.window.PortletWindowList;
@@ -56,7 +60,6 @@
 import com.mockrunner.mock.web.MockHttpServletResponse;
 import com.mockrunner.mock.web.MockHttpSession;
 import com.mockrunner.mock.web.MockServletConfig;
-import com.mockrunner.mock.web.MockServletContext;
 
 /**
  * TestPortletContainer
@@ -73,6 +76,10 @@
     private NavigationalStateComponent navFullSession;
     private NavigationalStateComponent navSession;
     private NavigationalStateComponent navPluto;
+    private SpringEngineHelper engineHelper;
+    private Engine engine;
+    private NavigationalStateCodec codec;
+    private PortalContext portalContext;
 
     /**
      * Defines the testcase name for JUnit.
@@ -98,17 +105,10 @@
     {
         super.setUp();
 
-        // need to flag internal JNDI on...
-        System.setProperty(AbstractEngine.JNDI_SUPPORT_FLAG_KEY, "true");
-        
-        // create Engine
-        PropertiesConfiguration config = new  PropertiesConfiguration();
-        config.load(new FileInputStream(PortalTestConstants.JETSPEED_PROPERTIES_PATH));
-        Mock servletConfigMock = new Mock(ServletConfig.class);
-        MockServletConfig msc = new MockServletConfig();
-        msc.setServletContext(new MockServletContext());
-        Engine engine = Jetspeed.createEngine(config, PortalTestConstants.PORTAL_WEBAPP_PATH, msc, SpringEngine.class);
-
+        HashMap context = new HashMap();
+        engineHelper = new SpringEngineHelper(context);
+        engineHelper.setUp();
+        engine = (Engine) context.get(SpringEngineHelper.ENGINE_ATTR);
         // mock test PortletWindow
         Mock entityMock = new Mock(MutablePortletEntity.class);        
         Mock windowListMock = new Mock(CompositeWindowList.class);
@@ -118,20 +118,13 @@
         windowListMock.expects(new AnyArgumentsMatcher()).method("add").withAnyArguments().will(
                 new VoidStub());
 
-        PortletWindowAccessor accessor = (PortletWindowAccessor) Jetspeed.getComponentManager().getComponent(PortletWindowAccessor.class);        
+        PortletWindowAccessor accessor = (PortletWindowAccessor) engine.getComponentManager().getComponent(PortletWindowAccessor.class);        
         accessor.createPortletWindow((PortletEntity)entityMock.proxy(), "111");
         accessor.createPortletWindow((PortletEntity)entityMock.proxy(), "222");
         accessor.createPortletWindow((PortletEntity)entityMock.proxy(), "333");
         
-        navFullSession = new JetspeedNavigationalStateComponent("org.apache.jetspeed.container.state.impl.SessionFullNavigationalState",
-                "org.apache.jetspeed.container.url.impl.QueryStringEncodingPortalURL",
-                 "org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateCodec");
-        navSession = new JetspeedNavigationalStateComponent("org.apache.jetspeed.container.state.impl.SessionNavigationalState",
-                "org.apache.jetspeed.container.url.impl.PathInfoEncodingPortalURL",
-                 "org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateCodec");
-        navPluto = new JetspeedNavigationalStateComponent("org.apache.jetspeed.container.state.impl.PathNavigationalState",
-               "org.apache.jetspeed.container.url.impl.PathInfoEncodingPortalURL",
-                "org.apache.jetspeed.container.state.impl.JetspeedNavigationalStateCodec");
+        codec = (NavigationalStateCodec) engine.getComponentManager().getComponent("NavigationalStateCodec");
+        portalContext = (PortalContext) engine.getComponentManager().getComponent("PortalContext");        
     }
 
     public static Test suite()
@@ -140,23 +133,44 @@
         return new TestSuite(TestNavigationalState.class);
     }
 
-    public void testAllComponents()
-        throws Exception
-    {
-
-        // general navigational state test
-        navigationTest(navFullSession, true);
-        navigationTest(navSession, false);
-        navigationTest(navPluto, false);
+    
+    public void testSessionFullStateAndQuery()
+    {        
+        SessionFullNavigationalState navState = new SessionFullNavigationalState(codec);
+        QueryStringEncodingPortalURL portalUrl = new QueryStringEncodingPortalURL(navState, portalContext);
+        HttpServletRequest request = buildRequest(portalUrl, true);
+        navState = new SessionFullNavigationalState(codec);
+        portalUrl = new QueryStringEncodingPortalURL(navState, portalContext);
+        doTestUrl(portalUrl, request);
+        
     }
-
-    private void navigationTest(NavigationalStateComponent component, boolean useQueryStringPortalURL)
-    throws Exception
+    
+    public void testSessionStateAndPathInfo()
+    {        
+        SessionNavigationalState navState = new SessionNavigationalState(codec);
+        PathInfoEncodingPortalURL portalUrl = new PathInfoEncodingPortalURL(navState, portalContext);
+        HttpServletRequest request = buildRequest(portalUrl, false);
+        navState = new SessionNavigationalState(codec);
+        portalUrl = new PathInfoEncodingPortalURL(navState, portalContext);
+        doTestUrl(portalUrl, request);
+    }
+    
+    public void testPathStateAndPathInfo()
+    {        
+        PathNavigationalState navState = new PathNavigationalState(codec);
+        PathInfoEncodingPortalURL portalUrl = new PathInfoEncodingPortalURL(navState, portalContext);
+        HttpServletRequest request = buildRequest(portalUrl, false);
+        navState = new PathNavigationalState(codec);
+        portalUrl = new PathInfoEncodingPortalURL(navState, portalContext);
+        doTestUrl(portalUrl, request);
+    }
+    
+    
+    protected HttpServletRequest buildRequest(PortalURL portalURL, boolean useQueryStringPortalURL)
     {
         MockHttpServletRequest request = new MockHttpServletRequest();
         MockHttpSession session = new MockHttpSession();
-        HttpServletResponse response = new MockHttpServletResponse();
-        ServletConfig config = new MockServletConfig();
+
         request.setSession(session);
         request.setServerName("www.sporteportal.com");
         request.setScheme("http");
@@ -165,22 +179,17 @@
         request.setPathInfo("stuff");
         request.setRequestURI("/jetspeed/portal/stuff");
 
-        JetspeedRequestContext context = new JetspeedRequestContext(request, response, config, null );
-        
-        // create base PortletURL
-        PortalURL url = component.createURL(context.getRequest(), context.getCharacterEncoding());
-        context.setPortalURL(url);
+        portalURL.setRequest(request);
+        portalURL.setCharacterEncoding("UTF-8");
 
         PortletWindow window = new PortletWindowImpl("111");
-        PortletWindow window2 = new PortletWindowImpl("222");
-        PortletWindow window3 = new PortletWindowImpl("333");
- 
+
         HashMap parameters = new HashMap();
         parameters.put("test",new String[]{"one","two","three"});
 
-        String portletURL = url.createPortletURL(window,parameters,PortletMode.EDIT,WindowState.MAXIMIZED,true,false);
+        String portletURL = portalURL.createPortletURL(window,parameters,PortletMode.EDIT,WindowState.MAXIMIZED,true,false);
         
-        String navStateParameterName = Jetspeed.getContext().getConfigurationProperty("portalurl.navigationalstate.parameter.name", AbstractPortalURL.DEFAULT_NAV_STATE_PARAMETER); 
+        String navStateParameterName = engine.getContext().getConfigurationProperty("portalurl.navigationalstate.parameter.name", AbstractPortalURL.DEFAULT_NAV_STATE_PARAMETER); 
 
         if ( useQueryStringPortalURL )
         {
@@ -191,34 +200,47 @@
             request.setPathInfo(portletURL.substring(portletURL.indexOf("/portal")+7));
         }
         
-        context = new JetspeedRequestContext(request, response, config, null );
-                
-        url = component.createURL(context.getRequest(), context.getCharacterEncoding());
-        context.setPortalURL(url);
-        NavigationalState nav = url.getNavigationalState();
-
-        // Check that they come out correctly
-        assertTrue("window mode is not set", nav.getMode(window).equals(PortletMode.EDIT));
-        assertTrue("window state is not set", nav.getState(window).equals(WindowState.MAXIMIZED));
-        PortletWindow target = nav.getPortletWindowOfAction();
-        assertNotNull("target window is null", target);
-        assertEquals("target window should equal window 111", target.getId(), "111");
-
-        PortletWindow maximizedWindow = nav.getMaximizedWindow();
-        assertNotNull("maximized window is null", maximizedWindow);
-        assertEquals("maximized window should equal window 111", maximizedWindow.getId(), "111");
-
-        Iterator iter = nav.getParameterNames(target);
-        int parameterCount = 0;
-        assertTrue("There should be one parameter",iter.hasNext());
-        while ( iter.hasNext() ) {
-            assertEquals("parameter name should equals \"test\"", (String)iter.next(), "test");
-            String[] values = nav.getParameterValues(target,"test");
-            assertNotNull("parameter name has no values", values);
-            assertEquals("parameter test should have 3 values", values.length, 3);
-            assertEquals("parameter test[0] should be \"one\"", values[0], "one");
-            assertEquals("parameter test[1] should be \"two\"", values[1], "two");
-            assertEquals("parameter test[2] should be \"three\"", values[2], "three");
-        }
+        return request;        
+    }
+    
+    protected void doTestUrl(PortalURL portalURL, HttpServletRequest request)
+    {             
+      portalURL.setRequest(request);
+      portalURL.setCharacterEncoding("UTF-8");
+      
+      PortletWindow window = new PortletWindowImpl("111");
+      NavigationalState nav = portalURL.getNavigationalState();
+
+      // Check that they come out correctly
+      assertTrue("window mode is not set", nav.getMode(window).equals(PortletMode.EDIT));
+      assertTrue("window state is not set", nav.getState(window).equals(WindowState.MAXIMIZED));
+      PortletWindow target = nav.getPortletWindowOfAction();
+      assertNotNull("target window is null", target);
+      assertEquals("target window should equal window 111", target.getId(), "111");
+
+      PortletWindow maximizedWindow = nav.getMaximizedWindow();
+      assertNotNull("maximized window is null", maximizedWindow);
+      assertEquals("maximized window should equal window 111", maximizedWindow.getId(), "111");
+
+      Iterator iter = nav.getParameterNames(target);
+      int parameterCount = 0;
+      assertTrue("There should be one parameter",iter.hasNext());
+      while ( iter.hasNext() ) {
+          assertEquals("parameter name should equals \"test\"", (String)iter.next(), "test");
+          String[] values = nav.getParameterValues(target,"test");
+          assertNotNull("parameter name has no values", values);
+          assertEquals("parameter test should have 3 values", values.length, 3);
+          assertEquals("parameter test[0] should be \"one\"", values[0], "one");
+          assertEquals("parameter test[1] should be \"two\"", values[1], "two");
+          assertEquals("parameter test[2] should be \"three\"", values[2], "three");
+      }
+        
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        engineHelper.tearDown();
+        super.tearDown();
     }
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/AbstractEngineTest.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/AbstractEngineTest.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/AbstractEngineTest.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/AbstractEngineTest.java Wed Jul 27 13:34:42 2005
@@ -15,20 +15,12 @@
  */
 package org.apache.jetspeed.engine;
 
-import java.io.FileInputStream;
-
-import javax.servlet.ServletConfig;
+import java.util.HashMap;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.jetspeed.Jetspeed;
-import org.apache.jetspeed.PortalTestConstants;
 import org.apache.jetspeed.components.ComponentManagement;
-import org.jmock.Mock;
-
-import com.mockrunner.mock.web.MockServletConfig;
-import com.mockrunner.mock.web.MockServletContext;
+import org.apache.jetspeed.testhelpers.SpringEngineHelper;
 
 /**
  * <p>
@@ -61,6 +53,8 @@
 
     protected Object[] keysToCheck;
 
+    private SpringEngineHelper engineHelper;
+
     public void testEngine() throws Exception
     {
         assertNotNull(engine.getComponentManager());
@@ -73,22 +67,16 @@
 
     protected void setUp() throws Exception
     {
-        super.setUp();
-        // need to flag internal JNDI on...
-        System.setProperty(AbstractEngine.JNDI_SUPPORT_FLAG_KEY, "true");
-        PropertiesConfiguration config = new PropertiesConfiguration();
-        config.load(new FileInputStream(PortalTestConstants.JETSPEED_PROPERTIES_PATH));
-        Mock servletConfigMock = new Mock(ServletConfig.class);
-        MockServletConfig msc = new MockServletConfig();
-        msc.setServletContext(new MockServletContext());
-        engine = Jetspeed.createEngine(config, PortalTestConstants.PORTAL_WEBAPP_PATH, msc, getEngineClass());
-
+       HashMap context = new HashMap();
+       engineHelper = new SpringEngineHelper(context);
+       engineHelper.setUp();
+       engine = (Engine) context.get(SpringEngineHelper.ENGINE_ATTR);
     }
 
     protected void tearDown() throws Exception
     {
-
-        super.tearDown();
+        engineHelper.tearDown();
+        super.tearDown();        
     }
 
     protected void verifyComponents(Object[] keys)
@@ -101,5 +89,4 @@
         }
     }
 
-    protected abstract Class getEngineClass();
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/engine/TestSpringEngine.java Wed Jul 27 13:34:42 2005
@@ -17,7 +17,6 @@
 import org.apache.jetspeed.capabilities.Capabilities;
 import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
-import org.apache.jetspeed.container.state.NavigationalStateComponent;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.prefs.PreferencesProvider;
@@ -48,16 +47,15 @@
 public class TestSpringEngine extends AbstractEngineTest
 {
     public TestSpringEngine()
-    {
-        System.out.println(System.getProperty("org.apache.jetspeed.database.user"));
+    {        
         keysToCheck = new Object[] {"IdGenerator", "DecorationLocator", "TemplateLocator", "IdGenerator", "PageFileCache", PageManager.class, 
                                      PortletRegistry.class, PortletEntityAccessComponent.class, "PortalServices",
                                      Profiler.class, Capabilities.class, PropertyManager.class, PreferencesProvider.class, UserManager.class,
                                      GroupManager.class, RoleManager.class, PermissionManager.class, RdbmsPolicy.class, SecurityProvider.class,
-                                     UserInfoManager.class, NavigationalStateComponent.class, RequestContextComponent.class, PortletWindowAccessor.class,
+                                     UserInfoManager.class, RequestContextComponent.class, PortletWindowAccessor.class,
                                      PortletRenderer.class, PageAggregator.class, PortletAggregator.class, "PAM",
                                      "deploymentManager", "portletFactory", ServletConfig.class, 
-                                     StaticInformationProvider.class};
+                                     StaticInformationProvider.class, "NavigationalStateCodec", "PortalURL", "NavigationalStateComponent"};
     }
     
     public static Test suite()
@@ -66,17 +64,6 @@
         return new TestSuite(TestSpringEngine.class);
     }
 
-    /**
-     * <p>
-     * getEngineClass
-     * </p>
-     * 
-     * @see org.apache.jetspeed.engine.AbstractEngineTest#getEngineClass()
-     * @return
-     */
-    protected Class getEngineClass()
-    {
-        return SpringEngine.class;
-    }
+
 
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java Wed Jul 27 13:34:42 2005
@@ -15,11 +15,14 @@
  */
 package org.apache.jetspeed.pipeline;
 
-import junit.framework.Test;
+import java.util.HashMap;
+import java.util.Map;
 
+import junit.framework.TestCase;
+
+import org.apache.jetspeed.engine.Engine;
 import org.apache.jetspeed.pipeline.valve.Valve;
-import org.apache.jetspeed.test.JetspeedTest;
-import org.apache.jetspeed.test.JetspeedTestSuite;
+import org.apache.jetspeed.testhelpers.SpringEngineHelper;
 
 /**
  * TestPipeline
@@ -27,44 +30,10 @@
  * @author <a href="taylor@apache.org">David Sean Taylor</a>
  * @version $Id$
  */
-public class TestPipeline extends JetspeedTest
+public class TestPipeline extends TestCase
 {
-
-    /**
-     * Defines the testcase name for JUnit.
-     *
-     * @param name the testcase's name.
-     */
-    public TestPipeline(String name)
-    {
-        super(name);
-    }
-
-    /**
-     * Start the tests.
-     *
-     * @param args the arguments. Not used
-     */
-    public static void main(String args[])
-    {
-        junit.awtui.TestRunner.main(new String[] { TestPipeline.class.getName()});
-    }
-
-    public void setup()
-    {
-    }
-
-    /**
-     * Creates the test suite.
-     *
-     * @return a test suite (<code>TestSuite</code>) that includes all methods
-     *         starting with "test"
-     */
-    public static Test suite()
-    {
-        // All methods starting with "test" will be executed in the test suite.
-        return new JetspeedTestSuite(TestPipeline.class);
-    }
+     private Engine engine;
+    private SpringEngineHelper engineHelper;
 
     /**
      * Tests
@@ -77,18 +46,33 @@
         Pipeline pipeline = engine.getPipeline();
         assertNotNull(pipeline);
         Valve[] valves = pipeline.getValves();
-        assertTrue(valves[0].toString().equals("LocalizationValve"));
-        assertTrue(valves[1].toString().equals("CapabilityValveImpl"));
-        assertTrue(valves[2].toString().equals("PortalURLValveImpl"));     
-        assertTrue(valves[3].toString().equals("SecurityValve"));
-        assertTrue(valves[4].toString().equals("PasswordCredentialValve"));                
-        assertTrue(valves[5].toString().equals("LoginValidationValve"));                
-        assertTrue(valves[6].toString().equals("ProfilerValve"));        
-        assertTrue(valves[7].toString().equals("ContainerValve"));
-        assertTrue(valves[8].toString().equals("ActionValveImpl"));     
-        assertTrue(valves[9].toString().equals("AggregatorValve"));
-        assertTrue(valves[10].toString().equals("CleanupValveImpl"));
+        assertEquals("CapabilityValveImpl", valves[0].toString());
+        assertEquals("PortalURLValveImpl", valves[1].toString());
+        assertEquals("SecurityValve", valves[2].toString());
+        assertEquals("LocalizationValve", valves[3].toString());
+        assertEquals("PasswordCredentialValve", valves[4].toString());
+        assertEquals("LoginValidationValve", valves[5].toString());
+        assertEquals("ProfilerValve", valves[6].toString());
+        assertEquals("ContainerValve", valves[7].toString());
+        assertEquals("ActionValveImpl", valves[8].toString());
+        assertEquals("AggregatorValve", valves[9].toString());
+        assertEquals("CleanupValveImpl", valves[10].toString());
+        
+        
         assertNotNull(engine.getPipeline("action-pipeline"));
         assertNotNull(engine.getPipeline("portlet-pipeline"));
+    }
+
+    protected void setUp() throws Exception
+    {
+        Map context = new HashMap();
+        engineHelper = new SpringEngineHelper(context);
+        engineHelper.setUp();
+        this.engine = (Engine)context.get(SpringEngineHelper.ENGINE_ATTR);
+    }
+
+    protected void tearDown() throws Exception
+    {
+        engineHelper.tearDown();
     }
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/test/JetspeedTestSuite.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/test/JetspeedTestSuite.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/test/JetspeedTestSuite.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/test/JetspeedTestSuite.java Wed Jul 27 13:34:42 2005
@@ -18,6 +18,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Map.Entry;
@@ -34,8 +35,8 @@
 import org.apache.jetspeed.PortalTestConstants;
 import org.apache.jetspeed.engine.Engine;
 import org.apache.jetspeed.engine.JetspeedEngineConstants;
-import org.apache.jetspeed.engine.SpringEngine;
 import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.testhelpers.SpringEngineHelper;
 import org.jmock.Mock;
 
 import com.mockrunner.mock.web.MockServletConfig;
@@ -52,7 +53,8 @@
  */
 public class JetspeedTestSuite extends TestSuite
 {
-    protected static Engine engine = null;    
+    protected static Engine engine = null;
+    private static SpringEngineHelper engineHelper;    
 
     /**
      * 
@@ -112,7 +114,10 @@
             Mock servletConfigMock = new Mock(ServletConfig.class);
             MockServletConfig msc = new MockServletConfig();
             msc.setServletContext(new MockServletContext());
-            engine = Jetspeed.createEngine(properties, applicationRoot, msc, SpringEngine.class);
+            HashMap context = new HashMap();
+            engineHelper = new SpringEngineHelper(context);
+            engineHelper.setUp();
+            engine = (Engine) context.get(SpringEngineHelper.ENGINE_ATTR);
 
         }
         catch (Exception e)

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/tools/TestWebXML.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/tools/TestWebXML.java?rev=225618&r1=225617&r2=225618&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/tools/TestWebXML.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/tools/TestWebXML.java Wed Jul 27 13:34:42 2005
@@ -15,9 +15,6 @@
  */
 package org.apache.jetspeed.tools;
 
-import org.apache.jetspeed.test.JetspeedTestSuite;
-
-import junit.framework.Test;
 import junit.framework.TestCase;
 
 /**
@@ -29,22 +26,7 @@
  */
 public class TestWebXML extends TestCase
 {
-    /**
-     * Creates a new instance.
-     */
-    public TestWebXML(String testName)
-    {
-        super(testName);
-    }
-
-    /**
-     * Return the Test
-     */
-    public static Test suite()
-    {
-        return new JetspeedTestSuite(TestWebXML.class);
-    }
-
+    
     /**
      * Setup the test.
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org