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

Comparing jsr166/src/test/tck/ConcurrentSkipListSubMapTest.java (file contents):
Revision 1.18 by jsr166, Fri May 27 19:21:27 2011 UTC vs.
Revision 1.25 by jsr166, Sat Apr 25 04:55:30 2015 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.*;
9 < import java.util.concurrent.*;
10 < import java.io.*;
7 > import java.util.ArrayList;
8 > import java.util.Arrays;
9 > import java.util.Collection;
10 > import java.util.Iterator;
11 > import java.util.Map;
12 > import java.util.NavigableMap;
13 > import java.util.Set;
14 > import java.util.SortedMap;
15 > import java.util.concurrent.ConcurrentNavigableMap;
16 > import java.util.concurrent.ConcurrentSkipListMap;
17 >
18 > import junit.framework.Test;
19 > import junit.framework.TestSuite;
20  
21   public class ConcurrentSkipListSubMapTest extends JSR166TestCase {
22      public static void main(String[] args) {
23 <        junit.textui.TestRunner.run(suite());
23 >        main(suite(), args);
24      }
25      public static Test suite() {
26          return new TestSuite(ConcurrentSkipListSubMapTest.class);
27      }
28  
29      /**
30 <     * Create a map from Integers 1-5 to Strings "A"-"E".
30 >     * Returns a new map from Integers 1-5 to Strings "A"-"E".
31       */
32      private static ConcurrentNavigableMap map5() {
33          ConcurrentSkipListMap map = new ConcurrentSkipListMap();
# Line 36 | Line 45 | public class ConcurrentSkipListSubMapTes
45      }
46  
47      /**
48 <     * Create a map from Integers -5 to -1 to Strings "A"-"E".
48 >     * Returns a new map from Integers -5 to -1 to Strings "A"-"E".
49       */
50      private static ConcurrentNavigableMap dmap5() {
51          ConcurrentSkipListMap map = new ConcurrentSkipListMap();
# Line 69 | Line 78 | public class ConcurrentSkipListSubMapTes
78      public void testClear() {
79          ConcurrentNavigableMap map = map5();
80          map.clear();
81 <        assertEquals(map.size(), 0);
81 >        assertEquals(0, map.size());
82      }
83  
84      /**
# Line 592 | Line 601 | public class ConcurrentSkipListSubMapTes
601       * A deserialized map equals original
602       */
603      public void testSerialization() throws Exception {
604 <        ConcurrentNavigableMap q = map5();
604 >        NavigableMap x = map5();
605 >        NavigableMap y = serialClone(x);
606  
607 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
608 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
609 <        out.writeObject(q);
610 <        out.close();
611 <
602 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
603 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
604 <        ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
605 <        assertEquals(q.size(), r.size());
606 <        assertTrue(q.equals(r));
607 <        assertTrue(r.equals(q));
607 >        assertNotSame(x, y);
608 >        assertEquals(x.size(), y.size());
609 >        assertEquals(x.toString(), y.toString());
610 >        assertEquals(x, y);
611 >        assertEquals(y, x);
612      }
613  
614      /**
# Line 748 | Line 752 | public class ConcurrentSkipListSubMapTes
752      public void testDescendingClear() {
753          ConcurrentNavigableMap map = dmap5();
754          map.clear();
755 <        assertEquals(map.size(), 0);
755 >        assertEquals(0, map.size());
756      }
757  
758      /**
# Line 1271 | Line 1275 | public class ConcurrentSkipListSubMapTes
1275       * A deserialized map equals original
1276       */
1277      public void testDescendingSerialization() throws Exception {
1278 <        ConcurrentNavigableMap q = dmap5();
1278 >        NavigableMap x = dmap5();
1279 >        NavigableMap y = serialClone(x);
1280  
1281 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
1282 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
1283 <        out.writeObject(q);
1284 <        out.close();
1285 <
1281 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
1282 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1283 <        ConcurrentNavigableMap r = (ConcurrentNavigableMap)in.readObject();
1284 <        assertEquals(q.size(), r.size());
1285 <        assertTrue(q.equals(r));
1286 <        assertTrue(r.equals(q));
1281 >        assertNotSame(x, y);
1282 >        assertEquals(x.size(), y.size());
1283 >        assertEquals(x.toString(), y.toString());
1284 >        assertEquals(x, y);
1285 >        assertEquals(y, x);
1286      }
1287  
1288      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines