@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(e3())); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES) public void testAdd_nullUnsupported() { try { collection.add(null); fail("add(null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)"); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) public void testAdd_unsupportedNotPresent() { try { collection.add(e3()); fail("add(notPresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3()); }
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(samples.e3)); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(e3())); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES) public void testAdd_nullUnsupported() { try { collection.add(null); fail("add(null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)"); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) public void testAdd_unsupportedNotPresent() { try { collection.add(samples.e3); fail("add(notPresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(samples.e3); }
@CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES) public void testAdd_nullUnsupported() { try { collection.add(null); fail("add(null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullMissingWhenNullUnsupported( "Should not contain null after unsupported add(null)"); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) public void testAdd_unsupportedNotPresent() { try { collection.add(e3()); fail("add(notPresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3()); }