1 16 package org.apache.commons.collections; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 22 import junit.framework.Test; 23 24 import org.apache.commons.collections.collection.AbstractTestCollection; 25 26 33 public class TestUnboundedFifoBuffer extends AbstractTestCollection { 34 35 public TestUnboundedFifoBuffer(String n) { 36 super(n); 37 } 38 39 public static Test suite() { 40 return BulkTest.makeSuite(TestUnboundedFifoBuffer.class); 41 } 42 43 48 public void verify() { 49 super.verify(); 50 Iterator iterator1 = collection.iterator(); 51 Iterator iterator2 = confirmed.iterator(); 52 while (iterator2.hasNext()) { 53 assertTrue(iterator1.hasNext()); 54 Object o1 = iterator1.next(); 55 Object o2 = iterator2.next(); 56 assertEquals(o1, o2); 57 } 58 } 59 60 65 public boolean isNullSupported() { 66 return false; 67 } 68 69 73 public boolean isFailFastSupported() { 74 return false; 75 } 76 77 83 public Collection makeConfirmedCollection() { 84 return new ArrayList (); 85 } 86 87 92 public Collection makeConfirmedFullCollection() { 93 Collection c = makeConfirmedCollection(); 94 c.addAll(java.util.Arrays.asList(getFullElements())); 95 return c; 96 } 97 98 103 public Collection makeCollection() { 104 return new UnboundedFifoBuffer(5); 105 } 106 107 111 public void testUnboundedFifoBufferRemove() { 112 resetFull(); 113 int size = confirmed.size(); 114 for (int i = 0; i < size; i++) { 115 Object o1 = ((UnboundedFifoBuffer)collection).remove(); 116 Object o2 = ((ArrayList )confirmed).remove(0); 117 assertEquals("Removed objects should be equal", o1, o2); 118 verify(); 119 } 120 } 121 122 125 public void testConstructorException1() { 126 try { 127 new UnboundedFifoBuffer(0); 128 } catch (IllegalArgumentException ex) { 129 return; 130 } 131 fail(); 132 } 133 134 137 public void testConstructorException2() { 138 try { 139 new UnboundedFifoBuffer(-20); 140 } catch (IllegalArgumentException ex) { 141 return; 142 } 143 fail(); 144 } 145 } 146 147 | Popular Tags |