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.7 by jsr166, Tue Mar 15 19:47: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  
# Line 15 | Line 15 | import java.io.*;
15  
16   public class AbstractQueueTest extends JSR166TestCase {
17      public static void main(String[] args) {
18 <        junit.textui.TestRunner.run (suite());
18 >        junit.textui.TestRunner.run(suite());
19      }
20      public static Test suite() {
21          return new TestSuite(AbstractQueueTest.class);
22      }
23  
24      static class Succeed extends AbstractQueue<Integer> {
25 <        public boolean offer(Integer x) {
25 >        public boolean offer(Integer x) {
26              if (x == null) throw new NullPointerException();
27 <            return true;
27 >            return true;
28          }
29          public Integer peek() { return one; }
30          public Integer poll() { return one; }
# Line 33 | Line 33 | public class AbstractQueueTest extends J
33      }
34  
35      static class Fail extends AbstractQueue<Integer> {
36 <        public boolean offer(Integer x) {
36 >        public boolean offer(Integer x) {
37              if (x == null) throw new NullPointerException();
38 <            return false;
38 >            return false;
39          }
40          public Integer peek() { return null; }
41          public Integer poll() { return null; }
# Line 59 | Line 59 | public class AbstractQueueTest extends J
59          try {
60              q.add(one);
61              shouldThrow();
62 <        } catch (IllegalStateException success) {
63 <        }
62 >        } catch (IllegalStateException success) {}
63      }
64  
65      /**
# Line 71 | Line 70 | public class AbstractQueueTest extends J
70          try {
71              q.add(null);
72              shouldThrow();
73 <        } catch (NullPointerException success) {
75 <        }
73 >        } catch (NullPointerException success) {}
74      }
75  
76      /**
# Line 91 | Line 89 | public class AbstractQueueTest extends J
89          try {
90              q.remove();
91              shouldThrow();
92 <        } catch (NoSuchElementException success) {
95 <        }
92 >        } catch (NoSuchElementException success) {}
93      }
94  
95  
# Line 112 | Line 109 | public class AbstractQueueTest extends J
109          try {
110              q.element();
111              shouldThrow();
112 <        } catch (NoSuchElementException success) {
116 <        }
112 >        } catch (NoSuchElementException success) {}
113      }
114  
115      /**
116 <     *  addAll(null) throws NPE
116 >     * addAll(null) throws NPE
117       */
118      public void testAddAll1() {
119          try {
120              Succeed q = new Succeed();
121              q.addAll(null);
122              shouldThrow();
123 <        }
128 <        catch (NullPointerException success) {}
123 >        } catch (NullPointerException success) {}
124      }
125  
126      /**
# Line 136 | Line 131 | public class AbstractQueueTest extends J
131              Succeed q = new Succeed();
132              q.addAll(q);
133              shouldThrow();
134 <        }
140 <        catch (IllegalArgumentException success) {}
134 >        } catch (IllegalArgumentException success) {}
135      }
136  
137  
138      /**
139 <     *  addAll of a collection with null elements throws NPE
139 >     * addAll of a collection with null elements throws NPE
140       */
141      public void testAddAll2() {
142          try {
# Line 150 | Line 144 | public class AbstractQueueTest extends J
144              Integer[] ints = new Integer[SIZE];
145              q.addAll(Arrays.asList(ints));
146              shouldThrow();
147 <        }
154 <        catch (NullPointerException success) {}
147 >        } catch (NullPointerException success) {}
148      }
149 +
150      /**
151       * addAll of a collection with any null elements throws NPE after
152       * possibly adding some elements
# Line 165 | Line 159 | public class AbstractQueueTest extends J
159                  ints[i] = new Integer(i);
160              q.addAll(Arrays.asList(ints));
161              shouldThrow();
162 <        }
169 <        catch (NullPointerException success) {}
162 >        } catch (NullPointerException success) {}
163      }
164 +
165      /**
166       * addAll throws ISE if an add fails
167       */
# Line 179 | Line 173 | public class AbstractQueueTest extends J
173                  ints[i] = new Integer(i);
174              q.addAll(Arrays.asList(ints));
175              shouldThrow();
176 <        }
183 <        catch (IllegalStateException success) {}
176 >        } catch (IllegalStateException success) {}
177      }
178  
179   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines