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

Comparing jsr166/src/test/tck/Collection8Test.java (file contents):
Revision 1.23 by jsr166, Mon Nov 14 21:33:58 2016 UTC vs.
Revision 1.25 by jsr166, Tue Nov 15 00:08:25 2016 UTC

# Line 61 | Line 61 | public class Collection8Test extends JSR
61      }
62  
63      /** Checks properties of empty collections. */
64 <    public void testEmptyMeansEmpty() throws InterruptedException {
64 >    public void testEmptyMeansEmpty() throws Throwable {
65          Collection c = impl.emptyCollection();
66          emptyMeansEmpty(c);
67  
68 <        if (c instanceof java.io.Serializable)
69 <            emptyMeansEmpty(serialClone(c));
68 >        if (c instanceof java.io.Serializable) {
69 >            try {
70 >                emptyMeansEmpty(serialClonePossiblyFailing(c));
71 >            } catch (java.io.NotSerializableException ex) {
72 >                // excusable when we have a serializable wrapper around
73 >                // a non-serializable collection, as can happen with:
74 >                // Vector.subList() => wrapped AbstractList$RandomAccessSubList
75 >                if (testImplementationDetails
76 >                    && (! c.getClass().getName().matches(
77 >                                "java.util.Collections.*")))
78 >                    throw ex;
79 >            }
80 >        }
81  
82          Collection clone = cloneableClone(c);
83          if (clone != null)
# Line 389 | Line 400 | public class Collection8Test extends JSR
400      public void testRemoveAfterForEachRemaining() {
401          Collection c = impl.emptyCollection();
402          ThreadLocalRandom rnd = ThreadLocalRandom.current();
403 <        {
403 >        testCollection: {
404              int n = 3 + rnd.nextInt(2);
405              for (int i = 0; i < n; i++) c.add(impl.makeElement(i));
406              Iterator it = c.iterator();
# Line 402 | Line 413 | public class Collection8Test extends JSR
413                  if (c instanceof java.util.concurrent.ArrayBlockingQueue) {
414                      assertIteratorExhausted(it);
415                  } else {
416 <                    it.remove();
416 >                    try { it.remove(); }
417 >                    catch (UnsupportedOperationException ok) {
418 >                        break testCollection;
419 >                    }
420                      assertEquals(n - 1, c.size());
421                      for (int i = 0; i < n - 1; i++)
422                          assertTrue(c.contains(impl.makeElement(i)));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines