51 |
|
|
52 |
|
|
53 |
|
/** |
54 |
< |
* addAll adds each element from the given collection |
54 |
> |
* addAll adds each element from the given collection |
55 |
|
*/ |
56 |
|
public void testAddAll() { |
57 |
|
CopyOnWriteArraySet full = populatedSet(3); |
64 |
|
} |
65 |
|
|
66 |
|
/** |
67 |
< |
* addAll adds each element from the given collection that did not |
67 |
> |
* addAll adds each element from the given collection that did not |
68 |
|
* already exist in the set |
69 |
|
*/ |
70 |
|
public void testAddAll2() { |
78 |
|
} |
79 |
|
|
80 |
|
/** |
81 |
< |
* add will not add the element if it already exists in the set |
81 |
> |
* add will not add the element if it already exists in the set |
82 |
|
*/ |
83 |
|
public void testAdd2() { |
84 |
|
CopyOnWriteArraySet full = populatedSet(3); |
87 |
|
} |
88 |
|
|
89 |
|
/** |
90 |
< |
* add adds the element when it does not exist |
91 |
< |
* in the set |
90 |
> |
* add adds the element when it does not exist |
91 |
> |
* in the set |
92 |
|
*/ |
93 |
|
public void testAdd3() { |
94 |
|
CopyOnWriteArraySet full = populatedSet(3); |
97 |
|
} |
98 |
|
|
99 |
|
/** |
100 |
< |
* clear removes all elements from the set |
100 |
> |
* clear removes all elements from the set |
101 |
|
*/ |
102 |
|
public void testClear() { |
103 |
|
CopyOnWriteArraySet full = populatedSet(3); |
134 |
|
|
135 |
|
|
136 |
|
/** |
137 |
< |
* containsAll returns true for collections with subset of elements |
137 |
> |
* containsAll returns true for collections with subset of elements |
138 |
|
*/ |
139 |
|
public void testContainsAll() { |
140 |
|
CopyOnWriteArraySet full = populatedSet(3); |
147 |
|
} |
148 |
|
|
149 |
|
/** |
150 |
< |
* isEmpty is true when empty, else false |
150 |
> |
* isEmpty is true when empty, else false |
151 |
|
*/ |
152 |
|
public void testIsEmpty() { |
153 |
|
CopyOnWriteArraySet empty = new CopyOnWriteArraySet(); |
157 |
|
} |
158 |
|
|
159 |
|
/** |
160 |
< |
* iterator() returns an iterator containing the elements of the set |
160 |
> |
* iterator() returns an iterator containing the elements of the set |
161 |
|
*/ |
162 |
|
public void testIterator() { |
163 |
|
CopyOnWriteArraySet full = populatedSet(3); |
178 |
|
try { |
179 |
|
it.remove(); |
180 |
|
shouldThrow(); |
181 |
< |
} |
182 |
< |
catch (UnsupportedOperationException success) {} |
181 |
> |
} catch (UnsupportedOperationException success) {} |
182 |
|
} |
183 |
|
|
184 |
|
/** |
194 |
|
|
195 |
|
|
196 |
|
/** |
197 |
< |
* removeAll removes all elements from the given collection |
197 |
> |
* removeAll removes all elements from the given collection |
198 |
|
*/ |
199 |
|
public void testRemoveAll() { |
200 |
|
CopyOnWriteArraySet full = populatedSet(3); |
217 |
|
} |
218 |
|
|
219 |
|
/** |
220 |
< |
* size returns the number of elements |
220 |
> |
* size returns the number of elements |
221 |
|
*/ |
222 |
|
public void testSize() { |
223 |
|
CopyOnWriteArraySet empty = new CopyOnWriteArraySet(); |
227 |
|
} |
228 |
|
|
229 |
|
/** |
230 |
< |
* toArray returns an Object array containing all elements from the set |
230 |
> |
* toArray returns an Object array containing all elements from the set |
231 |
|
*/ |
232 |
|
public void testToArray() { |
233 |
|
CopyOnWriteArraySet full = populatedSet(3); |
239 |
|
} |
240 |
|
|
241 |
|
/** |
242 |
< |
* toArray returns an Integer array containing all elements from |
243 |
< |
* the set |
242 |
> |
* toArray returns an Integer array containing all elements from |
243 |
> |
* the set |
244 |
|
*/ |
245 |
|
public void testToArray2() { |
246 |
|
CopyOnWriteArraySet full = populatedSet(3); |
270 |
|
/** |
271 |
|
* A deserialized serialized set is equal |
272 |
|
*/ |
273 |
< |
public void testSerialization() { |
273 |
> |
public void testSerialization() throws Exception { |
274 |
|
CopyOnWriteArraySet q = populatedSet(SIZE); |
275 |
|
|
276 |
< |
try { |
277 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
278 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
279 |
< |
out.writeObject(q); |
280 |
< |
out.close(); |
281 |
< |
|
282 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
283 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
284 |
< |
CopyOnWriteArraySet r = (CopyOnWriteArraySet)in.readObject(); |
285 |
< |
assertEquals(q.size(), r.size()); |
286 |
< |
assertTrue(q.equals(r)); |
288 |
< |
assertTrue(r.equals(q)); |
289 |
< |
} catch (Exception e) { |
290 |
< |
unexpectedException(); |
291 |
< |
} |
276 |
> |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
277 |
> |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
278 |
> |
out.writeObject(q); |
279 |
> |
out.close(); |
280 |
> |
|
281 |
> |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
282 |
> |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
283 |
> |
CopyOnWriteArraySet r = (CopyOnWriteArraySet)in.readObject(); |
284 |
> |
assertEquals(q.size(), r.size()); |
285 |
> |
assertTrue(q.equals(r)); |
286 |
> |
assertTrue(r.equals(q)); |
287 |
|
} |
288 |
|
|
289 |
|
} |