Lines Matching refs:collection

98    * Verifies that a collection is immutable.
100 * <p>A collection is considered immutable if:
105 * collection throw UnsupportedOperationException when those mutators
109 * @param collection the presumed-immutable collection
111 * {@code collection}. {@code collection} may or may not have {@code
115 Collection<E> collection, E sampleElement) {
119 copy.addAll(collection);
121 collection.add(sampleElement);
122 fail("add succeeded on unmodifiable collection");
126 assertCollectionsAreEquivalent(copy, collection);
129 collection.addAll(siblingCollection);
130 fail("addAll succeeded on unmodifiable collection");
133 assertCollectionsAreEquivalent(copy, collection);
136 collection.clear();
137 fail("clear succeeded on unmodifiable collection");
140 assertCollectionsAreEquivalent(copy, collection);
142 assertIteratorIsUnmodifiable(collection.iterator());
143 assertCollectionsAreEquivalent(copy, collection);
146 collection.remove(sampleElement);
147 fail("remove succeeded on unmodifiable collection");
150 assertCollectionsAreEquivalent(copy, collection);
153 collection.removeAll(siblingCollection);
154 fail("removeAll succeeded on unmodifiable collection");
157 assertCollectionsAreEquivalent(copy, collection);
160 collection.retainAll(siblingCollection);
161 fail("retainAll succeeded on unmodifiable collection");
164 assertCollectionsAreEquivalent(copy, collection);
211 // Multiset is a collection, so we can use all those tests.
218 fail("add(Object, int) succeeded on unmodifiable collection");
225 fail("remove(Object, int) succeeded on unmodifiable collection");