Source Code Cross Referenced for TestSubmissionModel.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » gui » model » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.gui.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: TestSubmissionModel.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.gui.model;
009:
010:        import java.util.Iterator;
011:
012:        import junit.framework.TestCase;
013:
014:        import com.uwyn.rife.gui.model.exceptions.GuiModelException;
015:
016:        public class TestSubmissionModel extends TestCase implements 
017:                ParticleModelListener {
018:            private Object mPropertyAdded = null;
019:            private Object mPropertyRemoved = null;
020:            private Object mPropertyRenamed = null;
021:
022:            public TestSubmissionModel(String name) {
023:                super (name);
024:            }
025:
026:            public void testInstantiation() {
027:                ElementModel elementmodel_instance = null;
028:                SubmissionModel submissionmodel_instance = null;
029:
030:                try {
031:                    elementmodel_instance = new ElementModel("elementmodel1");
032:                    submissionmodel_instance = new SubmissionModel(
033:                            elementmodel_instance, "submissionmodel1");
034:                } catch (GuiModelException e) {
035:                    assertTrue(e.getMessage(), false);
036:                }
037:
038:                assertTrue(submissionmodel_instance != null);
039:                assertTrue(submissionmodel_instance instanceof  SubmissionModel);
040:                assertSame(submissionmodel_instance.getParent(),
041:                        elementmodel_instance);
042:                assertTrue(elementmodel_instance
043:                        .containsChild(submissionmodel_instance));
044:            }
045:
046:            public void testGetId() {
047:                ElementModel elementmodel_instance = null;
048:                SubmissionModel submissionmodel_instance = null;
049:                SubmissionIdModel titlemodel_instance = null;
050:
051:                try {
052:                    elementmodel_instance = new ElementModel("elementmodel1");
053:                    submissionmodel_instance = new SubmissionModel(
054:                            elementmodel_instance, "submissionmodel1");
055:                } catch (GuiModelException e) {
056:                    assertTrue(e.getMessage(), false);
057:                }
058:
059:                titlemodel_instance = submissionmodel_instance.getId();
060:
061:                assertTrue(titlemodel_instance != null);
062:                assertTrue(titlemodel_instance instanceof  SubmissionIdModel);
063:                assertEquals(titlemodel_instance.getName(), "submissionmodel1");
064:            }
065:
066:            public void testChangeId() {
067:                ElementModel elementmodel_instance = null;
068:                SubmissionModel submissionmodel_instance = null;
069:                SubmissionIdModel titlemodel_instance = null;
070:
071:                try {
072:                    elementmodel_instance = new ElementModel("elementmodel1");
073:                    submissionmodel_instance = new SubmissionModel(
074:                            elementmodel_instance, "submissionmodel1");
075:                } catch (GuiModelException e) {
076:                    assertTrue(e.getMessage(), false);
077:                }
078:                assertTrue(submissionmodel_instance.addParticleListener(this ));
079:                titlemodel_instance = submissionmodel_instance.getId();
080:                assertNull(mPropertyRenamed);
081:
082:                try {
083:                    assertTrue(submissionmodel_instance.renameProperty(
084:                            titlemodel_instance, "submissionmodel2"));
085:                } catch (GuiModelException e) {
086:                    assertTrue(e.getMessage(), false);
087:                }
088:                assertSame(mPropertyRenamed, titlemodel_instance);
089:            }
090:
091:            public void testChangeIdToSameName() {
092:                ElementModel elementmodel_instance = null;
093:                SubmissionModel submissionmodel_instance = null;
094:                SubmissionIdModel titlemodel_instance = null;
095:
096:                try {
097:                    elementmodel_instance = new ElementModel("elementmodel1");
098:                    submissionmodel_instance = new SubmissionModel(
099:                            elementmodel_instance, "submissionmodel1");
100:                } catch (GuiModelException e) {
101:                    assertTrue(e.getMessage(), false);
102:                }
103:                assertTrue(submissionmodel_instance.addParticleListener(this ));
104:                titlemodel_instance = submissionmodel_instance.getId();
105:                assertNull(mPropertyRenamed);
106:
107:                try {
108:                    assertTrue(submissionmodel_instance.renameProperty(
109:                            titlemodel_instance, "submissionmodel1") == false);
110:                } catch (GuiModelException e) {
111:                    assertTrue(e.getMessage(), false);
112:                }
113:                assertNull(mPropertyRenamed);
114:            }
115:
116:            public void testTryToRemoveId() {
117:                ElementModel elementmodel_instance = null;
118:                SubmissionModel submissionmodel_instance = null;
119:                SubmissionIdModel titlemodel_instance = null;
120:
121:                try {
122:                    elementmodel_instance = new ElementModel("elementmodel1");
123:                    submissionmodel_instance = new SubmissionModel(
124:                            elementmodel_instance, "submissionmodel1");
125:                } catch (GuiModelException e) {
126:                    assertTrue(e.getMessage(), false);
127:                }
128:                assertTrue(submissionmodel_instance.addParticleListener(this ));
129:                titlemodel_instance = submissionmodel_instance.getId();
130:                assertNull(mPropertyRemoved);
131:
132:                try {
133:                    submissionmodel_instance
134:                            .removeProperty(titlemodel_instance);
135:                    fail();
136:                } catch (GuiModelException e) {
137:                    assertTrue(true);
138:                }
139:                assertNull(mPropertyRemoved);
140:            }
141:
142:            public void testIdConflicts() {
143:                ElementModel elementmodel_instance = null;
144:                SubmissionModel submissionmodel_instance1 = null;
145:
146:                try {
147:                    elementmodel_instance = new ElementModel("elementmodel1");
148:                    submissionmodel_instance1 = new SubmissionModel(
149:                            elementmodel_instance, "submissionmodel1");
150:                } catch (GuiModelException e) {
151:                    assertTrue(e.getMessage(), false);
152:                }
153:
154:                try {
155:                    submissionmodel_instance1.addParameter("parameter1");
156:                } catch (GuiModelException e) {
157:                    assertTrue(e.getMessage(), false);
158:                }
159:
160:                try {
161:                    new SubmissionModel(elementmodel_instance, "parameter1");
162:                    new SubmissionModel(elementmodel_instance,
163:                            "submissionmodel2");
164:                } catch (GuiModelException e) {
165:                    assertTrue(e.getMessage(), false);
166:                }
167:
168:                try {
169:                    new SubmissionModel(elementmodel_instance,
170:                            "submissionmodel1");
171:                    fail();
172:                } catch (GuiModelException e) {
173:                    assertTrue(true);
174:                }
175:            }
176:
177:            public void testNoInitialParameters() {
178:                ElementModel elementmodel_instance = null;
179:                SubmissionModel submissionmodel_instance = null;
180:
181:                try {
182:                    elementmodel_instance = new ElementModel("elementmodel1");
183:                    submissionmodel_instance = new SubmissionModel(
184:                            elementmodel_instance, "submissionmodel1");
185:                } catch (GuiModelException e) {
186:                    assertTrue(e.getMessage(), false);
187:                }
188:
189:                assertEquals(submissionmodel_instance.getParameters().size(), 0);
190:            }
191:
192:            public void testInitialParameterCountIsZero() {
193:                ElementModel elementmodel_instance = null;
194:                SubmissionModel submissionmodel_instance = null;
195:
196:                try {
197:                    elementmodel_instance = new ElementModel("elementmodel1");
198:                    submissionmodel_instance = new SubmissionModel(
199:                            elementmodel_instance, "submissionmodel1");
200:                } catch (GuiModelException e) {
201:                    assertTrue(e.getMessage(), false);
202:                }
203:
204:                assertEquals(submissionmodel_instance.countParameters(), 0);
205:            }
206:
207:            public void testAddOneParameter() {
208:                ElementModel elementmodel_instance = null;
209:                SubmissionModel submissionmodel_instance = null;
210:                SubmissionParameterModel parametermodel_instance = null;
211:
212:                try {
213:                    elementmodel_instance = new ElementModel("elementmodel1");
214:                    submissionmodel_instance = new SubmissionModel(
215:                            elementmodel_instance, "submissionmodel1");
216:                } catch (GuiModelException e) {
217:                    assertTrue(e.getMessage(), false);
218:                }
219:                assertTrue(submissionmodel_instance.addParticleListener(this ));
220:                assertNull(mPropertyAdded);
221:
222:                try {
223:                    parametermodel_instance = submissionmodel_instance
224:                            .addParameter("parametermodel1");
225:                } catch (GuiModelException e) {
226:                    assertTrue(e.getMessage(), false);
227:                }
228:                assertSame(mPropertyAdded, parametermodel_instance);
229:
230:                Iterator<SubmissionParameterModel> parameter_it = submissionmodel_instance
231:                        .getParameters().iterator();
232:                assertTrue(parameter_it.hasNext());
233:                SubmissionParameterModel parameter = parameter_it.next();
234:                assertEquals(parameter_it.hasNext(), false);
235:                assertSame(parameter, parametermodel_instance);
236:            }
237:
238:            public void testAddTheSameParameterTwice() {
239:                ElementModel elementmodel_instance = null;
240:                SubmissionModel submissionmodel_instance = null;
241:                SubmissionParameterModel parametermodel_instance = null;
242:
243:                try {
244:                    elementmodel_instance = new ElementModel("elementmodel1");
245:                    submissionmodel_instance = new SubmissionModel(
246:                            elementmodel_instance, "submissionmodel1");
247:                } catch (GuiModelException e) {
248:                    assertTrue(e.getMessage(), false);
249:                }
250:                assertTrue(submissionmodel_instance.addParticleListener(this ));
251:                assertNull(mPropertyAdded);
252:
253:                try {
254:                    parametermodel_instance = submissionmodel_instance
255:                            .addParameter("parametermodel1");
256:                } catch (GuiModelException e) {
257:                    assertTrue(e.getMessage(), false);
258:                }
259:                assertSame(mPropertyAdded, parametermodel_instance);
260:
261:                mPropertyAdded = null;
262:                try {
263:                    submissionmodel_instance.addParameter("parametermodel1");
264:                    fail();
265:                } catch (GuiModelException e) {
266:                    assertTrue(true);
267:                }
268:                assertNull(mPropertyAdded);
269:                Iterator<SubmissionParameterModel> parameter_it = submissionmodel_instance
270:                        .getParameters().iterator();
271:                assertTrue(parameter_it.hasNext());
272:                Object parameter = parameter_it.next();
273:                assertEquals(parameter_it.hasNext(), false);
274:                assertSame(parameter, parametermodel_instance);
275:            }
276:
277:            public void testAddTwoParameters() {
278:                ElementModel elementmodel_instance = null;
279:                SubmissionModel submissionmodel_instance = null;
280:                SubmissionParameterModel parametermodel_instance1 = null;
281:                SubmissionParameterModel parametermodel_instance2 = null;
282:
283:                try {
284:                    elementmodel_instance = new ElementModel("elementmodel1");
285:                    submissionmodel_instance = new SubmissionModel(
286:                            elementmodel_instance, "submissionmodel1");
287:                } catch (GuiModelException e) {
288:                    assertTrue(e.getMessage(), false);
289:                }
290:                assertTrue(submissionmodel_instance.addParticleListener(this ));
291:                assertNull(mPropertyAdded);
292:
293:                try {
294:                    parametermodel_instance1 = submissionmodel_instance
295:                            .addParameter("parametermodel1");
296:                    assertSame(mPropertyAdded, parametermodel_instance1);
297:                    parametermodel_instance2 = submissionmodel_instance
298:                            .addParameter("parametermodel2");
299:                    assertSame(mPropertyAdded, parametermodel_instance2);
300:                } catch (GuiModelException e) {
301:                    assertTrue(e.getMessage(), false);
302:                }
303:
304:                Iterator<SubmissionParameterModel> parameter_it = submissionmodel_instance
305:                        .getParameters().iterator();
306:                assertTrue(parameter_it.hasNext());
307:                SubmissionParameterModel parameter1 = parameter_it.next();
308:                assertTrue(parameter_it.hasNext());
309:                SubmissionParameterModel parameter2 = parameter_it.next();
310:                assertTrue(parameter_it.hasNext() == false);
311:                assertTrue((parameter1 == parametermodel_instance1 && parameter2 == parametermodel_instance2)
312:                        || (parameter2 == parametermodel_instance1 && parameter1 == parametermodel_instance2));
313:            }
314:
315:            public void testCountParameters() {
316:                ElementModel elementmodel_instance = null;
317:                SubmissionModel submissionmodel_instance = null;
318:                SubmissionParameterModel parametermodel_instance1 = null;
319:                SubmissionParameterModel parametermodel_instance2 = null;
320:
321:                try {
322:                    elementmodel_instance = new ElementModel("elementmodel1");
323:                    submissionmodel_instance = new SubmissionModel(
324:                            elementmodel_instance, "submissionmodel1");
325:                } catch (GuiModelException e) {
326:                    assertTrue(e.getMessage(), false);
327:                }
328:                assertTrue(submissionmodel_instance.addParticleListener(this ));
329:                assertNull(mPropertyAdded);
330:
331:                try {
332:                    parametermodel_instance1 = submissionmodel_instance
333:                            .addParameter("parametermodel1");
334:                    assertSame(mPropertyAdded, parametermodel_instance1);
335:                    parametermodel_instance2 = submissionmodel_instance
336:                            .addParameter("parametermodel2");
337:                    assertSame(mPropertyAdded, parametermodel_instance2);
338:                } catch (GuiModelException e) {
339:                    assertTrue(e.getMessage(), false);
340:                }
341:
342:                assertEquals(submissionmodel_instance.countParameters(), 2);
343:                assertEquals(submissionmodel_instance
344:                        .countProperties(SubmissionParameterModel.class), 2);
345:                assertEquals(submissionmodel_instance
346:                        .countProperties(ParticlePropertyModel.class), 3);
347:            }
348:
349:            public void testParameterConflicts() {
350:                ElementModel elementmodel_instance = null;
351:                SubmissionModel submissionmodel_instance = null;
352:
353:                try {
354:                    elementmodel_instance = new ElementModel("elementmodel1");
355:                    submissionmodel_instance = new SubmissionModel(
356:                            elementmodel_instance, "submissionmodel1");
357:
358:                    submissionmodel_instance.addParameter("parametermodel1");
359:                } catch (GuiModelException e) {
360:                    assertTrue(e.getMessage(), false);
361:                }
362:
363:                try {
364:                    submissionmodel_instance.addParameter("parametermodel1");
365:                    fail();
366:                } catch (GuiModelException e) {
367:                    assertTrue(true);
368:                }
369:                try {
370:                    submissionmodel_instance.addParameter("submissionmodel1");
371:                    submissionmodel_instance.addParameter("elementmodel1");
372:                } catch (GuiModelException e) {
373:                    assertTrue(e.getMessage(), false);
374:                }
375:            }
376:
377:            public void testRenameParameterConflict() {
378:                ElementModel elementmodel_instance = null;
379:                SubmissionModel submissionmodel_instance = null;
380:                SubmissionParameterModel parametermodel_instance1 = null;
381:
382:                try {
383:                    elementmodel_instance = new ElementModel("elementmodel1");
384:                    submissionmodel_instance = new SubmissionModel(
385:                            elementmodel_instance, "submissionmodel1");
386:                    parametermodel_instance1 = submissionmodel_instance
387:                            .addParameter("parametermodel1");
388:                    submissionmodel_instance.addParameter("parametermodel2");
389:                } catch (GuiModelException e) {
390:                    assertTrue(e.getMessage(), false);
391:                }
392:                assertTrue(submissionmodel_instance.addParticleListener(this ));
393:                assertNull(mPropertyRenamed);
394:                assertEquals(submissionmodel_instance.countParameters(), 2);
395:
396:                try {
397:                    assertTrue(submissionmodel_instance.renameProperty(
398:                            parametermodel_instance1, "parametermodel2"));
399:                    fail();
400:                } catch (GuiModelException e) {
401:                    assertTrue(true);
402:                }
403:
404:                assertNull(mPropertyRenamed);
405:                assertEquals(submissionmodel_instance.countParameters(), 2);
406:                assertSame(submissionmodel_instance.getParameters().iterator()
407:                        .next(), parametermodel_instance1);
408:                assertEquals(parametermodel_instance1.getName(),
409:                        "parametermodel1");
410:            }
411:
412:            public void parentChanged() {
413:            }
414:
415:            public void childAdded(ParticleModel child) {
416:            }
417:
418:            public void childRemoved(ParticleModel child) {
419:            }
420:
421:            public void propertyAdded(ParticlePropertyModel property) {
422:                mPropertyAdded = property;
423:            }
424:
425:            public void propertyRemoved(ParticlePropertyModel property) {
426:                mPropertyRemoved = property;
427:            }
428:
429:            public void propertyRenamed(ParticlePropertyModel property) {
430:                mPropertyRenamed = property;
431:            }
432:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.