You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/05/10 17:50:15 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestSortedMap.java

scolebourne    2003/05/10 08:50:15

  Modified:    collections/src/test/org/apache/commons/collections/decorators
                        TestAll.java
  Added:       collections/src/test/org/apache/commons/collections/decorators
                        TestFixedSizeSortedMap.java TestFixedSizeList.java
                        TestFixedSizeMap.java
               collections/src/test/org/apache/commons/collections
                        TestSortedMap.java
  Log:
  Add additional decorator tests for FixedSize
  
  Revision  Changes    Path
  1.2       +10 -7     jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestAll.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAll.java	10 May 2003 15:11:58 -0000	1.1
  +++ TestAll.java	10 May 2003 15:50:14 -0000	1.2
  @@ -74,15 +74,18 @@
           super(testName);
       }
   
  +    public static void main(String args[]) {
  +        String[] testCaseName = { TestAll.class.getName() };
  +        junit.textui.TestRunner.main(testCaseName);
  +    }
  +    
       public static Test suite() {
           TestSuite suite = new TestSuite();
  +        suite.addTest(TestFixedSizeList.suite());
  +        suite.addTest(TestFixedSizeMap.suite());
  +        suite.addTest(TestFixedSizeSortedMap.suite());
           suite.addTest(TestSequencedSet.suite());
           return suite;
       }
           
  -    public static void main(String args[]) {
  -        String[] testCaseName = { TestAll.class.getName() };
  -        junit.textui.TestRunner.main(testCaseName);
  -    }
  -    
   }
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeSortedMap.java
  
  Index: TestFixedSizeSortedMap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeSortedMap.java,v 1.1 2003/05/10 15:50:13 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.decorators;
  
  import java.util.Map;
  import java.util.SortedMap;
  import java.util.TreeMap;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.collections.TestSortedMap;
  
  /**
   * Extension of {@link TestSortedMap} for exercising the {@link FixedSizeSortedMap}
   * implementation.
   *
   * @version $Revision: 1.1 $ $Date: 2003/05/10 15:50:13 $
   * 
   * @author Stephen Colebourne
   */
  public class TestFixedSizeSortedMap extends TestSortedMap {
  
      public TestFixedSizeSortedMap(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestFixedSizeSortedMap.class);
      }
  
      public static void main(String args[]) {
          String[] testCaseName = { TestFixedSizeSortedMap.class.getName()};
          junit.textui.TestRunner.main(testCaseName);
      }
  
      public Map makeEmptyMap() {
          return FixedSizeSortedMap.decorate(new TreeMap());
      }
  
      protected Map makeFullMap() {
          SortedMap map = new TreeMap();
          addSampleMappings(map);
          return FixedSizeSortedMap.decorate(map);
      }
      
      protected boolean isAddRemoveModifiable() {
          return false;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeList.java
  
  Index: TestFixedSizeList.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeList.java,v 1.1 2003/05/10 15:50:14 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.decorators;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.collections.TestList;
  
  /**
   * Extension of {@link TestList} for exercising the {@link FixedSizeList}
   * implementation.
   *
   * @version $Revision: 1.1 $ $Date: 2003/05/10 15:50:14 $
   * 
   * @author Stephen Colebourne
   */
  public class TestFixedSizeList extends TestList {
  
      public TestFixedSizeList(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestFixedSizeList.class);
      }
  
      public static void main(String args[]) {
          String[] testCaseName = { TestFixedSizeList.class.getName()};
          junit.textui.TestRunner.main(testCaseName);
      }
  
      public List makeEmptyList() {
          return FixedSizeList.decorate(new ArrayList());
      }
  
      protected List makeFullList() {
          List list = new ArrayList();
          list.addAll(Arrays.asList(getFullElements()));
          return FixedSizeList.decorate(list);
      }
      
      protected boolean isAddSupported() {
          return false;
      }
  
      protected boolean isRemoveSupported() {
          return false;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeMap.java
  
  Index: TestFixedSizeMap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeMap.java,v 1.1 2003/05/10 15:50:14 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.decorators;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.collections.TestMap;
  
  /**
   * Extension of {@link TestMap} for exercising the {@link FixedSizeMap}
   * implementation.
   *
   * @version $Revision: 1.1 $ $Date: 2003/05/10 15:50:14 $
   * 
   * @author Stephen Colebourne
   */
  public class TestFixedSizeMap extends TestMap {
  
      public TestFixedSizeMap(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestFixedSizeMap.class);
      }
  
      public static void main(String args[]) {
          String[] testCaseName = { TestFixedSizeMap.class.getName()};
          junit.textui.TestRunner.main(testCaseName);
      }
  
      public Map makeEmptyMap() {
          return FixedSizeMap.decorate(new HashMap());
      }
  
      protected Map makeFullMap() {
          Map map = new HashMap();
          addSampleMappings(map);
          return FixedSizeMap.decorate(map);
      }
      
      protected boolean isAddRemoveModifiable() {
          return false;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/TestSortedMap.java
  
  Index: TestSortedMap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestSortedMap.java,v 1.1 2003/05/10 15:50:14 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections;
  
  
  /**
   * Tests base {@link java.util.SortedMap} methods and contracts.
   *
   * @version $Revision: 1.1 $ $Date: 2003/05/10 15:50:14 $
   * 
   * @author Stephen Colebourne
   */
  public abstract class TestSortedMap extends TestMap {
  
      public TestSortedMap(String testName) {
          super(testName);
      }
      
      /**
       * Can't sort null keys.
       * 
       * @return false
       */
      protected boolean useNullKey() {
          return false;
      }
  
  
      // TODO: Add the SortedMap tests!
  }
  
  
  

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