Source Code Cross Referenced for ExperimentTest.java in  » Science » Cougaar12_4 » org » cougaar » tools » csmart » experiment » 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 » Science » Cougaar12_4 » org.cougaar.tools.csmart.experiment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * <copyright>
003:         *  
004:         *  Copyright 2002-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */package org.cougaar.tools.csmart.experiment;
026:
027:        import java.io.File;
028:        import java.lang.IllegalArgumentException;
029:        import java.lang.IndexOutOfBoundsException;
030:        import java.util.List;
031:        import junit.framework.Test;
032:        import junit.framework.TestCase;
033:        import junit.framework.TestSuite;
034:        import org.cougaar.tools.csmart.recipe.RecipeBase;
035:        import org.cougaar.tools.csmart.recipe.RecipeComponent;
036:        import org.cougaar.tools.csmart.society.SocietyBase;
037:        import org.cougaar.tools.csmart.society.SocietyComponent;
038:
039:        /**
040:         *  Unit Test for classExperiment
041:         *
042:         *
043:         * Created: Fri Mar 22 13:30:26 2002
044:         *
045:         */
046:        public class ExperimentTest extends TestCase {
047:
048:            private Experiment experiment = null;
049:
050:            /**
051:             * Creates a new <code>ExperimentTest</code> instance.
052:             *
053:             * @param name test name
054:             */
055:            public ExperimentTest(String name) {
056:                super (name);
057:            }
058:
059:            protected void setUp() {
060:                experiment = new DBExperiment("testExperiment");
061:            }
062:
063:            public void testSocietyOperations() {
064:                SocietyComponent sc = new SimpleSociety("Testing");
065:                assertEquals("Test getSocietyComponentCount", 0, experiment
066:                        .getSocietyComponentCount());
067:
068:                experiment.addSocietyComponent(sc);
069:
070:                // Try to add a second one.
071:                try {
072:                    experiment.addSocietyComponent(sc);
073:                    fail("Expected IllegalArgumentException");
074:                } catch (IllegalArgumentException ee) {
075:                }
076:
077:                assertEquals("Test getSocietyComponentCount", 1, experiment
078:                        .getSocietyComponentCount());
079:                assertEquals("Test getSocietyComponent", sc, experiment
080:                        .getSocietyComponent());
081:                experiment.removeSocietyComponent();
082:                assertEquals("Test remove success", 0, experiment
083:                        .getSocietyComponentCount());
084:            }
085:
086:            public void testRecipeOperations() {
087:                RecipeComponent rc = new SimpleRecipe("Testing");
088:                RecipeComponent rc1 = new SimpleRecipe("Testing1");
089:                RecipeComponent rc2 = new SimpleRecipe("Testing2");
090:
091:                assertEquals("Test getRecipeCount", 0, experiment
092:                        .getRecipeComponentCount());
093:
094:                experiment.addRecipeComponent(rc);
095:
096:                // Try to add a second one, of same name.
097:                try {
098:                    experiment.addRecipeComponent(rc);
099:                    fail("Expected IllegalArgumentException");
100:                } catch (IllegalArgumentException ee) {
101:                }
102:
103:                assertEquals("Test getRecipeCount", 1, experiment
104:                        .getRecipeComponentCount());
105:                assertEquals("Test getRecipe(int)", rc, experiment
106:                        .getRecipeComponent(0));
107:
108:                // Try boundries
109:                try {
110:                    experiment.getRecipeComponent(-1);
111:                    fail("Expected IndexOutOfBoundsException");
112:                } catch (IndexOutOfBoundsException ee) {
113:                }
114:
115:                try {
116:                    experiment.getRecipeComponent(5);
117:                    fail("Expected IndexOutOfBoundsException");
118:                } catch (IndexOutOfBoundsException ee) {
119:                }
120:
121:                experiment.removeRecipeComponent(rc);
122:                assertEquals("Test Remove", 0, experiment
123:                        .getRecipeComponentCount());
124:
125:                RecipeComponent[] all = new RecipeComponent[3];
126:                all[0] = rc;
127:                all[1] = rc1;
128:                all[2] = rc2;
129:                experiment.setRecipeComponents(all);
130:                assertEquals("Test setRecipes", 3, experiment
131:                        .getRecipeComponentCount());
132:
133:                RecipeComponent[] dump = experiment.getRecipeComponents();
134:                assertEquals("Test getRecipes 1", all[0], dump[0]);
135:                assertEquals("Test getRecipes 2", all[1], dump[1]);
136:                assertEquals("Test getRecipes 3", all[2], dump[2]);
137:            }
138:
139:            public void testGenericComponentOperations() {
140:                RecipeComponent rc = new SimpleRecipe("r1");
141:                RecipeComponent rc2 = new SimpleRecipe("r2");
142:                SocietyComponent sc = new SimpleSociety("s");
143:
144:                experiment.addComponent(rc);
145:                assertEquals("Test Successful recipe add", 1, experiment
146:                        .getRecipeComponentCount());
147:                experiment.addComponent(sc);
148:                assertEquals("Test Successful society add", 1, experiment
149:                        .getSocietyComponentCount());
150:                assertEquals("Test getComponentCount", 2, experiment
151:                        .getComponentCount());
152:                experiment.removeComponent(rc);
153:                assertEquals("Test Successful recipe add", 0, experiment
154:                        .getRecipeComponentCount());
155:
156:            }
157:
158:            public void testRunInProgress() {
159:                experiment.setRunInProgress(true);
160:                assertEquals("Test Run In Progress", true, experiment
161:                        .isRunInProgress());
162:            }
163:
164:            public void testEditInProgress() {
165:                experiment.setEditInProgress(true);
166:                assertEquals("Test Edit In Progress", true, experiment
167:                        .isEditInProgress());
168:            }
169:
170:            public void testResultDirectory() {
171:                experiment.setResultDirectory(new File("Test"));
172:                assertEquals("Test ResultDirectory", new File("Test"),
173:                        experiment.getResultDirectory());
174:            }
175:
176:            public void testHostComponent() {
177:                HostComponent h = experiment.addHost("New Host");
178:
179:                // Try to add a second one, of same name.
180:                try {
181:                    experiment.addHost("New Host");
182:                    fail("addHost: Expected IllegalArgumentException");
183:                } catch (IllegalArgumentException ee) {
184:                }
185:
186:                try {
187:                    experiment.renameHost(h, "New Host");
188:                    fail("renameHost: Expected IllegalArgumentException");
189:                } catch (IllegalArgumentException ee) {
190:                }
191:
192:                experiment.renameHost(h, "New Name");
193:                HostComponent[] hosts = experiment.getHostComponents();
194:                assertEquals("Test get hosts", h, hosts[0]);
195:
196:                experiment.removeHost(h);
197:                hosts = experiment.getHostComponents();
198:                assertEquals("Test Remove Host", 0, hosts.length);
199:
200:            }
201:
202:            public void testNodeComponent() {
203:                NodeComponent n = experiment.addNode("New Node");
204:
205:                // Try to add a second one, of same name.
206:                try {
207:                    experiment.addNode("New Node");
208:                    fail("addNode: Expected IllegalArgumentException");
209:                } catch (IllegalArgumentException ee) {
210:                }
211:
212:                try {
213:                    experiment.renameNode(n, "New Node");
214:                    fail("renameNode: Expected IllegalArgumentException");
215:                } catch (IllegalArgumentException ee) {
216:                }
217:
218:                experiment.renameNode(n, "New Name");
219:                NodeComponent[] nodes = experiment.getNodeComponents();
220:                assertEquals("Test get nodes", n, nodes[0]);
221:
222:                experiment.removeNode(n);
223:                nodes = experiment.getNodeComponents();
224:                assertEquals("Test Remove Node", 0, nodes.length);
225:
226:            }
227:
228:            /**
229:             * @return a <code>TestSuite</code>
230:             */
231:            public static TestSuite suite() {
232:                return new TestSuite(ExperimentTest.class);
233:            }
234:
235:            /**
236:             * Entry point
237:             */
238:            public static void main(String[] args) {
239:                junit.textui.TestRunner.run(suite());
240:            }
241:
242:            public class SimpleSociety extends SocietyBase {
243:
244:                public SimpleSociety(String name) {
245:                    super (name);
246:                }
247:
248:                public void initProperties() {
249:                }
250:            }
251:
252:            public class SimpleRecipe extends RecipeBase {
253:
254:                public SimpleRecipe(String name) {
255:                    super (name);
256:                }
257:
258:                public void initProperties() {
259:                }
260:            }
261:
262:        }// ExperimentTest
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.