< prev index next >

test/jdk/java/util/concurrent/tck/Collection8Test.java

Print this page
rev 48215 : 8060192: Add default method <A> A[] Collection.toArray(IntFunction<A[]> generator)
Reviewed-by: martin, forax, psandoz


 172         if (c instanceof BlockingDeque) {
 173             BlockingDeque q = (BlockingDeque) c;
 174             assertNull(q.pollFirst(randomExpiredTimeout(), randomTimeUnit()));
 175             assertNull(q.pollLast(randomExpiredTimeout(), randomTimeUnit()));
 176         }
 177     }
 178 
 179     public void testNullPointerExceptions() throws InterruptedException {
 180         Collection c = impl.emptyCollection();
 181         assertThrows(
 182             NullPointerException.class,
 183             () -> c.addAll(null),
 184             () -> c.containsAll(null),
 185             () -> c.retainAll(null),
 186             () -> c.removeAll(null),
 187             () -> c.removeIf(null),
 188             () -> c.forEach(null),
 189             () -> c.iterator().forEachRemaining(null),
 190             () -> c.spliterator().forEachRemaining(null),
 191             () -> c.spliterator().tryAdvance(null),
 192             () -> c.toArray(null));
 193 
 194         if (!impl.permitsNulls()) {
 195             assertThrows(
 196                 NullPointerException.class,
 197                 () -> c.add(null));
 198         }
 199         if (!impl.permitsNulls() && c instanceof Queue) {
 200             Queue q = (Queue) c;
 201             assertThrows(
 202                 NullPointerException.class,
 203                 () -> q.offer(null));
 204         }
 205         if (!impl.permitsNulls() && c instanceof Deque) {
 206             Deque d = (Deque) c;
 207             assertThrows(
 208                 NullPointerException.class,
 209                 () -> d.addFirst(null),
 210                 () -> d.addLast(null),
 211                 () -> d.offerFirst(null),
 212                 () -> d.offerLast(null),




 172         if (c instanceof BlockingDeque) {
 173             BlockingDeque q = (BlockingDeque) c;
 174             assertNull(q.pollFirst(randomExpiredTimeout(), randomTimeUnit()));
 175             assertNull(q.pollLast(randomExpiredTimeout(), randomTimeUnit()));
 176         }
 177     }
 178 
 179     public void testNullPointerExceptions() throws InterruptedException {
 180         Collection c = impl.emptyCollection();
 181         assertThrows(
 182             NullPointerException.class,
 183             () -> c.addAll(null),
 184             () -> c.containsAll(null),
 185             () -> c.retainAll(null),
 186             () -> c.removeAll(null),
 187             () -> c.removeIf(null),
 188             () -> c.forEach(null),
 189             () -> c.iterator().forEachRemaining(null),
 190             () -> c.spliterator().forEachRemaining(null),
 191             () -> c.spliterator().tryAdvance(null),
 192             () -> c.toArray((Object[])null));
 193 
 194         if (!impl.permitsNulls()) {
 195             assertThrows(
 196                 NullPointerException.class,
 197                 () -> c.add(null));
 198         }
 199         if (!impl.permitsNulls() && c instanceof Queue) {
 200             Queue q = (Queue) c;
 201             assertThrows(
 202                 NullPointerException.class,
 203                 () -> q.offer(null));
 204         }
 205         if (!impl.permitsNulls() && c instanceof Deque) {
 206             Deque d = (Deque) c;
 207             assertThrows(
 208                 NullPointerException.class,
 209                 () -> d.addFirst(null),
 210                 () -> d.addLast(null),
 211                 () -> d.offerFirst(null),
 212                 () -> d.offerLast(null),


< prev index next >