commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815118 - /commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java
Date Tue, 15 Sep 2009 05:57:16 GMT
Author: bayard
Date: Tue Sep 15 05:57:16 2009
New Revision: 815118

URL: http://svn.apache.org/viewvc?rev=815118&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified;
mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r814050 | sebb | 2009-09-11 15:01:25 -0700 (Fri, 11 Sep 2009) | 1 line
    
    Some minor Javadoc fixes
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java?rev=815118&r1=815117&r2=815118&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java
(original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java
Tue Sep 15 05:57:16 2009
@@ -45,7 +45,7 @@
     Integer THREE = new Integer(3);
     Integer FOUR = new Integer(4);
     Integer FIVE = new Integer(5);
-    
+
     public TestMultiKey(String name) {
         super(name);
     }
@@ -66,87 +66,87 @@
     protected void tearDown() throws Exception {
         super.tearDown();
     }
-    
+
     //-----------------------------------------------------------------------
     public void testConstructors() throws Exception {
-        MultiKey mk = null;
-        mk = new MultiKey(ONE, TWO);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO}, mk.getKeys()));
+        MultiKey<Integer> mk = null;
+        mk = new MultiKey<Integer>(ONE, TWO);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO }, mk.getKeys()));
 
-        mk = new MultiKey(ONE, TWO, THREE);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE}, mk.getKeys()));
+        mk = new MultiKey<Integer>(ONE, TWO, THREE);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE }, mk.getKeys()));
 
-        mk = new MultiKey(ONE, TWO, THREE, FOUR);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE, FOUR}, mk.getKeys()));
+        mk = new MultiKey<Integer>(ONE, TWO, THREE, FOUR);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR }, mk.getKeys()));
 
-        mk = new MultiKey(ONE, TWO, THREE, FOUR, FIVE);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE, FOUR, FIVE}, mk.getKeys()));
+        mk = new MultiKey<Integer>(ONE, TWO, THREE, FOUR, FIVE);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR, FIVE }, mk.getKeys()));
 
-        mk = new MultiKey(new Object[] {THREE, FOUR, ONE, TWO}, false);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        mk = new MultiKey<Integer>(new Integer[] { THREE, FOUR, ONE, TWO }, false);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
     }
-    
+
     public void testConstructorsByArray() throws Exception {
-        MultiKey mk = null;
-        Object[] keys = new Object[] {THREE, FOUR, ONE, TWO};
-        mk = new MultiKey(keys);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        MultiKey<Integer> mk = null;
+        Integer[] keys = new Integer[] { THREE, FOUR, ONE, TWO };
+        mk = new MultiKey<Integer>(keys);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
         keys[3] = FIVE;  // no effect
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
 
-        keys = new Object[] {};
-        mk = new MultiKey(keys);
+        keys = new Integer[] {};
+        mk = new MultiKey<Integer>(keys);
         Assert.assertTrue(Arrays.equals(new Object[] {}, mk.getKeys()));
 
-        keys = new Object[] {THREE, FOUR, ONE, TWO};
-        mk = new MultiKey(keys, true);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        keys = new Integer[] { THREE, FOUR, ONE, TWO };
+        mk = new MultiKey<Integer>(keys, true);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
         keys[3] = FIVE;  // no effect
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
 
-        keys = new Object[] {THREE, FOUR, ONE, TWO};
-        mk = new MultiKey(keys, false);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        keys = new Integer[] { THREE, FOUR, ONE, TWO };
+        mk = new MultiKey<Integer>(keys, false);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
         // change key - don't do this!
         // the hashcode of the MultiKey is now broken
         keys[3] = FIVE;
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, FIVE}, mk.getKeys()));
-    }        
-    
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, FIVE }, mk.getKeys()));
+    }
+
     public void testConstructorsByArrayNull() throws Exception {
-        Object[] keys = null;
+        Integer[] keys = null;
         try {
-            new MultiKey(keys);
+            new MultiKey<Integer>(keys);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            new MultiKey(keys, true);
+            new MultiKey<Integer>(keys, true);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            new MultiKey(keys, false);
+            new MultiKey<Integer>(keys, false);
             fail();
         } catch (IllegalArgumentException ex) {}
     }
-    
+
     public void testSize() {
-        Assert.assertEquals(2, new MultiKey(ONE, TWO).size());
-        Assert.assertEquals(2, new MultiKey(null, null).size());
-        Assert.assertEquals(3, new MultiKey(ONE, TWO, THREE).size());
-        Assert.assertEquals(3, new MultiKey(null, null, null).size());
-        Assert.assertEquals(4, new MultiKey(ONE, TWO, THREE, FOUR).size());
-        Assert.assertEquals(4, new MultiKey(null, null, null, null).size());
-        Assert.assertEquals(5, new MultiKey(ONE, TWO, THREE, FOUR, FIVE).size());
-        Assert.assertEquals(5, new MultiKey(null, null, null, null, null).size());
-        
-        Assert.assertEquals(0, new MultiKey(new Object[] {}).size());
-        Assert.assertEquals(1, new MultiKey(new Object[] {ONE}).size());
-        Assert.assertEquals(2, new MultiKey(new Object[] {ONE, TWO}).size());
-        Assert.assertEquals(7, new MultiKey(new Object[] {ONE, TWO, ONE, TWO, ONE, TWO, ONE}).size());
+        Assert.assertEquals(2, new MultiKey<Integer>(ONE, TWO).size());
+        Assert.assertEquals(2, new MultiKey<Object>(null, null).size());
+        Assert.assertEquals(3, new MultiKey<Integer>(ONE, TWO, THREE).size());
+        Assert.assertEquals(3, new MultiKey<Object>(null, null, null).size());
+        Assert.assertEquals(4, new MultiKey<Integer>(ONE, TWO, THREE, FOUR).size());
+        Assert.assertEquals(4, new MultiKey<Object>(null, null, null, null).size());
+        Assert.assertEquals(5, new MultiKey<Integer>(ONE, TWO, THREE, FOUR, FIVE).size());
+        Assert.assertEquals(5, new MultiKey<Object>(null, null, null, null, null).size());
+
+        Assert.assertEquals(0, new MultiKey<Object>(new Object[] {}).size());
+        Assert.assertEquals(1, new MultiKey<Integer>(new Integer[] { ONE }).size());
+        Assert.assertEquals(2, new MultiKey<Integer>(new Integer[] { ONE, TWO }).size());
+        Assert.assertEquals(7, new MultiKey<Integer>(new Integer[] { ONE, TWO, ONE,
TWO, ONE, TWO, ONE }).size());
     }
-    
+
     public void testGetIndexed() {
-        MultiKey mk = new MultiKey(ONE, TWO);
+        MultiKey<Integer> mk = new MultiKey<Integer>(ONE, TWO);
         Assert.assertSame(ONE, mk.getKey(0));
         Assert.assertSame(TWO, mk.getKey(1));
         try {
@@ -158,18 +158,18 @@
             fail();
         } catch (IndexOutOfBoundsException ex) {}
     }
-    
+
     public void testGetKeysSimpleConstructor() {
-        MultiKey mk = new MultiKey(ONE, TWO);
+        MultiKey<Integer> mk = new MultiKey<Integer>(ONE, TWO);
         Object[] array = mk.getKeys();
         Assert.assertSame(ONE, array[0]);
         Assert.assertSame(TWO, array[1]);
         Assert.assertEquals(2, array.length);
     }
-    
+
     public void testGetKeysArrayConstructorCloned() {
-        Object[] keys = new Object[] {ONE, TWO};
-        MultiKey mk = new MultiKey(keys, true);
+        Integer[] keys = new Integer[] { ONE, TWO };
+        MultiKey<Integer> mk = new MultiKey<Integer>(keys, true);
         Object[] array = mk.getKeys();
         Assert.assertTrue(array != keys);
         Assert.assertTrue(Arrays.equals(array, keys));
@@ -177,10 +177,10 @@
         Assert.assertSame(TWO, array[1]);
         Assert.assertEquals(2, array.length);
     }
-    
+
     public void testGetKeysArrayConstructorNonCloned() {
-        Object[] keys = new Object[] {ONE, TWO};
-        MultiKey mk = new MultiKey(keys, false);
+        Integer[] keys = new Integer[] { ONE, TWO };
+        MultiKey<Integer> mk = new MultiKey<Integer>(keys, false);
         Object[] array = mk.getKeys();
         Assert.assertTrue(array != keys);  // still not equal
         Assert.assertTrue(Arrays.equals(array, keys));
@@ -188,32 +188,32 @@
         Assert.assertSame(TWO, array[1]);
         Assert.assertEquals(2, array.length);
     }
-    
+
     public void testHashCode() {
-        MultiKey mk1 = new MultiKey(ONE, TWO);
-        MultiKey mk2 = new MultiKey(ONE, TWO);
-        MultiKey mk3 = new MultiKey(ONE, "TWO");
-        
+        MultiKey<Integer> mk1 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Integer> mk2 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Object> mk3 = new MultiKey<Object>(ONE, "TWO");
+
         Assert.assertTrue(mk1.hashCode() == mk1.hashCode());
         Assert.assertTrue(mk1.hashCode() == mk2.hashCode());
         Assert.assertTrue(mk1.hashCode() != mk3.hashCode());
-        
+
         int total = (0 ^ ONE.hashCode()) ^ TWO.hashCode();
         Assert.assertEquals(total, mk1.hashCode());
     }
-    
+
     public void testEquals() {
-        MultiKey mk1 = new MultiKey(ONE, TWO);
-        MultiKey mk2 = new MultiKey(ONE, TWO);
-        MultiKey mk3 = new MultiKey(ONE, "TWO");
-        
+        MultiKey<Integer> mk1 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Integer> mk2 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Object> mk3 = new MultiKey<Object>(ONE, "TWO");
+
         Assert.assertEquals(mk1, mk1);
         Assert.assertEquals(mk1, mk2);
         Assert.assertTrue(mk1.equals(mk3) == false);
         Assert.assertTrue(mk1.equals("") == false);
         Assert.assertTrue(mk1.equals(null) == false);
     }
-    
+
     static class SystemHashCodeSimulatingKey implements Serializable {
 
         private static final long serialVersionUID = 1L;



Mime
View raw message