Source Code Cross Referenced for TestParticleModel.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: TestParticleModel.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.gui.model;
009:
010:        import com.uwyn.rife.gui.model.exceptions.GuiModelException;
011:        import java.util.Iterator;
012:        import junit.framework.TestCase;
013:
014:        public class TestParticleModel extends ParticleModel {
015:            public static class Test extends TestCase implements 
016:                    ParticleModelListener {
017:                private boolean mParentChanged = false;
018:                private Object mChildAdded = null;
019:                private Object mChildRemoved = null;
020:                private Object mPropertyAdded = null;
021:                private Object mPropertyRemoved = null;
022:                private Object mPropertyRenamed = null;
023:
024:                public Test(String name) {
025:                    super (name);
026:                }
027:
028:                public void testInstantiation() {
029:                    ParticleModel particlemodel_instance = new TestParticleModel();
030:
031:                    assertTrue(particlemodel_instance != null);
032:                    assertTrue(particlemodel_instance instanceof  ParticleModel);
033:                }
034:
035:                public void testAddParticleListener() {
036:                    ParticleModel particlemodel_instance = new TestParticleModel();
037:
038:                    assertTrue(particlemodel_instance.addParticleListener(this ));
039:                }
040:
041:                public void testRemoveParticleListener() {
042:                    ParticleModel particlemodel_instance = new TestParticleModel();
043:
044:                    assertTrue(particlemodel_instance.addParticleListener(this ));
045:                    assertTrue(particlemodel_instance
046:                            .removeParticleListener(this ));
047:                }
048:
049:                public void testNoInitialDescription() {
050:                    ParticleModel particlemodel_instance = new TestParticleModel();
051:
052:                    assertNull(particlemodel_instance.getDescription());
053:                }
054:
055:                public void testSetDescription() {
056:                    TestParticleModel particlemodel_instance = new TestParticleModel();
057:
058:                    particlemodel_instance.setDescription("the description");
059:
060:                    assertEquals(particlemodel_instance.getDescription(),
061:                            "the description");
062:                }
063:
064:                public void testGetEmptyInitialParent() {
065:                    ParticleModel particlemodel_instance = new TestParticleModel();
066:
067:                    assertNull(particlemodel_instance.getParent());
068:                }
069:
070:                public void testSetParent() {
071:                    TestParticleModel particlemodel_instance = new TestParticleModel();
072:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
073:
074:                    assertEquals(mParentChanged, false);
075:                    assertTrue(particlemodel_instance.addParticleListener(this ));
076:                    assertTrue(particlemodel_instance
077:                            .setParent(particlemodel_instance2));
078:                    assertEquals(mParentChanged, true);
079:                    assertSame(particlemodel_instance.getParent(),
080:                            particlemodel_instance2);
081:                }
082:
083:                public void testSetSameParentTwice() {
084:                    TestParticleModel particlemodel_instance = new TestParticleModel();
085:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
086:
087:                    assertEquals(mParentChanged, false);
088:                    assertTrue(particlemodel_instance.addParticleListener(this ));
089:                    assertTrue(particlemodel_instance
090:                            .setParent(particlemodel_instance2));
091:                    assertEquals(mParentChanged, true);
092:                    mParentChanged = false;
093:                    assertEquals(particlemodel_instance
094:                            .setParent(particlemodel_instance2), false);
095:                    assertEquals(mParentChanged, false);
096:                    assertSame(particlemodel_instance.getParent(),
097:                            particlemodel_instance2);
098:                }
099:
100:                public void testNoInitialChildren() {
101:                    ParticleModel particlemodel_instance = new TestParticleModel();
102:
103:                    assertEquals(particlemodel_instance.getChildren().size(), 0);
104:                }
105:
106:                public void testInitialChildCountIsZero() {
107:                    ParticleModel particlemodel_instance = new TestParticleModel();
108:
109:                    assertEquals(particlemodel_instance.countChildren(), 0);
110:                }
111:
112:                public void testAddOneChild() {
113:                    TestParticleModel particlemodel_instance = new TestParticleModel();
114:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
115:
116:                    assertNull(mChildAdded);
117:                    assertTrue(particlemodel_instance.addParticleListener(this ));
118:                    try {
119:                        particlemodel_instance
120:                                .addChild(particlemodel_instance2);
121:                    } catch (GuiModelException e) {
122:                        assertTrue(e.getMessage(), false);
123:                    }
124:                    assertSame(mChildAdded, particlemodel_instance2);
125:                    assertSame(particlemodel_instance2.getParent(),
126:                            particlemodel_instance);
127:                    Iterator<ParticleModel> child_it = particlemodel_instance
128:                            .getChildren().iterator();
129:                    Object child = null;
130:                    assertTrue(child_it.hasNext());
131:                    child = child_it.next();
132:                    assertEquals(child_it.hasNext(), false);
133:                    assertSame(child, particlemodel_instance2);
134:                    assertTrue(particlemodel_instance
135:                            .containsChild(particlemodel_instance2));
136:                }
137:
138:                public void testAddTheSameChildTwice() {
139:                    TestParticleModel particlemodel_instance = new TestParticleModel();
140:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
141:
142:                    assertNull(mChildAdded);
143:                    assertTrue(particlemodel_instance.addParticleListener(this ));
144:                    try {
145:                        particlemodel_instance
146:                                .addChild(particlemodel_instance2);
147:                    } catch (GuiModelException e) {
148:                        assertTrue(e.getMessage(), false);
149:                    }
150:                    assertSame(mChildAdded, particlemodel_instance2);
151:                    mChildAdded = null;
152:                    try {
153:                        particlemodel_instance
154:                                .addChild(particlemodel_instance2);
155:                        fail();
156:                    } catch (GuiModelException e) {
157:                        assertTrue(true);
158:                    }
159:                    assertNull(mChildAdded);
160:                    Iterator<ParticleModel> child_it = particlemodel_instance
161:                            .getChildren().iterator();
162:                    Object child = null;
163:                    assertTrue(child_it.hasNext());
164:                    child = child_it.next();
165:                    assertEquals(child_it.hasNext(), false);
166:                    assertSame(child, particlemodel_instance2);
167:                }
168:
169:                public void testAddTwoChildren() {
170:                    TestParticleModel particlemodel_instance = new TestParticleModel();
171:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
172:                    ParticleModel particlemodel_instance3 = new TestParticleModel();
173:
174:                    assertNull(mChildAdded);
175:                    assertTrue(particlemodel_instance.addParticleListener(this ));
176:                    try {
177:                        particlemodel_instance
178:                                .addChild(particlemodel_instance2);
179:                    } catch (GuiModelException e) {
180:                        assertTrue(e.getMessage(), false);
181:                    }
182:                    assertSame(mChildAdded, particlemodel_instance2);
183:                    mChildAdded = null;
184:                    try {
185:                        particlemodel_instance
186:                                .addChild(particlemodel_instance3);
187:                    } catch (GuiModelException e) {
188:                        assertTrue(e.getMessage(), false);
189:                    }
190:                    assertSame(mChildAdded, particlemodel_instance3);
191:                    mChildAdded = null;
192:                    assertSame(particlemodel_instance2.getParent(),
193:                            particlemodel_instance);
194:                    assertSame(particlemodel_instance3.getParent(),
195:                            particlemodel_instance);
196:                    Iterator<ParticleModel> child_it = particlemodel_instance
197:                            .getChildren().iterator();
198:                    Object child1 = null;
199:                    Object child2 = null;
200:                    assertTrue(child_it.hasNext());
201:                    child1 = child_it.next();
202:                    assertTrue(child_it.hasNext());
203:                    child2 = child_it.next();
204:                    assertEquals(child_it.hasNext(), false);
205:                    assertTrue((child1 == particlemodel_instance2 && child2 == particlemodel_instance3)
206:                            || (child1 == particlemodel_instance3 && child2 == particlemodel_instance2));
207:
208:                    assertTrue(particlemodel_instance
209:                            .containsChild(particlemodel_instance2));
210:                    assertTrue(particlemodel_instance
211:                            .containsChild(particlemodel_instance3));
212:                }
213:
214:                public void testCountChildren() {
215:                    TestParticleModel particlemodel_instance = new TestParticleModel();
216:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
217:                    ParticleModel particlemodel_instance3 = new TestParticleModel();
218:
219:                    try {
220:                        particlemodel_instance
221:                                .addChild(particlemodel_instance2);
222:                        particlemodel_instance
223:                                .addChild(particlemodel_instance3);
224:                    } catch (GuiModelException e) {
225:                        assertTrue(e.getMessage(), false);
226:                    }
227:                    assertEquals(particlemodel_instance.countChildren(), 2);
228:                }
229:
230:                public void testCountTypedChildren() {
231:                    TestParticleModel particlemodel_instance = new TestParticleModel();
232:                    ParticleModel particlemodel2_instance1 = new TestParticleModel2();
233:                    ParticleModel particlemodel2_instance2 = new TestParticleModel2();
234:                    ParticleModel particlemodel3_instance = new TestParticleModel3();
235:
236:                    try {
237:                        particlemodel_instance
238:                                .addChild(particlemodel2_instance1);
239:                        particlemodel_instance
240:                                .addChild(particlemodel2_instance2);
241:                        particlemodel_instance
242:                                .addChild(particlemodel3_instance);
243:                    } catch (GuiModelException e) {
244:                        assertTrue(e.getMessage(), false);
245:                    }
246:                    assertEquals(particlemodel_instance
247:                            .countChildren(TestParticleModel2.class), 2);
248:                    assertEquals(particlemodel_instance
249:                            .countChildren(TestParticleModel3.class), 1);
250:                }
251:
252:                public void testGetTypedChildren() {
253:                    TestParticleModel particlemodel_instance = new TestParticleModel();
254:                    ParticleModel particlemodel2_instance = new TestParticleModel2();
255:                    ParticleModel particlemodel3_instance = new TestParticleModel3();
256:
257:                    try {
258:                        particlemodel_instance
259:                                .addChild(particlemodel2_instance);
260:                        particlemodel_instance
261:                                .addChild(particlemodel3_instance);
262:                    } catch (GuiModelException e) {
263:                        assertTrue(e.getMessage(), false);
264:                    }
265:                    Iterator<TestParticleModel2> child_it = particlemodel_instance
266:                            .getChildren(TestParticleModel2.class).iterator();
267:                    assertTrue(child_it.hasNext());
268:                    TestParticleModel2 child = child_it.next();
269:                    assertEquals(child_it.hasNext(), false);
270:                    assertSame(child, particlemodel2_instance);
271:                }
272:
273:                public void testRemoveInexistantChild() {
274:                    ParticleModel particlemodel_instance = new TestParticleModel();
275:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
276:
277:                    assertNull(mChildRemoved);
278:                    assertTrue(particlemodel_instance.addParticleListener(this ));
279:                    assertEquals(particlemodel_instance
280:                            .removeChild(particlemodel_instance2), false);
281:                    assertNull(mChildRemoved);
282:                }
283:
284:                public void testRemoveOneChild() {
285:                    TestParticleModel particlemodel_instance = new TestParticleModel();
286:                    ParticleModel particlemodel_instance2 = new TestParticleModel();
287:
288:                    assertNull(mChildRemoved);
289:                    assertTrue(particlemodel_instance.addParticleListener(this ));
290:                    try {
291:                        particlemodel_instance
292:                                .addChild(particlemodel_instance2);
293:                    } catch (GuiModelException e) {
294:                        assertTrue(e.getMessage(), false);
295:                    }
296:                    assertTrue(particlemodel_instance
297:                            .removeChild(particlemodel_instance2));
298:                    assertSame(mChildRemoved, particlemodel_instance2);
299:                    assertEquals(particlemodel_instance.getChildren().size(), 0);
300:                }
301:
302:                public void testNoInitialProperties() {
303:                    ParticleModel particlemodel_instance = new TestParticleModel();
304:
305:                    assertEquals(particlemodel_instance.getProperties().size(),
306:                            0);
307:                }
308:
309:                public void testInitialPropertyCountIsZero() {
310:                    ParticleModel particlemodel_instance = new TestParticleModel();
311:
312:                    assertEquals(particlemodel_instance.countProperties(), 0);
313:                }
314:
315:                public void testAddOneProperty() {
316:                    TestParticleModel particlemodel_instance = null;
317:                    ParticlePropertyModel propertymodel_instance = null;
318:
319:                    particlemodel_instance = new TestParticleModel();
320:                    assertTrue(particlemodel_instance.addParticleListener(this ));
321:                    assertNull(mPropertyAdded);
322:
323:                    try {
324:                        propertymodel_instance = new TestParticlePropertyModel1(
325:                                particlemodel_instance, "particleproperty1");
326:                    } catch (GuiModelException e) {
327:                        assertTrue(e.getMessage(), false);
328:                    }
329:                    assertSame(mPropertyAdded, propertymodel_instance);
330:
331:                    assertSame(propertymodel_instance.getParticle(),
332:                            particlemodel_instance);
333:                    Iterator<TestParticlePropertyModel1> property_it = particlemodel_instance
334:                            .getProperties(TestParticlePropertyModel1.class)
335:                            .iterator();
336:                    assertTrue(property_it.hasNext());
337:                    Object property = property_it.next();
338:                    assertEquals(property_it.hasNext(), false);
339:                    assertSame(property, propertymodel_instance);
340:                }
341:
342:                public void testAddTheSamePropertyTwice() {
343:                    TestParticleModel particlemodel_instance = null;
344:                    ParticlePropertyModel propertymodel_instance = null;
345:
346:                    particlemodel_instance = new TestParticleModel();
347:                    assertTrue(particlemodel_instance.addParticleListener(this ));
348:                    assertNull(mPropertyAdded);
349:
350:                    try {
351:                        propertymodel_instance = new TestParticlePropertyModel1(
352:                                particlemodel_instance, "particleproperty1");
353:                    } catch (GuiModelException e) {
354:                        assertTrue(e.getMessage(), false);
355:                    }
356:                    assertSame(mPropertyAdded, propertymodel_instance);
357:
358:                    mPropertyAdded = null;
359:                    try {
360:                        particlemodel_instance
361:                                .addProperty(propertymodel_instance);
362:                        fail();
363:                    } catch (GuiModelException e) {
364:                        assertTrue(true);
365:                    }
366:                    assertNull(mPropertyAdded);
367:                    Iterator<TestParticlePropertyModel1> property_it = particlemodel_instance
368:                            .getProperties(TestParticlePropertyModel1.class)
369:                            .iterator();
370:                    assertTrue(property_it.hasNext());
371:                    TestParticlePropertyModel1 property = property_it.next();
372:                    assertEquals(property_it.hasNext(), false);
373:                    assertSame(property, propertymodel_instance);
374:                }
375:
376:                public void testAddTwoProperties() {
377:                    TestParticleModel particlemodel_instance = null;
378:                    ParticlePropertyModel propertymodel_instance1 = null;
379:                    ParticlePropertyModel propertymodel_instance2 = null;
380:
381:                    particlemodel_instance = new TestParticleModel();
382:                    assertTrue(particlemodel_instance.addParticleListener(this ));
383:                    assertNull(mPropertyAdded);
384:
385:                    try {
386:                        propertymodel_instance1 = new TestParticlePropertyModel1(
387:                                particlemodel_instance, "particleproperty1");
388:                        assertSame(mPropertyAdded, propertymodel_instance1);
389:                        mPropertyAdded = null;
390:                        propertymodel_instance2 = new TestParticlePropertyModel1(
391:                                particlemodel_instance, "particleproperty2");
392:                        assertSame(mPropertyAdded, propertymodel_instance2);
393:                    } catch (GuiModelException e) {
394:                        assertTrue(e.getMessage(), false);
395:                    }
396:
397:                    assertSame(propertymodel_instance1.getParticle(),
398:                            particlemodel_instance);
399:                    assertSame(propertymodel_instance2.getParticle(),
400:                            particlemodel_instance);
401:                    Iterator<TestParticlePropertyModel1> property_it = particlemodel_instance
402:                            .getProperties(TestParticlePropertyModel1.class)
403:                            .iterator();
404:                    assertTrue(property_it.hasNext());
405:                    TestParticlePropertyModel1 property1 = property_it.next();
406:                    assertTrue(property_it.hasNext());
407:                    TestParticlePropertyModel1 property2 = property_it.next();
408:                    assertEquals(property_it.hasNext(), false);
409:                    assertTrue((property1 == propertymodel_instance1 && property2 == propertymodel_instance2)
410:                            || (property2 == propertymodel_instance1 && property1 == propertymodel_instance2));
411:                }
412:
413:                public void testCountProperties() {
414:                    TestParticleModel particlemodel_instance = null;
415:
416:                    particlemodel_instance = new TestParticleModel();
417:
418:                    try {
419:                        new TestParticlePropertyModel1(particlemodel_instance,
420:                                "particleproperty1");
421:                        new TestParticlePropertyModel1(particlemodel_instance,
422:                                "particleproperty2");
423:                    } catch (GuiModelException e) {
424:                        assertTrue(e.getMessage(), false);
425:                    }
426:                    try {
427:                        new TestParticlePropertyModel1(particlemodel_instance,
428:                                "particleproperty3");
429:                    } catch (GuiModelException e) {
430:                        assertTrue(e.getMessage(), false);
431:                    }
432:
433:                    assertEquals(particlemodel_instance.countProperties(), 3);
434:                }
435:
436:                public void testCountTypedProperties() {
437:                    TestParticleModel particlemodel_instance = null;
438:
439:                    particlemodel_instance = new TestParticleModel();
440:
441:                    try {
442:                        new TestParticlePropertyModel1(particlemodel_instance,
443:                                "particleproperty1");
444:                        new TestParticlePropertyModel2(particlemodel_instance,
445:                                "particleproperty1");
446:                        new TestParticlePropertyModel3(particlemodel_instance,
447:                                "particleproperty1");
448:                        new TestParticlePropertyModel3(particlemodel_instance,
449:                                "particleproperty2");
450:                        new TestParticlePropertyModel4(particlemodel_instance,
451:                                "particleproperty1");
452:                    } catch (GuiModelException e) {
453:                        assertTrue(e.getMessage(), false);
454:                    }
455:
456:                    assertEquals(particlemodel_instance
457:                            .countProperties(TestParticlePropertyModel1.class),
458:                            5);
459:                    assertEquals(particlemodel_instance
460:                            .countProperties(TestParticlePropertyModel2.class),
461:                            4);
462:                    assertEquals(particlemodel_instance
463:                            .countProperties(TestParticlePropertyModel3.class),
464:                            2);
465:                    assertEquals(particlemodel_instance
466:                            .countProperties(TestParticlePropertyModel4.class),
467:                            1);
468:                }
469:
470:                public void testContainsProperty() {
471:                    TestParticleModel particlemodel_instance1 = null;
472:                    TestParticleModel particlemodel_instance2 = null;
473:                    ParticlePropertyModel propertymodel_instance1 = null;
474:                    ParticlePropertyModel propertymodel_instance2 = null;
475:
476:                    particlemodel_instance1 = new TestParticleModel();
477:                    particlemodel_instance2 = new TestParticleModel();
478:
479:                    try {
480:                        propertymodel_instance1 = new TestParticlePropertyModel(
481:                                particlemodel_instance1, "particleproperty");
482:                        propertymodel_instance2 = new TestParticlePropertyModel(
483:                                particlemodel_instance2, "particleproperty");
484:                    } catch (GuiModelException e) {
485:                        assertTrue(e.getMessage(), false);
486:                    }
487:                    assertTrue(particlemodel_instance1
488:                            .containsProperty(propertymodel_instance1));
489:                    assertEquals(particlemodel_instance1
490:                            .containsProperty(propertymodel_instance2), false);
491:                }
492:
493:                public void testGetProperty() {
494:                    TestParticleModel particlemodel_instance = null;
495:                    ParticlePropertyModel propertymodel_instance1 = null;
496:                    ParticlePropertyModel propertymodel_instance2 = null;
497:
498:                    particlemodel_instance = new TestParticleModel();
499:
500:                    try {
501:                        propertymodel_instance1 = new TestParticlePropertyModel(
502:                                particlemodel_instance, "particleproperty1");
503:                        propertymodel_instance2 = new TestParticlePropertyModel(
504:                                particlemodel_instance, "particleproperty2");
505:                    } catch (GuiModelException e) {
506:                        assertTrue(e.getMessage(), false);
507:                    }
508:                    assertSame(particlemodel_instance.getProperty(
509:                            ParticlePropertyModel.class, "particleproperty1"),
510:                            propertymodel_instance1);
511:                    assertSame(particlemodel_instance.getProperty(
512:                            TestParticlePropertyModel.class,
513:                            "particleproperty1"), propertymodel_instance1);
514:                    assertSame(particlemodel_instance.getProperty(
515:                            TestParticlePropertyModel.class,
516:                            "particleproperty2"), propertymodel_instance2);
517:                    assertNull(particlemodel_instance.getProperty(
518:                            TestParticlePropertyModel2.class,
519:                            "particleproperty1"));
520:                    assertNull(particlemodel_instance.getProperty(
521:                            TestParticlePropertyModel.class,
522:                            "particleproperty3"));
523:                }
524:
525:                public void testRenameProperty() {
526:                    TestParticleModel particlemodel_instance = null;
527:                    ParticlePropertyModel propertymodel_instance1 = null;
528:
529:                    particlemodel_instance = new TestParticleModel();
530:                    assertTrue(particlemodel_instance.addParticleListener(this ));
531:
532:                    try {
533:                        propertymodel_instance1 = new TestParticlePropertyModel(
534:                                particlemodel_instance, "particleproperty1");
535:                        new TestParticlePropertyModel(particlemodel_instance,
536:                                "particleproperty2");
537:                    } catch (GuiModelException e) {
538:                        assertTrue(e.getMessage(), false);
539:                    }
540:                    try {
541:                        assertEquals(particlemodel_instance.renameProperty(
542:                                propertymodel_instance1, "particleproperty1"),
543:                                false);
544:                        assertNull(mPropertyRenamed);
545:                    } catch (GuiModelException e) {
546:                        assertTrue(e.getMessage(), false);
547:                    }
548:                    try {
549:                        assertTrue(particlemodel_instance.renameProperty(
550:                                propertymodel_instance1, "particleproperty3"));
551:                        assertSame(mPropertyRenamed, propertymodel_instance1);
552:                        mPropertyRenamed = null;
553:                    } catch (GuiModelException e) {
554:                        assertTrue(e.getMessage(), false);
555:                    }
556:                    try {
557:                        particlemodel_instance.renameProperty(
558:                                propertymodel_instance1, "particleproperty2");
559:                        fail();
560:                    } catch (GuiModelException e) {
561:                        assertTrue(true);
562:                    }
563:                }
564:
565:                public void testRemoveInexistantProperty() {
566:                    TestParticleModel particlemodel_instance1 = null;
567:                    TestParticleModel particlemodel_instance2 = null;
568:                    ParticlePropertyModel propertymodel_instance = null;
569:
570:                    particlemodel_instance1 = new TestParticleModel();
571:                    particlemodel_instance2 = new TestParticleModel();
572:                    assertTrue(particlemodel_instance1
573:                            .addParticleListener(this ));
574:                    assertTrue(particlemodel_instance2
575:                            .addParticleListener(this ));
576:                    assertNull(mPropertyRemoved);
577:
578:                    try {
579:                        propertymodel_instance = new TestParticlePropertyModel1(
580:                                particlemodel_instance1, "particleproperty1");
581:                    } catch (GuiModelException e) {
582:                        assertTrue(e.getMessage(), false);
583:                    }
584:
585:                    try {
586:                        assertEquals(particlemodel_instance2
587:                                .removeProperty(propertymodel_instance), false);
588:                    } catch (GuiModelException e) {
589:                        assertTrue(e.getMessage(), false);
590:                    }
591:                    assertNull(mPropertyRemoved);
592:                }
593:
594:                public void testRemoveOneProperty() {
595:                    TestParticleModel particlemodel_instance = null;
596:                    ParticlePropertyModel propertymodel_instance = null;
597:
598:                    particlemodel_instance = new TestParticleModel();
599:                    assertTrue(particlemodel_instance.addParticleListener(this ));
600:                    assertNull(mPropertyRemoved);
601:
602:                    try {
603:                        propertymodel_instance = new TestParticlePropertyModel1(
604:                                particlemodel_instance, "particleproperty1");
605:                    } catch (GuiModelException e) {
606:                        assertTrue(e.getMessage(), false);
607:                    }
608:
609:                    try {
610:                        assertTrue(particlemodel_instance
611:                                .removeProperty(propertymodel_instance));
612:                    } catch (GuiModelException e) {
613:                        assertTrue(e.getMessage(), false);
614:                    }
615:                    assertSame(mPropertyRemoved, propertymodel_instance);
616:                    assertNull(propertymodel_instance.getParticle());
617:                    assertEquals(particlemodel_instance.getProperties(
618:                            TestParticlePropertyModel1.class).size(), 0);
619:                }
620:
621:                public void parentChanged() {
622:                    mParentChanged = true;
623:                }
624:
625:                public void childAdded(ParticleModel child) {
626:                    mChildAdded = child;
627:                }
628:
629:                public void childRemoved(ParticleModel child) {
630:                    mChildRemoved = child;
631:                }
632:
633:                public void propertyAdded(ParticlePropertyModel property) {
634:                    mPropertyAdded = property;
635:                }
636:
637:                public void propertyRemoved(ParticlePropertyModel property) {
638:                    mPropertyRemoved = property;
639:                }
640:
641:                public void propertyRenamed(ParticlePropertyModel property) {
642:                    mPropertyRenamed = property;
643:                }
644:            }
645:
646:            private static class TestParticleModel2 extends ParticleModel {
647:            }
648:
649:            private static class TestParticleModel3 extends ParticleModel {
650:            }
651:
652:            private static class TestParticlePropertyModel1 extends
653:                    ParticlePropertyModel {
654:                public TestParticlePropertyModel1(ParticleModel particleModel,
655:                        String name) throws GuiModelException {
656:                    super (particleModel, name);
657:                }
658:            }
659:
660:            private static class TestParticlePropertyModel2 extends
661:                    TestParticlePropertyModel1 {
662:                public TestParticlePropertyModel2(ParticleModel particleModel,
663:                        String name) throws GuiModelException {
664:                    super (particleModel, name);
665:                }
666:            }
667:
668:            private static class TestParticlePropertyModel3 extends
669:                    TestParticlePropertyModel2 {
670:                public TestParticlePropertyModel3(ParticleModel particleModel,
671:                        String name) throws GuiModelException {
672:                    super (particleModel, name);
673:                }
674:            }
675:
676:            private static class TestParticlePropertyModel4 extends
677:                    TestParticlePropertyModel2 {
678:                public TestParticlePropertyModel4(ParticleModel particleModel,
679:                        String name) throws GuiModelException {
680:                    super(particleModel, name);
681:                }
682:            }
683:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.