1 16 package org.apache.commons.collections.buffer; 17 18 import java.util.Arrays ; 19 import java.util.Collection ; 20 21 import junit.framework.Test; 22 23 import org.apache.commons.collections.BoundedCollection; 24 import org.apache.commons.collections.BufferOverflowException; 25 import org.apache.commons.collections.BulkTest; 26 27 35 public class TestBoundedFifoBuffer2 extends TestBoundedFifoBuffer { 36 37 public TestBoundedFifoBuffer2(String n) { 38 super(n); 39 } 40 41 public static Test suite() { 42 return BulkTest.makeSuite(TestBoundedFifoBuffer2.class); 43 } 44 45 52 public Collection makeFullCollection() { 53 return new BoundedFifoBuffer(Arrays.asList(getFullElements())); 54 } 55 56 57 63 public boolean isAddSupported() { 64 return false; 65 } 66 67 68 72 public void testUnsupportedAdd() { 73 } 74 75 76 79 public void testBufferOverflow() { 80 resetFull(); 81 try { 82 collection.add(getOtherElements()[0]); 83 fail("add should raise BufferOverflow."); 84 } catch (BufferOverflowException e) { 85 } 87 verify(); 88 89 try { 90 collection.addAll(Arrays.asList(getOtherElements())); 91 fail("addAll should raise BufferOverflow."); 92 } catch (BufferOverflowException e) { 93 } 95 verify(); 96 } 97 98 101 public void testIsFull() { 102 resetFull(); 103 assertEquals(true, ((BoundedCollection) collection).isFull()); 104 ((BoundedFifoBuffer) collection).remove(); 105 assertEquals(false, ((BoundedCollection) collection).isFull()); 106 ((BoundedFifoBuffer) collection).add("jj"); 107 assertEquals(true, ((BoundedCollection) collection).isFull()); 108 } 109 110 113 public void testMaxSize() { 114 resetFull(); 115 assertEquals(getFullElements().length, ((BoundedCollection) collection).maxSize()); 116 ((BoundedFifoBuffer) collection).remove(); 117 assertEquals(getFullElements().length, ((BoundedCollection) collection).maxSize()); 118 ((BoundedFifoBuffer) collection).add("jj"); 119 assertEquals(getFullElements().length, ((BoundedCollection) collection).maxSize()); 120 } 121 122 } 123 124 | Popular Tags |