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 ta...@apache.org on 2005/11/25 21:36:41 UTC

svn commit: r349022 - in /portals/jetspeed-2/trunk/components/portal/src: java/org/apache/jetspeed/ajax/ test/org/apache/jetspeed/layout/ test/org/apache/jetspeed/testhelpers/ test/resources/ test/resources/assembly/

Author: taylor
Date: Fri Nov 25 12:36:38 2005
New Revision: 349022

URL: http://svn.apache.org/viewcvs?rev=349022&view=rev
Log:
Tests passing on Portlet Placement and Layout components
Next, hook in Page Manager to actually update on placements

Added:
    portals/jetspeed-2/trunk/components/portal/src/test/resources/
    portals/jetspeed-2/trunk/components/portal/src/test/resources/assembly/
    portals/jetspeed-2/trunk/components/portal/src/test/resources/assembly/test-layout-api.xml
Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/SpringEngineHelper.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java?rev=349022&r1=349021&r2=349022&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/ajax/AjaxRequestServiceImpl.java Fri Nov 25 12:36:38 2005
@@ -22,6 +22,7 @@
 import java.io.StringWriter;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
@@ -87,12 +88,12 @@
     {
         this.objects = objects;
         this.velocityEngine = velocityEngine;
-        this.urlParameterName = urlParameterName;
+        this.urlParameterName = urlParameterName;        
     }
-
+    
     // This is the entry point for this service
     public void process(RequestContext requestContext) throws AJAXException
-    {
+    {        
         // Lookup the object that is to be used
         String objectKey = requestContext.getRequestParameter(urlParameterName);
         if (objectKey != null)

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java?rev=349022&r1=349021&r2=349022&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java Fri Nov 25 12:36:38 2005
@@ -15,12 +15,21 @@
  */
 package org.apache.jetspeed.layout;
 
-import org.apache.jetspeed.AbstractPortalContainerTestCase;
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.jetspeed.ajax.AjaxRequestService;
 import org.apache.jetspeed.components.ComponentManager;
 import org.apache.jetspeed.components.SpringComponentManager;
+import org.apache.jetspeed.components.factorybeans.ServletConfigFactoryBean;
 import org.apache.jetspeed.layout.impl.LayoutValve;
+import org.apache.jetspeed.mocks.ResourceLocatingServletContext;
 import org.apache.jetspeed.pipeline.PipelineException;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.velocity.app.VelocityEngine;
+
+import com.mockrunner.mock.web.MockServletConfig;
 
 /**
  * Test for Fragment placement
@@ -28,12 +37,16 @@
  * @author <a>David Gurney </a>
  * @version $Id: $
  */
-public class TestLayout extends AbstractPortalContainerTestCase
+public class TestLayout extends TestCase
 {
 
-    private ComponentManager m_oComponentManager;
+    private ComponentManager cm;
 
-    private LayoutValve m_oLv;
+    private LayoutValve valve;
+    
+    private VelocityEngine velocity;
+    
+    private AjaxRequestService ajax;
 
     public static void main(String[] args)
     {
@@ -47,31 +60,39 @@
     {
         super.setUp();
 
+        String appRoot =  "./"; //PortalTestConstants.JETSPEED_APPLICATION_ROOT;
+        
+        MockServletConfig servletConfig = new MockServletConfig();        
+        ResourceLocatingServletContext servletContent = new ResourceLocatingServletContext(new File(appRoot));        
+        servletConfig.setServletContext(servletContent);
+        ServletConfigFactoryBean.setServletConfig(servletConfig);
+        
         // Load the Spring configs
         String[] bootConfigs = null;
         String[] appConfigs =
-        { "src/webapp/WEB-INF/assembly/layout-api.xml",
+        { //"src/webapp/WEB-INF/assembly/layout-api.xml",
                 "src/test/resources/assembly/test-layout-api.xml"};
-        m_oComponentManager = new SpringComponentManager(bootConfigs,
-                appConfigs, null, ".");
-        m_oComponentManager.start();
-
-        // Get a valid LayoutValve from Spring
-        m_oLv = (LayoutValve) m_oComponentManager.getComponent("layoutValve");
+        
+                
+        cm = new SpringComponentManager(bootConfigs, appConfigs, servletContent, ".");
+        cm.start();
+        valve = (LayoutValve) cm.getComponent("layoutValve");
+        velocity = (VelocityEngine) cm.getComponent("AjaxVelocityEngine");
+        ajax = (AjaxRequestService) cm.getComponent("AjaxRequestService");
+                
     }
 
     protected void tearDown() throws Exception
     {
-        m_oComponentManager.stop();
+        cm.stop();
     }
 
-    public void xtestNullRequestContext()
+    public void testNullRequestContext()
     {
-        // Get the layout that has a null request context
-        LayoutValve lv = new LayoutValve(null);
+        // Get the layout that has a null request context        
         try
         {
-            lv.invoke(null, null);
+            valve.invoke(null, null);
             TestLayout.fail("should have thrown an exception");
         } catch (PipelineException e)
         {
@@ -79,14 +100,14 @@
         }
     }
 
-    public void xtestNullParameters()
+    public void testNullParameters()
     {
         try
         {
             // Test the success case
             RequestContext rc = FragmentUtil
                     .setupRequestContext(null, "1234", "0", "0");
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
                     "failure"));
         } catch (PipelineException e)
@@ -99,7 +120,7 @@
             // Test the success case
             RequestContext rc = FragmentUtil.setupRequestContext("moveabs", null, "0",
                     "0");
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
@@ -114,7 +135,7 @@
             // Test the success case
             RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "1234",
                     null, "0");
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
@@ -129,7 +150,7 @@
             // Test the success case
             RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "1234",
                     "0", null);
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
@@ -140,7 +161,7 @@
         }
     }
 
-    public void xtestMoveSuccess()
+    public void testMoveSuccess()
     {
         moveSuccess("moveabs", "1", "0", "0", "0", "0", "0", "0"); // Doesn't
                                                                     // really
@@ -236,7 +257,7 @@
                                                                     // move
     }
 
-    public void xtestMoveFailure()
+    public void testMoveFailure()
     {
         moveFailure("moveabs", "bogus", "0", "0", "0", "0"); // non integer
                                                                 // portlet id
@@ -267,7 +288,7 @@
                         null);
             }
 
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
@@ -313,7 +334,7 @@
                 rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId, null,
                         null);
             }
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
@@ -336,7 +357,7 @@
                 rc = FragmentUtil.setupRequestContext(a_sMoveType, null, null, null);
             }
 
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
@@ -347,7 +368,7 @@
         }
     }
 
-    public void xtestRemove()
+    public void testRemove()
     {
         remove("1");
         remove("2");
@@ -364,7 +385,7 @@
 
             rc = FragmentUtil.setupRequestContext("remove", p_sPortletId, null, null);
 
-            m_oLv.invoke(rc, null);
+            valve.invoke(rc, null);
 
             // Take a look at the response to verify a failiure
             TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/SpringEngineHelper.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/SpringEngineHelper.java?rev=349022&r1=349021&r2=349022&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/SpringEngineHelper.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/testhelpers/SpringEngineHelper.java Fri Nov 25 12:36:38 2005
@@ -1,3 +1,18 @@
+/*
+ * 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.testhelpers;
 
 import java.io.File;

Added: portals/jetspeed-2/trunk/components/portal/src/test/resources/assembly/test-layout-api.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/test/resources/assembly/test-layout-api.xml?rev=349022&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/resources/assembly/test-layout-api.xml (added)
+++ portals/jetspeed-2/trunk/components/portal/src/test/resources/assembly/test-layout-api.xml Fri Nov 25 12:36:38 2005
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<beans>
+
+<!-- AJAX Actions 
+    
+    == Constructor Arguments ==
+    index 0 = render response VM template, generates XML NORMAL response
+    index 1 = render response VM template, generates XML ERROR response
+    index 1 = action name from AJAX Request
+    
+    -->
+<bean id="AjaxMovePortletAbsolute"
+    class="org.apache.jetspeed.layout.impl.MovePortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/move.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+    <constructor-arg index="2">
+        <value>moveabs</value>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxMovePortletLeft"
+    class="org.apache.jetspeed.layout.impl.MovePortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/move.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+    <constructor-arg index="2">
+        <value>moveleft</value>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxMovePortletRight"
+    class="org.apache.jetspeed.layout.impl.MovePortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/move.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+    <constructor-arg index="2">
+        <value>moveright</value>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxMovePortletUp"
+    class="org.apache.jetspeed.layout.impl.MovePortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/move.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+    <constructor-arg index="2">
+        <value>moveup</value>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxMovePortletDown"
+    class="org.apache.jetspeed.layout.impl.MovePortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/move.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+    <constructor-arg index="2">
+        <value>movedown</value>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxAddPortlet"
+    class="org.apache.jetspeed.layout.impl.AddPortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/add.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxRemovePortlet"
+    class="org.apache.jetspeed.layout.impl.RemovePortletAction">
+    <constructor-arg index="0">
+        <value>org/apache/jetspeed/layout/ajax-xml/remove.vm</value>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <value>org/apache/jetspeed/layout/ajax-xml/error.vm</value>
+    </constructor-arg>
+</bean>
+
+
+<bean id="AjaxRequestService" class="org.apache.jetspeed.ajax.AjaxRequestServiceImpl">
+    <constructor-arg index="0">
+        <map>
+            <entry key="moveabs">
+                <ref bean="AjaxMovePortletAbsolute"/>
+            </entry>
+            <entry key="moveleft">
+                <ref bean="AjaxMovePortletLeft"/>
+            </entry>
+            <entry key="moveright">
+                <ref bean="AjaxMovePortletRight"/>
+            </entry>
+            <entry key="moveup">
+                <ref bean="AjaxMovePortletUp"/>
+            </entry>
+            <entry key="movedown">
+                <ref bean="AjaxMovePortletDown"/>
+            </entry>
+            <entry key="add">
+                <ref bean="AjaxAddPortlet"/>
+            </entry>
+            <entry key="remove">
+                <ref bean="AjaxRemovePortlet"/>
+            </entry>
+        </map>
+    </constructor-arg>
+    <constructor-arg index="1">
+        <ref bean="AjaxVelocityEngine"/>
+    </constructor-arg>
+</bean>
+
+<bean id="AjaxVelocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
+    <property name="velocityProperties">
+        <props>
+            <prop key="resource.loader">class</prop>
+            <prop key="class.resource.loader.class">
+                org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
+            </prop>
+        </props>
+    </property>
+  </bean>
+  
+	<bean id="layoutValve"
+		class="org.apache.jetspeed.layout.impl.LayoutValve"
+		init-method="initialize">
+		<constructor-arg index="0">
+			<ref bean="AjaxRequestService"/>
+		</constructor-arg>
+	</bean>
+  
+</beans>
\ No newline at end of file



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