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 2004/06/12 01:29:07 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/bidimap TestDualTreeBidiMap2.java TestAll.java

scolebourne    2004/06/11 16:29:07

  Modified:    collections/src/test/org/apache/commons/collections/bidimap
                        TestAll.java
  Added:       collections/data/test
                        DualTreeBidiMap.fullCollection.version3.Test2.obj
                        DualTreeBidiMap.emptyCollection.version3.Test2.obj
               collections/src/test/org/apache/commons/collections/bidimap
                        TestDualTreeBidiMap2.java
  Log:
  Test DualTreeBidiMap with comparator
  
  Revision  Changes    Path
  1.1                  jakarta-commons/collections/data/test/DualTreeBidiMap.fullCollection.version3.Test2.obj
  
  	<<Binary file>>
  
  
  1.1                  jakarta-commons/collections/data/test/DualTreeBidiMap.emptyCollection.version3.Test2.obj
  
  	<<Binary file>>
  
  
  1.7       +2 -1      jakarta-commons/collections/src/test/org/apache/commons/collections/bidimap/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/bidimap/TestAll.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestAll.java	18 Feb 2004 01:20:40 -0000	1.6
  +++ TestAll.java	11 Jun 2004 23:29:07 -0000	1.7
  @@ -43,6 +43,7 @@
           
           suite.addTest(TestDualHashBidiMap.suite());
           suite.addTest(TestDualTreeBidiMap.suite());
  +        suite.addTest(TestDualTreeBidiMap2.suite());
           suite.addTest(TestTreeBidiMap.suite());
           
           suite.addTest(TestAbstractOrderedBidiMapDecorator.suite());
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap2.java
  
  Index: TestDualTreeBidiMap2.java
  ===================================================================
  /*
   *  Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.commons.collections.bidimap;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  import java.util.Map;
  import java.util.TreeMap;
  
  import junit.framework.Test;
  import junit.textui.TestRunner;
  
  import org.apache.commons.collections.BidiMap;
  import org.apache.commons.collections.BulkTest;
  import org.apache.commons.collections.SortedBidiMap;
  import org.apache.commons.collections.comparators.ComparableComparator;
  import org.apache.commons.collections.comparators.ReverseComparator;
  
  /**
   * JUnit tests.
   * 
   * @version $Revision: 1.1 $ $Date: 2004/06/11 23:29:07 $
   * 
   * @author Matthew Hawthorne
   * @author Stephen Colebourne
   */
  public class TestDualTreeBidiMap2 extends AbstractTestSortedBidiMap {
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
      
      public static Test suite() {
          return BulkTest.makeSuite(TestDualTreeBidiMap2.class);
      }
  
      public TestDualTreeBidiMap2(String testName) {
          super(testName);
      }
  
      public BidiMap makeEmptyBidiMap() {
          return new DualTreeBidiMap(new ReverseComparator(ComparableComparator.getInstance()));
      }
  
      public Map makeConfirmedMap() {
          return new TreeMap(new ReverseComparator(ComparableComparator.getInstance()));
      }
  
      public void testComparator() {
          resetEmpty();
          SortedBidiMap bidi = (SortedBidiMap) map;
          assertNotNull(bidi.comparator());
          assertTrue(bidi.comparator() instanceof ReverseComparator);
      }
  
      public void testSerializeDeserializeCheckComparator() throws Exception {
          SortedBidiMap obj = (SortedBidiMap) makeObject();
          if (obj instanceof Serializable && isTestSerialization()) {
              ByteArrayOutputStream buffer = new ByteArrayOutputStream();
              ObjectOutputStream out = new ObjectOutputStream(buffer);
              out.writeObject(obj);
              out.close();
  
              ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
              Object dest = in.readObject();
              in.close();
              
              SortedBidiMap bidi = (SortedBidiMap) dest;
              assertNotNull(obj.comparator());
              assertNotNull(bidi.comparator());
              assertTrue(bidi.comparator() instanceof ReverseComparator);
          }
      }
  
      public String getCompatibilityVersion() {
          return "3.Test2";
      }
  
      /**
       * Override to prevent infinite recursion of tests.
       */
      public String[] ignoredTests() {
          return new String[] {"TestDualTreeBidiMap2.bulkTestInverseMap.bulkTestInverseMap"};
      }
      
  //    public void testCreate() throws Exception {
  //        resetEmpty();
  //        writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/DualTreeBidiMap.emptyCollection.version3.Test2.obj");
  //        resetFull();
  //        writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/DualTreeBidiMap.fullCollection.version3.Test2.obj");
  //    }
  }
  
  
  

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