1 16 package org.apache.commons.collections.buffer; 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.BulkTest; 25 import org.apache.commons.collections.collection.AbstractTestCollection; 26 27 34 public class TestUnboundedFifoBuffer extends AbstractTestCollection { 35 36 public TestUnboundedFifoBuffer(String n) { 37 super(n); 38 } 39 40 public static Test suite() { 41 return BulkTest.makeSuite(TestUnboundedFifoBuffer.class); 42 } 43 44 49 public void verify() { 50 super.verify(); 51 Iterator iterator1 = collection.iterator(); 52 Iterator iterator2 = confirmed.iterator(); 53 while (iterator2.hasNext()) { 54 assertTrue(iterator1.hasNext()); 55 Object o1 = iterator1.next(); 56 Object o2 = iterator2.next(); 57 assertEquals(o1, o2); 58 } 59 } 60 61 66 public boolean isNullSupported() { 67 return false; 68 } 69 70 74 public boolean isFailFastSupported() { 75 return false; 76 } 77 78 84 public Collection makeConfirmedCollection() { 85 return new ArrayList (); 86 } 87 88 93 public Collection makeConfirmedFullCollection() { 94 Collection c = makeConfirmedCollection(); 95 c.addAll(java.util.Arrays.asList(getFullElements())); 96 return c; 97 } 98 99 104 public Collection makeCollection() { 105 return new UnboundedFifoBuffer(5); 106 } 107 108 112 public void testUnboundedFifoBufferRemove() { 113 resetFull(); 114 int size = confirmed.size(); 115 for (int i = 0; i < size; i++) { 116 Object o1 = ((UnboundedFifoBuffer)collection).remove(); 117 Object o2 = ((ArrayList )confirmed).remove(0); 118 assertEquals("Removed objects should be equal", o1, o2); 119 verify(); 120 } 121 } 122 123 126 public void testConstructorException1() { 127 try { 128 new UnboundedFifoBuffer(0); 129 } catch (IllegalArgumentException ex) { 130 return; 131 } 132 fail(); 133 } 134 135 138 public void testConstructorException2() { 139 try { 140 new UnboundedFifoBuffer(-20); 141 } catch (IllegalArgumentException ex) { 142 return; 143 } 144 fail(); 145 } 146 147 public String getCompatibilityVersion() { 148 return "3.1"; 149 } 150 151 158 } 159 | Popular Tags |