1 16 package org.apache.commons.collections; 17 18 import java.util.Arrays ; 19 import java.util.Collection ; 20 21 import junit.framework.Test; 22 23 31 public class TestBoundedFifoBuffer2 extends TestBoundedFifoBuffer { 32 33 public TestBoundedFifoBuffer2(String n) { 34 super(n); 35 } 36 37 public static Test suite() { 38 return BulkTest.makeSuite(TestBoundedFifoBuffer2.class); 39 } 40 41 48 public Collection makeFullCollection() { 49 return new BoundedFifoBuffer(Arrays.asList(getFullElements())); 50 } 51 52 53 59 public boolean isAddSupported() { 60 return false; 61 } 62 63 64 68 public void testUnsupportedAdd() { 69 } 70 71 72 75 public void testBufferOverflow() { 76 resetFull(); 77 try { 78 collection.add(getOtherElements()[0]); 79 fail("add should raise BufferOverflow."); 80 } catch (BufferOverflowException e) { 81 } 83 verify(); 84 85 try { 86 collection.addAll(Arrays.asList(getOtherElements())); 87 fail("addAll should raise BufferOverflow."); 88 } catch (BufferOverflowException e) { 89 } 91 verify(); 92 } 93 94 97 public void testIsFull() { 98 resetFull(); 99 assertEquals(true, ((BoundedCollection) collection).isFull()); 100 ((BoundedFifoBuffer) collection).remove(); 101 assertEquals(false, ((BoundedCollection) collection).isFull()); 102 ((BoundedFifoBuffer) collection).add("jj"); 103 assertEquals(true, ((BoundedCollection) collection).isFull()); 104 } 105 106 109 public void testMaxSize() { 110 resetFull(); 111 assertEquals(getFullElements().length, ((BoundedCollection) collection).maxSize()); 112 ((BoundedFifoBuffer) collection).remove(); 113 assertEquals(getFullElements().length, ((BoundedCollection) collection).maxSize()); 114 ((BoundedFifoBuffer) collection).add("jj"); 115 assertEquals(getFullElements().length, ((BoundedCollection) collection).maxSize()); 116 } 117 118 } 119 120 | Popular Tags |