portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r591353 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout: FragmentUtil.java TestLayout.java TestPortletPlacement.java
Date Fri, 02 Nov 2007 15:03:12 GMT
Author: ate
Date: Fri Nov  2 08:03:10 2007
New Revision: 591353

URL: http://svn.apache.org/viewvc?rev=591353&view=rev
Log:
Layout testcases fixed by Dennis Dam which provided the patch.
All tests are working again, thanks!
 

Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/FragmentUtil.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestPortletPlacement.java

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/FragmentUtil.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/FragmentUtil.java?rev=591353&r1=591352&r2=591353&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/FragmentUtil.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/FragmentUtil.java Fri Nov  2 08:03:10 2007
@@ -1,159 +1,163 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You 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.layout;
-
-import org.apache.jetspeed.om.page.ContentPage;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.page.Page;
-import org.apache.jetspeed.om.page.ContentPageImpl;
-import org.apache.jetspeed.om.page.psml.PageImpl;
-import org.apache.jetspeed.request.JetspeedRequestContext;
-import org.apache.jetspeed.request.RequestContext;
-
-import com.mockrunner.mock.web.MockHttpServletRequest;
-import com.mockrunner.mock.web.MockHttpServletResponse;
-import com.mockrunner.mock.web.MockHttpSession;
-import com.mockrunner.mock.web.MockServletConfig;
-import com.mockrunner.mock.web.MockServletContext;
-
-/**
- * Test for Fragment placement
- * 
- * @author <a>David Gurney </a>
- * @version $Id: $
- */
-public class FragmentUtil
-{
-
-    public static RequestContext buildFullRequestContext()
-    {
-        // Build a request object and populate it with fragments
-        RequestContext a_oRC = setupRequestContext("remove", "1234", "0", "0");
-
-        // Build some fragments and add them to the request context
-        // Prepare some fragments
-        Fragment a_oLayout = buildFragment("layout", "6", "layout", 0, 0);
-        Fragment a_oFrag1 = buildFragment("frag1", "1", "portlet", 1, 0);
-        Fragment a_oFrag2 = buildFragment("frag2", "2", "portlet", 1, 1);
-        Fragment a_oFrag3 = buildFragment("frag3", "3", "portlet", 2, 0);
-        Fragment a_oFrag4 = buildFragment("frag4", "4", "portlet", 2, 1);
-        Fragment a_oFrag5 = buildFragment("frag5", "5", "portlet", 2, 2);
-
-        LocalFragmentImpl a_oLocalLayout = (LocalFragmentImpl) a_oLayout;
-        a_oLocalLayout.addFragment(a_oFrag1);
-        a_oLocalLayout.addFragment(a_oFrag2);
-        a_oLocalLayout.addFragment(a_oFrag3);
-        a_oLocalLayout.addFragment(a_oFrag4);
-        a_oLocalLayout.addFragment(a_oFrag5);
-
-        Page a_oPage = new PageImpl();
-        a_oPage.setRootFragment(a_oLayout);
-        ContentPage a_oContentPage = new ContentPageImpl(a_oPage);
-        a_oRC.setPage(a_oContentPage);
-
-        return a_oRC;
-    }
-
-    // Helper method to find a string within the response
-    public static boolean findValue(RequestContext p_oRequestContext,
-            String p_sValue)
-    {
-        MockHttpServletResponse mr = (MockHttpServletResponse) p_oRequestContext
-                .getResponse();
-        String a_sContent = mr.getOutputStreamContent();
-        boolean a_bResults = a_sContent.indexOf(p_sValue) >= 0;
-        return a_bResults;
-    }
-
-    // Helper method
-    public static RequestContext setupRequestContext(String p_sAction,
-            String p_sPortletId, String p_sCol, String p_sRow)
-    {
-        MockServletConfig config = new MockServletConfig();
-        MockServletContext context = new MockServletContext();
-        MockHttpSession session = new MockHttpSession();
-        session.setupServletContext(context);
-        MockHttpServletRequest request = new MockHttpServletRequest();
-        request.setupAddParameter("action", p_sAction);
-        request.setupAddParameter("id", p_sPortletId);
-        if (p_sRow != null)
-        {
-            request.setupAddParameter("row", p_sRow);
-        }
-        if (p_sCol != null)
-        {
-            request.setupAddParameter("col", p_sCol);
-        }
-
-        request.setSession(session);
-        MockHttpServletResponse response = new MockHttpServletResponse();
-
-        RequestContext a_oRC = new JetspeedRequestContext(request, response,
-                config, null);
-
-        Page a_oPage = setupPage();
-        ContentPage a_oContentPage = new ContentPageImpl(a_oPage);
-
-        a_oRC.setPage(a_oContentPage);
-
-        return a_oRC;
-    }
-
-    // Helper method
-    public static Page setupPage()
-    {
-        // Prepare some fragments
-        Fragment a_oLayout = buildFragment("layout", "6", "layout", 0, 0);
-        Fragment a_oFrag1 = buildFragment("frag1", "1", "portlet", 1, 0);
-        Fragment a_oFrag2 = buildFragment("frag2", "2", "portlet", 1, 1);
-        Fragment a_oFrag3 = buildFragment("frag3", "3", "portlet", 2, 0);
-        Fragment a_oFrag4 = buildFragment("frag4", "4", "portlet", 2, 1);
-        Fragment a_oFrag5 = buildFragment("frag5", "5", "portlet", 2, 2);
-
-        LocalFragmentImpl a_oLocalLayout = (LocalFragmentImpl) a_oLayout;
-        a_oLocalLayout.addFragment(a_oFrag1);
-        a_oLocalLayout.addFragment(a_oFrag2);
-        a_oLocalLayout.addFragment(a_oFrag3);
-        a_oLocalLayout.addFragment(a_oFrag4);
-        a_oLocalLayout.addFragment(a_oFrag5);
-
-        Page a_oPage = new PageImpl();
-        a_oPage.setRootFragment(a_oLayout);
-
-        return a_oPage;
-    }
-
-    public static Fragment buildFragment(String p_sName, String p_sId,
-            String p_sType, int p_iCol, int p_iRow)
-    {
-        LocalFragmentImpl a_oFrag = new LocalFragmentImpl();
-        a_oFrag.setName(p_sName);
-        a_oFrag.setType(p_sType);
-        a_oFrag.setLayoutColumn(p_iCol);
-        a_oFrag.setLayoutRow(p_iRow);
-        a_oFrag.setId(p_sId);
-        return a_oFrag;
-    }
-    
-    public static void debugContentOutput(RequestContext rc)
-    {
-        MockHttpServletResponse mr = (MockHttpServletResponse) rc.getResponse();        
-        String content = mr.getOutputStreamContent();
-        System.out.println("content = " + content);
-    }
-
-}
+ * 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.layout;
+
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.om.page.ContentPage;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.ContentPageImpl;
+import org.apache.jetspeed.om.page.psml.PageImpl;
+import org.apache.jetspeed.request.JetspeedRequestContext;
+import org.apache.jetspeed.request.RequestContext;
+
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockHttpServletResponse;
+import com.mockrunner.mock.web.MockHttpSession;
+import com.mockrunner.mock.web.MockServletConfig;
+import com.mockrunner.mock.web.MockServletContext;
+
+/**
+ * Test for Fragment placement
+ * 
+ * @author <a>David Gurney </a>
+ * @version $Id: $
+ */
+public class FragmentUtil
+{
+
+    public static RequestContext buildFullRequestContext()
+    {
+        // Build a request object and populate it with fragments
+        RequestContext a_oRC = setupRequestContext("remove", "1234", "0", "0");
+
+        // Build some fragments and add them to the request context
+        // Prepare some fragments
+        Fragment a_oLayout = buildFragment("layout", "6", "layout", 0, 0);
+        Fragment a_oFrag1 = buildFragment("frag1", "1", "portlet", 1, 0);
+        Fragment a_oFrag2 = buildFragment("frag2", "2", "portlet", 1, 1);
+        Fragment a_oFrag3 = buildFragment("frag3", "3", "portlet", 2, 0);
+        Fragment a_oFrag4 = buildFragment("frag4", "4", "portlet", 2, 1);
+        Fragment a_oFrag5 = buildFragment("frag5", "5", "portlet", 2, 2);
+
+        LocalFragmentImpl a_oLocalLayout = (LocalFragmentImpl) a_oLayout;
+        a_oLocalLayout.addFragment(a_oFrag1);
+        a_oLocalLayout.addFragment(a_oFrag2);
+        a_oLocalLayout.addFragment(a_oFrag3);
+        a_oLocalLayout.addFragment(a_oFrag4);
+        a_oLocalLayout.addFragment(a_oFrag5);
+
+        Page a_oPage = new PageImpl();
+        a_oPage.setRootFragment(a_oLayout);
+        ContentPage a_oContentPage = new ContentPageImpl(a_oPage);
+        a_oRC.setPage(a_oContentPage);
+
+        return a_oRC;
+    }
+
+    // Helper method to find a string within the response
+    public static boolean findValue(RequestContext p_oRequestContext,
+            String p_sValue)
+    {
+        MockHttpServletResponse mr = (MockHttpServletResponse) p_oRequestContext
+                .getResponse();
+        String a_sContent = mr.getOutputStreamContent();
+        boolean a_bResults = a_sContent.indexOf(p_sValue) >= 0;
+        return a_bResults;
+    }
+
+    // Helper method
+    public static RequestContext setupRequestContext(String p_sAction,
+            String p_sPortletId, String p_sCol, String p_sRow)
+    {
+        MockServletConfig config = new MockServletConfig();
+        MockServletContext context = new MockServletContext();
+        MockHttpSession session = new MockHttpSession();
+        session.setupServletContext(context);
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        request.setupAddParameter("action", p_sAction);
+        request.setupAddParameter("id", p_sPortletId);
+        if (p_sRow != null)
+        {
+            request.setupAddParameter("row", p_sRow);
+        }
+        if (p_sCol != null)
+        {
+            request.setupAddParameter("col", p_sCol);
+        }
+
+        request.setSession(session);
+        MockHttpServletResponse response = new MockHttpServletResponse();
+
+        RequestContext a_oRC = new JetspeedRequestContext(request, response,
+                config, null);
+        
+        a_oRC.setSubject(new Subject());
+        
+        Page a_oPage = setupPage();
+        ContentPage a_oContentPage = new ContentPageImpl(a_oPage);
+
+        a_oRC.setPage(a_oContentPage);
+
+        return a_oRC;
+    }
+
+    // Helper method
+    public static Page setupPage()
+    {
+        // Prepare some fragments
+        Fragment a_oLayout = buildFragment("layout", "6", "layout", 0, 0);
+        Fragment a_oFrag1 = buildFragment("frag1", "1", "portlet", 1, 0);
+        Fragment a_oFrag2 = buildFragment("frag2", "2", "portlet", 1, 1);
+        Fragment a_oFrag3 = buildFragment("frag3", "3", "portlet", 2, 0);
+        Fragment a_oFrag4 = buildFragment("frag4", "4", "portlet", 2, 1);
+        Fragment a_oFrag5 = buildFragment("frag5", "5", "portlet", 2, 2);
+
+        LocalFragmentImpl a_oLocalLayout = (LocalFragmentImpl) a_oLayout;
+        a_oLocalLayout.addFragment(a_oFrag1);
+        a_oLocalLayout.addFragment(a_oFrag2);
+        a_oLocalLayout.addFragment(a_oFrag3);
+        a_oLocalLayout.addFragment(a_oFrag4);
+        a_oLocalLayout.addFragment(a_oFrag5);
+
+        Page a_oPage = new PageImpl();
+        a_oPage.setRootFragment(a_oLayout);
+
+        return a_oPage;
+    }
+
+    public static Fragment buildFragment(String p_sName, String p_sId,
+            String p_sType, int p_iCol, int p_iRow)
+    {
+        LocalFragmentImpl a_oFrag = new LocalFragmentImpl();
+        a_oFrag.setName(p_sName);
+        a_oFrag.setType(p_sType);
+        a_oFrag.setLayoutColumn(p_iCol);
+        a_oFrag.setLayoutRow(p_iRow);
+        a_oFrag.setId(p_sId);
+        return a_oFrag;
+    }
+    
+    public static void debugContentOutput(RequestContext rc)
+    {
+        MockHttpServletResponse mr = (MockHttpServletResponse) rc.getResponse();        
+        String content = mr.getOutputStreamContent();
+        System.out.println("content = " + content);
+    }
+
+}

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java?rev=591353&r1=591352&r2=591353&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestLayout.java Fri Nov  2 08:03:10 2007
@@ -1,418 +1,419 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You 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.layout;
-
-import java.io.File;
-
-import junit.framework.TestCase;
-
-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 com.mockrunner.mock.web.MockServletConfig;
-
-/**
- * Test for Fragment placement
- * 
- * @author <a>David Gurney </a>
- * @version $Id: $
- */
-public class TestLayout extends TestCase
-{
-
-    private ComponentManager cm;
-
-    private LayoutValve valve;
-    
-    public static void main(String[] args)
-    {
-        junit.swingui.TestRunner.run(TestLayout.class);
-    }
-
-    /**
-     * Setup the request context
-     */
-    protected void setUp() throws Exception
-    {
-        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/test/resources/assembly/test-layout-api.xml"};
-        
-                
-        cm = new SpringComponentManager(bootConfigs, appConfigs, servletContent, ".");
-        cm.start();
-        valve = (LayoutValve) cm.getComponent("layoutValve");
-    }
-
-    protected void tearDown() throws Exception
-    {
-        cm.stop();
-    }
-
-    public void testNullRequestContext()
-    {
-        // Get the layout that has a null request context        
-        try
-        {
-            valve.invoke(null, null);
-            TestLayout.fail("should have thrown an exception");
-        } catch (PipelineException e)
-        {
-            TestLayout.assertTrue("detected null request context", true);
-        }
-    }
-
-    public void testNullParameters()
-    {
-        try
-        {
-            // Test the success case
-            RequestContext rc = FragmentUtil
-                    .setupRequestContext(null, "1234", "0", "0");
-            valve.invoke(rc, null);
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "failure"));
-        } catch (PipelineException e)
-        {
-            TestLayout.fail("unexpected exception");
-        }
-
-        try
-        {
-            // Test the success case
-            RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "33", "0",
-                    "0");
-            valve.invoke(rc, null);
-
-            // Take a look at the response to verify a failiure
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "failure"));
-        } catch (PipelineException e)
-        {
-            TestLayout.fail("unexpected exception");
-        }
-
-        try
-        {
-            // Test the success case
-            RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "1234",
-                    null, "0");
-            valve.invoke(rc, null);
-
-            // Take a look at the response to verify a failiure
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "failure"));
-        } catch (PipelineException e)
-        {
-            TestLayout.fail("unexpected exception");
-        }
-
-        try
-        {
-            // Test the success case
-            RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "1234",
-                    "0", null);
-            valve.invoke(rc, null);
-
-            // Take a look at the response to verify a failiure
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "failure"));
-        } catch (PipelineException e)
-        {
-            TestLayout.fail("unexpected exception");
-        }
-    }
-
-    public void testEasy()
-    {
-        moveSuccess("moveabs", "1", "1", "0", "1", "1", "1", "1"); // Move down
-        moveSuccess("moveright", "1", "1", "0", "2", "0", "2", "0"); // Straight across
-    }
-    
-    public void testMoveSuccess()
-    {
-        moveSuccess("moveabs", "1", "1", "0", "1", "0", "1", "0"); // Doesn't
-                                                                    // really
-                                                                    // move
-        moveSuccess("moveabs", "1", "1", "0", "1", "1", "1", "1"); // Move down
-
-        moveSuccess("moveabs", "2", "1", "1", "1", "0", "1", "0"); // Move up
-        moveSuccess("moveabs", "1", "1", "0", "2", "0", "2", "0"); // Move
-                                                                    // right
-        moveSuccess("moveabs", "3", "2", "0", "1", "0", "1", "0"); // Move left
-        moveSuccess("moveabs", "2", "1", "1", "2", "2", "2", "2"); // Move
-                                                                    // right &
-                                                                    // move down
-        moveSuccess("moveabs", "3", "2", "0", "1", "1", "1", "1"); // Move left
-                                                                    // & move
-                                                                    // down
-        moveSuccess("moveabs", "4", "2", "1", "1", "0", "1", "0"); // Move left
-                                                                    // & move up
-
-        moveSuccess("moveabs", "1", "1", "0", "1", "2", "1", "1"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-        moveSuccess("moveabs", "2", "1", "1", "1", "2", "1", "1"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-        moveSuccess("moveabs", "3", "2", "0", "2", "3", "2", "2"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-        moveSuccess("moveabs", "4", "2", "1", "2", "3", "2", "2"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-        moveSuccess("moveabs", "5", "2", "2", "2", "3", "2", "2"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-        moveSuccess("moveabs", "1", "1", "0", "2", "4", "2", "3"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-        moveSuccess("moveabs", "2", "1", "1", "2", "4", "2", "3"); // Move too
-                                                                    // far down,
-                                                                    // should be
-                                                                    // at end of
-                                                                    // row
-
-        moveSuccess("moveleft", "1", "1", "0", "0", "0", "0", "0"); // Shouldn't
-                                                                    // move
-        moveSuccess("moveleft", "6", "0", "0", "0", "0", "0", "0"); // Shouldn't
-                                                                    // move
-        moveSuccess("moveleft", "3", "2", "0", "1", "0", "1", "0"); // Straight
-                                                                    // across
-        moveSuccess("moveleft", "4", "2", "1", "1", "1", "1", "1"); // Straight
-                                                                    // across
-        moveSuccess("moveleft", "5", "2", "2", "1", "2", "1", "2"); // Straight
-                                                                    // across
-
-        moveSuccess("moveright", "1", "1", "0", "2", "0", "2", "0"); // Straight
-                                                                        // across
-        moveSuccess("moveright", "2", "1", "1", "2", "1", "2", "1"); // Straight
-                                                                        // across
-        moveSuccess("moveright", "3", "2", "0", "3", "0", "3", "0"); // Shouldn't
-//                                                                        // move
-        moveSuccess("moveright", "4", "2", "1", "3", "0", "3", "0"); // Shouldn't
-                                                                        // move
-        moveSuccess("moveright", "5", "2", "2", "3", "0", "3", "0"); // Shouldn't
-                                                                        // move
-
-        moveSuccess("moveup", "2", "1", "1", "1", "0", "1", "0"); // Straight
-                                                                    // across
-        moveSuccess("moveup", "4", "2", "1", "2", "0", "2", "0"); // Straight
-                                                                    // across
-        moveSuccess("moveup", "5", "2", "2", "2", "1", "2", "1"); // Straight
-                                                                    // across
-
-        moveSuccess("movedown", "1", "1", "0", "1", "1", "1", "1"); // Straight
-                                                                    // across
-        moveSuccess("movedown", "2", "1", "1", "1", "1", "1", "1"); // Shouldn't
-                                                                    // move
-        moveSuccess("movedown", "3", "2", "0", "2", "1", "2", "1"); // Straight
-                                                                    // across
-        moveSuccess("movedown", "4", "2", "1", "2", "2", "2", "2"); // Straight
-                                                                    // across
-        moveSuccess("movedown", "5", "2", "2", "2", "2", "2", "2"); // Shouldn't
-                                                                    // move
-    }
-
-    public void testMoveFailure()
-    {
-        moveFailure("moveabs", "bogus", "0", "0", "0", "0"); // non integer
-                                                                // portlet id
-        moveFailure("moveleft", "0", "0", "0", "0", "0"); // portlet not found
-        // moveFailure("moveabs", "1", "0", "0", "3", "0"); // non existent
-                                                            // column
-        moveFailure("bogus", "0", "0", "0", "0", "0"); // bogus action
-        moveFailure("moveabs", "1", "0", "0", "a", "0"); // non integer value
-        moveFailure("moveabs", "1", "0", "0", "0", "b"); // non integer value
-    }
-
-    public void moveSuccess(String a_sMoveType, String p_sPortletId,
-            String p_sOldCol, String p_sOldRow, String p_sNewCol,
-            String p_sNewRow, String p_sExpectedNewCol, String p_sExpectedNewRow)
-    {
-        try
-        {
-            // Test the success case
-            RequestContext rc = null;
-
-            if (a_sMoveType.equalsIgnoreCase("moveabs"))
-            {
-                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId,
-                        p_sNewCol, p_sNewRow);
-            } else
-            {
-                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId, null,
-                        null);
-            }
-
-            valve.invoke(rc, null);
-
-            // Take a look at the response to verify a failiure
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "success"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<js>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<status>success</status>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<action>" + a_sMoveType + "</action>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<id>" + p_sPortletId + "</id>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<old_position><col>" + p_sOldCol + "</col><row>"
-                            + p_sOldRow + "</row></old_position>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<new_position><col>" + p_sExpectedNewCol + "</col><row>"
-                            + p_sExpectedNewRow + "</row></new_position>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "</js>"));
-        } catch (PipelineException e)
-        {
-            e.printStackTrace();
-            TestLayout.fail("layout valve failed");
-        }
-    }
-
-    public void moveFailure(String a_sMoveType, String p_sPortletId,
-            String p_sOldCol, String p_sOldRow, String p_sNewCol,
-            String p_sNewRow)
-    {
-        try
-        {
-            // Test failure case
-            RequestContext rc = null;
-
-            if (a_sMoveType.equalsIgnoreCase("moveabs"))
-            {
-                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId,
-                        p_sNewCol, p_sNewRow);
-            } else
-            {
-                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId, null,
-                        null);
-            }
-            valve.invoke(rc, null);
-
-            //FragmentUtil.debugContentOutput(rc);
-            
-            // Take a look at the response to verify a failure            
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<status>failure</status>"));
-        } catch (PipelineException p)
-        {
-            TestLayout.fail("unexpected exception");
-        }
-
-        try
-        {
-            // Test failure case
-            RequestContext rc = null;
-
-            if (a_sMoveType.equalsIgnoreCase("moveabs"))
-            {
-                rc = FragmentUtil.setupRequestContext(a_sMoveType, "1234", "0", "foo");
-            } else
-            {
-                rc = FragmentUtil.setupRequestContext(a_sMoveType, "1234", null, null);
-            }
-
-            valve.invoke(rc, null);
-
-            // Take a look at the response to verify a failiure
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<status>failure</status>"));
-        } catch (PipelineException p)
-        {
-            TestLayout.fail("unexpected exception");
-        }
-    }
-
-    public void testRemove()
-    {
-        remove("1");
-        remove("2");
-        remove("3");
-        remove("4");
-    }
-
-    private void remove(String p_sPortletId)
-    {
-        try
-        {
-            // Test the success case
-            RequestContext rc = null;
-
-            rc = FragmentUtil.setupRequestContext("remove", p_sPortletId, null, null);
-
-            valve.invoke(rc, null);
-
-            // Take a look at the response to verify a failiure
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "success"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<js>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<status>success</status>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<action>" + "remove" + "</action>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<id>" + p_sPortletId + "</id>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<old_position>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<col>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "<row>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "</old_position>"));
-            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
-                    "</js>"));
-        } catch (PipelineException e)
-        {
-            e.printStackTrace();
-            TestLayout.fail("layout valve failed");
-        }
-
-    }
-}
+ * 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.layout;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+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 com.mockrunner.mock.web.MockServletConfig;
+
+/**
+ * Test for Fragment placement
+ * 
+ * @author <a>David Gurney </a>
+ * @version $Id: $
+ */
+public class TestLayout extends TestCase
+{
+
+    private ComponentManager cm;
+
+    private LayoutValve valve;
+    
+    public static void main(String[] args)
+    {
+        junit.swingui.TestRunner.run(TestLayout.class);
+    }
+
+    /**
+     * Setup the request context
+     */
+    protected void setUp() throws Exception
+    {
+        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/test/resources/assembly/test-layout-api.xml"};
+        
+                
+        cm = new SpringComponentManager(bootConfigs, appConfigs, servletContent, ".");
+        cm.start();
+        valve = (LayoutValve) cm.getComponent("layoutValve");
+    }
+
+    protected void tearDown() throws Exception
+    {
+        cm.stop();
+    }
+
+    public void testNullRequestContext()
+    {
+        // Get the layout that has a null request context        
+        try
+        {
+            valve.invoke(null, null);
+            TestLayout.fail("should have thrown an exception");
+        } catch (PipelineException e)
+        {
+            TestLayout.assertTrue("detected null request context", true);
+        }
+    }
+
+    public void testNullParameters()
+    {
+        try
+        {
+            // Test the success case
+            RequestContext rc = FragmentUtil
+                    .setupRequestContext(null, "1234", "0", "0");
+            valve.invoke(rc, null);
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "failure"));
+        } catch (PipelineException e)
+        {
+            TestLayout.fail("unexpected exception");
+        }
+
+        try
+        {
+            // Test the success case
+            RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "33", "0",
+                    "0");
+            valve.invoke(rc, null);
+
+            // Take a look at the response to verify a failiure
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "failure"));
+        } catch (PipelineException e)
+        {
+            TestLayout.fail("unexpected exception");
+        }
+
+        try
+        {
+            // Test the success case
+            RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "1234",
+                    null, "0");
+            valve.invoke(rc, null);
+
+            // Take a look at the response to verify a failiure
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "failure"));
+        } catch (PipelineException e)
+        {
+            TestLayout.fail("unexpected exception");
+        }
+
+        try
+        {
+            // Test the success case
+            RequestContext rc = FragmentUtil.setupRequestContext("moveabs", "1234",
+                    "0", null);
+            valve.invoke(rc, null);
+
+            // Take a look at the response to verify a failiure
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "failure"));
+        } catch (PipelineException e)
+        {
+            TestLayout.fail("unexpected exception");
+        }
+    }
+
+    public void testEasy()
+    {
+        moveSuccess("moveabs", "1", "1", "0", "1", "1", "1", "1"); // Move down
+        moveSuccess("moveright", "1", "1", "0", "2", "0", "2", "0"); // Straight across
+    }
+    
+    public void testMoveSuccess()
+    {
+        moveSuccess("moveabs", "1", "1", "0", "1", "0", "1", "0"); // Doesn't
+                                                                    // really
+                                                                    // move
+        moveSuccess("moveabs", "1", "1", "0", "1", "1", "1", "1"); // Move down
+
+        moveSuccess("moveabs", "2", "1", "1", "1", "0", "1", "0"); // Move up
+        moveSuccess("moveabs", "1", "1", "0", "2", "0", "2", "0"); // Move
+                                                                    // right
+        moveSuccess("moveabs", "3", "2", "0", "1", "0", "1", "0"); // Move left
+        moveSuccess("moveabs", "2", "1", "1", "2", "2", "2", "2"); // Move
+                                                                    // right &
+                                                                    // move down
+        moveSuccess("moveabs", "3", "2", "0", "1", "1", "1", "1"); // Move left
+                                                                    // & move
+                                                                    // down
+        moveSuccess("moveabs", "4", "2", "1", "1", "0", "1", "0"); // Move left
+                                                                    // & move up
+
+        moveSuccess("moveabs", "1", "1", "0", "1", "2", "1", "1"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+        moveSuccess("moveabs", "2", "1", "1", "1", "2", "1", "1"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+        moveSuccess("moveabs", "3", "2", "0", "2", "3", "2", "2"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+        moveSuccess("moveabs", "4", "2", "1", "2", "3", "2", "2"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+        moveSuccess("moveabs", "5", "2", "2", "2", "3", "2", "2"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+        moveSuccess("moveabs", "1", "1", "0", "2", "4", "2", "3"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+        moveSuccess("moveabs", "2", "1", "1", "2", "4", "2", "3"); // Move too
+                                                                    // far down,
+                                                                    // should be
+                                                                    // at end of
+                                                                    // row
+
+        moveSuccess("moveleft", "1", "1", "0", "0", "0", "0", "0"); // Shouldn't
+                                                                    // move
+// Root layout ("6") shouldn't/cannot be moved, so the following test doesn't make sense
+//      moveSuccess("moveleft", "6", "0", "0", "0", "0", "0", "0"); // Shouldn't
+                                                                    // move
+        moveSuccess("moveleft", "3", "2", "0", "1", "0", "1", "0"); // Straight
+                                                                    // across
+        moveSuccess("moveleft", "4", "2", "1", "1", "1", "1", "1"); // Straight
+                                                                    // across
+        moveSuccess("moveleft", "5", "2", "2", "1", "2", "1", "2"); // Straight
+                                                                    // across
+
+        moveSuccess("moveright", "1", "1", "0", "2", "0", "2", "0"); // Straight
+                                                                        // across
+        moveSuccess("moveright", "2", "1", "1", "2", "1", "2", "1"); // Straight
+                                                                        // across
+        moveSuccess("moveright", "3", "2", "0", "3", "0", "2", "0"); // Shouldn't
+//                                                                        // move
+        moveSuccess("moveright", "4", "2", "1", "3", "0", "2", "1"); // Shouldn't
+                                                                        // move
+        moveSuccess("moveright", "5", "2", "2", "3", "0", "2", "2"); // Shouldn't
+                                                                        // move
+
+        moveSuccess("moveup", "2", "1", "1", "1", "0", "1", "0"); // Straight
+                                                                    // across
+        moveSuccess("moveup", "4", "2", "1", "2", "0", "2", "0"); // Straight
+                                                                    // across
+        moveSuccess("moveup", "5", "2", "2", "2", "1", "2", "1"); // Straight
+                                                                    // across
+
+        moveSuccess("movedown", "1", "1", "0", "1", "1", "1", "1"); // Straight
+                                                                    // across
+        moveSuccess("movedown", "2", "1", "1", "1", "1", "1", "1"); // Shouldn't
+                                                                    // move
+        moveSuccess("movedown", "3", "2", "0", "2", "1", "2", "1"); // Straight
+                                                                    // across
+        moveSuccess("movedown", "4", "2", "1", "2", "2", "2", "2"); // Straight
+                                                                    // across
+        moveSuccess("movedown", "5", "2", "2", "2", "2", "2", "2"); // Shouldn't
+                                                                    // move
+    }
+
+    public void testMoveFailure()
+    {
+        moveFailure("moveabs", "bogus", "0", "0", "0", "0"); // non integer
+                                                                // portlet id
+        moveFailure("moveleft", "0", "0", "0", "0", "0"); // portlet not found
+        // moveFailure("moveabs", "1", "0", "0", "3", "0"); // non existent
+                                                            // column
+        moveFailure("bogus", "0", "0", "0", "0", "0"); // bogus action
+        moveFailure("moveabs", "1", "0", "0", "a", "0"); // non integer value
+        moveFailure("moveabs", "1", "0", "0", "0", "b"); // non integer value
+    }
+
+    public void moveSuccess(String a_sMoveType, String p_sPortletId,
+            String p_sOldCol, String p_sOldRow, String p_sNewCol,
+            String p_sNewRow, String p_sExpectedNewCol, String p_sExpectedNewRow)
+    {
+        try
+        {
+            // Test the success case
+            RequestContext rc = null;
+
+            if (a_sMoveType.equalsIgnoreCase("moveabs"))
+            {
+                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId,
+                        p_sNewCol, p_sNewRow);
+            } else
+            {
+                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId, null,
+                        null);
+            }
+
+            valve.invoke(rc, null);
+
+            // Take a look at the response to verify a failiure
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "success"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<js>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<status>success</status>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<action>" + a_sMoveType + "</action>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<id>" + p_sPortletId + "</id>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<old_position><col>" + p_sOldCol + "</col><row>"
+                            + p_sOldRow + "</row></old_position>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<new_position><col>" + p_sExpectedNewCol + "</col><row>"
+                            + p_sExpectedNewRow + "</row></new_position>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "</js>"));
+        } catch (PipelineException e)
+        {
+            e.printStackTrace();
+            TestLayout.fail("layout valve failed");
+        }
+    }
+
+    public void moveFailure(String a_sMoveType, String p_sPortletId,
+            String p_sOldCol, String p_sOldRow, String p_sNewCol,
+            String p_sNewRow)
+    {
+        try
+        {
+            // Test failure case
+            RequestContext rc = null;
+
+            if (a_sMoveType.equalsIgnoreCase("moveabs"))
+            {
+                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId,
+                        p_sNewCol, p_sNewRow);
+            } else
+            {
+                rc = FragmentUtil.setupRequestContext(a_sMoveType, p_sPortletId, null,
+                        null);
+            }
+            valve.invoke(rc, null);
+
+            //FragmentUtil.debugContentOutput(rc);
+            
+            // Take a look at the response to verify a failure            
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<status>failure</status>"));
+        } catch (PipelineException p)
+        {
+            TestLayout.fail("unexpected exception");
+        }
+
+        try
+        {
+            // Test failure case
+            RequestContext rc = null;
+
+            if (a_sMoveType.equalsIgnoreCase("moveabs"))
+            {
+                rc = FragmentUtil.setupRequestContext(a_sMoveType, "1234", "0", "foo");
+            } else
+            {
+                rc = FragmentUtil.setupRequestContext(a_sMoveType, "1234", null, null);
+            }
+
+            valve.invoke(rc, null);
+
+            // Take a look at the response to verify a failiure
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<status>failure</status>"));
+        } catch (PipelineException p)
+        {
+            TestLayout.fail("unexpected exception");
+        }
+    }
+
+    public void testRemove()
+    {
+        remove("1");
+        remove("2");
+        remove("3");
+        remove("4");
+    }
+
+    private void remove(String p_sPortletId)
+    {
+        try
+        {
+            // Test the success case
+            RequestContext rc = null;
+
+            rc = FragmentUtil.setupRequestContext("remove", p_sPortletId, null, null);
+
+            valve.invoke(rc, null);
+
+            // Take a look at the response to verify a failiure
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "success"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<js>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<status>success</status>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<action>" + "remove" + "</action>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<id>" + p_sPortletId + "</id>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<old_position>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<col>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "<row>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "</old_position>"));
+            TestLayout.assertTrue("couldn't find value", FragmentUtil.findValue(rc,
+                    "</js>"));
+        } catch (PipelineException e)
+        {
+            e.printStackTrace();
+            TestLayout.fail("layout valve failed");
+        }
+
+    }
+}

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestPortletPlacement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestPortletPlacement.java?rev=591353&r1=591352&r2=591353&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestPortletPlacement.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/layout/TestPortletPlacement.java Fri Nov  2 08:03:10 2007
@@ -1,226 +1,226 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You 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.layout;
-
-import junit.framework.TestCase;
-
-import org.apache.jetspeed.layout.impl.CoordinateImpl;
-import org.apache.jetspeed.layout.impl.PortletPlacementContextImpl;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.request.RequestContext;
-
-/**
- * Test for Fragment placement
- * 
- * @author <a>David Gurney </a>
- * @version $Id: $
- */
-public class TestPortletPlacement extends TestCase
-{
-
-    public void testGetFragmentAt()
-    {
-        // Build a request object and populate it with fragments
-        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
-
-        try
-        {
-            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
-            int a_iNumCols = ppc.getNumberColumns();
-            assertEquals(a_iNumCols, 3);
-
-            int a_iNumRows = ppc.getNumberRows(1);
-            assertEquals(a_iNumRows, 2);
-
-            a_iNumRows = ppc.getNumberRows(2);
-            assertEquals(a_iNumRows, 3);
-
-            // Check the fragments
-            Fragment a_oFrag = ppc
-                    .getFragmentAtNewCoordinate(new CoordinateImpl(1, 0, 1, 0));
-            assertNotNull("null fragment found at 1,0", a_oFrag);
-            assertEquals(a_oFrag.getId(), "1");
-            assertEquals(a_oFrag.getName(), "frag1");
-
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 1,
-                    1, 1));
-            assertNotNull("null fragment found at 1,1", a_oFrag);
-            assertEquals(a_oFrag.getId(), "2");
-            assertEquals(a_oFrag.getName(), "frag2");
-
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(2, 0,
-                    2, 0));
-            assertNotNull("null fragment found at 2,0", a_oFrag);
-            assertEquals(a_oFrag.getId(), "3");
-            assertEquals(a_oFrag.getName(), "frag3");
-
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(2, 1,
-                    2, 1));
-            assertNotNull("null fragment found at 2,1", a_oFrag);
-            assertEquals(a_oFrag.getId(), "4");
-            assertEquals(a_oFrag.getName(), "frag4");
-
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(2, 2,
-                    2, 2));
-            assertNotNull("null fragment found at 2,2", a_oFrag);
-            assertEquals(a_oFrag.getId(), "5");
-            assertEquals(a_oFrag.getName(), "frag5");
-
-        } catch (PortletPlacementException e)
-        {
-            fail("creating the PortletPlacementManager failed");
-        }
-    }
-
-    public void testGetFragmentById()
-    {
-        // Build a request object and populate it with fragments
-        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
-
-        try
-        {
-            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
-
-            // Check the fragments
-            Fragment a_oFrag = ppc.getFragmentById("1");
-            assertNotNull("null fragment with id 1", a_oFrag);
-            assertEquals(a_oFrag.getId(), "1");
-            assertEquals(a_oFrag.getName(), "frag1");
-
-            a_oFrag = ppc.getFragmentById("2");
-            assertNotNull("null fragment with id 2", a_oFrag);
-            assertEquals(a_oFrag.getId(), "2");
-            assertEquals(a_oFrag.getName(), "frag2");
-
-            a_oFrag = ppc.getFragmentById("3");
-            assertNotNull("null fragment with id 3", a_oFrag);
-            assertEquals(a_oFrag.getId(), "3");
-            assertEquals(a_oFrag.getName(), "frag3");
-
-            a_oFrag = ppc.getFragmentById("4");
-            assertNotNull("null fragment with id 4", a_oFrag);
-            assertEquals(a_oFrag.getId(), "4");
-            assertEquals(a_oFrag.getName(), "frag4");
-
-            a_oFrag = ppc.getFragmentById("5");
-            assertNotNull("null fragment with id 5", a_oFrag);
-            assertEquals(a_oFrag.getId(), "5");
-            assertEquals(a_oFrag.getName(), "frag5");
-
-        } catch (PortletPlacementException e)
-        {
-            fail("creating the PortletPlacementManager failed");
-        }
-    }
-
-    public void testRemoveFragment()
-    {
-        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
-
-        try
-        {
-            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
-
-            Fragment a_oFrag = ppc
-                    .getFragmentAtNewCoordinate(new CoordinateImpl(1, 0, 1, 0));
-
-            Coordinate a_oCoordinate = ppc.remove(a_oFrag);
-
-            assertEquals(a_oCoordinate.getOldCol(), 1);
-            assertEquals(a_oCoordinate.getOldRow(), 0);
-
-            // Should be the second fragment now that the first has been deleted
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 0,
-                    1, 0));
-            assertEquals(a_oFrag.getId(), "2");
-            assertEquals(a_oFrag.getName(), "frag2");
-        } catch (PortletPlacementException e)
-        {
-            fail("creating the PortletPlacementManager failed");
-        }
-    }
-
-    public void footestFragmentMoveabs()
-    {
-        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
-
-        try
-        {
-            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
-
-            Fragment a_oFrag = ppc
-                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 0));
-
-            Coordinate a_oCoordinate = ppc.moveAbsolute(a_oFrag, new CoordinateImpl(
-                    0, 0, 0, 1));
-
-            assertEquals(a_oCoordinate.getOldCol(), 0);
-            assertEquals(a_oCoordinate.getOldRow(), 0);
-            assertEquals(a_oCoordinate.getNewCol(), 0);
-            assertEquals(a_oCoordinate.getNewRow(), 1);
-
-            // Should be the second fragment now that the first has been moved
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
-                    0, 0));
-            assertEquals(a_oFrag.getId(), "2");
-            assertEquals(a_oFrag.getName(), "frag2");
-
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
-                    0, 1));
-            assertEquals(a_oFrag.getId(), "1");
-            assertEquals(a_oFrag.getName(), "frag1");
-        } catch (PortletPlacementException e)
-        {
-            fail("creating the PortletPlacementManager failed");
-        }
-    }
-
-    public void footestFragmentMoveUp()
-    {
-        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
-
-        try
-        {
-            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
-
-            Fragment a_oFrag = ppc
-                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 1));
-
-            Coordinate a_oCoordinate = ppc.moveUp(a_oFrag);
-
-            assertEquals(a_oCoordinate.getOldCol(), 0);
-            assertEquals(a_oCoordinate.getOldRow(), 1);
-            assertEquals(a_oCoordinate.getNewCol(), 0);
-            assertEquals(a_oCoordinate.getNewRow(), 0);
-
-            // Should be the second fragment since it was moved up
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
-                    0, 0));
-            assertEquals(a_oFrag.getId(), "2");
-            assertEquals(a_oFrag.getName(), "frag2");
-
-            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
-                    0, 1));
-            assertEquals(a_oFrag.getId(), "1");
-            assertEquals(a_oFrag.getName(), "frag1");
-        } catch (PortletPlacementException e)
-        {
-            fail("creating the PortletPlacementManager failed");
-        }
-    }
-
-}
+ * 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.layout;
+
+import junit.framework.TestCase;
+
+import org.apache.jetspeed.layout.impl.CoordinateImpl;
+import org.apache.jetspeed.layout.impl.PortletPlacementContextImpl;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Test for Fragment placement
+ * 
+ * @author <a>David Gurney </a>
+ * @version $Id: $
+ */
+public class TestPortletPlacement extends TestCase
+{
+
+    public void testGetFragmentAt()
+    {
+        // Build a request object and populate it with fragments
+        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
+
+        try
+        {
+            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
+            int a_iNumCols = ppc.getNumberColumns();
+            assertEquals(a_iNumCols, 2);
+
+            int a_iNumRows = ppc.getNumberRows(1);
+            assertEquals(a_iNumRows, 2);
+
+            a_iNumRows = ppc.getNumberRows(2);
+            assertEquals(a_iNumRows, 3);
+
+            // Check the fragments
+            Fragment a_oFrag = ppc
+                    .getFragmentAtNewCoordinate(new CoordinateImpl(1, 0, 1, 0));
+            assertNotNull("null fragment found at 1,0", a_oFrag);
+            assertEquals(a_oFrag.getId(), "1");
+            assertEquals(a_oFrag.getName(), "frag1");
+
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 1,
+                    1, 1));
+            assertNotNull("null fragment found at 1,1", a_oFrag);
+            assertEquals(a_oFrag.getId(), "2");
+            assertEquals(a_oFrag.getName(), "frag2");
+
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(2, 0,
+                    2, 0));
+            assertNotNull("null fragment found at 2,0", a_oFrag);
+            assertEquals(a_oFrag.getId(), "3");
+            assertEquals(a_oFrag.getName(), "frag3");
+
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(2, 1,
+                    2, 1));
+            assertNotNull("null fragment found at 2,1", a_oFrag);
+            assertEquals(a_oFrag.getId(), "4");
+            assertEquals(a_oFrag.getName(), "frag4");
+
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(2, 2,
+                    2, 2));
+            assertNotNull("null fragment found at 2,2", a_oFrag);
+            assertEquals(a_oFrag.getId(), "5");
+            assertEquals(a_oFrag.getName(), "frag5");
+
+        } catch (PortletPlacementException e)
+        {
+            fail("creating the PortletPlacementManager failed");
+        }
+    }
+
+    public void testGetFragmentById()
+    {
+        // Build a request object and populate it with fragments
+        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
+
+        try
+        {
+            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
+
+            // Check the fragments
+            Fragment a_oFrag = ppc.getFragmentById("1");
+            assertNotNull("null fragment with id 1", a_oFrag);
+            assertEquals(a_oFrag.getId(), "1");
+            assertEquals(a_oFrag.getName(), "frag1");
+
+            a_oFrag = ppc.getFragmentById("2");
+            assertNotNull("null fragment with id 2", a_oFrag);
+            assertEquals(a_oFrag.getId(), "2");
+            assertEquals(a_oFrag.getName(), "frag2");
+
+            a_oFrag = ppc.getFragmentById("3");
+            assertNotNull("null fragment with id 3", a_oFrag);
+            assertEquals(a_oFrag.getId(), "3");
+            assertEquals(a_oFrag.getName(), "frag3");
+
+            a_oFrag = ppc.getFragmentById("4");
+            assertNotNull("null fragment with id 4", a_oFrag);
+            assertEquals(a_oFrag.getId(), "4");
+            assertEquals(a_oFrag.getName(), "frag4");
+
+            a_oFrag = ppc.getFragmentById("5");
+            assertNotNull("null fragment with id 5", a_oFrag);
+            assertEquals(a_oFrag.getId(), "5");
+            assertEquals(a_oFrag.getName(), "frag5");
+
+        } catch (PortletPlacementException e)
+        {
+            fail("creating the PortletPlacementManager failed");
+        }
+    }
+
+    public void testRemoveFragment()
+    {
+        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
+
+        try
+        {
+            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
+
+            Fragment a_oFrag = ppc
+                    .getFragmentAtNewCoordinate(new CoordinateImpl(1, 0, 1, 0));
+
+            Coordinate a_oCoordinate = ppc.remove(a_oFrag);
+
+            assertEquals(a_oCoordinate.getOldCol(), 1);
+            assertEquals(a_oCoordinate.getOldRow(), 0);
+
+            // Should be the second fragment now that the first has been deleted
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 0,
+                    1, 0));
+            assertEquals(a_oFrag.getId(), "2");
+            assertEquals(a_oFrag.getName(), "frag2");
+        } catch (PortletPlacementException e)
+        {
+            fail("creating the PortletPlacementManager failed");
+        }
+    }
+
+    public void footestFragmentMoveabs()
+    {
+        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
+
+        try
+        {
+            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
+
+            Fragment a_oFrag = ppc
+                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 0));
+
+            Coordinate a_oCoordinate = ppc.moveAbsolute(a_oFrag, new CoordinateImpl(
+                    0, 0, 0, 1));
+
+            assertEquals(a_oCoordinate.getOldCol(), 0);
+            assertEquals(a_oCoordinate.getOldRow(), 0);
+            assertEquals(a_oCoordinate.getNewCol(), 0);
+            assertEquals(a_oCoordinate.getNewRow(), 1);
+
+            // Should be the second fragment now that the first has been moved
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
+                    0, 0));
+            assertEquals(a_oFrag.getId(), "2");
+            assertEquals(a_oFrag.getName(), "frag2");
+
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
+                    0, 1));
+            assertEquals(a_oFrag.getId(), "1");
+            assertEquals(a_oFrag.getName(), "frag1");
+        } catch (PortletPlacementException e)
+        {
+            fail("creating the PortletPlacementManager failed");
+        }
+    }
+
+    public void footestFragmentMoveUp()
+    {
+        RequestContext requestContext = FragmentUtil.buildFullRequestContext();
+
+        try
+        {
+            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
+
+            Fragment a_oFrag = ppc
+                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 1));
+
+            Coordinate a_oCoordinate = ppc.moveUp(a_oFrag);
+
+            assertEquals(a_oCoordinate.getOldCol(), 0);
+            assertEquals(a_oCoordinate.getOldRow(), 1);
+            assertEquals(a_oCoordinate.getNewCol(), 0);
+            assertEquals(a_oCoordinate.getNewRow(), 0);
+
+            // Should be the second fragment since it was moved up
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
+                    0, 0));
+            assertEquals(a_oFrag.getId(), "2");
+            assertEquals(a_oFrag.getName(), "frag2");
+
+            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
+                    0, 1));
+            assertEquals(a_oFrag.getId(), "1");
+            assertEquals(a_oFrag.getName(), "frag1");
+        } catch (PortletPlacementException e)
+        {
+            fail("creating the PortletPlacementManager failed");
+        }
+    }
+
+}



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


Mime
View raw message