Source Code Cross Referenced for TestBagUtils.java in  » Library » Apache-common-Collections » org » apache » commons » collections » 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 
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;
017:
018:        import junit.framework.Test;
019:
020:        import org.apache.commons.collections.bag.HashBag;
021:        import org.apache.commons.collections.bag.PredicatedBag;
022:        import org.apache.commons.collections.bag.PredicatedSortedBag;
023:        import org.apache.commons.collections.bag.SynchronizedBag;
024:        import org.apache.commons.collections.bag.SynchronizedSortedBag;
025:        import org.apache.commons.collections.bag.TransformedBag;
026:        import org.apache.commons.collections.bag.TransformedSortedBag;
027:        import org.apache.commons.collections.bag.TreeBag;
028:        import org.apache.commons.collections.bag.UnmodifiableBag;
029:        import org.apache.commons.collections.bag.UnmodifiableSortedBag;
030:
031:        /**
032:         * Tests for BagUtils factory methods.
033:         * 
034:         * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
035:         *
036:         * @author Phil Steitz
037:         */
038:        public class TestBagUtils extends BulkTest {
039:
040:            public TestBagUtils(String name) {
041:                super (name);
042:            }
043:
044:            public static Test suite() {
045:                return BulkTest.makeSuite(TestBagUtils.class);
046:            }
047:
048:            //----------------------------------------------------------------------
049:
050:            protected Class stringClass = this .getName().getClass();
051:            protected Predicate truePredicate = PredicateUtils.truePredicate();
052:            protected Transformer nopTransformer = TransformerUtils
053:                    .nopTransformer();
054:
055:            //----------------------------------------------------------------------
056:
057:            public void testSynchronizedBag() {
058:                Bag bag = BagUtils.synchronizedBag(new HashBag());
059:                assertTrue("Returned object should be a SynchronizedBag.",
060:                        bag instanceof  SynchronizedBag);
061:                try {
062:                    bag = BagUtils.synchronizedBag(null);
063:                    fail("Expecting IllegalArgumentException for null bag.");
064:                } catch (IllegalArgumentException ex) {
065:                    // expected
066:                }
067:            }
068:
069:            public void testUnmodifiableBag() {
070:                Bag bag = BagUtils.unmodifiableBag(new HashBag());
071:                assertTrue("Returned object should be an UnmodifiableBag.",
072:                        bag instanceof  UnmodifiableBag);
073:                try {
074:                    bag = BagUtils.unmodifiableBag(null);
075:                    fail("Expecting IllegalArgumentException for null bag.");
076:                } catch (IllegalArgumentException ex) {
077:                    // expected
078:                }
079:            }
080:
081:            public void testPredicatedBag() {
082:                Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate);
083:                assertTrue("Returned object should be a PredicatedBag.",
084:                        bag instanceof  PredicatedBag);
085:                try {
086:                    bag = BagUtils.predicatedBag(null, truePredicate);
087:                    fail("Expecting IllegalArgumentException for null bag.");
088:                } catch (IllegalArgumentException ex) {
089:                    // expected
090:                }
091:                try {
092:                    bag = BagUtils.predicatedBag(new HashBag(), null);
093:                    fail("Expecting IllegalArgumentException for null predicate.");
094:                } catch (IllegalArgumentException ex) {
095:                    // expected
096:                }
097:            }
098:
099:            public void testTypedBag() {
100:                Bag bag = BagUtils.typedBag(new HashBag(), stringClass);
101:                assertTrue("Returned object should be a TypedBag.",
102:                        bag instanceof  PredicatedBag);
103:                try {
104:                    bag = BagUtils.typedBag(null, stringClass);
105:                    fail("Expecting IllegalArgumentException for null bag.");
106:                } catch (IllegalArgumentException ex) {
107:                    // expected
108:                }
109:                try {
110:                    bag = BagUtils.typedBag(new HashBag(), null);
111:                    fail("Expecting IllegalArgumentException for null type.");
112:                } catch (IllegalArgumentException ex) {
113:                    // expected
114:                }
115:            }
116:
117:            public void testTransformedBag() {
118:                Bag bag = BagUtils
119:                        .transformedBag(new HashBag(), nopTransformer);
120:                assertTrue("Returned object should be an TransformedBag.",
121:                        bag instanceof  TransformedBag);
122:                try {
123:                    bag = BagUtils.transformedBag(null, nopTransformer);
124:                    fail("Expecting IllegalArgumentException for null bag.");
125:                } catch (IllegalArgumentException ex) {
126:                    // expected
127:                }
128:                try {
129:                    bag = BagUtils.transformedBag(new HashBag(), null);
130:                    fail("Expecting IllegalArgumentException for null transformer.");
131:                } catch (IllegalArgumentException ex) {
132:                    // expected
133:                }
134:            }
135:
136:            public void testSynchronizedSortedBag() {
137:                Bag bag = BagUtils.synchronizedSortedBag(new TreeBag());
138:                assertTrue(
139:                        "Returned object should be a SynchronizedSortedBag.",
140:                        bag instanceof  SynchronizedSortedBag);
141:                try {
142:                    bag = BagUtils.synchronizedSortedBag(null);
143:                    fail("Expecting IllegalArgumentException for null bag.");
144:                } catch (IllegalArgumentException ex) {
145:                    // expected
146:                }
147:            }
148:
149:            public void testUnmodifiableSortedBag() {
150:                Bag bag = BagUtils.unmodifiableSortedBag(new TreeBag());
151:                assertTrue(
152:                        "Returned object should be an UnmodifiableSortedBag.",
153:                        bag instanceof  UnmodifiableSortedBag);
154:                try {
155:                    bag = BagUtils.unmodifiableSortedBag(null);
156:                    fail("Expecting IllegalArgumentException for null bag.");
157:                } catch (IllegalArgumentException ex) {
158:                    // expected
159:                }
160:            }
161:
162:            public void testPredicatedSortedBag() {
163:                Bag bag = BagUtils.predicatedSortedBag(new TreeBag(),
164:                        truePredicate);
165:                assertTrue("Returned object should be a PredicatedSortedBag.",
166:                        bag instanceof  PredicatedSortedBag);
167:                try {
168:                    bag = BagUtils.predicatedSortedBag(null, truePredicate);
169:                    fail("Expecting IllegalArgumentException for null bag.");
170:                } catch (IllegalArgumentException ex) {
171:                    // expected
172:                }
173:                try {
174:                    bag = BagUtils.predicatedSortedBag(new TreeBag(), null);
175:                    fail("Expecting IllegalArgumentException for null predicate.");
176:                } catch (IllegalArgumentException ex) {
177:                    // expected
178:                }
179:            }
180:
181:            public void testTypedSortedBag() {
182:                Bag bag = BagUtils.typedSortedBag(new TreeBag(), stringClass);
183:                assertTrue("Returned object should be a TypedSortedBag.",
184:                        bag instanceof  PredicatedSortedBag);
185:                try {
186:                    bag = BagUtils.typedSortedBag(null, stringClass);
187:                    fail("Expecting IllegalArgumentException for null bag.");
188:                } catch (IllegalArgumentException ex) {
189:                    // expected
190:                }
191:                try {
192:                    bag = BagUtils.typedSortedBag(new TreeBag(), null);
193:                    fail("Expecting IllegalArgumentException for null type.");
194:                } catch (IllegalArgumentException ex) {
195:                    // expected
196:                }
197:            }
198:
199:            public void testTransformedSortedBag() {
200:                Bag bag = BagUtils.transformedSortedBag(new TreeBag(),
201:                        nopTransformer);
202:                assertTrue("Returned object should be an TransformedSortedBag",
203:                        bag instanceof  TransformedSortedBag);
204:                try {
205:                    bag = BagUtils.transformedSortedBag(null, nopTransformer);
206:                    fail("Expecting IllegalArgumentException for null bag.");
207:                } catch (IllegalArgumentException ex) {
208:                    // expected
209:                }
210:                try {
211:                    bag = BagUtils.transformedSortedBag(new TreeBag(), null);
212:                    fail("Expecting IllegalArgumentException for null transformer.");
213:                } catch (IllegalArgumentException ex) {
214:                    // expected
215:                }
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.