Source Code Cross Referenced for TestSubmission.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) 


0001:        /*
0002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003:         * Distributed under the terms of either:
0004:         * - the common development and distribution license (CDDL), v1.0; or
0005:         * - the GNU Lesser General Public License, v2.1 or later
0006:         * $Id: TestSubmission.java 3693 2007-03-14 10:55:56Z gbevin $
0007:         */
0008:        package com.uwyn.rife.engine;
0009:
0010:        import com.uwyn.rife.engine.exceptions.*;
0011:
0012:        import com.uwyn.rife.tools.ExceptionUtils;
0013:        import java.util.LinkedHashMap;
0014:        import junit.framework.TestCase;
0015:
0016:        public class TestSubmission extends TestCase {
0017:            public TestSubmission(String name) {
0018:                super (name);
0019:            }
0020:
0021:            public void testInstantiation() {
0022:                Submission submission = null;
0023:
0024:                submission = new Submission();
0025:
0026:                assertNotNull(submission);
0027:            }
0028:
0029:            public void testNoInitialParameters() {
0030:                Submission submission = new Submission();
0031:
0032:                assertEquals(submission.getParameterNames().size(), 0);
0033:            }
0034:
0035:            public void testNoInitialNamedBeans() {
0036:                Submission submission = new Submission();
0037:
0038:                assertEquals(submission.getBeanNames().size(), 0);
0039:            }
0040:
0041:            public void testNoInitialBeans() {
0042:                Submission submission = new Submission();
0043:
0044:                assertEquals(submission.getBeans().size(), 0);
0045:            }
0046:
0047:            public void testNoInitialFiles() {
0048:                Submission submission = new Submission();
0049:
0050:                assertEquals(submission.getFileNames().size(), 0);
0051:            }
0052:
0053:            public void testAddParameter() throws EngineException {
0054:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0055:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0056:                Submission submission = new Submission();
0057:                element.addSubmission("submission1", submission);
0058:
0059:                submission.addParameter("parameter1", null);
0060:                assertEquals(submission.getParameterNames().size(), 1);
0061:                submission.addParameter("parameter2", null);
0062:                assertEquals(submission.getParameterNames().size(), 2);
0063:                submission.addParameter("parameter3", null);
0064:                assertEquals(submission.getParameterNames().size(), 3);
0065:
0066:                assertTrue(submission.containsParameter("parameter1"));
0067:                assertTrue(submission.containsParameter("parameter2"));
0068:                assertTrue(submission.containsParameter("parameter3"));
0069:            }
0070:
0071:            public void testAddParameterRegexp() throws EngineException {
0072:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0073:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0074:                Submission submission = new Submission();
0075:                element.addSubmission("submission1", submission);
0076:
0077:                submission.addParameterRegexp("paramA(\\d+)");
0078:                assertEquals(submission.getParameterRegexps().size(), 1);
0079:                submission.addParameterRegexp("paramB(\\d+)");
0080:                assertEquals(submission.getParameterRegexps().size(), 2);
0081:                submission.addParameterRegexp("paramC(\\d+)");
0082:                assertEquals(submission.getParameterRegexps().size(), 3);
0083:
0084:                assertTrue(submission.containsParameter("paramA1"));
0085:                assertTrue(submission.containsParameter("paramA2"));
0086:                assertTrue(submission.containsParameter("paramA3"));
0087:                assertTrue(submission.containsParameter("paramB1"));
0088:                assertTrue(submission.containsParameter("paramB2"));
0089:                assertTrue(submission.containsParameter("paramB3"));
0090:                assertTrue(submission.containsParameter("paramC1"));
0091:                assertTrue(submission.containsParameter("paramC2"));
0092:                assertTrue(submission.containsParameter("paramC3"));
0093:                assertTrue(!submission.containsParameter("paramA"));
0094:                assertTrue(!submission.containsParameter("paramB"));
0095:                assertTrue(!submission.containsParameter("paramC"));
0096:            }
0097:
0098:            public void testAddFile() throws EngineException {
0099:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0100:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0101:                Submission submission = new Submission();
0102:                element.addSubmission("submission1", submission);
0103:
0104:                submission.addFile("file1");
0105:                assertEquals(submission.getFileNames().size(), 1);
0106:                submission.addFile("file2");
0107:                assertEquals(submission.getFileNames().size(), 2);
0108:                submission.addFile("file3");
0109:                assertEquals(submission.getFileNames().size(), 3);
0110:
0111:                assertTrue(submission.containsFile("file1"));
0112:                assertTrue(submission.containsFile("file2"));
0113:                assertTrue(submission.containsFile("file3"));
0114:            }
0115:
0116:            public void testAddBean() throws EngineException {
0117:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0118:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0119:                Submission submission = new Submission();
0120:                element.addSubmission("submission1", submission);
0121:
0122:                assertFalse(submission.containsNamedBean("bean1"));
0123:
0124:                BeanDeclaration bean1 = new BeanDeclaration(
0125:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0126:                        null, null);
0127:                submission.addBean(bean1, null);
0128:                assertEquals(submission.getBeanNames().size(), 0);
0129:                assertEquals(submission.getBeans().size(), 1);
0130:                assertEquals(submission.getBeans().iterator().next(), bean1);
0131:                assertEquals(submission.getParameterNames().size(), 22);
0132:                assertEquals(submission.getFileNames().size(), 3);
0133:                assertTrue(submission.containsParameter("enum"));
0134:                assertTrue(submission.containsParameter("string"));
0135:                assertTrue(submission.containsParameter("stringbuffer"));
0136:                assertTrue(submission.containsParameter("int"));
0137:                assertTrue(submission.containsParameter("integer"));
0138:                assertTrue(submission.containsParameter("char"));
0139:                assertTrue(submission.containsParameter("boolean"));
0140:                assertTrue(submission.containsParameter("booleanObject"));
0141:                assertTrue(submission.containsParameter("byteObject"));
0142:                assertTrue(submission.containsParameter("double"));
0143:                assertTrue(submission.containsParameter("doubleObject"));
0144:                assertTrue(submission.containsParameter("float"));
0145:                assertTrue(submission.containsParameter("floatObject"));
0146:                assertTrue(submission.containsParameter("long"));
0147:                assertTrue(submission.containsParameter("longObject"));
0148:                assertTrue(submission.containsParameter("short"));
0149:                assertTrue(submission.containsParameter("shortObject"));
0150:                assertTrue(submission.containsParameter("date"));
0151:                assertTrue(submission.containsParameter("dateFormatted"));
0152:                assertTrue(submission.containsParameter("datesFormatted"));
0153:                assertTrue(submission.containsParameter("serializableParam"));
0154:                assertTrue(submission.containsParameter("serializableParams"));
0155:                assertTrue(submission.containsFile("stringFile"));
0156:                assertTrue(submission.containsFile("bytesFile"));
0157:                assertTrue(submission.containsFile("streamFile"));
0158:            }
0159:
0160:            public void testAddBeanPrefix() throws EngineException {
0161:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0162:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0163:                Submission submission = new Submission();
0164:                element.addSubmission("submission1", submission);
0165:
0166:                assertFalse(submission.containsNamedBean("bean1"));
0167:
0168:                BeanDeclaration bean1 = new BeanDeclaration(
0169:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0170:                        "prefix_", null);
0171:                submission.addBean(bean1, null);
0172:                assertEquals(submission.getBeanNames().size(), 0);
0173:                assertEquals(submission.getBeans().size(), 1);
0174:                assertEquals(submission.getBeans().iterator().next(), bean1);
0175:                assertEquals(submission.getParameterNames().size(), 22);
0176:                assertEquals(submission.getFileNames().size(), 3);
0177:                assertTrue(submission.containsParameter("prefix_enum"));
0178:                assertTrue(submission.containsParameter("prefix_string"));
0179:                assertTrue(submission.containsParameter("prefix_stringbuffer"));
0180:                assertTrue(submission.containsParameter("prefix_int"));
0181:                assertTrue(submission.containsParameter("prefix_integer"));
0182:                assertTrue(submission.containsParameter("prefix_char"));
0183:                assertTrue(submission.containsParameter("prefix_boolean"));
0184:                assertTrue(submission.containsParameter("prefix_booleanObject"));
0185:                assertTrue(submission.containsParameter("prefix_byteObject"));
0186:                assertTrue(submission.containsParameter("prefix_double"));
0187:                assertTrue(submission.containsParameter("prefix_doubleObject"));
0188:                assertTrue(submission.containsParameter("prefix_float"));
0189:                assertTrue(submission.containsParameter("prefix_floatObject"));
0190:                assertTrue(submission.containsParameter("prefix_long"));
0191:                assertTrue(submission.containsParameter("prefix_longObject"));
0192:                assertTrue(submission.containsParameter("prefix_short"));
0193:                assertTrue(submission.containsParameter("prefix_shortObject"));
0194:                assertTrue(submission.containsParameter("prefix_date"));
0195:                assertTrue(submission.containsParameter("prefix_dateFormatted"));
0196:                assertTrue(submission
0197:                        .containsParameter("prefix_datesFormatted"));
0198:                assertTrue(submission
0199:                        .containsParameter("prefix_serializableParam"));
0200:                assertTrue(submission
0201:                        .containsParameter("prefix_serializableParams"));
0202:                assertTrue(submission.containsFile("prefix_stringFile"));
0203:                assertTrue(submission.containsFile("prefix_bytesFile"));
0204:                assertTrue(submission.containsFile("prefix_streamFile"));
0205:            }
0206:
0207:            public void testAddBeanGroup() throws EngineException {
0208:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0209:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0210:                Submission submission = new Submission();
0211:                element.addSubmission("submission1", submission);
0212:
0213:                assertFalse(submission.containsNamedBean("bean1"));
0214:
0215:                BeanDeclaration bean1 = new BeanDeclaration(
0216:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0217:                        null, "somegroup");
0218:                submission.addBean(bean1, null);
0219:                assertEquals(submission.getBeanNames().size(), 0);
0220:                assertEquals(submission.getBeans().size(), 1);
0221:                assertEquals(submission.getBeans().iterator().next(), bean1);
0222:                assertEquals(submission.getParameterNames().size(), 5);
0223:                assertEquals(submission.getFileNames().size(), 0);
0224:                assertTrue(submission.containsParameter("enum"));
0225:                assertTrue(submission.containsParameter("string"));
0226:                assertTrue(submission.containsParameter("int"));
0227:                assertTrue(submission.containsParameter("longObject"));
0228:                assertTrue(submission.containsParameter("short"));
0229:            }
0230:
0231:            public void testAddBeanGroupPrefix() throws EngineException {
0232:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0233:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0234:                Submission submission = new Submission();
0235:                element.addSubmission("submission1", submission);
0236:
0237:                assertFalse(submission.containsNamedBean("bean1"));
0238:
0239:                BeanDeclaration bean1 = new BeanDeclaration(
0240:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0241:                        "prefix_", "somegroup");
0242:                submission.addBean(bean1, null);
0243:                assertEquals(submission.getBeanNames().size(), 0);
0244:                assertEquals(submission.getBeans().size(), 1);
0245:                assertEquals(submission.getBeans().iterator().next(), bean1);
0246:                assertEquals(submission.getParameterNames().size(), 5);
0247:                assertEquals(submission.getFileNames().size(), 0);
0248:                assertTrue(submission.containsParameter("prefix_enum"));
0249:                assertTrue(submission.containsParameter("prefix_string"));
0250:                assertTrue(submission.containsParameter("prefix_int"));
0251:                assertTrue(submission.containsParameter("prefix_longObject"));
0252:                assertTrue(submission.containsParameter("prefix_short"));
0253:            }
0254:
0255:            public void testAddNamedBean() throws EngineException {
0256:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0257:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0258:                Submission submission = new Submission();
0259:                element.addSubmission("submission1", submission);
0260:
0261:                assertFalse(submission.containsNamedBean("bean1"));
0262:
0263:                BeanDeclaration bean1 = new BeanDeclaration(
0264:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0265:                        null, null);
0266:                submission.addBean(bean1, "bean1");
0267:                assertTrue(submission.containsNamedBean("bean1"));
0268:                assertEquals(submission.getBeanNames().size(), 1);
0269:                assertEquals(submission.getBeanNames().iterator().next(),
0270:                        "bean1");
0271:                assertEquals(submission.getBeans().size(), 1);
0272:                assertEquals(submission.getBeans().iterator().next(), bean1);
0273:                assertEquals(submission.getParameterNames().size(), 22);
0274:                assertEquals(submission.getFileNames().size(), 3);
0275:                assertTrue(submission.containsParameter("enum"));
0276:                assertTrue(submission.containsParameter("string"));
0277:                assertTrue(submission.containsParameter("stringbuffer"));
0278:                assertTrue(submission.containsParameter("int"));
0279:                assertTrue(submission.containsParameter("integer"));
0280:                assertTrue(submission.containsParameter("char"));
0281:                assertTrue(submission.containsParameter("boolean"));
0282:                assertTrue(submission.containsParameter("booleanObject"));
0283:                assertTrue(submission.containsParameter("byteObject"));
0284:                assertTrue(submission.containsParameter("double"));
0285:                assertTrue(submission.containsParameter("doubleObject"));
0286:                assertTrue(submission.containsParameter("float"));
0287:                assertTrue(submission.containsParameter("floatObject"));
0288:                assertTrue(submission.containsParameter("long"));
0289:                assertTrue(submission.containsParameter("longObject"));
0290:                assertTrue(submission.containsParameter("short"));
0291:                assertTrue(submission.containsParameter("shortObject"));
0292:                assertTrue(submission.containsParameter("date"));
0293:                assertTrue(submission.containsParameter("dateFormatted"));
0294:                assertTrue(submission.containsParameter("datesFormatted"));
0295:                assertTrue(submission.containsParameter("serializableParam"));
0296:                assertTrue(submission.containsParameter("serializableParams"));
0297:                assertTrue(submission.containsFile("stringFile"));
0298:                assertTrue(submission.containsFile("bytesFile"));
0299:                assertTrue(submission.containsFile("streamFile"));
0300:                BeanDeclaration bean2 = submission.getNamedBean("bean1");
0301:                assertNotNull(bean2);
0302:                assertEquals(bean1, bean2);
0303:            }
0304:
0305:            public void testAddNamedBeanPrefix() throws EngineException {
0306:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0307:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0308:                Submission submission = new Submission();
0309:                element.addSubmission("submission1", submission);
0310:
0311:                assertFalse(submission.containsNamedBean("bean1"));
0312:
0313:                BeanDeclaration bean1 = new BeanDeclaration(
0314:                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0315:                        "prefix_", null);
0316:                submission.addBean(bean1, "bean1");
0317:                assertTrue(submission.containsNamedBean("bean1"));
0318:                assertEquals(submission.getBeanNames().size(), 1);
0319:                assertEquals(submission.getBeanNames().iterator().next(),
0320:                        "bean1");
0321:                assertEquals(submission.getBeans().size(), 1);
0322:                assertEquals(submission.getBeans().iterator().next(), bean1);
0323:                assertEquals(submission.getParameterNames().size(), 22);
0324:                assertEquals(submission.getFileNames().size(), 3);
0325:                assertTrue(submission.containsParameter("prefix_enum"));
0326:                assertTrue(submission.containsParameter("prefix_string"));
0327:                assertTrue(submission.containsParameter("prefix_stringbuffer"));
0328:                assertTrue(submission.containsParameter("prefix_int"));
0329:                assertTrue(submission.containsParameter("prefix_integer"));
0330:                assertTrue(submission.containsParameter("prefix_char"));
0331:                assertTrue(submission.containsParameter("prefix_boolean"));
0332:                assertTrue(submission.containsParameter("prefix_booleanObject"));
0333:                assertTrue(submission.containsParameter("prefix_byteObject"));
0334:                assertTrue(submission.containsParameter("prefix_double"));
0335:                assertTrue(submission.containsParameter("prefix_doubleObject"));
0336:                assertTrue(submission.containsParameter("prefix_float"));
0337:                assertTrue(submission.containsParameter("prefix_floatObject"));
0338:                assertTrue(submission.containsParameter("prefix_long"));
0339:                assertTrue(submission.containsParameter("prefix_longObject"));
0340:                assertTrue(submission.containsParameter("prefix_short"));
0341:                assertTrue(submission.containsParameter("prefix_shortObject"));
0342:                assertTrue(submission.containsParameter("prefix_date"));
0343:                assertTrue(submission.containsParameter("prefix_dateFormatted"));
0344:                assertTrue(submission
0345:                        .containsParameter("prefix_datesFormatted"));
0346:                assertTrue(submission
0347:                        .containsParameter("prefix_serializableParam"));
0348:                assertTrue(submission
0349:                        .containsParameter("prefix_serializableParams"));
0350:                assertTrue(submission.containsFile("prefix_stringFile"));
0351:                assertTrue(submission.containsFile("prefix_bytesFile"));
0352:                assertTrue(submission.containsFile("prefix_streamFile"));
0353:                BeanDeclaration bean2 = submission.getNamedBean("bean1");
0354:                assertNotNull(bean2);
0355:                assertEquals(bean1, bean2);
0356:            }
0357:
0358:            public void testAddDuplicateParameter() {
0359:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0360:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0361:                Submission submission = new Submission();
0362:                element.addSubmission("submission1", submission);
0363:
0364:                try {
0365:                    submission.addParameter("parameter1", null);
0366:                } catch (EngineException e) {
0367:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0368:                }
0369:                assertEquals(submission.getParameterNames().size(), 1);
0370:                try {
0371:                    submission.addParameter("parameter1", null);
0372:                    fail();
0373:                } catch (ParameterExistsException e) {
0374:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0375:                    assertEquals(e.getSubmissionName(), "submission1");
0376:                    assertEquals(e.getParameterName(), "parameter1");
0377:                } catch (EngineException e) {
0378:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0379:                }
0380:                assertEquals(submission.getParameterNames().size(), 1);
0381:            }
0382:
0383:            public void testAddDuplicateFile() {
0384:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0385:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0386:                Submission submission = new Submission();
0387:                element.addSubmission("submission1", submission);
0388:
0389:                try {
0390:                    submission.addFile("file1");
0391:                } catch (EngineException e) {
0392:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0393:                }
0394:                assertEquals(submission.getFileNames().size(), 1);
0395:                try {
0396:                    submission.addFile("file1");
0397:                    fail();
0398:                } catch (FileExistsException e) {
0399:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0400:                    assertEquals(e.getSubmissionName(), "submission1");
0401:                    assertEquals(e.getFileName(), "file1");
0402:                } catch (EngineException e) {
0403:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0404:                }
0405:                assertEquals(submission.getFileNames().size(), 1);
0406:            }
0407:
0408:            public void testAddDuplicateNamedBean() {
0409:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0410:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0411:                Submission submission = new Submission();
0412:                element.addSubmission("submission1", submission);
0413:
0414:                try {
0415:                    submission
0416:                            .addBean(
0417:                                    new BeanDeclaration(
0418:                                            "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0419:                                            null, null), "bean1");
0420:                } catch (EngineException e) {
0421:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0422:                }
0423:                assertEquals(submission.getBeanNames().size(), 1);
0424:                try {
0425:                    submission
0426:                            .addBean(
0427:                                    new BeanDeclaration(
0428:                                            "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0429:                                            "prefix_", null), "bean1");
0430:                    fail();
0431:                } catch (NamedSubmissionBeanExistsException e) {
0432:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0433:                    assertEquals(e.getSubmissionName(), "submission1");
0434:                    assertEquals(e.getBeanName(), "bean1");
0435:                } catch (EngineException e) {
0436:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0437:                }
0438:                assertEquals(submission.getBeanNames().size(), 1);
0439:            }
0440:
0441:            public void testAddBeanUnknownGroup() {
0442:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0443:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0444:                Submission submission = new Submission();
0445:                element.addSubmission("submission1", submission);
0446:
0447:                try {
0448:                    submission
0449:                            .addBean(
0450:                                    new BeanDeclaration(
0451:                                            "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0452:                                            null, "unknown"), null);
0453:                } catch (SubmissionBeanGroupNotFoundException e) {
0454:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0455:                    assertEquals(e.getSubmissionName(), "submission1");
0456:                    assertEquals(e.getClassName(),
0457:                            "com.uwyn.rife.engine.testelements.submission.BeanImpl");
0458:                    assertEquals(e.getGroupName(), "unknown");
0459:                } catch (EngineException e) {
0460:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0461:                }
0462:                assertEquals(submission.getBeanNames().size(), 0);
0463:                assertEquals(submission.getBeans().size(), 0);
0464:
0465:                try {
0466:                    submission
0467:                            .addBean(
0468:                                    new BeanDeclaration(
0469:                                            "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0470:                                            null, "unknown"), "bean1");
0471:                } catch (NamedSubmissionBeanGroupNotFoundException e) {
0472:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0473:                    assertEquals(e.getSubmissionName(), "submission1");
0474:                    assertEquals(e.getClassName(),
0475:                            "com.uwyn.rife.engine.testelements.submission.BeanImpl");
0476:                    assertEquals(e.getGroupName(), "unknown");
0477:                    assertEquals(e.getBeanName(), "bean1");
0478:                } catch (EngineException e) {
0479:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0480:                }
0481:                assertEquals(submission.getBeanNames().size(), 0);
0482:                assertEquals(submission.getBeans().size(), 0);
0483:            }
0484:
0485:            public void testAddBeanGroupOnNonValidationClass() {
0486:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0487:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0488:                Submission submission = new Submission();
0489:                element.addSubmission("submission1", submission);
0490:
0491:                try {
0492:                    submission
0493:                            .addBean(
0494:                                    new BeanDeclaration(
0495:                                            "com.uwyn.rife.engine.testelements.submission.BeanPojo",
0496:                                            null, "thegroup"), null);
0497:                } catch (SubmissionBeanGroupRequiresValidatedConstrainedException e) {
0498:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0499:                    assertEquals(e.getSubmissionName(), "submission1");
0500:                    assertEquals(e.getClassName(),
0501:                            "com.uwyn.rife.engine.testelements.submission.BeanPojo");
0502:                    assertEquals(e.getGroupName(), "thegroup");
0503:                } catch (EngineException e) {
0504:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0505:                }
0506:                assertEquals(submission.getBeanNames().size(), 0);
0507:                assertEquals(submission.getBeans().size(), 0);
0508:
0509:                try {
0510:                    submission
0511:                            .addBean(
0512:                                    new BeanDeclaration(
0513:                                            "com.uwyn.rife.engine.testelements.submission.BeanPojo",
0514:                                            null, "thegroup"), "bean1");
0515:                } catch (NamedSubmissionBeanGroupRequiresValidatedConstrainedException e) {
0516:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0517:                    assertEquals(e.getSubmissionName(), "submission1");
0518:                    assertEquals(e.getClassName(),
0519:                            "com.uwyn.rife.engine.testelements.submission.BeanPojo");
0520:                    assertEquals(e.getGroupName(), "thegroup");
0521:                    assertEquals(e.getBeanName(), "bean1");
0522:                } catch (EngineException e) {
0523:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0524:                }
0525:                assertEquals(submission.getBeanNames().size(), 0);
0526:                assertEquals(submission.getBeans().size(), 0);
0527:            }
0528:
0529:            public void testValidateBeanName() throws EngineException {
0530:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0531:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0532:                Submission submission = new Submission();
0533:                element.addSubmission("submission1", submission);
0534:
0535:                try {
0536:                    submission.validateBeanName("bean1");
0537:                    fail();
0538:                } catch (NamedSubmissionBeanUnknownException e) {
0539:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0540:                    assertEquals(e.getSubmissionName(), "submission1");
0541:                    assertEquals(e.getBeanName(), "bean1");
0542:                } catch (EngineException e) {
0543:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0544:                }
0545:
0546:                submission
0547:                        .addBean(
0548:                                new BeanDeclaration(
0549:                                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0550:                                        null, null), "bean1");
0551:                try {
0552:                    submission.validateBeanName("bean1");
0553:                    assertTrue(true);
0554:                } catch (EngineException e) {
0555:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0556:                }
0557:            }
0558:
0559:            public void testGetNamedBean() throws EngineException {
0560:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0561:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0562:                Submission submission = new Submission();
0563:                element.addSubmission("submission1", submission);
0564:
0565:                try {
0566:                    submission.getNamedBean("bean1");
0567:                    fail();
0568:                } catch (NamedSubmissionBeanUnknownException e) {
0569:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0570:                    assertEquals(e.getSubmissionName(), "submission1");
0571:                    assertEquals(e.getBeanName(), "bean1");
0572:                } catch (EngineException e) {
0573:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0574:                }
0575:
0576:                submission
0577:                        .addBean(
0578:                                new BeanDeclaration(
0579:                                        "com.uwyn.rife.engine.testelements.submission.BeanImpl",
0580:                                        "prf", null), "bean1");
0581:                try {
0582:                    assertEquals(submission.getNamedBean("bean1")
0583:                            .getClassname(),
0584:                            "com.uwyn.rife.engine.testelements.submission.BeanImpl");
0585:                    assertEquals(submission.getNamedBean("bean1").getPrefix(),
0586:                            "prf");
0587:                    assertTrue(true);
0588:                } catch (EngineException e) {
0589:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0590:                }
0591:            }
0592:
0593:            public void testParameterRegexpConflict() {
0594:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0595:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0596:                Submission submission = new Submission();
0597:                element.addSubmission("submission1", submission);
0598:
0599:                try {
0600:                    submission.addParameterRegexp("parameterregexp(\\d+)");
0601:                } catch (EngineException e) {
0602:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0603:                }
0604:                assertEquals(submission.getParameterRegexps().size(), 1);
0605:
0606:                element.addInput("input1", null);
0607:                try {
0608:                    submission.addParameterRegexp("input(.*)");
0609:                    fail();
0610:                } catch (ParameterRegexpInputConflictException e) {
0611:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0612:                    assertEquals(e.getSubmissionName(), "submission1");
0613:                    assertEquals(e.getInputName(), "input1");
0614:                    assertEquals(e.getConflictName(), "^input(.*)$");
0615:                } catch (EngineException e) {
0616:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0617:                }
0618:                assertEquals(submission.getParameterRegexps().size(), 1);
0619:
0620:                element.addIncookie("incookie1", null);
0621:                try {
0622:                    submission.addParameterRegexp("incookie(.*)");
0623:                    fail();
0624:                } catch (ParameterRegexpIncookieConflictException e) {
0625:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0626:                    assertEquals(e.getSubmissionName(), "submission1");
0627:                    assertEquals(e.getIncookieName(), "incookie1");
0628:                    assertEquals(e.getConflictName(), "^incookie(.*)$");
0629:                } catch (EngineException e) {
0630:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0631:                }
0632:                assertEquals(submission.getParameterRegexps().size(), 1);
0633:
0634:                submission.addParameter("parameter1", null);
0635:                try {
0636:                    submission.addParameterRegexp("parameter(\\d+)");
0637:                    fail();
0638:                } catch (ParameterRegexpParameterConflictException e) {
0639:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0640:                    assertEquals(e.getSubmissionName(), "submission1");
0641:                    assertEquals(e.getParameterName(), "parameter1");
0642:                    assertEquals(e.getConflictName(), "^parameter(\\d+)$");
0643:                } catch (EngineException e) {
0644:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0645:                }
0646:                assertEquals(submission.getParameterRegexps().size(), 1);
0647:
0648:                submission.addFile("file1");
0649:                try {
0650:                    submission.addParameterRegexp("file(\\d+)");
0651:                    fail();
0652:                } catch (ParameterRegexpFileConflictException e) {
0653:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0654:                    assertEquals(e.getSubmissionName(), "submission1");
0655:                    assertEquals(e.getFileName(), "file1");
0656:                    assertEquals(e.getConflictName(), "^file(\\d+)$");
0657:                } catch (EngineException e) {
0658:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0659:                }
0660:                assertEquals(submission.getParameterRegexps().size(), 1);
0661:
0662:                element.setGlobalVars(new LinkedHashMap<String, GlobalVar>() {
0663:                    {
0664:                        put("globalvar1", new GlobalVar(null));
0665:                    }
0666:                });
0667:                try {
0668:                    submission.addParameterRegexp("globalvar(.*)");
0669:                    fail();
0670:                } catch (ParameterRegexpGlobalVarConflictException e) {
0671:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0672:                    assertEquals(e.getSubmissionName(), "submission1");
0673:                    assertEquals(e.getGlobalVarName(), "globalvar1");
0674:                    assertEquals(e.getConflictName(), "^globalvar(.*)$");
0675:                } catch (EngineException e) {
0676:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0677:                }
0678:                assertEquals(submission.getParameterRegexps().size(), 1);
0679:
0680:                element.setGlobalCookies(new LinkedHashMap<String, String>() {
0681:                    {
0682:                        put("globalcookie1", null);
0683:                    }
0684:                });
0685:                try {
0686:                    submission.addParameterRegexp("globalcookie(.*)");
0687:                    fail();
0688:                } catch (ParameterRegexpGlobalCookieConflictException e) {
0689:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0690:                    assertEquals(e.getSubmissionName(), "submission1");
0691:                    assertEquals(e.getGlobalCookieName(), "globalcookie1");
0692:                    assertEquals(e.getConflictName(), "^globalcookie(.*)$");
0693:                } catch (EngineException e) {
0694:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0695:                }
0696:                assertEquals(submission.getParameterRegexps().size(), 1);
0697:
0698:            }
0699:
0700:            public void testParameterConflicts() {
0701:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0702:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0703:                Submission submission = new Submission();
0704:                element.addSubmission("submission1", submission);
0705:
0706:                try {
0707:                    submission.addParameter("parameter1", null);
0708:                } catch (EngineException e) {
0709:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0710:                }
0711:                assertEquals(submission.getParameterNames().size(), 1);
0712:
0713:                element.addInput("input1", null);
0714:                try {
0715:                    submission.addParameter("input1", null);
0716:                    fail();
0717:                } catch (ParameterInputConflictException e) {
0718:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0719:                    assertEquals(e.getSubmissionName(), "submission1");
0720:                    assertEquals(e.getConflictName(), "input1");
0721:                } catch (EngineException e) {
0722:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0723:                }
0724:                assertEquals(submission.getParameterNames().size(), 1);
0725:
0726:                element.addIncookie("incookie1", null);
0727:                try {
0728:                    submission.addParameter("incookie1", null);
0729:                    fail();
0730:                } catch (ParameterIncookieConflictException e) {
0731:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0732:                    assertEquals(e.getSubmissionName(), "submission1");
0733:                    assertEquals(e.getConflictName(), "incookie1");
0734:                } catch (EngineException e) {
0735:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0736:                }
0737:                assertEquals(submission.getParameterNames().size(), 1);
0738:
0739:                submission.addFile("file1");
0740:                try {
0741:                    submission.addParameter("file1", null);
0742:                    fail();
0743:                } catch (ParameterFileConflictException e) {
0744:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0745:                    assertEquals(e.getSubmissionName(), "submission1");
0746:                    assertEquals(e.getConflictName(), "file1");
0747:                } catch (EngineException e) {
0748:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0749:                }
0750:                assertEquals(submission.getParameterNames().size(), 1);
0751:
0752:                submission.addParameterRegexp("regexpparameter(\\d+)");
0753:                try {
0754:                    submission.addParameter("regexpparameter1", null);
0755:                    fail();
0756:                } catch (ParameterParameterRegexpConflictException e) {
0757:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0758:                    assertEquals(e.getSubmissionName(), "submission1");
0759:                    assertEquals(e.getConflictName(), "regexpparameter1");
0760:                    assertEquals(e.getParameterRegexp(),
0761:                            "^regexpparameter(\\d+)$");
0762:                } catch (EngineException e) {
0763:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0764:                }
0765:                assertEquals(submission.getFileNames().size(), 1);
0766:
0767:                submission.addFileRegexp("regexpfile(\\d+)");
0768:                try {
0769:                    submission.addParameter("regexpfile1", null);
0770:                    fail();
0771:                } catch (ParameterFileRegexpConflictException e) {
0772:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0773:                    assertEquals(e.getSubmissionName(), "submission1");
0774:                    assertEquals(e.getConflictName(), "regexpfile1");
0775:                    assertEquals(e.getFileRegexp(), "^regexpfile(\\d+)$");
0776:                } catch (EngineException e) {
0777:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0778:                }
0779:                assertEquals(submission.getFileNames().size(), 1);
0780:
0781:                LinkedHashMap<String, GlobalVar> globals_vars = new LinkedHashMap<String, GlobalVar>();
0782:                globals_vars.put("globalvar1", new GlobalVar(null));
0783:                element = new ElementInfo("element/test2.xml", "text/html",
0784:                        TestElement2.class.getName(), ElementType.JAVA_CLASS);
0785:                element.setGlobalVars(globals_vars);
0786:                submission = new Submission();
0787:                element.addSubmission("submission1", submission);
0788:                try {
0789:                    submission.addParameter("globalvar1", null);
0790:                    fail();
0791:                } catch (ParameterGlobalVarConflictException e) {
0792:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0793:                    assertEquals(e.getConflictName(), "globalvar1");
0794:                } catch (EngineException e) {
0795:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0796:                }
0797:                assertEquals(submission.getParameterNames().size(), 0);
0798:
0799:                LinkedHashMap<String, String> globals_cookies = new LinkedHashMap<String, String>();
0800:                globals_cookies.put("globalcookie1", null);
0801:                element = new ElementInfo("element/test2.xml", "text/html",
0802:                        TestElement2.class.getName(), ElementType.JAVA_CLASS);
0803:                element.setGlobalCookies(globals_cookies);
0804:                submission = new Submission();
0805:                element.addSubmission("submission1", submission);
0806:                try {
0807:                    submission.addParameter("globalcookie1", null);
0808:                    fail();
0809:                } catch (ParameterGlobalCookieConflictException e) {
0810:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0811:                    assertEquals(e.getConflictName(), "globalcookie1");
0812:                } catch (EngineException e) {
0813:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0814:                }
0815:                assertEquals(submission.getParameterNames().size(), 0);
0816:            }
0817:
0818:            public void testFileRegexpConflict() {
0819:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0820:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0821:                Submission submission = new Submission();
0822:                element.addSubmission("submission1", submission);
0823:
0824:                try {
0825:                    submission.addFileRegexp("fileregexp(\\d+)");
0826:                } catch (EngineException e) {
0827:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0828:                }
0829:                assertEquals(submission.getFileRegexps().size(), 1);
0830:
0831:                element.addInput("input1", null);
0832:                try {
0833:                    submission.addFileRegexp("input(.*)");
0834:                    fail();
0835:                } catch (FileRegexpInputConflictException e) {
0836:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0837:                    assertEquals(e.getSubmissionName(), "submission1");
0838:                    assertEquals(e.getInputName(), "input1");
0839:                    assertEquals(e.getConflictName(), "^input(.*)$");
0840:                } catch (EngineException e) {
0841:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0842:                }
0843:                assertEquals(submission.getFileRegexps().size(), 1);
0844:
0845:                element.addIncookie("incookie1", null);
0846:                try {
0847:                    submission.addFileRegexp("incookie(.*)");
0848:                    fail();
0849:                } catch (FileRegexpIncookieConflictException e) {
0850:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0851:                    assertEquals(e.getSubmissionName(), "submission1");
0852:                    assertEquals(e.getIncookieName(), "incookie1");
0853:                    assertEquals(e.getConflictName(), "^incookie(.*)$");
0854:                } catch (EngineException e) {
0855:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0856:                }
0857:                assertEquals(submission.getFileRegexps().size(), 1);
0858:
0859:                submission.addFile("file1");
0860:                try {
0861:                    submission.addFileRegexp("file(\\d+)");
0862:                    fail();
0863:                } catch (FileRegexpFileConflictException e) {
0864:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0865:                    assertEquals(e.getSubmissionName(), "submission1");
0866:                    assertEquals(e.getFileName(), "file1");
0867:                    assertEquals(e.getConflictName(), "^file(\\d+)$");
0868:                } catch (EngineException e) {
0869:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0870:                }
0871:                assertEquals(submission.getFileRegexps().size(), 1);
0872:
0873:                submission.addParameter("param1", null);
0874:                try {
0875:                    submission.addFileRegexp("param(\\d+)");
0876:                    fail();
0877:                } catch (FileRegexpParameterConflictException e) {
0878:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0879:                    assertEquals(e.getSubmissionName(), "submission1");
0880:                    assertEquals(e.getParameterName(), "param1");
0881:                    assertEquals(e.getConflictName(), "^param(\\d+)$");
0882:                } catch (EngineException e) {
0883:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0884:                }
0885:                assertEquals(submission.getFileRegexps().size(), 1);
0886:
0887:                element.setGlobalVars(new LinkedHashMap<String, GlobalVar>() {
0888:                    {
0889:                        put("globalvar1", new GlobalVar(null));
0890:                    }
0891:                });
0892:                try {
0893:                    submission.addFileRegexp("globalvar(.*)");
0894:                    fail();
0895:                } catch (FileRegexpGlobalVarConflictException e) {
0896:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0897:                    assertEquals(e.getSubmissionName(), "submission1");
0898:                    assertEquals(e.getGlobalVarName(), "globalvar1");
0899:                    assertEquals(e.getConflictName(), "^globalvar(.*)$");
0900:                } catch (EngineException e) {
0901:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0902:                }
0903:                assertEquals(submission.getFileRegexps().size(), 1);
0904:
0905:                element.setGlobalCookies(new LinkedHashMap<String, String>() {
0906:                    {
0907:                        put("globalcookie1", null);
0908:                    }
0909:                });
0910:                try {
0911:                    submission.addFileRegexp("globalcookie(.*)");
0912:                    fail();
0913:                } catch (FileRegexpGlobalCookieConflictException e) {
0914:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0915:                    assertEquals(e.getSubmissionName(), "submission1");
0916:                    assertEquals(e.getGlobalCookieName(), "globalcookie1");
0917:                    assertEquals(e.getConflictName(), "^globalcookie(.*)$");
0918:                } catch (EngineException e) {
0919:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0920:                }
0921:                assertEquals(submission.getFileRegexps().size(), 1);
0922:
0923:            }
0924:
0925:            public void testFileConflicts() {
0926:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
0927:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
0928:                Submission submission = new Submission();
0929:                element.addSubmission("submission1", submission);
0930:
0931:                try {
0932:                    submission.addFile("file1");
0933:                } catch (EngineException e) {
0934:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0935:                }
0936:                assertEquals(submission.getFileNames().size(), 1);
0937:
0938:                element.addInput("input1", null);
0939:                try {
0940:                    submission.addFile("input1");
0941:                    fail();
0942:                } catch (FileInputConflictException e) {
0943:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0944:                    assertEquals(e.getSubmissionName(), "submission1");
0945:                    assertEquals(e.getConflictName(), "input1");
0946:                } catch (EngineException e) {
0947:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0948:                }
0949:                assertEquals(submission.getFileNames().size(), 1);
0950:
0951:                element.addIncookie("incookie1", null);
0952:                try {
0953:                    submission.addFile("incookie1");
0954:                    fail();
0955:                } catch (FileIncookieConflictException e) {
0956:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0957:                    assertEquals(e.getSubmissionName(), "submission1");
0958:                    assertEquals(e.getConflictName(), "incookie1");
0959:                } catch (EngineException e) {
0960:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0961:                }
0962:                assertEquals(submission.getFileNames().size(), 1);
0963:
0964:                submission.addParameter("parameter1", null);
0965:                try {
0966:                    submission.addFile("parameter1");
0967:                    fail();
0968:                } catch (FileParameterConflictException e) {
0969:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0970:                    assertEquals(e.getSubmissionName(), "submission1");
0971:                    assertEquals(e.getConflictName(), "parameter1");
0972:                } catch (EngineException e) {
0973:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0974:                }
0975:                assertEquals(submission.getFileNames().size(), 1);
0976:
0977:                submission.addParameterRegexp("regexpparameter(\\d+)");
0978:                try {
0979:                    submission.addFile("regexpparameter1");
0980:                    fail();
0981:                } catch (FileParameterRegexpConflictException e) {
0982:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0983:                    assertEquals(e.getSubmissionName(), "submission1");
0984:                    assertEquals(e.getConflictName(), "regexpparameter1");
0985:                    assertEquals(e.getParameterRegexp(),
0986:                            "^regexpparameter(\\d+)$");
0987:                } catch (EngineException e) {
0988:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0989:                }
0990:                assertEquals(submission.getFileNames().size(), 1);
0991:
0992:                submission.addFileRegexp("regexpfile(\\d+)");
0993:                try {
0994:                    submission.addFile("regexpfile1");
0995:                    fail();
0996:                } catch (FileFileRegexpConflictException e) {
0997:                    assertSame(e.getDeclarationName(), "element/test4.xml");
0998:                    assertEquals(e.getSubmissionName(), "submission1");
0999:                    assertEquals(e.getConflictName(), "regexpfile1");
1000:                    assertEquals(e.getFileRegexp(), "^regexpfile(\\d+)$");
1001:                } catch (EngineException e) {
1002:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1003:                }
1004:                assertEquals(submission.getFileNames().size(), 1);
1005:
1006:                LinkedHashMap<String, GlobalVar> globals_vars = new LinkedHashMap<String, GlobalVar>();
1007:                globals_vars.put("globalvar1", new GlobalVar(null));
1008:                element = new ElementInfo("element/test2.xml", "text/html",
1009:                        TestElement2.class.getName(), ElementType.JAVA_CLASS);
1010:                element.setGlobalVars(globals_vars);
1011:                submission = new Submission();
1012:                element.addSubmission("submission1", submission);
1013:                try {
1014:                    submission.addFile("globalvar1");
1015:                    fail();
1016:                } catch (FileGlobalVarConflictException e) {
1017:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1018:                    assertEquals(e.getConflictName(), "globalvar1");
1019:                } catch (EngineException e) {
1020:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1021:                }
1022:                assertEquals(submission.getFileNames().size(), 0);
1023:
1024:                LinkedHashMap<String, String> globals_cookies = new LinkedHashMap<String, String>();
1025:                globals_cookies.put("globalcookie1", null);
1026:                element = new ElementInfo("element/test2.xml", "text/html",
1027:                        TestElement2.class.getName(), ElementType.JAVA_CLASS);
1028:                element.setGlobalCookies(globals_cookies);
1029:                submission = new Submission();
1030:                element.addSubmission("submission1", submission);
1031:                try {
1032:                    submission.addFile("globalcookie1");
1033:                    fail();
1034:                } catch (FileGlobalCookieConflictException e) {
1035:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1036:                    assertEquals(e.getConflictName(), "globalcookie1");
1037:                } catch (EngineException e) {
1038:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1039:                }
1040:                assertEquals(submission.getFileNames().size(), 0);
1041:            }
1042:
1043:            public void testAddParameterDefaultValues() throws EngineException {
1044:                ElementInfo element = new ElementInfo("element/test4.xml", "/",
1045:                        TestElement4.class.getName(), ElementType.JAVA_CLASS);
1046:                Submission submission = new Submission();
1047:                element.addSubmission("submission1", submission);
1048:
1049:                assertTrue(false == submission.hasParameterDefaults());
1050:
1051:                submission.addParameter("parameter1", new String[] { "one",
1052:                        "two" });
1053:                submission.addParameter("parameter2", new String[] { "three" });
1054:                submission.addParameter("parameter3", null);
1055:
1056:                assertTrue(submission.hasParameterDefaults());
1057:
1058:                assertTrue(submission.hasParameterDefaultValues("parameter1"));
1059:                assertTrue(submission.hasParameterDefaultValues("parameter2"));
1060:                assertTrue(false == submission
1061:                        .hasParameterDefaultValues("parameter3"));
1062:
1063:                assertNotNull(submission
1064:                        .getParameterDefaultValues("parameter1"));
1065:                assertNotNull(submission
1066:                        .getParameterDefaultValues("parameter2"));
1067:                assertNull(submission.getParameterDefaultValues("parameter3"));
1068:
1069:                assertEquals(2, submission
1070:                        .getParameterDefaultValues("parameter1").length);
1071:                assertEquals(1, submission
1072:                        .getParameterDefaultValues("parameter2").length);
1073:
1074:                assertEquals("one", submission
1075:                        .getParameterDefaultValues("parameter1")[0]);
1076:                assertEquals("two", submission
1077:                        .getParameterDefaultValues("parameter1")[1]);
1078:                assertEquals("three", submission
1079:                        .getParameterDefaultValues("parameter2")[0]);
1080:            }
1081:        }
1082:
1083:        class TestElement4 extends Element {
1084:            public void processElement() throws EngineException {
1085:                print("the content");
1086:            }
1087:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.