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

Comparing jsr166/src/test/tck/ConcurrentLinkedQueueTest.java (file contents):
Revision 1.12 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.13 by jsr166, Sat Nov 21 10:25:05 2009 UTC

# Line 49 | Line 49 | public class ConcurrentLinkedQueueTest e
49          try {
50              ConcurrentLinkedQueue q = new ConcurrentLinkedQueue((Collection)null);
51              shouldThrow();
52 <        }
53 <        catch (NullPointerException success) {}
52 >        } catch (NullPointerException success) {}
53      }
54  
55      /**
# Line 61 | Line 60 | public class ConcurrentLinkedQueueTest e
60              Integer[] ints = new Integer[SIZE];
61              ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints));
62              shouldThrow();
63 <        }
65 <        catch (NullPointerException success) {}
63 >        } catch (NullPointerException success) {}
64      }
65  
66      /**
# Line 131 | Line 129 | public class ConcurrentLinkedQueueTest e
129              ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
130              q.offer(null);
131              shouldThrow();
132 <        } catch (NullPointerException success) { }
132 >        } catch (NullPointerException success) {}
133      }
134  
135      /**
# Line 142 | Line 140 | public class ConcurrentLinkedQueueTest e
140              ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
141              q.add(null);
142              shouldThrow();
143 <        } catch (NullPointerException success) { }
143 >        } catch (NullPointerException success) {}
144      }
145  
146  
# Line 174 | Line 172 | public class ConcurrentLinkedQueueTest e
172              ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
173              q.addAll(null);
174              shouldThrow();
175 <        }
178 <        catch (NullPointerException success) {}
175 >        } catch (NullPointerException success) {}
176      }
177  
178      /**
# Line 186 | Line 183 | public class ConcurrentLinkedQueueTest e
183              ConcurrentLinkedQueue q = populatedQueue(SIZE);
184              q.addAll(q);
185              shouldThrow();
186 <        }
190 <        catch (IllegalArgumentException success) {}
186 >        } catch (IllegalArgumentException success) {}
187      }
188  
189      /**
# Line 199 | Line 195 | public class ConcurrentLinkedQueueTest e
195              Integer[] ints = new Integer[SIZE];
196              q.addAll(Arrays.asList(ints));
197              shouldThrow();
198 <        }
203 <        catch (NullPointerException success) {}
198 >        } catch (NullPointerException success) {}
199      }
200      /**
201       *  addAll of a collection with any null elements throws NPE after
# Line 214 | Line 209 | public class ConcurrentLinkedQueueTest e
209                  ints[i] = new Integer(i);
210              q.addAll(Arrays.asList(ints));
211              shouldThrow();
212 <        }
218 <        catch (NullPointerException success) {}
212 >        } catch (NullPointerException success) {}
213      }
214  
215      /**
# Line 273 | Line 267 | public class ConcurrentLinkedQueueTest e
267          try {
268              q.element();
269              shouldThrow();
270 <        }
277 <        catch (NoSuchElementException success) {}
270 >        } catch (NoSuchElementException success) {}
271      }
272  
273      /**
# Line 288 | Line 281 | public class ConcurrentLinkedQueueTest e
281          try {
282              q.remove();
283              shouldThrow();
284 <        } catch (NoSuchElementException success) {
292 <        }
284 >        } catch (NoSuchElementException success) {}
285      }
286  
287      /**
# Line 468 | Line 460 | public class ConcurrentLinkedQueueTest e
460          q.add(two);
461          q.add(three);
462  
463 <        try {
464 <            for (Iterator it = q.iterator(); it.hasNext();) {
465 <                q.remove();
474 <                it.next();
475 <            }
476 <        }
477 <        catch (ConcurrentModificationException e) {
478 <            shouldThrow();
463 >        for (Iterator it = q.iterator(); it.hasNext();) {
464 >            q.remove();
465 >            it.next();
466          }
467  
468          assertEquals("queue should be empty again", 0, q.size());
# Line 513 | Line 500 | public class ConcurrentLinkedQueueTest e
500      /**
501       * A deserialized serialized queue has same elements in same order
502       */
503 <    public void testSerialization() {
503 >    public void testSerialization() throws Exception {
504          ConcurrentLinkedQueue q = populatedQueue(SIZE);
505 <        try {
506 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
507 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
508 <            out.writeObject(q);
509 <            out.close();
510 <
511 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
512 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
513 <            ConcurrentLinkedQueue r = (ConcurrentLinkedQueue)in.readObject();
514 <            assertEquals(q.size(), r.size());
515 <            while (!q.isEmpty())
529 <                assertEquals(q.remove(), r.remove());
530 <        } catch (Exception e) {
531 <            unexpectedException();
532 <        }
505 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
506 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
507 >        out.writeObject(q);
508 >        out.close();
509 >
510 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
511 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
512 >        ConcurrentLinkedQueue r = (ConcurrentLinkedQueue)in.readObject();
513 >        assertEquals(q.size(), r.size());
514 >        while (!q.isEmpty())
515 >            assertEquals(q.remove(), r.remove());
516      }
517  
518   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines