Source Code Cross Referenced for TestGrowthList.java in  » Library » Apache-common-Collections » org » apache » commons » collections » list » 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.list 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 2005 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.list;
017:
018:        import java.util.ArrayList;
019:        import java.util.Arrays;
020:        import java.util.Collection;
021:        import java.util.List;
022:
023:        import junit.framework.Test;
024:        import junit.framework.TestSuite;
025:
026:        /**
027:         * Extension of {@link TestList} for exercising the {@link GrowthList}.
028:         *
029:         * @since Commons Collections 3.2
030:         * @version $Revision: 155406 $ $Date: 2005-05-15 19:30:49 +0100 (Sun, 15 May 2005) $
031:         * 
032:         * @author Stephen Colebourne
033:         */
034:        public class TestGrowthList extends AbstractTestList {
035:
036:            public TestGrowthList(String testName) {
037:                super (testName);
038:            }
039:
040:            public static Test suite() {
041:                return new TestSuite(TestGrowthList.class);
042:            }
043:
044:            public static void main(String args[]) {
045:                String[] testCaseName = { TestGrowthList.class.getName() };
046:                junit.textui.TestRunner.main(testCaseName);
047:            }
048:
049:            public List makeEmptyList() {
050:                return new GrowthList();
051:            }
052:
053:            public List makeFullList() {
054:                List list = new ArrayList();
055:                list.addAll(Arrays.asList(getFullElements()));
056:                return GrowthList.decorate(list);
057:            }
058:
059:            //-----------------------------------------------------------------------
060:            public void testGrowthAdd() {
061:                Integer one = new Integer(1);
062:                GrowthList grower = new GrowthList();
063:                assertEquals(0, grower.size());
064:                grower.add(1, one);
065:                assertEquals(2, grower.size());
066:                assertEquals(null, grower.get(0));
067:                assertEquals(one, grower.get(1));
068:            }
069:
070:            public void testGrowthAddAll() {
071:                Integer one = new Integer(1);
072:                Integer two = new Integer(2);
073:                Collection coll = new ArrayList();
074:                coll.add(one);
075:                coll.add(two);
076:                GrowthList grower = new GrowthList();
077:                assertEquals(0, grower.size());
078:                grower.addAll(1, coll);
079:                assertEquals(3, grower.size());
080:                assertEquals(null, grower.get(0));
081:                assertEquals(one, grower.get(1));
082:                assertEquals(two, grower.get(2));
083:            }
084:
085:            public void testGrowthSet1() {
086:                Integer one = new Integer(1);
087:                GrowthList grower = new GrowthList();
088:                assertEquals(0, grower.size());
089:                grower.set(1, one);
090:                assertEquals(2, grower.size());
091:                assertEquals(null, grower.get(0));
092:                assertEquals(one, grower.get(1));
093:            }
094:
095:            public void testGrowthSet2() {
096:                Integer one = new Integer(1);
097:                GrowthList grower = new GrowthList();
098:                assertEquals(0, grower.size());
099:                grower.set(0, one);
100:                assertEquals(1, grower.size());
101:                assertEquals(one, grower.get(0));
102:            }
103:
104:            //-----------------------------------------------------------------------
105:            /**
106:             * Override.
107:             */
108:            public void testListAddByIndexBoundsChecking() {
109:                List list;
110:                Object element = getOtherElements()[0];
111:                try {
112:                    list = makeEmptyList();
113:                    list.add(-1, element);
114:                    fail("List.add should throw IndexOutOfBoundsException [-1]");
115:                } catch (IndexOutOfBoundsException e) {
116:                    // expected
117:                }
118:            }
119:
120:            /**
121:             * Override.
122:             */
123:            public void testListAddByIndexBoundsChecking2() {
124:                List list;
125:                Object element = getOtherElements()[0];
126:                try {
127:                    list = makeFullList();
128:                    list.add(-1, element);
129:                    fail("List.add should throw IndexOutOfBoundsException [-1]");
130:                } catch (IndexOutOfBoundsException e) {
131:                    // expected
132:                }
133:            }
134:
135:            /**
136:             * Override.
137:             */
138:            public void testListSetByIndexBoundsChecking() {
139:                List list = makeEmptyList();
140:                Object element = getOtherElements()[0];
141:                try {
142:                    list.set(-1, element);
143:                    fail("List.set should throw IndexOutOfBoundsException [-1]");
144:                } catch (IndexOutOfBoundsException e) {
145:                    // expected
146:                }
147:            }
148:
149:            /**
150:             * Override.
151:             */
152:            public void testListSetByIndexBoundsChecking2() {
153:                List list = makeFullList();
154:                Object element = getOtherElements()[0];
155:                try {
156:                    list.set(-1, element);
157:                    fail("List.set should throw IndexOutOfBoundsException [-1]");
158:                } catch (IndexOutOfBoundsException e) {
159:                    // expected
160:                }
161:            }
162:
163:            //-----------------------------------------------------------------------
164:            public String getCompatibilityVersion() {
165:                return "3.2";
166:            }
167:
168:            //    public void testCreate() throws Exception {
169:            //        resetEmpty();
170:            //        writeExternalFormToDisk((java.io.Serializable) collection, "C:/commons/collections/data/test/GrowthList.emptyCollection.version3.2.obj");
171:            //        resetFull();
172:            //        writeExternalFormToDisk((java.io.Serializable) collection, "C:/commons/collections/data/test/GrowthList.fullCollection.version3.2.obj");
173:            //    }
174:
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.