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

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


  User: julien  
  Date: 06/07/30 20:39:31

  Added:       portlet/src/main/org/jboss/portal/test/portlet 
                        PropertiesTestCase.java
  Log:
  package move of Properties and TransportGuarantee to org.jboss.portal.portlet
  
  Revision  Changes    Path
  1.1      date: 2006/07/31 00:39:31;  author: julien;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/test/portlet/PropertiesTestCase.java
  
  Index: PropertiesTestCase.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 junit.framework.TestCase;
  
  import org.jboss.portal.common.util.Tools;
  import org.jboss.portal.portlet.Properties;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class PropertiesTestCase extends TestCase
  {
  
     public PropertiesTestCase(String name)
     {
        super(name);
     }
  
     public void testA()
     {
        Properties props = new Properties();
        props.setProperty("name1", "value1");
  
        props.addProperty("name2", "value2");
  
        props.setProperty("name3", "value3-1");
        props.addProperty("name3", "value3-2");
  
        props.addProperty("name4", "value4-1");
        props.addProperty("name4", "value4-2");
  
        props.setProperty("name5", "value5-1");
        props.setProperty("name5", "value5-2");
  
        props.addProperty("name6", "value6-1");
        props.setProperty("name6", "value6-2");
  
        assertEquals("value1", props.getProperty("name1"));
        assertEquals(1, props.getProperties("name1").size());
        assertEquals("value1", props.getProperties("name1").get(0));
  
        assertEquals("value2", props.getProperty("name2"));
        assertEquals(1, props.getProperties("name2").size());
        assertEquals("value2", props.getProperties("name2").get(0));
  
        assertEquals("value3-1", props.getProperty("name3"));
        assertEquals(2, props.getProperties("name3").size());
        assertEquals("value3-1", props.getProperties("name3").get(0));
        assertEquals("value3-2", props.getProperties("name3").get(1));
  
        assertEquals("value4-1", props.getProperty("name4"));
        assertEquals(2, props.getProperties("name4").size());
        assertEquals("value4-1", props.getProperties("name4").get(0));
        assertEquals("value4-2", props.getProperties("name4").get(1));
  
        assertEquals(1, props.getProperties("name5").size());
        assertEquals("value5-2", props.getProperties("name5").get(0));
  
        assertEquals("value6-2", props.getProperty("name6"));
        assertEquals(1, props.getProperties("name6").size());
        assertEquals("value6-2", props.getProperties("name6").get(0));
  
        assertEquals(null, props.getProperties("not here"));
        assertNull(props.getProperty("not here"));
        assertEquals(Tools.toSet(new Object[]{"name1","name2","name3","name4","name5","name6"}), props.getPropertyNames());
  
        try
        {
           props.setProperty(null, "not null");
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
  
        try
        {
           props.setProperty("not null", null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
  
        try
        {
           props.setProperty(null, null);
           fail("Expected IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
        }
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list