[jboss-cvs] jboss-portal/portlet/src/main/org/jboss/portal/test/portlet ...

Julien Viet julien at jboss.com
Sun Jul 30 20:20:51 EDT 2006


  User: julien  
  Date: 06/07/30 20:20:51

  Modified:    portlet/src/main/org/jboss/portal/test/portlet  
                        PortletRequestDecoderTestCase.java
  Added:       portlet/src/main/org/jboss/portal/test/portlet  
                        ParametersTestCase.java
  Log:
  move the Parameters class to org.jboss.portal.portlet package
  
  Revision  Changes    Path
  1.4       +2 -2      jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PortletRequestDecoderTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- PortletRequestDecoderTestCase.java	12 Jul 2006 08:17:50 -0000	1.3
  +++ PortletRequestDecoderTestCase.java	31 Jul 2006 00:20:51 -0000	1.4
  @@ -26,7 +26,7 @@
   import org.jboss.portal.portlet.ParametersStateString;
   import org.jboss.portal.portlet.OpaqueStateString;
   import org.jboss.portal.server.request.RequestParameter;
  -import org.jboss.portal.server.util.Parameters;
  +import org.jboss.portal.portlet.Parameters;
   import org.jboss.portal.portlet.Mode;
   import org.jboss.portal.portlet.WindowState;
   
  @@ -35,7 +35,7 @@
   
   /**
    * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class PortletRequestDecoderTestCase extends TestCase
   {
  
  
  
  1.1      date: 2006/07/31 00:20:51;  author: julien;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java
  
  Index: ParametersTestCase.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.test.portlet;
  
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.jboss.portal.test.AbstractTestCase;
  import org.jboss.portal.portlet.Parameters;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class ParametersTestCase
        extends AbstractTestCase
  {
  
     public ParametersTestCase(String name)
     {
        super(name);
     }
  
     private Parameters param;
  
     public void setUp()
     {
        param = new Parameters();
     }
  
     public void tearDown()
     {
        param = null;
     }
  
     public void testGetWithNullName()
     {
        try
        {
           param.getValue(null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testSet()
     {
        param.setValue("a", "b");
        assertEquals(param.getValue("a"), "b");
     }
  
     public void testSetWithNullName()
     {
        try
        {
           param.setValue(null, "b");
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testSetWithNullValue()
     {
        try
        {
           param.setValue("a", null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testRemoveWithNullName()
     {
        try
        {
           param.remove(null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testRemove()
     {
        param.setValue("a", "b");
        param.remove("a");
        assertEquals(param.getValue("a"), null);
     }
  
     public void testSetValues()
     {
        param.setValues("a", new String[] { "b", "c" });
        assertTrue(Arrays.equals(param.getValues("a"), new String[] {
              "b", "c" }));
        assertEquals(param.getValue("a"), "b");
     }
  
     public void testSetValuesWithNullName()
     {
        try
        {
           param.setValues(null, new String[] { "a" });
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testSetValuesWithNullValues()
     {
        try
        {
           param.setValues("a", null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testSetValuesWithZeroLengthValues()
     {
        try
        {
           param.setValues("a", new String[0]);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testSetValuesWithOneNullValue()
     {
        try
        {
           param.setValues("a", new String[] { "a", null });
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testSetValuesWithNullParameters()
     {
        try
        {
           param.replace((Parameters)null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testReplaceWithParameters()
     {
        Parameters other = new Parameters();
        other.setValue("a", "b");
        other.setValues("c", new String[] { "d", "e" });
        param.replace(other);
        assertEquals(param.getValue("a"), "b");
        assertTrue(Arrays.equals(param.getValues("c"), new String[] {
              "d", "e" }));
     }
  
     public void testCopyConstructorWithNullParameters()
     {
        try
        {
           new Parameters((Parameters) null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testCopyConstructorWithNullMap()
     {
        try
        {
           new Parameters((Map) null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testReplaceWithNullMap()
     {
        try
        {
           param.replace((Map)null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testReplaceWithInvalidMap()
     {
        try
        {
           Map map = new HashMap();
           map.put("a", null);
           param.replace(map);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
        try
        {
           Map map = new HashMap();
           map.put("a", new String[0]);
           param.replace(map);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
        try
        {
           Map map = new HashMap();
           map.put("a", new String[] { null });
           param.replace(map);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
        try
        {
           Map map = new HashMap();
           map.put("a", new Object());
           param.replace(map);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
     public void testReplace()
     {
        param.setValue("a", "b");
        param.setValues("c", new String[]{"d","e"});
        param.setValue("f", "g");
        Map map = new HashMap();
        map.put("a", new String[]{"_b"});
        map.put("c", new String[]{"_d","_e"});
        map.put("_f", new String[]{"_g"});
        param.replace(map);
        assertTrue(Arrays.equals(param.getValues("a"), new String[] {"_b"}));
        assertTrue(Arrays.equals(param.getValues("c"), new String[] {"_d","_e"}));
        assertTrue(Arrays.equals(param.getValues("_f"), new String[] {"_g"}));
        assertEquals(null, map.get("g"));
     }
  
     public void testClear()
     {
        param.setValue("a", "b");
        param.clear();
        assertNull(param.getValue("a"));
     }
  }
  
  



More information about the jboss-cvs-commits mailing list