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

Comparing jsr166/src/test/tck/AbstractQueueTest.java (file contents):
Revision 1.1 by dl, Sat Jan 10 20:37:20 2004 UTC vs.
Revision 1.8 by jsr166, Fri May 27 19:07:06 2011 UTC

# Line 1 | Line 1
1   /*
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.
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9
9   import junit.framework.*;
10   import java.util.*;
11   import java.util.concurrent.*;
# Line 15 | Line 14 | import java.io.*;
14  
15   public class AbstractQueueTest 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(AbstractQueueTest.class);
21      }
22  
23      static class Succeed extends AbstractQueue<Integer> {
24 <        public boolean offer(Integer x) {
24 >        public boolean offer(Integer x) {
25              if (x == null) throw new NullPointerException();
26 <            return true;
26 >            return true;
27          }
28          public Integer peek() { return one; }
29          public Integer poll() { return one; }
# Line 33 | Line 32 | public class AbstractQueueTest extends J
32      }
33  
34      static class Fail extends AbstractQueue<Integer> {
35 <        public boolean offer(Integer x) {
35 >        public boolean offer(Integer x) {
36              if (x == null) throw new NullPointerException();
37 <            return false;
37 >            return false;
38          }
39          public Integer peek() { return null; }
40          public Integer poll() { return null; }
# Line 59 | Line 58 | public class AbstractQueueTest extends J
58          try {
59              q.add(one);
60              shouldThrow();
61 <        } catch (IllegalStateException success) {
63 <        }
61 >        } catch (IllegalStateException success) {}
62      }
63  
64      /**
# Line 71 | Line 69 | public class AbstractQueueTest extends J
69          try {
70              q.add(null);
71              shouldThrow();
72 <        } catch (NullPointerException success) {
75 <        }
72 >        } catch (NullPointerException success) {}
73      }
74  
75      /**
# Line 91 | Line 88 | public class AbstractQueueTest extends J
88          try {
89              q.remove();
90              shouldThrow();
91 <        } catch (NoSuchElementException success) {
95 <        }
91 >        } catch (NoSuchElementException success) {}
92      }
93  
98
94      /**
95       * element returns normally if peek succeeds
96       */
# Line 112 | Line 107 | public class AbstractQueueTest extends J
107          try {
108              q.element();
109              shouldThrow();
110 <        } catch (NoSuchElementException success) {
116 <        }
110 >        } catch (NoSuchElementException success) {}
111      }
112  
113      /**
114 <     *  addAll(null) throws NPE
114 >     * addAll(null) throws NPE
115       */
116      public void testAddAll1() {
117          try {
118              Succeed q = new Succeed();
119              q.addAll(null);
120              shouldThrow();
121 <        }
128 <        catch (NullPointerException success) {}
121 >        } catch (NullPointerException success) {}
122      }
123  
124      /**
# Line 136 | Line 129 | public class AbstractQueueTest extends J
129              Succeed q = new Succeed();
130              q.addAll(q);
131              shouldThrow();
132 <        }
140 <        catch (IllegalArgumentException success) {}
132 >        } catch (IllegalArgumentException success) {}
133      }
134  
143
135      /**
136 <     *  addAll of a collection with null elements throws NPE
136 >     * addAll of a collection with null elements throws NPE
137       */
138      public void testAddAll2() {
139          try {
# Line 150 | Line 141 | public class AbstractQueueTest extends J
141              Integer[] ints = new Integer[SIZE];
142              q.addAll(Arrays.asList(ints));
143              shouldThrow();
144 <        }
154 <        catch (NullPointerException success) {}
144 >        } catch (NullPointerException success) {}
145      }
146 +
147      /**
148       * addAll of a collection with any null elements throws NPE after
149       * possibly adding some elements
# Line 165 | Line 156 | public class AbstractQueueTest extends J
156                  ints[i] = new Integer(i);
157              q.addAll(Arrays.asList(ints));
158              shouldThrow();
159 <        }
169 <        catch (NullPointerException success) {}
159 >        } catch (NullPointerException success) {}
160      }
161 +
162      /**
163       * addAll throws ISE if an add fails
164       */
# Line 179 | Line 170 | public class AbstractQueueTest extends J
170                  ints[i] = new Integer(i);
171              q.addAll(Arrays.asList(ints));
172              shouldThrow();
173 <        }
183 <        catch (IllegalStateException success) {}
173 >        } catch (IllegalStateException success) {}
174      }
175  
176   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines