Source Code Cross Referenced for TestAnnotations2ElementInfo.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » engine » 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.engine 
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: TestAnnotations2ElementInfo.java 3693 2007-03-14 10:55:56Z gbevin $
007:         */
008:        package com.uwyn.rife.engine;
009:
010:        import com.uwyn.rife.engine.annotations.*;
011:        import com.uwyn.rife.engine.testelements.annotations.*;
012:
013:        import com.uwyn.rife.engine.exceptions.EngineException;
014:        import com.uwyn.rife.engine.exceptions.PropertyNameMismatchErrorException;
015:        import com.uwyn.rife.resources.ResourceFinderClasspath;
016:        import java.lang.reflect.Method;
017:        import java.util.LinkedHashMap;
018:        import junit.framework.TestCase;
019:
020:        public class TestAnnotations2ElementInfo extends TestCase {
021:            public TestAnnotations2ElementInfo(String name) {
022:                super (name);
023:            }
024:
025:            public void testInstantiation() {
026:                SiteBuilder site_builder = new SiteBuilder("test",
027:                        ResourceFinderClasspath.getInstance());
028:                ElementInfoBuilder elementinfo_builder = site_builder
029:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
030:                                + ":" + Simple.class.getName());
031:
032:                assertNotNull(elementinfo_builder);
033:            }
034:
035:            public void testPrioritizedMethod() throws Exception {
036:                Object test_object = new Object() {
037:                    @SuppressWarnings("unused")
038:                    public void eee() {
039:                    }
040:
041:                    @SuppressWarnings("unused")
042:                    public void bbb() {
043:                    }
044:
045:                    @SuppressWarnings("unused")
046:                    public void ddd() {
047:                    }
048:
049:                    @SuppressWarnings("unused")
050:                    public void ccc() {
051:                    }
052:
053:                    @SuppressWarnings("unused")
054:                    public void aaa() {
055:                    }
056:                };
057:
058:                Class test_class = test_object.getClass();
059:
060:                Method aaa = test_class
061:                        .getDeclaredMethod("aaa", new Class[] {});
062:                Method bbb = test_class
063:                        .getDeclaredMethod("bbb", new Class[] {});
064:                Method ccc = test_class
065:                        .getDeclaredMethod("ccc", new Class[] {});
066:                Method ddd = test_class
067:                        .getDeclaredMethod("ddd", new Class[] {});
068:                Method eee = test_class
069:                        .getDeclaredMethod("eee", new Class[] {});
070:
071:                PrioritizedMethod prior_aaa1 = new PrioritizedMethod(aaa, null);
072:                PrioritizedMethod prior_aaa2 = new PrioritizedMethod(aaa, null);
073:                PrioritizedMethod prior_aaa3 = new PrioritizedMethod(aaa,
074:                        new int[] { 0, 3 });
075:                PrioritizedMethod prior_bbb = new PrioritizedMethod(bbb,
076:                        new int[] { 0 });
077:                PrioritizedMethod prior_ccc = new PrioritizedMethod(ccc,
078:                        new int[] { 0, 3 });
079:                PrioritizedMethod prior_ddd = new PrioritizedMethod(ddd,
080:                        new int[] { 1, 4 });
081:                PrioritizedMethod prior_eee = new PrioritizedMethod(eee,
082:                        new int[] { 1, 4, 0 });
083:
084:                assertTrue(prior_aaa1.equals(prior_aaa1));
085:                assertTrue(prior_aaa1.equals(prior_aaa2));
086:                assertFalse(prior_aaa1.equals(prior_aaa3));
087:                assertTrue(prior_aaa2.equals(prior_aaa1));
088:                assertTrue(prior_aaa2.equals(prior_aaa2));
089:                assertFalse(prior_aaa2.equals(prior_aaa3));
090:                assertFalse(prior_aaa3.equals(prior_aaa1));
091:                assertFalse(prior_aaa3.equals(prior_aaa2));
092:                assertTrue(prior_aaa3.equals(prior_aaa3));
093:
094:                assertTrue(prior_aaa1.compareTo(prior_aaa1) == 0);
095:                assertTrue(prior_aaa1.compareTo(prior_aaa2) == 0);
096:                assertTrue(prior_aaa1.compareTo(prior_aaa3) < 0);
097:                assertTrue(prior_aaa1.compareTo(prior_bbb) < 0);
098:                assertTrue(prior_aaa1.compareTo(prior_ccc) < 0);
099:                assertTrue(prior_aaa1.compareTo(prior_ddd) < 0);
100:                assertTrue(prior_aaa1.compareTo(prior_eee) < 0);
101:
102:                assertTrue(prior_aaa2.compareTo(prior_aaa1) == 0);
103:                assertTrue(prior_aaa2.compareTo(prior_aaa2) == 0);
104:                assertTrue(prior_aaa2.compareTo(prior_aaa3) < 0);
105:                assertTrue(prior_aaa2.compareTo(prior_bbb) < 0);
106:                assertTrue(prior_aaa2.compareTo(prior_ccc) < 0);
107:                assertTrue(prior_aaa2.compareTo(prior_ddd) < 0);
108:                assertTrue(prior_aaa2.compareTo(prior_eee) < 0);
109:
110:                assertTrue(prior_aaa3.compareTo(prior_aaa1) > 0);
111:                assertTrue(prior_aaa3.compareTo(prior_aaa2) > 0);
112:                assertTrue(prior_aaa3.compareTo(prior_aaa3) == 0);
113:                assertTrue(prior_aaa3.compareTo(prior_bbb) > 0);
114:                assertTrue(prior_aaa3.compareTo(prior_ccc) < 0);
115:                assertTrue(prior_aaa3.compareTo(prior_ddd) < 0);
116:                assertTrue(prior_aaa3.compareTo(prior_eee) < 0);
117:
118:                assertTrue(prior_bbb.compareTo(prior_aaa1) > 0);
119:                assertTrue(prior_bbb.compareTo(prior_aaa2) > 0);
120:                assertTrue(prior_bbb.compareTo(prior_aaa3) < 0);
121:                assertTrue(prior_bbb.compareTo(prior_bbb) == 0);
122:                assertTrue(prior_bbb.compareTo(prior_ccc) < 0);
123:                assertTrue(prior_bbb.compareTo(prior_ddd) < 0);
124:                assertTrue(prior_bbb.compareTo(prior_eee) < 0);
125:
126:                assertTrue(prior_ccc.compareTo(prior_aaa1) > 0);
127:                assertTrue(prior_ccc.compareTo(prior_aaa2) > 0);
128:                assertTrue(prior_ccc.compareTo(prior_aaa3) > 0);
129:                assertTrue(prior_ccc.compareTo(prior_bbb) > 0);
130:                assertTrue(prior_ccc.compareTo(prior_ccc) == 0);
131:                assertTrue(prior_ccc.compareTo(prior_ddd) < 0);
132:                assertTrue(prior_ccc.compareTo(prior_eee) < 0);
133:
134:                assertTrue(prior_ddd.compareTo(prior_aaa1) > 0);
135:                assertTrue(prior_ddd.compareTo(prior_aaa2) > 0);
136:                assertTrue(prior_ddd.compareTo(prior_aaa3) > 0);
137:                assertTrue(prior_ddd.compareTo(prior_bbb) > 0);
138:                assertTrue(prior_ddd.compareTo(prior_ccc) > 0);
139:                assertTrue(prior_ddd.compareTo(prior_ddd) == 0);
140:                assertTrue(prior_ddd.compareTo(prior_eee) < 0);
141:
142:                assertTrue(prior_eee.compareTo(prior_aaa1) > 0);
143:                assertTrue(prior_eee.compareTo(prior_aaa2) > 0);
144:                assertTrue(prior_eee.compareTo(prior_aaa3) > 0);
145:                assertTrue(prior_eee.compareTo(prior_bbb) > 0);
146:                assertTrue(prior_eee.compareTo(prior_ccc) > 0);
147:                assertTrue(prior_eee.compareTo(prior_ddd) > 0);
148:                assertTrue(prior_eee.compareTo(prior_eee) == 0);
149:            }
150:
151:            public void testParser() {
152:                SiteBuilder site_builder = new SiteBuilder("test",
153:                        ResourceFinderClasspath.getInstance());
154:                ElementInfoBuilder elementinfo_builder = site_builder
155:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
156:                                + ":" + Simple.class.getName());
157:
158:                elementinfo_builder.process();
159:
160:                ElementInfo elementinfo = elementinfo_builder
161:                        .createElementInfo(
162:                                new LinkedHashMap<String, GlobalExit>(),
163:                                new LinkedHashMap<String, GlobalVar>(),
164:                                new LinkedHashMap<String, String>(),
165:                                new LinkedHashMap<String, BeanDeclaration>());
166:
167:                assertEquals(elementinfo.getInputNames().size(), 28);
168:                assertTrue(elementinfo.containsInput("input1"));
169:                assertTrue(elementinfo.containsInput("input2"));
170:                assertTrue(elementinfo.containsInput("input3"));
171:                assertTrue(elementinfo.containsInput("string1"));
172:                assertTrue(elementinfo.containsInput("string2"));
173:                assertTrue(elementinfo.containsInput("string3"));
174:                assertTrue(elementinfo.containsInput("enum4"));
175:                assertTrue(elementinfo.containsInput("date5"));
176:                assertTrue(elementinfo.containsInput("string6"));
177:                assertTrue(elementinfo.containsInput("string7"));
178:                assertTrue(elementinfo.containsInput("string8"));
179:                assertTrue(elementinfo.containsInput("prefix_string1"));
180:                assertTrue(elementinfo.containsInput("prefix_string2"));
181:                assertTrue(elementinfo.containsInput("prefix_string3"));
182:                assertTrue(elementinfo.containsInput("prefix_enum4"));
183:                assertTrue(elementinfo.containsInput("prefix_date5"));
184:                assertTrue(elementinfo.containsInput("prefixgroup_enum"));
185:                assertTrue(elementinfo.containsInput("prefixgroup_string"));
186:                assertTrue(elementinfo.containsInput("prefixgroup_int"));
187:                assertTrue(elementinfo.containsInput("prefixgroup_longObject"));
188:                assertTrue(elementinfo.containsInput("prefixgroup_short"));
189:                assertTrue(elementinfo.containsInput("enum"));
190:                assertTrue(elementinfo.containsInput("string"));
191:                assertTrue(elementinfo.containsInput("int"));
192:                assertTrue(elementinfo.containsInput("longObject"));
193:                assertTrue(elementinfo.containsInput("short"));
194:                assertTrue(elementinfo.containsInput("key1"));
195:                assertTrue(elementinfo.containsInput("key2"));
196:
197:                assertEquals(elementinfo.getOutputNames().size(), 27);
198:                assertTrue(elementinfo.containsOutput("output1"));
199:                assertTrue(elementinfo.containsOutput("output2"));
200:                assertTrue(elementinfo.containsOutput("output3"));
201:                assertTrue(elementinfo.containsOutput("output4"));
202:                assertTrue(elementinfo.containsOutput("string1"));
203:                assertTrue(elementinfo.containsOutput("string2"));
204:                assertTrue(elementinfo.containsOutput("string3"));
205:                assertTrue(elementinfo.containsOutput("enum4"));
206:                assertTrue(elementinfo.containsOutput("date5"));
207:                assertTrue(elementinfo.containsOutput("string6"));
208:                assertTrue(elementinfo.containsOutput("string7"));
209:                assertTrue(elementinfo.containsOutput("string8"));
210:                assertTrue(elementinfo.containsOutput("prefix_enum4"));
211:                assertTrue(elementinfo.containsOutput("prefix_date5"));
212:                assertTrue(elementinfo.containsOutput("prefix_string6"));
213:                assertTrue(elementinfo.containsOutput("prefix_string7"));
214:                assertTrue(elementinfo.containsOutput("prefix_string8"));
215:                assertTrue(elementinfo.containsOutput("prefixgroup_enum"));
216:                assertTrue(elementinfo.containsOutput("prefixgroup_string"));
217:                assertTrue(elementinfo.containsOutput("prefixgroup_int"));
218:                assertTrue(elementinfo.containsOutput("prefixgroup_longObject"));
219:                assertTrue(elementinfo.containsOutput("prefixgroup_short"));
220:                assertTrue(elementinfo.containsOutput("enum"));
221:                assertTrue(elementinfo.containsOutput("string"));
222:                assertTrue(elementinfo.containsOutput("int"));
223:                assertTrue(elementinfo.containsOutput("longObject"));
224:                assertTrue(elementinfo.containsOutput("short"));
225:
226:                assertEquals(elementinfo.getIncookieNames().size(), 2);
227:                assertTrue(elementinfo.containsIncookie("incookie1"));
228:                assertTrue(elementinfo.containsIncookie("incookie2"));
229:
230:                assertEquals(elementinfo.getOutcookieNames().size(), 4);
231:                assertTrue(elementinfo.containsOutcookie("outcookie1"));
232:                assertTrue(elementinfo.containsOutcookie("outcookie2"));
233:                assertTrue(elementinfo.containsOutcookie("outcookie3"));
234:                assertTrue(elementinfo.containsOutcookie("outcookie4"));
235:
236:                assertEquals(elementinfo.getNamedInbeanNames().size(), 2);
237:                assertTrue(elementinfo.containsNamedInbean("inbean1"));
238:                assertEquals(elementinfo.getNamedInbeanInfo("inbean1")
239:                        .getClassname(),
240:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1");
241:                assertEquals(elementinfo.getNamedInbeanInfo("inbean1")
242:                        .getPrefix(), null);
243:                assertEquals(elementinfo.getNamedInbeanInfo("inbean1")
244:                        .getGroupName(), null);
245:                assertTrue(elementinfo.containsNamedInbean("inbean2"));
246:                assertEquals(elementinfo.getNamedInbeanInfo("inbean2")
247:                        .getClassname(),
248:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl");
249:                assertEquals(elementinfo.getNamedInbeanInfo("inbean2")
250:                        .getPrefix(), "prefixgroup_");
251:                assertEquals(elementinfo.getNamedInbeanInfo("inbean2")
252:                        .getGroupName(), "somegroup");
253:
254:                assertEquals(elementinfo.getNamedOutbeanNames().size(), 2);
255:                assertTrue(elementinfo.containsNamedOutbean("outbean1"));
256:                assertEquals(elementinfo.getNamedOutbeanInfo("outbean1")
257:                        .getClassname(),
258:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2");
259:                assertEquals(elementinfo.getNamedOutbeanInfo("outbean1")
260:                        .getPrefix(), "prefix_");
261:                assertEquals(elementinfo.getNamedOutbeanInfo("outbean1")
262:                        .getGroupName(), null);
263:                assertTrue(elementinfo.containsNamedOutbean("outbean2"));
264:                assertEquals(elementinfo.getNamedOutbeanInfo("outbean2")
265:                        .getClassname(),
266:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl");
267:                assertEquals(elementinfo.getNamedOutbeanInfo("outbean2")
268:                        .getPrefix(), null);
269:                assertEquals(elementinfo.getNamedOutbeanInfo("outbean2")
270:                        .getGroupName(), "somegroup");
271:
272:                assertEquals(elementinfo.getChildTriggerNames().size(), 2);
273:                assertTrue(elementinfo.containsChildTrigger("input1"));
274:                assertTrue(elementinfo.containsChildTrigger("input2"));
275:
276:                assertEquals(elementinfo.getExitNames().size(), 3);
277:                assertTrue(elementinfo.containsExit("exit1"));
278:                assertTrue(elementinfo.containsExit("exit2"));
279:                assertTrue(elementinfo.containsExit("exit3"));
280:
281:                assertEquals(elementinfo.getSubmissionNames().size(), 3);
282:                assertTrue(elementinfo.containsSubmission("submission1"));
283:                assertTrue(elementinfo.containsSubmission("submission2"));
284:                assertTrue(elementinfo.containsSubmission("anotherSubmission"));
285:
286:                assertNotNull(elementinfo.getSubmission("submission1"));
287:                assertNotNull(elementinfo.getSubmission("submission2"));
288:
289:                assertEquals(elementinfo.getSubmission("submission1")
290:                        .getParameterNames().size(), 13);
291:                assertTrue(elementinfo.getSubmission("submission1")
292:                        .containsParameter("param1"));
293:                assertTrue(elementinfo.getSubmission("submission1")
294:                        .containsParameter("param2"));
295:                assertTrue(elementinfo.getSubmission("submission1")
296:                        .containsParameter("param3"));
297:                assertTrue(elementinfo.getSubmission("submission1")
298:                        .containsParameter("subm_enum"));
299:                assertTrue(elementinfo.getSubmission("submission1")
300:                        .containsParameter("subm_string"));
301:                assertTrue(elementinfo.getSubmission("submission1")
302:                        .containsParameter("subm_int"));
303:                assertTrue(elementinfo.getSubmission("submission1")
304:                        .containsParameter("subm_longObject"));
305:                assertTrue(elementinfo.getSubmission("submission1")
306:                        .containsParameter("subm_short"));
307:                assertTrue(elementinfo.getSubmission("submission1")
308:                        .containsParameter("subm_string1"));
309:                assertTrue(elementinfo.getSubmission("submission1")
310:                        .containsParameter("subm_string2"));
311:                assertTrue(elementinfo.getSubmission("submission1")
312:                        .containsParameter("subm_string3"));
313:                assertTrue(elementinfo.getSubmission("submission1")
314:                        .containsParameter("subm_enum4"));
315:                assertTrue(elementinfo.getSubmission("submission1")
316:                        .containsParameter("subm_date5"));
317:                assertEquals(elementinfo.getSubmission("submission1")
318:                        .getParameterRegexps().size(), 2);
319:                assertTrue(elementinfo.getSubmission("submission1")
320:                        .containsParameter("paramA1"));
321:                assertTrue(elementinfo.getSubmission("submission1")
322:                        .containsParameter("paramA2"));
323:                assertTrue(elementinfo.getSubmission("submission1")
324:                        .containsParameter("paramB1"));
325:                assertTrue(elementinfo.getSubmission("submission1")
326:                        .containsParameter("paramB2"));
327:                assertEquals(elementinfo.getSubmission("submission1")
328:                        .getFileNames().size(), 2);
329:                assertTrue(elementinfo.getSubmission("submission1")
330:                        .containsFile("file1"));
331:                assertTrue(elementinfo.getSubmission("submission1")
332:                        .containsFile("file2"));
333:
334:                assertEquals(elementinfo.getSubmission("submission2")
335:                        .getParameterNames().size(), 3);
336:                assertTrue(elementinfo.getSubmission("submission2")
337:                        .containsParameter("param1"));
338:                assertTrue(elementinfo.getSubmission("submission2")
339:                        .containsParameter("param2"));
340:                assertTrue(elementinfo.getSubmission("submission2")
341:                        .containsParameter("param3"));
342:                assertEquals(elementinfo.getSubmission("submission2")
343:                        .getParameterRegexps().size(), 1);
344:                assertTrue(elementinfo.getSubmission("submission2")
345:                        .containsParameter("paramC1"));
346:                assertTrue(elementinfo.getSubmission("submission2")
347:                        .containsParameter("paramC2"));
348:                assertEquals(elementinfo.getSubmission("submission2")
349:                        .getFileNames().size(), 2);
350:                assertTrue(elementinfo.getSubmission("submission2")
351:                        .containsFile("file1"));
352:                assertTrue(elementinfo.getSubmission("submission2")
353:                        .containsFile("file2"));
354:
355:                assertEquals(elementinfo.getSubmission("anotherSubmission")
356:                        .getParameterNames().size(), 1);
357:                assertTrue(elementinfo.getSubmission("anotherSubmission")
358:                        .containsParameter("param4"));
359:                assertEquals(elementinfo.getSubmission("anotherSubmission")
360:                        .getParameterRegexps().size(), 0);
361:                assertEquals(elementinfo.getSubmission("anotherSubmission")
362:                        .getFileNames().size(), 0);
363:            }
364:
365:            public void testPropertyMismatchedIncookie() {
366:                SiteBuilder site_builder = new SiteBuilder("test",
367:                        ResourceFinderClasspath.getInstance());
368:                ElementInfoBuilder elementinfo_builder = site_builder
369:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
370:                                + ":"
371:                                + PropertyMismatchInCookie.class.getName());
372:
373:                try {
374:                    elementinfo_builder.process();
375:                    fail("Expected exception.");
376:                } catch (EngineException e1) {
377:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
378:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
379:                                .getCause();
380:                        assertEquals("incookie", e2.getActualPropertyName());
381:                        assertEquals("setIncookie", e2.getMethod().getName());
382:                        assertEquals(PropertyMismatchInCookie.class.getName(),
383:                                e2.getImplementationName());
384:                        assertSame(InCookieProperty.class, e2
385:                                .getAnnotationType());
386:                        assertEquals("badname", e2.getExpectedPropertyName());
387:                        assertEquals("test", e2.getSiteDeclarationName());
388:                    }
389:                }
390:            }
391:
392:            public void testPropertyMismatchedInBean() {
393:                SiteBuilder site_builder = new SiteBuilder("test",
394:                        ResourceFinderClasspath.getInstance());
395:                ElementInfoBuilder elementinfo_builder = site_builder
396:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
397:                                + ":" + PropertyMismatchInBean.class.getName());
398:
399:                try {
400:                    elementinfo_builder.process();
401:                    fail("Expected exception.");
402:                } catch (EngineException e1) {
403:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
404:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
405:                                .getCause();
406:                        assertEquals("inBean1", e2.getActualPropertyName());
407:                        assertEquals("setInBean1", e2.getMethod().getName());
408:                        assertEquals(PropertyMismatchInBean.class.getName(), e2
409:                                .getImplementationName());
410:                        assertSame(InBeanProperty.class, e2.getAnnotationType());
411:                        assertEquals("badname", e2.getExpectedPropertyName());
412:                        assertEquals("test", e2.getSiteDeclarationName());
413:                    }
414:                }
415:            }
416:
417:            public void testPropertyMismatchedInput() {
418:                SiteBuilder site_builder = new SiteBuilder("test",
419:                        ResourceFinderClasspath.getInstance());
420:                ElementInfoBuilder elementinfo_builder = site_builder
421:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
422:                                + ":" + PropertyMismatchInput.class.getName());
423:
424:                try {
425:                    elementinfo_builder.process();
426:                    fail("Expected exception.");
427:                } catch (EngineException e1) {
428:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
429:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
430:                                .getCause();
431:                        assertEquals("input", e2.getActualPropertyName());
432:                        assertEquals("setInput", e2.getMethod().getName());
433:                        assertEquals(PropertyMismatchInput.class.getName(), e2
434:                                .getImplementationName());
435:                        assertSame(InputProperty.class, e2.getAnnotationType());
436:                        assertEquals("badname", e2.getExpectedPropertyName());
437:                        assertEquals("test", e2.getSiteDeclarationName());
438:                    }
439:                }
440:            }
441:
442:            public void testPropertyMismatchedParam() {
443:                SiteBuilder site_builder = new SiteBuilder("test",
444:                        ResourceFinderClasspath.getInstance());
445:                ElementInfoBuilder elementinfo_builder = site_builder
446:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
447:                                + ":" + PropertyMismatchParam.class.getName());
448:
449:                try {
450:                    elementinfo_builder.process();
451:                    fail("Expected exception.");
452:                } catch (EngineException e1) {
453:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
454:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
455:                                .getCause();
456:                        assertEquals("param", e2.getActualPropertyName());
457:                        assertEquals("setParam", e2.getMethod().getName());
458:                        assertEquals(PropertyMismatchParam.class.getName(), e2
459:                                .getImplementationName());
460:                        assertSame(ParamProperty.class, e2.getAnnotationType());
461:                        assertEquals("badname", e2.getExpectedPropertyName());
462:                        assertEquals("test", e2.getSiteDeclarationName());
463:                    }
464:                }
465:            }
466:
467:            public void testPropertyMismatchedSubmissionBean() {
468:                SiteBuilder site_builder = new SiteBuilder("test",
469:                        ResourceFinderClasspath.getInstance());
470:                ElementInfoBuilder elementinfo_builder = site_builder
471:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
472:                                + ":"
473:                                + PropertyMismatchSubmissionBean.class
474:                                        .getName());
475:
476:                try {
477:                    elementinfo_builder.process();
478:                    fail("Expected exception.");
479:                } catch (EngineException e1) {
480:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
481:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
482:                                .getCause();
483:                        assertEquals("submissionBean", e2
484:                                .getActualPropertyName());
485:                        assertEquals("setSubmissionBean", e2.getMethod()
486:                                .getName());
487:                        assertEquals(PropertyMismatchSubmissionBean.class
488:                                .getName(), e2.getImplementationName());
489:                        assertSame(SubmissionBeanProperty.class, e2
490:                                .getAnnotationType());
491:                        assertEquals("badname", e2.getExpectedPropertyName());
492:                        assertEquals("test", e2.getSiteDeclarationName());
493:                    }
494:                }
495:            }
496:
497:            public void testPropertyMismatchedFile() {
498:                SiteBuilder site_builder = new SiteBuilder("test",
499:                        ResourceFinderClasspath.getInstance());
500:                ElementInfoBuilder elementinfo_builder = site_builder
501:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
502:                                + ":" + PropertyMismatchFile.class.getName());
503:
504:                try {
505:                    elementinfo_builder.process();
506:                    fail("Expected exception.");
507:                } catch (EngineException e1) {
508:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
509:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
510:                                .getCause();
511:                        assertEquals("file", e2.getActualPropertyName());
512:                        assertEquals("setFile", e2.getMethod().getName());
513:                        assertEquals(PropertyMismatchFile.class.getName(), e2
514:                                .getImplementationName());
515:                        assertSame(FileProperty.class, e2.getAnnotationType());
516:                        assertEquals("badname", e2.getExpectedPropertyName());
517:                        assertEquals("test", e2.getSiteDeclarationName());
518:                    }
519:                }
520:            }
521:
522:            public void testPropertyMismatchedOutBean() {
523:                SiteBuilder site_builder = new SiteBuilder("test",
524:                        ResourceFinderClasspath.getInstance());
525:                ElementInfoBuilder elementinfo_builder = site_builder
526:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
527:                                + ":" + PropertyMismatchOutBean.class.getName());
528:
529:                try {
530:                    elementinfo_builder.process();
531:                    fail("Expected exception.");
532:                } catch (EngineException e1) {
533:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
534:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
535:                                .getCause();
536:                        assertEquals("outBean1", e2.getActualPropertyName());
537:                        assertEquals("setOutBean1", e2.getMethod().getName());
538:                        assertEquals(PropertyMismatchOutBean.class.getName(),
539:                                e2.getImplementationName());
540:                        assertSame(OutBeanProperty.class, e2
541:                                .getAnnotationType());
542:                        assertEquals("badname", e2.getExpectedPropertyName());
543:                        assertEquals("test", e2.getSiteDeclarationName());
544:                    }
545:                }
546:            }
547:
548:            public void testPropertyMismatchedOutCookie() {
549:                SiteBuilder site_builder = new SiteBuilder("test",
550:                        ResourceFinderClasspath.getInstance());
551:                ElementInfoBuilder elementinfo_builder = site_builder
552:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
553:                                + ":"
554:                                + PropertyMismatchOutCookie.class.getName());
555:
556:                try {
557:                    elementinfo_builder.process();
558:                    fail("Expected exception.");
559:                } catch (EngineException e1) {
560:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
561:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
562:                                .getCause();
563:                        assertEquals("outcookie", e2.getActualPropertyName());
564:                        assertEquals("setOutCookie", e2.getMethod().getName());
565:                        assertEquals(PropertyMismatchOutCookie.class.getName(),
566:                                e2.getImplementationName());
567:                        assertSame(OutCookieProperty.class, e2
568:                                .getAnnotationType());
569:                        assertEquals("badname", e2.getExpectedPropertyName());
570:                        assertEquals("test", e2.getSiteDeclarationName());
571:                    }
572:                }
573:            }
574:
575:            public void testPropertyMismatchedOutput() {
576:                SiteBuilder site_builder = new SiteBuilder("test",
577:                        ResourceFinderClasspath.getInstance());
578:                ElementInfoBuilder elementinfo_builder = site_builder
579:                        .enterElement(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
580:                                + ":" + PropertyMismatchOutput.class.getName());
581:
582:                try {
583:                    elementinfo_builder.process();
584:                    fail("Expected exception.");
585:                } catch (EngineException e1) {
586:                    if (e1.getCause() instanceof  PropertyNameMismatchErrorException) {
587:                        PropertyNameMismatchErrorException e2 = (PropertyNameMismatchErrorException) e1
588:                                .getCause();
589:                        assertEquals("output", e2.getActualPropertyName());
590:                        assertEquals("setOutput", e2.getMethod().getName());
591:                        assertEquals(PropertyMismatchOutput.class.getName(), e2
592:                                .getImplementationName());
593:                        assertSame(OutputProperty.class, e2.getAnnotationType());
594:                        assertEquals("badname", e2.getExpectedPropertyName());
595:                        assertEquals("test", e2.getSiteDeclarationName());
596:                    }
597:                }
598:            }
599:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.