Source Code Cross Referenced for TestBoundedFifoBuffer.java in  » Library » Apache-common-Collections » org » apache » commons » collections » buffer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common Collections » org.apache.commons.collections.buffer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 2001-2004 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:        package org.apache.commons.collections.buffer;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.Iterator;
021:
022:        import junit.framework.Test;
023:
024:        import org.apache.commons.collections.BufferUnderflowException;
025:        import org.apache.commons.collections.BulkTest;
026:        import org.apache.commons.collections.collection.AbstractTestCollection;
027:
028:        /**
029:         * Test cases for BoundedFifoBuffer.
030:         * 
031:         * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
032:         * 
033:         * @author Paul Jack
034:         */
035:        public class TestBoundedFifoBuffer extends AbstractTestCollection {
036:
037:            public TestBoundedFifoBuffer(String n) {
038:                super (n);
039:            }
040:
041:            public static Test suite() {
042:                return BulkTest.makeSuite(TestBoundedFifoBuffer.class);
043:            }
044:
045:            //-----------------------------------------------------------------------
046:            /**
047:             *  Runs through the regular verifications, but also verifies that 
048:             *  the buffer contains the same elements in the same sequence as the
049:             *  list.
050:             */
051:            public void verify() {
052:                super .verify();
053:                Iterator iterator1 = collection.iterator();
054:                Iterator iterator2 = confirmed.iterator();
055:                while (iterator2.hasNext()) {
056:                    assertTrue(iterator1.hasNext());
057:                    Object o1 = iterator1.next();
058:                    Object o2 = iterator2.next();
059:                    assertEquals(o1, o2);
060:                }
061:            }
062:
063:            //-----------------------------------------------------------------------
064:            /**
065:             * Overridden because UnboundedFifoBuffer doesn't allow null elements.
066:             * @return false
067:             */
068:            public boolean isNullSupported() {
069:                return false;
070:            }
071:
072:            /**
073:             * Overridden because UnboundedFifoBuffer isn't fail fast.
074:             * @return false
075:             */
076:            public boolean isFailFastSupported() {
077:                return false;
078:            }
079:
080:            //-----------------------------------------------------------------------  
081:            /**
082:             *  Returns an empty ArrayList.
083:             *
084:             *  @return an empty ArrayList
085:             */
086:            public Collection makeConfirmedCollection() {
087:                return new ArrayList();
088:            }
089:
090:            /**
091:             *  Returns a full ArrayList.
092:             *
093:             *  @return a full ArrayList
094:             */
095:            public Collection makeConfirmedFullCollection() {
096:                Collection c = makeConfirmedCollection();
097:                c.addAll(java.util.Arrays.asList(getFullElements()));
098:                return c;
099:            }
100:
101:            /**
102:             *  Returns an empty BoundedFifoBuffer that won't overflow.  
103:             *  
104:             *  @return an empty BoundedFifoBuffer
105:             */
106:            public Collection makeCollection() {
107:                return new BoundedFifoBuffer(100);
108:            }
109:
110:            //-----------------------------------------------------------------------  
111:            /**
112:             * Tests that the removal operation actually removes the first element.
113:             */
114:            public void testBoundedFifoBufferRemove() {
115:                resetFull();
116:                int size = confirmed.size();
117:                for (int i = 0; i < size; i++) {
118:                    Object o1 = ((BoundedFifoBuffer) collection).remove();
119:                    Object o2 = ((ArrayList) confirmed).remove(0);
120:                    assertEquals("Removed objects should be equal", o1, o2);
121:                    verify();
122:                }
123:
124:                try {
125:                    ((BoundedFifoBuffer) collection).remove();
126:                    fail("Empty buffer should raise Underflow.");
127:                } catch (BufferUnderflowException e) {
128:                    // expected
129:                }
130:            }
131:
132:            /**
133:             * Tests that the constructor correctly throws an exception.
134:             */
135:            public void testConstructorException1() {
136:                try {
137:                    new BoundedFifoBuffer(0);
138:                } catch (IllegalArgumentException ex) {
139:                    return;
140:                }
141:                fail();
142:            }
143:
144:            /**
145:             * Tests that the constructor correctly throws an exception.
146:             */
147:            public void testConstructorException2() {
148:                try {
149:                    new BoundedFifoBuffer(-20);
150:                } catch (IllegalArgumentException ex) {
151:                    return;
152:                }
153:                fail();
154:            }
155:
156:            /**
157:             * Tests that the constructor correctly throws an exception.
158:             */
159:            public void testConstructorException3() {
160:                try {
161:                    new BoundedFifoBuffer(null);
162:                } catch (NullPointerException ex) {
163:                    return;
164:                }
165:                fail();
166:            }
167:
168:            public String getCompatibilityVersion() {
169:                return "3.1";
170:            }
171:
172:            // BZ 33071 -- gets start=end=1 before removal of interior element
173:            public void testShift() {
174:                BoundedFifoBuffer fifo = new BoundedFifoBuffer(3);
175:                fifo.add("a");
176:                fifo.add("b");
177:                fifo.add("c");
178:                fifo.remove();
179:                fifo.add("e");
180:                fifo.remove("c");
181:            }
182:
183:            //    public void testCreate() throws Exception {
184:            //        resetEmpty();
185:            //        writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/BoundedFifoBuffer.emptyCollection.version3.1.obj");
186:            //        resetFull();
187:            //        writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/BoundedFifoBuffer.fullCollection.version3.1.obj");
188:            //    }
189:
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.