ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.13 by dl, Sat May 28 14:09:27 2005 UTC vs.
Revision 1.14 by jsr166, Mon Nov 2 20:28:31 2009 UTC

# Line 2 | Line 2
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain
5 < * Other contributors include Andrew Wright, Jeffrey Hayes,
6 < * Pat Fisher, Mike Judd.
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
# Line 14 | Line 14 | import java.io.*;
14  
15   public class ConcurrentHashMapTest extends JSR166TestCase{
16      public static void main(String[] args) {
17 <        junit.textui.TestRunner.run (suite());  
17 >        junit.textui.TestRunner.run (suite());
18      }
19      public static Test suite() {
20          return new TestSuite(ConcurrentHashMapTest.class);
# Line 23 | Line 23 | public class ConcurrentHashMapTest exten
23      /**
24       * Create a map from Integers 1-5 to Strings "A"-"E".
25       */
26 <    private static ConcurrentHashMap map5() {  
26 >    private static ConcurrentHashMap map5() {
27          ConcurrentHashMap map = new ConcurrentHashMap(5);
28          assertTrue(map.isEmpty());
29          map.put(one, "A");
# Line 66 | Line 66 | public class ConcurrentHashMapTest exten
66          assertTrue(map.contains("A"));
67          assertFalse(map.contains("Z"));
68      }
69 <    
69 >
70      /**
71       *  containsKey returns true for contained key
72       */
# Line 216 | Line 216 | public class ConcurrentHashMapTest exten
216          Iterator it = s.iterator();
217          while (it.hasNext()) {
218              Map.Entry e = (Map.Entry) it.next();
219 <            assertTrue(
219 >            assertTrue(
220                         (e.getKey().equals(one) && e.getValue().equals("A")) ||
221                         (e.getKey().equals(two) && e.getValue().equals("B")) ||
222                         (e.getKey().equals(three) && e.getValue().equals("C")) ||
# Line 340 | Line 340 | public class ConcurrentHashMapTest exten
340          for (int i = 1; i <= 5; ++i) {
341              assertTrue(s.indexOf(String.valueOf(i)) >= 0);
342          }
343 <    }        
343 >    }
344  
345      // Exception tests
346 <    
346 >
347      /**
348 <     * Cannot create with negative capacity
348 >     * Cannot create with negative capacity
349       */
350      public void testConstructor1() {
351          try {
# Line 585 | Line 585 | public class ConcurrentHashMapTest exten
585       * SetValue of an EntrySet entry sets value in the map.
586       */
587      public void testSetValueWriteThrough() {
588 <        // Adapted from a bug report by Eric Zoerner
588 >        // Adapted from a bug report by Eric Zoerner
589          ConcurrentHashMap map = new ConcurrentHashMap(2, 5.0f, 1);
590          assertTrue(map.isEmpty());
591          for (int i = 0; i < 20; i++)
592              map.put(new Integer(i), new Integer(i));
593          assertFalse(map.isEmpty());
594          Map.Entry entry1 = (Map.Entry)map.entrySet().iterator().next();
595 <        
595 >
596          // assert that entry1 is not 16
597          assertTrue("entry is 16, test not valid",
598                     !entry1.getKey().equals(new Integer(16)));
599 <        
600 <        // remove 16 (a different key) from map
599 >
600 >        // remove 16 (a different key) from map
601          // which just happens to cause entry1 to be cloned in map
602          map.remove(new Integer(16));
603          entry1.setValue("XYZ");
604          assertTrue(map.containsValue("XYZ")); // fails
605      }
606 <    
606 >
607   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines