Source Code Cross Referenced for TestCommandPackage.java in  » Test-Coverage » NoUnit » net » firstpartners » nounit » ui » test » 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 » Test Coverage » NoUnit » net.firstpartners.nounit.ui.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.firstpartners.nounit.ui.test;
002:
003:        /**
004:         * Title:        NoUnit - Identify Classes that are not being unit Tested
005:         *
006:         * Copyright (C) 2001  Paul Browne , FirstPartners.net
007:         *
008:         *
009:         * This program is free software; you can redistribute it and/or 
010:         * modify it under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; either version 2
012:         * of the License, or (at your option) any later version.
013:         *
014:         * This program is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017:         * GNU General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU General Public License
020:         * along with this program; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
022:         *
023:         * @author Paul Browne
024:         * @version 0.7
025:         */
026:
027:        import java.util.HashMap;
028:        import java.util.Iterator;
029:        import java.util.Vector;
030:
031:        import junit.framework.Test;
032:        import junit.framework.TestCase;
033:        import junit.framework.TestSuite;
034:        import net.firstpartners.nounit.ui.common.CommandPackage;
035:
036:        /**
037:         * Test the Command package class in the Junit testrunner
038:         */
039:        public class TestCommandPackage extends TestCase {
040:
041:            /**
042:             * Call the Junit test constructor
043:             * @param name
044:             */
045:            public TestCommandPackage(String name) {
046:                super (name);
047:            }
048:
049:            /**
050:             * Enable Junit to run this Class individually
051:             * @param args
052:             */
053:            public static void main(String[] args) {
054:                junit.textui.TestRunner.run(suite());
055:            }
056:
057:            /**
058:             * Enable Junit to run this class
059:             * @return TestSuite
060:             */
061:            public static Test suite() {
062:                return new TestSuite(TestCommandPackage.class);
063:            }
064:
065:            /**
066:             * Test the creation of the Command Package (Method1) and retrieving Values
067:             * from the command line
068:             * @exception NoUnitException
069:             */
070:            public void testCommandPackageCreation() throws Exception {
071:
072:                String[] tmpSeparateArray = TestUserData.getCommandLineValues();
073:
074:                //Create Command Package
075:                CommandPackage testCommandPackage = new CommandPackage(
076:                        tmpSeparateArray);
077:
078:                //Check that Value Pairs come out ok
079:            }
080:
081:            /**
082:             * Test getting of keys from Command Package
083:             */
084:            public void testGetKeys() throws Exception {
085:
086:                CommandPackage newWP = new CommandPackage();
087:                assertTrue(newWP.getStoreNames() != null);
088:                assertTrue(newWP.getStoreNames().hasNext()); //pre populated with base defaults
089:
090:                //Add values to CommandPackage
091:                newWP.addValue("key1", "value1");
092:                newWP.addValue("key2", "value2");
093:                newWP.addValue("key3", "value3");
094:
095:                Iterator myEnum = newWP.getStoreNames();
096:                assertTrue(newWP.getStoreNames() != null);
097:            }
098:
099:            /**
100:             * Test adding of Keys
101:             */
102:            public void testAddHashTable() throws Exception {
103:
104:                CommandPackage newWP = new CommandPackage();
105:                assertTrue(!newWP.getValuePairs().isEmpty()); //pre populated with base defaults
106:
107:                //Create New Hashtable and add values
108:                HashMap newHash = new HashMap();
109:                newHash.put("key1", "value1");
110:                newHash.put("key2", "value2");
111:                newHash.put("key3", "value3");
112:                newWP.addValues(newHash);
113:
114:                assertTrue(newWP.getValuePairs() != null);
115:                HashMap outHash = newWP.getValuePairs();
116:                assertTrue(!outHash.isEmpty());
117:                assertTrue(outHash.containsKey("key1"));
118:                assertTrue(outHash.containsKey("key2"));
119:                assertTrue(outHash.containsKey("key3"));
120:                assertTrue(outHash.containsKey("key1"));
121:                assertTrue(outHash.containsKey("key2"));
122:                assertTrue(outHash.containsKey("key3"));
123:
124:            }
125:
126:            /**
127:             * Test Storage / Retrieval of Ints
128:             */
129:            public void testStoreGetInt() throws Exception {
130:
131:                CommandPackage newWP = new CommandPackage();
132:
133:                newWP.addValue("num1", new Integer(1024));
134:                newWP.addValue("num2", "876");
135:                newWP.addValue("letters", "xyz");
136:
137:                assertTrue(newWP.getInt("num1") == 1024);
138:                assertTrue(newWP.getInt("num2") == 876);
139:                assertTrue(newWP.getInt("letters") == 0);
140:                assertTrue(newWP.getInt("some-randon-non-existant-key") == 0);
141:
142:            }
143:
144:            /**
145:             * Test Storage / Retrieval of Ints
146:             */
147:            public void testMultipleValues() throws Exception {
148:
149:                CommandPackage newWP = new CommandPackage();
150:
151:                String[] valuesAdd = { "samekey", "value1", "samekey",
152:                        "value2", "samekey", "value3" };
153:
154:                newWP.addValues(valuesAdd);
155:
156:                Object tmpObject = newWP.getValue("samekey");
157:                assertTrue(tmpObject != null);
158:                assertTrue(tmpObject instanceof  Vector);
159:
160:                //Try with normal get object method
161:                Vector tmpVector = (Vector) tmpObject;
162:                assertTrue(!tmpVector.isEmpty());
163:                assertTrue(tmpVector.contains("value1"));
164:                assertTrue(tmpVector.contains("value2"));
165:                assertTrue(tmpVector.contains("value3"));
166:                assertTrue(tmpVector.size() == 3);
167:
168:                //Try with getVector method
169:                tmpVector = newWP.getVector("samekey");
170:                assertTrue(!tmpVector.isEmpty());
171:                assertTrue(tmpVector.contains("value1"));
172:                assertTrue(tmpVector.contains("value2"));
173:                assertTrue(tmpVector.contains("value3"));
174:                assertTrue(tmpVector.size() == 3);
175:
176:            }
177:
178:            /**
179:             * Check Double Add
180:             * Objects added at differenct times should not be vectorized...
181:             */
182:            public void testDoubleAdd() throws Exception {
183:
184:                CommandPackage myWP = new CommandPackage();
185:
186:                myWP.addValue("key1", "value1");
187:
188:                //Unique Values
189:                String[] valuesAdd = { "key1", "value1", "key2", "value2",
190:                        "key3", "value3" };
191:
192:                //Add Twice to try and force vectoization
193:                myWP.addValues(valuesAdd);
194:                myWP.addValues(valuesAdd);
195:
196:                //Test Results
197:                Object tmpObject = myWP.getValue("key1");
198:                assertTrue(tmpObject instanceof  String);
199:
200:            }
201:
202:            /**
203:             * test add additional data
204:             */
205:            public void testAddAdditionalData() {
206:
207:                CommandPackage myWp = new CommandPackage();
208:                myWp.addAdditionalValue("somerandomkeyxxx", "someobject");
209:
210:                Object tmpObject = myWp.getValue("somerandomkeyxxx");
211:                assertTrue(tmpObject != null);
212:                assertTrue(tmpObject instanceof  String);
213:
214:                //now add another value
215:                myWp.addAdditionalValue("somerandomkeyxxx", "someotherobject");
216:                tmpObject = myWp.getValue("somerandomkeyxxx");
217:                assertTrue(tmpObject != null);
218:                assertTrue(tmpObject instanceof  Vector);
219:
220:                //Test contents of Vector
221:                Vector tmpVector = (Vector) tmpObject;
222:                assertTrue(!tmpVector.isEmpty());
223:                assertTrue(tmpVector.contains("someobject"));
224:                assertTrue(tmpVector.contains("someotherobject"));
225:
226:            }
227:
228:            /**
229:             * test remove method
230:             */
231:            public void testRemove() {
232:
233:                CommandPackage myWp = new CommandPackage();
234:                myWp.addValue("X2345", "LLL");
235:                assertTrue(myWp.getValue("X2345") != null);
236:                myWp.remove("X2345");
237:                assertTrue(myWp.getValue("X2345") == null);
238:
239:            }
240:
241:            /**
242:             * Test Move Method
243:             */
244:            public void testMove() {
245:
246:                CommandPackage myWp = new CommandPackage();
247:
248:                myWp.addValue("SomeKey1", "SomeValue");
249:                assertTrue(myWp.getValue("SomeKey1") != null);
250:                assertTrue(myWp.getValue("SomeNewKey1") == null);
251:
252:                myWp.move("SomeKey1", "SomeNewKey1");
253:                assertTrue(myWp.getValue("SomeKey1") == null);
254:                assertTrue(myWp.getValue("SomeNewKey1") != null);
255:
256:            }
257:
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.