Source Code Cross Referenced for TestElementInfo.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: TestElementInfo.java 3701 2007-03-18 12:24:23Z gbevin $
0007:         */
0008:        package com.uwyn.rife.engine;
0009:
0010:        import com.uwyn.rife.engine.exceptions.*;
0011:
0012:        import com.uwyn.rife.rep.Rep;
0013:        import com.uwyn.rife.tools.ExceptionUtils;
0014:        import java.util.Collection;
0015:        import java.util.Iterator;
0016:        import java.util.LinkedHashMap;
0017:        import java.util.Map;
0018:        import java.util.Set;
0019:        import junit.framework.TestCase;
0020:
0021:        public class TestElementInfo extends TestCase {
0022:            public TestElementInfo(String name) {
0023:                super (name);
0024:            }
0025:
0026:            public void testInstantiation() throws EngineException {
0027:                ElementInfo element_info1 = null;
0028:                ElementInfo element_info2 = null;
0029:
0030:                element_info1 = new ElementInfo("element/test2.xml",
0031:                        "text/html", TestElement2.class.getName(),
0032:                        ElementType.JAVA_CLASS);
0033:                assertNotNull(element_info1);
0034:                element_info2 = new ElementInfo("element/test3.xml",
0035:                        "text/html", TestElement3.class.getName(),
0036:                        ElementType.JAVA_CLASS);
0037:                assertNotNull(element_info2);
0038:            }
0039:
0040:            public void testGetElement() throws EngineException {
0041:                // use publically available classes
0042:                ElementInfo element_info1 = new ElementInfo(
0043:                        "element/test2.xml", "text/html",
0044:                        com.uwyn.rife.engine.testelements.engine.Simple.class
0045:                                .getName(), ElementType.JAVA_CLASS);
0046:                ElementInfo element_info2 = new ElementInfo(
0047:                        "element/test3.xml", "text/html",
0048:                        com.uwyn.rife.engine.testelements.inputs.Normal.class
0049:                                .getName(), ElementType.JAVA_CLASS);
0050:
0051:                // these can't be the same classes since the classloader is different
0052:                assertEquals(element_info1.getElement().getClass().getName(),
0053:                        com.uwyn.rife.engine.testelements.engine.Simple.class
0054:                                .getName());
0055:                assertEquals(element_info2.getElement().getClass().getName(),
0056:                        com.uwyn.rife.engine.testelements.inputs.Normal.class
0057:                                .getName());
0058:            }
0059:
0060:            public void testClone() throws EngineException {
0061:                ElementInfo element_info_dest = new ElementInfo(
0062:                        "element/test3.xml", "text/html", TestElement3.class
0063:                                .getName(), ElementType.JAVA_CLASS);
0064:                element_info_dest.addInput("input1", null);
0065:                element_info_dest.addInput("input2", null);
0066:                element_info_dest.addInput("input3", null);
0067:
0068:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0069:                        "text/html", TestElement2.class.getName(),
0070:                        ElementType.JAVA_CLASS);
0071:
0072:                LinkedHashMap<String, GlobalExit> globalexits = new LinkedHashMap<String, GlobalExit>();
0073:                globalexits.put("globalexit1", new GlobalExit("DEST1", false,
0074:                        false, false, false, false, false).setGroupId(0));
0075:                globalexits.put("globalexit2", new GlobalExit(null, true,
0076:                        false, false, false, false, true).setGroupId(0));
0077:                globalexits.put("globalexit3", new GlobalExit(null, false,
0078:                        true, false, false, false, false).setGroupId(0));
0079:                element_info.setGlobalExits(globalexits);
0080:
0081:                LinkedHashMap<String, GlobalVar> globalvars = new LinkedHashMap<String, GlobalVar>();
0082:                globalvars.put("globalvar1", new GlobalVar(null).setGroupId(0));
0083:                globalvars.put("globalvar2", new GlobalVar(null).setGroupId(0));
0084:                globalvars.put("globalvar3", new GlobalVar(null).setGroupId(0));
0085:                element_info.setGlobalVars(globalvars);
0086:
0087:                element_info.addStaticProperty("property1", "value1");
0088:                element_info.addStaticProperty("property2", "value2");
0089:                element_info.addStaticProperty("property3", "value3");
0090:
0091:                element_info.addInput("input1", null);
0092:                element_info.addInput("input2", null);
0093:                element_info.addInput("input3", null);
0094:
0095:                element_info.addOutput("output1", null);
0096:                element_info.addOutput("output2", null);
0097:                element_info.addOutput("output3", null);
0098:
0099:                element_info.addIncookie("incookie1", null);
0100:                element_info.addIncookie("incookie2", null);
0101:                element_info.addIncookie("incookie3", null);
0102:
0103:                element_info.addOutcookie("outcookie1", null);
0104:                element_info.addOutcookie("outcookie2", null);
0105:                element_info.addOutcookie("outcookie3", null);
0106:
0107:                LinkedHashMap<String, BeanDeclaration> namedglobalbeans = new LinkedHashMap<String, BeanDeclaration>();
0108:                namedglobalbeans.put("globalbean1", new BeanDeclaration(
0109:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0110:                        null, null));
0111:                namedglobalbeans.put("globalbean2", new BeanDeclaration(
0112:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0113:                        null, null));
0114:                element_info.setNamedGlobalBeans(namedglobalbeans);
0115:
0116:                element_info.addNamedInbean("inbean1", new BeanDeclaration(
0117:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0118:                        null, null));
0119:                element_info.addNamedInbean("inbean2", new BeanDeclaration(
0120:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0121:                        null, null));
0122:
0123:                element_info.addNamedOutbean("outbean1", new BeanDeclaration(
0124:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0125:                        null, null));
0126:                element_info.addNamedOutbean("outbean2", new BeanDeclaration(
0127:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0128:                        null, null));
0129:                element_info.addNamedOutbean("outbean3", new BeanDeclaration(
0130:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0131:                        null, null));
0132:
0133:                element_info.addExit("exit1");
0134:                element_info.addExit("exit2");
0135:                element_info.addExit("exit3");
0136:
0137:                element_info.setFlowLink(new FlowLink("exit1",
0138:                        element_info_dest, false, false, false, false, true));
0139:                FlowLink flowlink = new FlowLink("exit2", null, true, true,
0140:                        true, true, false);
0141:                element_info.setFlowLink(flowlink);
0142:
0143:                element_info.addDataLink(new DataLink("output1",
0144:                        element_info_dest, false, "input1", null));
0145:                element_info.addDataLink(new DataLink("output1",
0146:                        element_info_dest, false, "input2", flowlink));
0147:                element_info.addDataLink(new DataLink("output1", null, true,
0148:                        "input3", null));
0149:                element_info.addDataLink(new DataLink("output2",
0150:                        element_info_dest, false, "input2", null));
0151:                element_info.addDataLink(new DataLink("output2", null, true,
0152:                        "input3", null));
0153:
0154:                Submission submission1 = new Submission();
0155:                Submission submission2 = new Submission();
0156:                Submission submission3 = new Submission();
0157:                element_info.addSubmission("submission1", submission1);
0158:                element_info.addSubmission("submission2", submission2);
0159:                element_info.addSubmission("submission3", submission3);
0160:                submission1.addParameter("parameter1", null);
0161:                submission1.addParameter("parameter2", null);
0162:                submission1.addParameter("parameter3", null);
0163:                submission2.addParameter("parameter1", null);
0164:                submission2.addParameter("parameter2", null);
0165:                submission3.addParameter("parameter1", null);
0166:
0167:                // make a clone
0168:                ElementInfo element_info_clone = element_info.clone();
0169:                assertNotNull(element_info_clone);
0170:
0171:                // modify the original
0172:                globalexits.put("globalexit4", new GlobalExit("DEST2", false,
0173:                        false, false, false, true, true).setGroupId(0));
0174:                globalvars.put("globalvar4", new GlobalVar(null).setGroupId(0));
0175:                namedglobalbeans.put("globalbean3", new BeanDeclaration(
0176:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0177:                        "peefix", null));
0178:                element_info.addStaticProperty("property4", "value4");
0179:                element_info.addInput("input4", null);
0180:                element_info.addOutput("output4", null);
0181:                element_info.addIncookie("incookie4", null);
0182:                element_info.addOutcookie("outcookie4", null);
0183:                element_info.addNamedInbean("inbean3", new BeanDeclaration(
0184:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0185:                        null, null));
0186:                element_info.addNamedOutbean("outbean4", new BeanDeclaration(
0187:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0188:                        null, null));
0189:                element_info.addExit("exit4");
0190:                element_info.setFlowLink(new FlowLink("exit3",
0191:                        element_info_dest, false, false, false, false, false));
0192:                element_info.addDataLink(new DataLink("output3",
0193:                        element_info_dest, false, "input3", flowlink));
0194:                submission1.addParameter("parameter4", null);
0195:                Submission submission4 = new Submission();
0196:                element_info.addSubmission("submission4", submission4);
0197:                submission4.addParameter("parameter1", null);
0198:
0199:                // check if the clone has remained intact
0200:                assertEquals(4, element_info.getGlobalExitNames().size());
0201:                assertEquals(3, element_info_clone.getGlobalExitNames().size());
0202:                assertEquals(4, element_info.getGlobalVarNames().size());
0203:                assertEquals(3, element_info_clone.getGlobalVarNames().size());
0204:                assertEquals(4 + Rep.getProperties().size(), element_info
0205:                        .getPropertyNames().size());
0206:                assertEquals(3 + Rep.getProperties().size(), element_info_clone
0207:                        .getPropertyNames().size());
0208:                assertEquals(4, element_info.getInputNames().size());
0209:                assertEquals(3, element_info_clone.getInputNames().size());
0210:                assertEquals(4, element_info.getOutputNames().size());
0211:                assertEquals(3, element_info_clone.getOutputNames().size());
0212:                assertEquals(4, element_info.getIncookieNames().size());
0213:                assertEquals(3, element_info_clone.getIncookieNames().size());
0214:                assertEquals(4, element_info.getOutcookieNames().size());
0215:                assertEquals(3, element_info_clone.getOutcookieNames().size());
0216:                assertEquals(3, element_info.getNamedGlobalBeanNames().size());
0217:                assertEquals(2, element_info_clone.getNamedGlobalBeanNames()
0218:                        .size());
0219:                assertEquals(3, element_info.getNamedInbeanNames().size());
0220:                assertEquals(2, element_info_clone.getNamedInbeanNames().size());
0221:                assertEquals(4, element_info.getNamedOutbeanNames().size());
0222:                assertEquals(3, element_info_clone.getNamedOutbeanNames()
0223:                        .size());
0224:                assertSame(element_info.getFlowLink("exit3").getTarget(),
0225:                        element_info_dest);
0226:                assertNull(element_info_clone.getFlowLink("exit3"));
0227:                assertEquals(1, element_info.getDataLinkInputs("output3",
0228:                        element_info_dest, false, flowlink).size());
0229:                assertNull(element_info_clone.getDataLinkInputs("output3",
0230:                        element_info_dest, false, flowlink));
0231:                assertEquals(4, element_info.getSubmission("submission1")
0232:                        .getParameterNames().size());
0233:                assertEquals(3, element_info_clone.getSubmission("submission1")
0234:                        .getParameterNames().size());
0235:                assertEquals(4, element_info.getSubmissionNames().size());
0236:                assertEquals(3, element_info_clone.getSubmissionNames().size());
0237:            }
0238:
0239:            public void testGetUninstantiatableElement() throws EngineException {
0240:                ElementInfo element_info = new ElementInfo(
0241:                        "element/test_not_instantiatable.xml", "text/html",
0242:                        TestElementNotInstantiatable.class.getName(),
0243:                        ElementType.JAVA_CLASS);
0244:
0245:                try {
0246:                    element_info.getElement();
0247:                    fail();
0248:                } catch (EngineException e) {
0249:                    assertTrue(true);
0250:                }
0251:            }
0252:
0253:            public void testNoInitialPropertyNames() throws EngineException {
0254:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0255:                        "text/html", TestElement2.class.getName(),
0256:                        ElementType.JAVA_CLASS);
0257:
0258:                assertEquals(element_info.getPropertyNames().size(), 0);
0259:            }
0260:
0261:            public void testNoInitialGlobalNames() throws EngineException {
0262:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0263:                        "text/html", TestElement2.class.getName(),
0264:                        ElementType.JAVA_CLASS);
0265:
0266:                assertNull(element_info.getGlobalVarNames());
0267:            }
0268:
0269:            public void testNoInitialInputNames() throws EngineException {
0270:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0271:                        "text/html", TestElement2.class.getName(),
0272:                        ElementType.JAVA_CLASS);
0273:
0274:                assertEquals(element_info.getInputNames().size(), 0);
0275:            }
0276:
0277:            public void testNoInitialOutputNames() throws EngineException {
0278:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0279:                        "text/html", TestElement2.class.getName(),
0280:                        ElementType.JAVA_CLASS);
0281:
0282:                assertEquals(element_info.getOutputNames().size(), 0);
0283:            }
0284:
0285:            public void testNoInitialIncookieNames() throws EngineException {
0286:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0287:                        "text/html", TestElement2.class.getName(),
0288:                        ElementType.JAVA_CLASS);
0289:
0290:                assertEquals(element_info.getIncookieNames().size(), 0);
0291:            }
0292:
0293:            public void testNoInitialOutcookieNames() throws EngineException {
0294:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0295:                        "text/html", TestElement2.class.getName(),
0296:                        ElementType.JAVA_CLASS);
0297:
0298:                assertEquals(element_info.getOutcookieNames().size(), 0);
0299:            }
0300:
0301:            public void testNoInitialNamedGlobalbeanNames()
0302:                    throws EngineException {
0303:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0304:                        "text/html", TestElement2.class.getName(),
0305:                        ElementType.JAVA_CLASS);
0306:
0307:                assertNull(element_info.getNamedGlobalBeanNames());
0308:            }
0309:
0310:            public void testNoInitialNamedInbeanNames() throws EngineException {
0311:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0312:                        "text/html", TestElement2.class.getName(),
0313:                        ElementType.JAVA_CLASS);
0314:
0315:                assertEquals(element_info.getNamedInbeanNames().size(), 0);
0316:            }
0317:
0318:            public void testNoInitialNamedOutbeanNames() throws EngineException {
0319:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0320:                        "text/html", TestElement2.class.getName(),
0321:                        ElementType.JAVA_CLASS);
0322:
0323:                assertEquals(element_info.getNamedOutbeanNames().size(), 0);
0324:            }
0325:
0326:            public void testNoInitialExitNames() throws EngineException {
0327:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0328:                        "text/html", TestElement2.class.getName(),
0329:                        ElementType.JAVA_CLASS);
0330:
0331:                assertEquals(element_info.getExitNames().size(), 0);
0332:            }
0333:
0334:            public void testNoInitialSubmissionNames() throws EngineException {
0335:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0336:                        "text/html", TestElement2.class.getName(),
0337:                        ElementType.JAVA_CLASS);
0338:
0339:                assertEquals(element_info.getSubmissionNames().size(), 0);
0340:            }
0341:
0342:            public void testAddGlobal() throws EngineException {
0343:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0344:                        "text/html", TestElement2.class.getName(),
0345:                        ElementType.JAVA_CLASS);
0346:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
0347:                globals.put("globalvar1", new GlobalVar(null).setGroupId(0));
0348:                globals.put("globalvar2", new GlobalVar(null).setGroupId(0));
0349:                globals.put("globalvar3", new GlobalVar(null).setGroupId(0));
0350:
0351:                element_info.setGlobalVars(globals);
0352:
0353:                assertEquals(element_info.getGlobalVarNames().size(), 3);
0354:
0355:                assertTrue(element_info.containsGlobalVar("globalvar1"));
0356:                assertTrue(element_info.containsGlobalVar("globalvar2"));
0357:                assertTrue(element_info.containsGlobalVar("globalvar3"));
0358:            }
0359:
0360:            public void testAddStaticProperty() throws EngineException {
0361:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0362:                        "text/html", TestElement2.class.getName(),
0363:                        ElementType.JAVA_CLASS);
0364:
0365:                element_info.addStaticProperty("property1", "value1");
0366:                assertEquals(element_info.getPropertyNames().size(), 1 + Rep
0367:                        .getProperties().size());
0368:                element_info.addStaticProperty("property2", "value2");
0369:                assertEquals(element_info.getPropertyNames().size(), 2 + Rep
0370:                        .getProperties().size());
0371:                element_info.addStaticProperty("property3", "value3");
0372:                assertEquals(element_info.getPropertyNames().size(), 3 + Rep
0373:                        .getProperties().size());
0374:
0375:                assertTrue(element_info.containsProperty("property1"));
0376:                assertTrue(element_info.containsProperty("property2"));
0377:                assertTrue(element_info.containsProperty("property3"));
0378:
0379:                assertEquals("value1", element_info.getProperty("property1"));
0380:                assertEquals("value2", element_info.getProperty("property2"));
0381:                assertEquals("value3", element_info.getProperty("property3"));
0382:            }
0383:
0384:            public void testAddInput() throws EngineException {
0385:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0386:                        "text/html", TestElement2.class.getName(),
0387:                        ElementType.JAVA_CLASS);
0388:
0389:                element_info.addInput("input1", null);
0390:                assertEquals(element_info.getInputNames().size(), 1);
0391:                element_info.addInput("input2", null);
0392:                assertEquals(element_info.getInputNames().size(), 2);
0393:                element_info.addInput("input3", null);
0394:                assertEquals(element_info.getInputNames().size(), 3);
0395:
0396:                assertTrue(element_info.containsInput("input1"));
0397:                assertTrue(element_info.containsInput("input2"));
0398:                assertTrue(element_info.containsInput("input3"));
0399:            }
0400:
0401:            public void testAddOutput() throws EngineException {
0402:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0403:                        "text/html", TestElement2.class.getName(),
0404:                        ElementType.JAVA_CLASS);
0405:
0406:                element_info.addOutput("output1", null);
0407:                assertEquals(element_info.getOutputNames().size(), 1);
0408:                element_info.addOutput("output2", null);
0409:                assertEquals(element_info.getOutputNames().size(), 2);
0410:                element_info.addOutput("output3", null);
0411:                assertEquals(element_info.getOutputNames().size(), 3);
0412:
0413:                assertTrue(element_info.containsOutput("output1"));
0414:                assertTrue(element_info.containsOutput("output2"));
0415:                assertTrue(element_info.containsOutput("output3"));
0416:            }
0417:
0418:            public void testAddIncookie() throws EngineException {
0419:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0420:                        "text/html", TestElement2.class.getName(),
0421:                        ElementType.JAVA_CLASS);
0422:
0423:                element_info.addIncookie("incookie1", null);
0424:                assertEquals(element_info.getIncookieNames().size(), 1);
0425:                element_info.addIncookie("incookie2", null);
0426:                assertEquals(element_info.getIncookieNames().size(), 2);
0427:                element_info.addIncookie("incookie3", null);
0428:                assertEquals(element_info.getIncookieNames().size(), 3);
0429:
0430:                assertTrue(element_info.containsIncookie("incookie1"));
0431:                assertTrue(element_info.containsIncookie("incookie2"));
0432:                assertTrue(element_info.containsIncookie("incookie3"));
0433:            }
0434:
0435:            public void testAddOutcookie() throws EngineException {
0436:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0437:                        "text/html", TestElement2.class.getName(),
0438:                        ElementType.JAVA_CLASS);
0439:
0440:                element_info.addOutcookie("outcookie1", null);
0441:                assertEquals(element_info.getOutcookieNames().size(), 1);
0442:                element_info.addOutcookie("outcookie2", null);
0443:                assertEquals(element_info.getOutcookieNames().size(), 2);
0444:                element_info.addOutcookie("outcookie3", null);
0445:                assertEquals(element_info.getOutcookieNames().size(), 3);
0446:
0447:                assertTrue(element_info.containsOutcookie("outcookie1"));
0448:                assertTrue(element_info.containsOutcookie("outcookie2"));
0449:                assertTrue(element_info.containsOutcookie("outcookie3"));
0450:            }
0451:
0452:            public void testAddNamedGlobalBean() throws EngineException {
0453:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0454:                        "text/html", TestElement2.class.getName(),
0455:                        ElementType.JAVA_CLASS);
0456:
0457:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
0458:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0459:                        null, null);
0460:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
0461:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0462:                        "prefix_", null);
0463:                LinkedHashMap<String, BeanDeclaration> namedglobalbeans = new LinkedHashMap<String, BeanDeclaration>();
0464:                namedglobalbeans.put("globalbean1", bean_declaration1);
0465:                namedglobalbeans.put("globalbean2", bean_declaration2);
0466:                namedglobalbeans.put("globalbean3", bean_declaration1);
0467:                element_info.setNamedGlobalBeans(namedglobalbeans);
0468:
0469:                assertEquals(element_info.getNamedGlobalBeanNames().size(), 3);
0470:
0471:                assertTrue(element_info.containsNamedGlobalBean("globalbean1"));
0472:                assertTrue(element_info.containsNamedGlobalBean("globalbean2"));
0473:                assertTrue(element_info.containsNamedGlobalBean("globalbean3"));
0474:
0475:                BeanDeclaration bean_declaration = null;
0476:
0477:                bean_declaration = element_info
0478:                        .getNamedGlobalBeanInfo("globalbean1");
0479:                assertEquals(bean_declaration1.getClassname(), bean_declaration
0480:                        .getClassname());
0481:                assertEquals(bean_declaration1.getPrefix(), bean_declaration
0482:                        .getPrefix());
0483:                bean_declaration = null;
0484:                bean_declaration = element_info
0485:                        .getNamedGlobalBeanInfo("globalbean2");
0486:                assertEquals(bean_declaration2.getClassname(), bean_declaration
0487:                        .getClassname());
0488:                assertEquals(bean_declaration2.getPrefix(), bean_declaration
0489:                        .getPrefix());
0490:                bean_declaration = null;
0491:                bean_declaration = element_info
0492:                        .getNamedGlobalBeanInfo("globalbean3");
0493:                assertEquals(bean_declaration1.getClassname(), bean_declaration
0494:                        .getClassname());
0495:                assertEquals(bean_declaration1.getPrefix(), bean_declaration
0496:                        .getPrefix());
0497:            }
0498:
0499:            public void testAddNamedInbean() throws EngineException {
0500:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0501:                        "text/html", TestElement2.class.getName(),
0502:                        ElementType.JAVA_CLASS);
0503:
0504:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
0505:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0506:                        null, null);
0507:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
0508:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0509:                        "prefix_", null);
0510:                element_info.addNamedInbean("inbean1", bean_declaration1);
0511:                assertEquals(element_info.getNamedInbeanNames().size(), 1);
0512:                element_info.addNamedInbean("inbean2", bean_declaration1);
0513:                assertEquals(element_info.getNamedInbeanNames().size(), 2);
0514:                element_info.addNamedInbean("inbean3", bean_declaration2);
0515:                assertEquals(element_info.getNamedInbeanNames().size(), 3);
0516:
0517:                assertTrue(element_info.containsNamedInbean("inbean1"));
0518:                assertTrue(element_info.containsNamedInbean("inbean2"));
0519:                assertTrue(element_info.containsNamedInbean("inbean3"));
0520:
0521:                BeanDeclaration bean_declaration = null;
0522:
0523:                bean_declaration = element_info.getNamedInbeanInfo("inbean1");
0524:                assertEquals(bean_declaration1.getClassname(), bean_declaration
0525:                        .getClassname());
0526:                assertEquals(bean_declaration1.getPrefix(), bean_declaration
0527:                        .getPrefix());
0528:                bean_declaration = null;
0529:                bean_declaration = element_info.getNamedInbeanInfo("inbean2");
0530:                assertEquals(bean_declaration1.getClassname(), bean_declaration
0531:                        .getClassname());
0532:                assertEquals(bean_declaration1.getPrefix(), bean_declaration
0533:                        .getPrefix());
0534:                bean_declaration = null;
0535:                bean_declaration = element_info.getNamedInbeanInfo("inbean3");
0536:                assertEquals(bean_declaration2.getClassname(), bean_declaration
0537:                        .getClassname());
0538:                assertEquals(bean_declaration2.getPrefix(), bean_declaration
0539:                        .getPrefix());
0540:            }
0541:
0542:            public void testAddNamedOutbean() throws EngineException {
0543:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0544:                        "text/html", TestElement2.class.getName(),
0545:                        ElementType.JAVA_CLASS);
0546:
0547:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
0548:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0549:                        null, null);
0550:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
0551:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0552:                        "prefix_", null);
0553:                element_info.addNamedOutbean("outbean1", bean_declaration1);
0554:                assertEquals(element_info.getNamedOutbeanNames().size(), 1);
0555:                element_info.addNamedOutbean("outbean2", bean_declaration1);
0556:                assertEquals(element_info.getNamedOutbeanNames().size(), 2);
0557:                element_info.addNamedOutbean("outbean3", bean_declaration2);
0558:                assertEquals(element_info.getNamedOutbeanNames().size(), 3);
0559:
0560:                assertTrue(element_info.containsNamedOutbean("outbean1"));
0561:                assertTrue(element_info.containsNamedOutbean("outbean2"));
0562:                assertTrue(element_info.containsNamedOutbean("outbean3"));
0563:
0564:                BeanDeclaration bean_declaration = null;
0565:
0566:                bean_declaration = element_info.getNamedOutbeanInfo("outbean1");
0567:                assertEquals(bean_declaration1.getClassname(), bean_declaration
0568:                        .getClassname());
0569:                assertEquals(bean_declaration1.getPrefix(), bean_declaration
0570:                        .getPrefix());
0571:                bean_declaration = null;
0572:                bean_declaration = element_info.getNamedOutbeanInfo("outbean2");
0573:                assertEquals(bean_declaration1.getClassname(), bean_declaration
0574:                        .getClassname());
0575:                assertEquals(bean_declaration1.getPrefix(), bean_declaration
0576:                        .getPrefix());
0577:                bean_declaration = null;
0578:                bean_declaration = element_info.getNamedOutbeanInfo("outbean3");
0579:                assertEquals(bean_declaration2.getClassname(), bean_declaration
0580:                        .getClassname());
0581:                assertEquals(bean_declaration2.getPrefix(), bean_declaration
0582:                        .getPrefix());
0583:            }
0584:
0585:            public void testAddChildTrigger() throws EngineException {
0586:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0587:                        "text/html", TestElement2.class.getName(),
0588:                        ElementType.JAVA_CLASS);
0589:                element_info.addInput("childtrigger1", null);
0590:                element_info.addInput("childtrigger2", null);
0591:                element_info.addInput("childtrigger3", null);
0592:
0593:                element_info.addChildTrigger("childtrigger1");
0594:                assertEquals(element_info.getChildTriggerNames().size(), 1);
0595:                element_info.addChildTrigger("childtrigger2");
0596:                assertEquals(element_info.getChildTriggerNames().size(), 2);
0597:                element_info.addChildTrigger("childtrigger3");
0598:                assertEquals(element_info.getChildTriggerNames().size(), 3);
0599:
0600:                assertTrue(element_info.containsChildTrigger("childtrigger1"));
0601:                assertTrue(element_info.containsChildTrigger("childtrigger2"));
0602:                assertTrue(element_info.containsChildTrigger("childtrigger3"));
0603:            }
0604:
0605:            public void testAddExit() throws EngineException {
0606:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0607:                        "text/html", TestElement2.class.getName(),
0608:                        ElementType.JAVA_CLASS);
0609:
0610:                element_info.addExit("exit1");
0611:                assertEquals(element_info.getExitNames().size(), 1);
0612:                element_info.addExit("exit2");
0613:                assertEquals(element_info.getExitNames().size(), 2);
0614:                element_info.addExit("exit3");
0615:                assertEquals(element_info.getExitNames().size(), 3);
0616:
0617:                assertTrue(element_info.containsExit("exit1"));
0618:                assertTrue(element_info.containsExit("exit2"));
0619:                assertTrue(element_info.containsExit("exit3"));
0620:            }
0621:
0622:            public void testAddSubmission() throws EngineException {
0623:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0624:                        "text/html", TestElement2.class.getName(),
0625:                        ElementType.JAVA_CLASS);
0626:
0627:                Submission submission1 = new Submission();
0628:                Submission submission2 = new Submission();
0629:                Submission submission3 = new Submission();
0630:
0631:                element_info.addSubmission("submission1", submission1);
0632:                assertEquals(element_info.getSubmissionNames().size(), 1);
0633:                element_info.addSubmission("submission2", submission2);
0634:                assertEquals(element_info.getSubmissionNames().size(), 2);
0635:                element_info.addSubmission("submission3", submission3);
0636:                assertEquals(element_info.getSubmissionNames().size(), 3);
0637:
0638:                assertTrue(element_info.containsSubmission("submission1"));
0639:                assertTrue(element_info.containsSubmission("submission2"));
0640:                assertTrue(element_info.containsSubmission("submission3"));
0641:
0642:                assertSame(element_info.getSubmission("submission1"),
0643:                        submission1);
0644:                assertSame(element_info.getSubmission("submission2"),
0645:                        submission2);
0646:                assertSame(element_info.getSubmission("submission3"),
0647:                        submission3);
0648:            }
0649:
0650:            public void testAddReservedInput() throws EngineException {
0651:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0652:                        "text/html", TestElement2.class.getName(),
0653:                        ElementType.JAVA_CLASS);
0654:
0655:                try {
0656:                    element_info.addInput(ReservedParameters.SUBMISSION, null);
0657:                    fail();
0658:                } catch (ReservedInputNameException e) {
0659:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0660:                    assertEquals(e.getInputName(),
0661:                            ReservedParameters.SUBMISSION);
0662:                } catch (EngineException e) {
0663:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0664:                }
0665:
0666:                try {
0667:                    element_info
0668:                            .addInput(ReservedParameters.CHILDREQUEST, null);
0669:                    fail();
0670:                } catch (ReservedInputNameException e) {
0671:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0672:                    assertEquals(e.getInputName(),
0673:                            ReservedParameters.CHILDREQUEST);
0674:                } catch (EngineException e) {
0675:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0676:                }
0677:
0678:                try {
0679:                    element_info.addInput(ReservedParameters.TRIGGERLIST, null);
0680:                    fail();
0681:                } catch (ReservedInputNameException e) {
0682:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0683:                    assertEquals(e.getInputName(),
0684:                            ReservedParameters.TRIGGERLIST);
0685:                } catch (EngineException e) {
0686:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0687:                }
0688:
0689:                assertEquals(element_info.getInputNames().size(), 0);
0690:            }
0691:
0692:            public void testAddReservedOutput() throws EngineException {
0693:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0694:                        "text/html", TestElement2.class.getName(),
0695:                        ElementType.JAVA_CLASS);
0696:
0697:                try {
0698:                    element_info.addOutput(ReservedParameters.SUBMISSION, null);
0699:                    fail();
0700:                } catch (ReservedOutputNameException e) {
0701:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0702:                    assertEquals(e.getOutputName(),
0703:                            ReservedParameters.SUBMISSION);
0704:                } catch (EngineException e) {
0705:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0706:                }
0707:
0708:                try {
0709:                    element_info.addOutput(ReservedParameters.CHILDREQUEST,
0710:                            null);
0711:                    fail();
0712:                } catch (ReservedOutputNameException e) {
0713:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0714:                    assertEquals(e.getOutputName(),
0715:                            ReservedParameters.CHILDREQUEST);
0716:                } catch (EngineException e) {
0717:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0718:                }
0719:
0720:                try {
0721:                    element_info
0722:                            .addOutput(ReservedParameters.TRIGGERLIST, null);
0723:                    fail();
0724:                } catch (ReservedOutputNameException e) {
0725:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0726:                    assertEquals(e.getOutputName(),
0727:                            ReservedParameters.TRIGGERLIST);
0728:                } catch (EngineException e) {
0729:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0730:                }
0731:
0732:                assertEquals(element_info.getOutputNames().size(), 0);
0733:            }
0734:
0735:            public void testAddDuplicateGlobal() throws EngineException {
0736:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0737:                        "text/html", TestElement2.class.getName(),
0738:                        ElementType.JAVA_CLASS);
0739:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
0740:                globals.put("globalvar1", new GlobalVar(null).setGroupId(0));
0741:                globals.put("globalvar2", new GlobalVar(null).setGroupId(0));
0742:                globals.put("globalvar3", new GlobalVar(null).setGroupId(0));
0743:                globals.put("globalvar1", new GlobalVar(null).setGroupId(0));
0744:
0745:                element_info.setGlobalVars(globals);
0746:
0747:                assertEquals(element_info.getGlobalVarNames().size(), 3);
0748:
0749:                assertTrue(element_info.containsGlobalVar("globalvar1"));
0750:                assertTrue(element_info.containsGlobalVar("globalvar2"));
0751:                assertTrue(element_info.containsGlobalVar("globalvar3"));
0752:            }
0753:
0754:            public void testAddDuplicateStaticProperty() throws EngineException {
0755:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0756:                        "text/html", TestElement2.class.getName(),
0757:                        ElementType.JAVA_CLASS);
0758:
0759:                try {
0760:                    element_info.addStaticProperty("property1", "value1");
0761:                    assertEquals(element_info.getPropertyNames().size(),
0762:                            1 + Rep.getProperties().size());
0763:                    assertEquals("value1", element_info
0764:                            .getProperty("property1"));
0765:                    element_info.addStaticProperty("property1", "value2");
0766:                    assertEquals(element_info.getPropertyNames().size(),
0767:                            1 + Rep.getProperties().size());
0768:                    assertEquals("value2", element_info
0769:                            .getProperty("property1"));
0770:                } catch (EngineException e) {
0771:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0772:                }
0773:            }
0774:
0775:            public void testAddDuplicateInput() throws EngineException {
0776:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0777:                        "text/html", TestElement2.class.getName(),
0778:                        ElementType.JAVA_CLASS);
0779:
0780:                try {
0781:                    element_info.addInput("input1", null);
0782:                } catch (EngineException e) {
0783:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0784:                }
0785:                assertEquals(element_info.getInputNames().size(), 1);
0786:                try {
0787:                    element_info.addInput("input1", null);
0788:                    fail();
0789:                } catch (InputExistsException e) {
0790:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0791:                    assertEquals(e.getInputName(), "input1");
0792:                } catch (EngineException e) {
0793:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0794:                }
0795:                assertEquals(element_info.getInputNames().size(), 1);
0796:            }
0797:
0798:            public void testAddDuplicateOutput() throws EngineException {
0799:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0800:                        "text/html", TestElement2.class.getName(),
0801:                        ElementType.JAVA_CLASS);
0802:
0803:                try {
0804:                    element_info.addOutput("output1", null);
0805:                } catch (EngineException e) {
0806:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0807:                }
0808:                assertEquals(element_info.getOutputNames().size(), 1);
0809:                try {
0810:                    element_info.addOutput("output1", null);
0811:                    fail();
0812:                } catch (OutputExistsException e) {
0813:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0814:                    assertEquals(e.getOutputName(), "output1");
0815:                } catch (EngineException e) {
0816:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0817:                }
0818:                assertEquals(element_info.getOutputNames().size(), 1);
0819:            }
0820:
0821:            public void testAddDuplicateIncookie() throws EngineException {
0822:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0823:                        "text/html", TestElement2.class.getName(),
0824:                        ElementType.JAVA_CLASS);
0825:
0826:                try {
0827:                    element_info.addIncookie("incookie1", null);
0828:                } catch (EngineException e) {
0829:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0830:                }
0831:                assertEquals(element_info.getIncookieNames().size(), 1);
0832:                try {
0833:                    element_info.addIncookie("incookie1", null);
0834:                    fail();
0835:                } catch (IncookieExistsException e) {
0836:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0837:                    assertEquals(e.getIncookieName(), "incookie1");
0838:                } catch (EngineException e) {
0839:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0840:                }
0841:                assertEquals(element_info.getIncookieNames().size(), 1);
0842:            }
0843:
0844:            public void testAddDuplicateOutcookie() throws EngineException {
0845:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0846:                        "text/html", TestElement2.class.getName(),
0847:                        ElementType.JAVA_CLASS);
0848:
0849:                try {
0850:                    element_info.addOutcookie("outcookie1", null);
0851:                } catch (EngineException e) {
0852:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0853:                }
0854:                assertEquals(element_info.getOutcookieNames().size(), 1);
0855:                try {
0856:                    element_info.addOutcookie("outcookie1", null);
0857:                    fail();
0858:                } catch (OutcookieExistsException e) {
0859:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0860:                    assertEquals(e.getOutcookieName(), "outcookie1");
0861:                } catch (EngineException e) {
0862:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0863:                }
0864:                assertEquals(element_info.getOutcookieNames().size(), 1);
0865:            }
0866:
0867:            public void testAddDuplicateNamedGlobalBean()
0868:                    throws EngineException {
0869:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0870:                        "text/html", TestElement2.class.getName(),
0871:                        ElementType.JAVA_CLASS);
0872:
0873:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
0874:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0875:                        null, null);
0876:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
0877:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0878:                        "prefix_", null);
0879:                LinkedHashMap<String, BeanDeclaration> namedglobalbeans = new LinkedHashMap<String, BeanDeclaration>();
0880:                namedglobalbeans.put("globalbean1", bean_declaration1);
0881:                namedglobalbeans.put("globalbean1", bean_declaration2);
0882:                element_info.setNamedGlobalBeans(namedglobalbeans);
0883:
0884:                assertEquals(element_info.getNamedGlobalBeanNames().size(), 1);
0885:
0886:                assertTrue(element_info.containsNamedGlobalBean("globalbean1"));
0887:
0888:                BeanDeclaration bean_declaration = null;
0889:
0890:                bean_declaration = element_info
0891:                        .getNamedGlobalBeanInfo("globalbean1");
0892:                assertEquals(bean_declaration2.getClassname(), bean_declaration
0893:                        .getClassname());
0894:                assertEquals(bean_declaration2.getPrefix(), bean_declaration
0895:                        .getPrefix());
0896:            }
0897:
0898:            public void testAddDuplicateNamedInbean() throws EngineException {
0899:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0900:                        "text/html", TestElement2.class.getName(),
0901:                        ElementType.JAVA_CLASS);
0902:
0903:                try {
0904:                    element_info
0905:                            .addNamedInbean(
0906:                                    "inbean1",
0907:                                    new BeanDeclaration(
0908:                                            "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0909:                                            null, null));
0910:                } catch (EngineException e) {
0911:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0912:                }
0913:                assertEquals(element_info.getNamedInbeanNames().size(), 1);
0914:                try {
0915:                    element_info
0916:                            .addNamedInbean(
0917:                                    "inbean1",
0918:                                    new BeanDeclaration(
0919:                                            "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0920:                                            null, null));
0921:                    fail();
0922:                } catch (NamedInbeanExistsException e) {
0923:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0924:                    assertEquals(e.getInbeanName(), "inbean1");
0925:                } catch (EngineException e) {
0926:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0927:                }
0928:                assertEquals(element_info.getNamedInbeanNames().size(), 1);
0929:            }
0930:
0931:            public void testAddDuplicateNamedOutbean() throws EngineException {
0932:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0933:                        "text/html", TestElement2.class.getName(),
0934:                        ElementType.JAVA_CLASS);
0935:
0936:                try {
0937:                    element_info
0938:                            .addNamedOutbean(
0939:                                    "outbean1",
0940:                                    new BeanDeclaration(
0941:                                            "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
0942:                                            null, null));
0943:                } catch (EngineException e) {
0944:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0945:                }
0946:                assertEquals(element_info.getNamedOutbeanNames().size(), 1);
0947:                try {
0948:                    element_info
0949:                            .addNamedOutbean(
0950:                                    "outbean1",
0951:                                    new BeanDeclaration(
0952:                                            "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
0953:                                            null, null));
0954:                    fail();
0955:                } catch (NamedOutbeanExistsException e) {
0956:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0957:                    assertEquals(e.getOutbeanName(), "outbean1");
0958:                } catch (EngineException e) {
0959:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0960:                }
0961:                assertEquals(element_info.getNamedOutbeanNames().size(), 1);
0962:            }
0963:
0964:            public void testAddDuplicateChildTrigger() throws EngineException {
0965:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0966:                        "text/html", TestElement2.class.getName(),
0967:                        ElementType.JAVA_CLASS);
0968:                element_info.addInput("childtrigger1", null);
0969:
0970:                try {
0971:                    element_info.addChildTrigger("childtrigger1");
0972:                } catch (EngineException e) {
0973:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0974:                }
0975:                assertEquals(element_info.getChildTriggerNames().size(), 1);
0976:                try {
0977:                    element_info.addChildTrigger("childtrigger1");
0978:                    fail();
0979:                } catch (ChildTriggerExistsException e) {
0980:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
0981:                    assertEquals(e.getChildTriggerName(), "childtrigger1");
0982:                } catch (EngineException e) {
0983:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0984:                }
0985:                assertEquals(element_info.getChildTriggerNames().size(), 1);
0986:            }
0987:
0988:            public void testAddDuplicateExit() throws EngineException {
0989:                ElementInfo element_info = new ElementInfo("element/test2.xml",
0990:                        "text/html", TestElement2.class.getName(),
0991:                        ElementType.JAVA_CLASS);
0992:
0993:                try {
0994:                    element_info.addExit("exit1");
0995:                } catch (EngineException e) {
0996:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0997:                }
0998:                assertEquals(element_info.getExitNames().size(), 1);
0999:                try {
1000:                    element_info.addExit("exit1");
1001:                    fail();
1002:                } catch (ExitExistsException e) {
1003:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1004:                    assertEquals(e.getExitName(), "exit1");
1005:                } catch (EngineException e) {
1006:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1007:                }
1008:                assertEquals(element_info.getExitNames().size(), 1);
1009:            }
1010:
1011:            public void testAddDuplicateSubmission() throws EngineException {
1012:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1013:                        "text/html", TestElement2.class.getName(),
1014:                        ElementType.JAVA_CLASS);
1015:
1016:                try {
1017:                    element_info.addSubmission("submission1", new Submission());
1018:                } catch (EngineException e) {
1019:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1020:                }
1021:                assertEquals(element_info.getSubmissionNames().size(), 1);
1022:                try {
1023:                    element_info.addSubmission("submission1", new Submission());
1024:                    fail();
1025:                } catch (SubmissionExistsException e) {
1026:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1027:                    assertEquals(e.getSubmissionName(), "submission1");
1028:                } catch (EngineException e) {
1029:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1030:                }
1031:                assertEquals(element_info.getSubmissionNames().size(), 1);
1032:            }
1033:
1034:            public void testGlobalVarConflicts() throws EngineException {
1035:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1036:                        "text/html", TestElement2.class.getName(),
1037:                        ElementType.JAVA_CLASS);
1038:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
1039:                Submission submission = null;
1040:
1041:                globals.put("input1", new GlobalVar(null).setGroupId(0));
1042:                globals.put("output1", new GlobalVar(null).setGroupId(0));
1043:                globals.put("property1", new GlobalVar(null).setGroupId(0));
1044:                globals.put("parameter1", new GlobalVar(null).setGroupId(0));
1045:                globals.put("file1", new GlobalVar(null).setGroupId(0));
1046:
1047:                try {
1048:                    element_info.setGlobalVars(globals);
1049:                } catch (EngineException e) {
1050:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1051:                }
1052:
1053:                element_info = new ElementInfo("element/test2.xml",
1054:                        "text/html", TestElement2.class.getName(),
1055:                        ElementType.JAVA_CLASS);
1056:                element_info.addInput("input1", null);
1057:                try {
1058:                    element_info.setGlobalVars(globals);
1059:                    fail();
1060:                } catch (GlobalVarInputConflictException e) {
1061:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1062:                    assertEquals(e.getConflictName(), "input1");
1063:                } catch (EngineException e) {
1064:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1065:                }
1066:
1067:                element_info = new ElementInfo("element/test2.xml",
1068:                        "text/html", TestElement2.class.getName(),
1069:                        ElementType.JAVA_CLASS);
1070:                element_info.addOutput("output1", null);
1071:                try {
1072:                    element_info.setGlobalVars(globals);
1073:                    fail();
1074:                } catch (GlobalVarOutputConflictException e) {
1075:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1076:                    assertEquals(e.getConflictName(), "output1");
1077:                } catch (EngineException e) {
1078:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1079:                }
1080:
1081:                submission = new Submission();
1082:                element_info = new ElementInfo("element/test2.xml",
1083:                        "text/html", TestElement2.class.getName(),
1084:                        ElementType.JAVA_CLASS);
1085:                element_info.addSubmission("submission1", submission);
1086:                submission.addParameter("parameter1", null);
1087:                try {
1088:                    element_info.setGlobalVars(globals);
1089:                    fail();
1090:                } catch (GlobalVarParameterConflictException e) {
1091:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1092:                    assertEquals(e.getSubmissionName(), "submission1");
1093:                    assertEquals(e.getConflictName(), "parameter1");
1094:                } catch (EngineException e) {
1095:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1096:                }
1097:
1098:                submission = new Submission();
1099:                element_info = new ElementInfo("element/test2.xml",
1100:                        "text/html", TestElement2.class.getName(),
1101:                        ElementType.JAVA_CLASS);
1102:                element_info.addSubmission("submission1", submission);
1103:                submission.addFile("file1");
1104:                try {
1105:                    element_info.setGlobalVars(globals);
1106:                    fail();
1107:                } catch (GlobalVarFileConflictException e) {
1108:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1109:                    assertEquals(e.getSubmissionName(), "submission1");
1110:                    assertEquals(e.getConflictName(), "file1");
1111:                } catch (EngineException e) {
1112:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1113:                }
1114:            }
1115:
1116:            public void testGlobalCookieConflicts() throws EngineException {
1117:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1118:                        "text/html", TestElement2.class.getName(),
1119:                        ElementType.JAVA_CLASS);
1120:                LinkedHashMap<String, String> globals = new LinkedHashMap<String, String>();
1121:                Submission submission = null;
1122:
1123:                globals.put("incookie1", null);
1124:                globals.put("outcookie1", null);
1125:                globals.put("property1", null);
1126:                globals.put("parameter1", null);
1127:                globals.put("file1", null);
1128:
1129:                try {
1130:                    element_info.setGlobalCookies(globals);
1131:                } catch (EngineException e) {
1132:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1133:                }
1134:
1135:                element_info = new ElementInfo("element/test2.xml",
1136:                        "text/html", TestElement2.class.getName(),
1137:                        ElementType.JAVA_CLASS);
1138:                element_info.addIncookie("incookie1", null);
1139:                try {
1140:                    element_info.setGlobalCookies(globals);
1141:                    fail();
1142:                } catch (GlobalCookieIncookieConflictException e) {
1143:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1144:                    assertEquals(e.getConflictName(), "incookie1");
1145:                } catch (EngineException e) {
1146:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1147:                }
1148:
1149:                element_info = new ElementInfo("element/test2.xml",
1150:                        "text/html", TestElement2.class.getName(),
1151:                        ElementType.JAVA_CLASS);
1152:                element_info.addOutcookie("outcookie1", null);
1153:                try {
1154:                    element_info.setGlobalCookies(globals);
1155:                    fail();
1156:                } catch (GlobalCookieOutcookieConflictException e) {
1157:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1158:                    assertEquals(e.getConflictName(), "outcookie1");
1159:                } catch (EngineException e) {
1160:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1161:                }
1162:
1163:                submission = new Submission();
1164:                element_info = new ElementInfo("element/test2.xml",
1165:                        "text/html", TestElement2.class.getName(),
1166:                        ElementType.JAVA_CLASS);
1167:                element_info.addSubmission("submission1", submission);
1168:                submission.addParameter("parameter1", null);
1169:                try {
1170:                    element_info.setGlobalCookies(globals);
1171:                    fail();
1172:                } catch (GlobalCookieParameterConflictException e) {
1173:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1174:                    assertEquals(e.getSubmissionName(), "submission1");
1175:                    assertEquals(e.getConflictName(), "parameter1");
1176:                } catch (EngineException e) {
1177:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1178:                }
1179:
1180:                submission = new Submission();
1181:                element_info = new ElementInfo("element/test2.xml",
1182:                        "text/html", TestElement2.class.getName(),
1183:                        ElementType.JAVA_CLASS);
1184:                element_info.addSubmission("submission1", submission);
1185:                submission.addFile("file1");
1186:                try {
1187:                    element_info.setGlobalCookies(globals);
1188:                    fail();
1189:                } catch (GlobalCookieFileConflictException e) {
1190:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1191:                    assertEquals(e.getSubmissionName(), "submission1");
1192:                    assertEquals(e.getConflictName(), "file1");
1193:                } catch (EngineException e) {
1194:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1195:                }
1196:            }
1197:
1198:            public void testInputConflicts() throws EngineException {
1199:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1200:                        "text/html", TestElement2.class.getName(),
1201:                        ElementType.JAVA_CLASS);
1202:
1203:                try {
1204:                    element_info.addInput("input1", null);
1205:                } catch (EngineException e) {
1206:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1207:                }
1208:
1209:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
1210:                globals.put("input1", new GlobalVar(null).setGroupId(0));
1211:                element_info = new ElementInfo("element/test2.xml",
1212:                        "text/html", TestElement2.class.getName(),
1213:                        ElementType.JAVA_CLASS);
1214:                element_info.setGlobalVars(globals);
1215:                try {
1216:                    element_info.addInput("input1", null);
1217:                    fail();
1218:                } catch (InputGlobalVarConflictException e) {
1219:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1220:                    assertEquals(e.getConflictName(), "input1");
1221:                } catch (EngineException e) {
1222:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1223:                }
1224:
1225:                Submission submission = null;
1226:                submission = new Submission();
1227:                element_info = new ElementInfo("element/test2.xml",
1228:                        "text/html", TestElement2.class.getName(),
1229:                        ElementType.JAVA_CLASS);
1230:                element_info.addSubmission("submission1", submission);
1231:                submission.addParameter("input1", null);
1232:                try {
1233:                    element_info.addInput("input1", null);
1234:                    fail();
1235:                } catch (InputParameterConflictException e) {
1236:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1237:                    assertEquals(e.getSubmissionName(), "submission1");
1238:                    assertEquals(e.getConflictName(), "input1");
1239:                } catch (EngineException e) {
1240:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1241:                }
1242:
1243:                submission = new Submission();
1244:                element_info = new ElementInfo("element/test2.xml",
1245:                        "text/html", TestElement2.class.getName(),
1246:                        ElementType.JAVA_CLASS);
1247:                element_info.addSubmission("submission1", submission);
1248:                submission.addFile("input1");
1249:                try {
1250:                    element_info.addInput("input1", null);
1251:                    fail();
1252:                } catch (InputFileConflictException e) {
1253:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1254:                    assertEquals(e.getSubmissionName(), "submission1");
1255:                    assertEquals(e.getConflictName(), "input1");
1256:                } catch (EngineException e) {
1257:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1258:                }
1259:
1260:                submission = new Submission();
1261:                element_info = new ElementInfo("element/test2.xml",
1262:                        "text/html", TestElement2.class.getName(),
1263:                        ElementType.JAVA_CLASS);
1264:                element_info.addSubmission("submission1", submission);
1265:                submission.addParameterRegexp("regexpparameter(.*)");
1266:                try {
1267:                    element_info.addInput("regexpparameter1", null);
1268:                    fail();
1269:                } catch (InputParameterConflictException e) {
1270:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1271:                    assertEquals(e.getSubmissionName(), "submission1");
1272:                    assertEquals(e.getConflictName(), "regexpparameter1");
1273:                } catch (EngineException e) {
1274:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1275:                }
1276:            }
1277:
1278:            public void testOutputConflicts() throws EngineException {
1279:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1280:                        "text/html", TestElement2.class.getName(),
1281:                        ElementType.JAVA_CLASS);
1282:
1283:                try {
1284:                    element_info.addOutput("output1", null);
1285:                } catch (EngineException e) {
1286:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1287:                }
1288:
1289:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
1290:                globals.put("output1", new GlobalVar(null).setGroupId(0));
1291:                element_info = new ElementInfo("element/test2.xml",
1292:                        "text/html", TestElement2.class.getName(),
1293:                        ElementType.JAVA_CLASS);
1294:                element_info.setGlobalVars(globals);
1295:                try {
1296:                    element_info.addOutput("output1", null);
1297:                    fail();
1298:                } catch (OutputGlobalVarConflictException e) {
1299:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1300:                    assertEquals(e.getConflictName(), "output1");
1301:                } catch (EngineException e) {
1302:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1303:                }
1304:            }
1305:
1306:            public void testParamConflicts() throws EngineException {
1307:                ElementInfo element_info = null;
1308:                Submission submission = null;
1309:                submission = new Submission();
1310:                element_info = new ElementInfo("element/test2.xml",
1311:                        "text/html", TestElement2.class.getName(),
1312:                        ElementType.JAVA_CLASS);
1313:                element_info.addSubmission("submission1", submission);
1314:                try {
1315:                    submission.addParameter("parameter1", null);
1316:                } catch (EngineException e) {
1317:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1318:                }
1319:
1320:                submission = new Submission();
1321:                element_info = new ElementInfo("element/test2.xml",
1322:                        "text/html", TestElement2.class.getName(),
1323:                        ElementType.JAVA_CLASS);
1324:                element_info.addSubmission("submission1", submission);
1325:                element_info.addInput("parameter1", null);
1326:                try {
1327:                    submission.addParameter("parameter1", null);
1328:                    fail();
1329:                } catch (ParameterInputConflictException e) {
1330:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1331:                    assertEquals(e.getSubmissionName(), "submission1");
1332:                    assertEquals(e.getConflictName(), "parameter1");
1333:                } catch (EngineException e) {
1334:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1335:                }
1336:
1337:                submission = new Submission();
1338:                element_info = new ElementInfo("element/test2.xml",
1339:                        "text/html", TestElement2.class.getName(),
1340:                        ElementType.JAVA_CLASS);
1341:                element_info.addSubmission("submission1", submission);
1342:                submission.addFile("parameter1");
1343:                try {
1344:                    submission.addParameter("parameter1", null);
1345:                    fail();
1346:                } catch (ParameterFileConflictException e) {
1347:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1348:                    assertEquals(e.getSubmissionName(), "submission1");
1349:                    assertEquals(e.getConflictName(), "parameter1");
1350:                } catch (EngineException e) {
1351:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1352:                }
1353:
1354:                submission = new Submission();
1355:                element_info = new ElementInfo("element/test2.xml",
1356:                        "text/html", TestElement2.class.getName(),
1357:                        ElementType.JAVA_CLASS);
1358:                element_info.addSubmission("submission1", submission);
1359:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
1360:                globals.put("parameter1", new GlobalVar(null).setGroupId(0));
1361:                element_info.setGlobalVars(globals);
1362:                try {
1363:                    submission.addParameter("parameter1", null);
1364:                    fail();
1365:                } catch (ParameterGlobalVarConflictException e) {
1366:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1367:                    assertEquals(e.getSubmissionName(), "submission1");
1368:                    assertEquals(e.getConflictName(), "parameter1");
1369:                } catch (EngineException e) {
1370:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1371:                }
1372:            }
1373:
1374:            public void testFileConflicts() throws EngineException {
1375:                ElementInfo element_info = null;
1376:                Submission submission = null;
1377:                submission = new Submission();
1378:                element_info = new ElementInfo("element/test2.xml",
1379:                        "text/html", TestElement2.class.getName(),
1380:                        ElementType.JAVA_CLASS);
1381:                element_info.addSubmission("submission1", submission);
1382:                try {
1383:                    submission.addFile("file1");
1384:                } catch (EngineException e) {
1385:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1386:                }
1387:
1388:                submission = new Submission();
1389:                element_info = new ElementInfo("element/test2.xml",
1390:                        "text/html", TestElement2.class.getName(),
1391:                        ElementType.JAVA_CLASS);
1392:                element_info.addSubmission("submission1", submission);
1393:                element_info.addInput("file1", null);
1394:                try {
1395:                    submission.addFile("file1");
1396:                    fail();
1397:                } catch (FileInputConflictException e) {
1398:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1399:                    assertEquals(e.getSubmissionName(), "submission1");
1400:                    assertEquals(e.getConflictName(), "file1");
1401:                } catch (EngineException e) {
1402:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1403:                }
1404:
1405:                submission = new Submission();
1406:                element_info = new ElementInfo("element/test2.xml",
1407:                        "text/html", TestElement2.class.getName(),
1408:                        ElementType.JAVA_CLASS);
1409:                element_info.addSubmission("submission1", submission);
1410:                submission.addParameter("file1", null);
1411:                try {
1412:                    submission.addFile("file1");
1413:                    fail();
1414:                } catch (FileParameterConflictException e) {
1415:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1416:                    assertEquals(e.getSubmissionName(), "submission1");
1417:                    assertEquals(e.getConflictName(), "file1");
1418:                } catch (EngineException e) {
1419:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1420:                }
1421:
1422:                submission = new Submission();
1423:                element_info = new ElementInfo("element/test2.xml",
1424:                        "text/html", TestElement2.class.getName(),
1425:                        ElementType.JAVA_CLASS);
1426:                element_info.addSubmission("submission1", submission);
1427:                LinkedHashMap<String, GlobalVar> globals = new LinkedHashMap<String, GlobalVar>();
1428:                globals.put("file1", new GlobalVar(null).setGroupId(0));
1429:                element_info.setGlobalVars(globals);
1430:                try {
1431:                    submission.addFile("file1");
1432:                    fail();
1433:                } catch (FileGlobalVarConflictException e) {
1434:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1435:                    assertEquals(e.getSubmissionName(), "submission1");
1436:                    assertEquals(e.getConflictName(), "file1");
1437:                } catch (EngineException e) {
1438:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1439:                }
1440:            }
1441:
1442:            public void testIncookieConflicts() throws EngineException {
1443:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1444:                        "text/html", TestElement2.class.getName(),
1445:                        ElementType.JAVA_CLASS);
1446:
1447:                try {
1448:                    element_info.addIncookie("incookie1", null);
1449:                } catch (EngineException e) {
1450:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1451:                }
1452:
1453:                LinkedHashMap<String, String> globals = new LinkedHashMap<String, String>();
1454:                globals.put("incookie1", null);
1455:                element_info = new ElementInfo("element/test2.xml",
1456:                        "text/html", TestElement2.class.getName(),
1457:                        ElementType.JAVA_CLASS);
1458:                element_info.setGlobalCookies(globals);
1459:                try {
1460:                    element_info.addIncookie("incookie1", null);
1461:                    fail();
1462:                } catch (IncookieGlobalCookieConflictException e) {
1463:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1464:                    assertEquals(e.getConflictName(), "incookie1");
1465:                } catch (EngineException e) {
1466:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1467:                }
1468:
1469:                Submission submission = null;
1470:                submission = new Submission();
1471:                element_info = new ElementInfo("element/test2.xml",
1472:                        "text/html", TestElement2.class.getName(),
1473:                        ElementType.JAVA_CLASS);
1474:                element_info.addSubmission("submission1", submission);
1475:                submission.addParameter("incookie1", null);
1476:                try {
1477:                    element_info.addIncookie("incookie1", null);
1478:                    fail();
1479:                } catch (IncookieParameterConflictException e) {
1480:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1481:                    assertEquals(e.getSubmissionName(), "submission1");
1482:                    assertEquals(e.getConflictName(), "incookie1");
1483:                } catch (EngineException e) {
1484:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1485:                }
1486:
1487:                submission = new Submission();
1488:                element_info = new ElementInfo("element/test2.xml",
1489:                        "text/html", TestElement2.class.getName(),
1490:                        ElementType.JAVA_CLASS);
1491:                element_info.addSubmission("submission1", submission);
1492:                submission.addFile("incookie1");
1493:                try {
1494:                    element_info.addIncookie("incookie1", null);
1495:                    fail();
1496:                } catch (IncookieFileConflictException e) {
1497:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1498:                    assertEquals(e.getSubmissionName(), "submission1");
1499:                    assertEquals(e.getConflictName(), "incookie1");
1500:                } catch (EngineException e) {
1501:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1502:                }
1503:            }
1504:
1505:            public void testOutcookieConflicts() throws EngineException {
1506:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1507:                        "text/html", TestElement2.class.getName(),
1508:                        ElementType.JAVA_CLASS);
1509:
1510:                try {
1511:                    element_info.addOutcookie("outcookie1", null);
1512:                } catch (EngineException e) {
1513:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1514:                }
1515:
1516:                LinkedHashMap<String, String> globals = new LinkedHashMap<String, String>();
1517:                globals.put("outcookie1", null);
1518:                element_info = new ElementInfo("element/test2.xml",
1519:                        "text/html", TestElement2.class.getName(),
1520:                        ElementType.JAVA_CLASS);
1521:                element_info.setGlobalCookies(globals);
1522:                try {
1523:                    element_info.addOutcookie("outcookie1", null);
1524:                    fail();
1525:                } catch (OutcookieGlobalCookieConflictException e) {
1526:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1527:                    assertEquals(e.getConflictName(), "outcookie1");
1528:                } catch (EngineException e) {
1529:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1530:                }
1531:            }
1532:
1533:            public void testNamedGlobalBeanConflicts() throws EngineException {
1534:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1535:                        "text/html", TestElement2.class.getName(),
1536:                        ElementType.JAVA_CLASS);
1537:                LinkedHashMap<String, BeanDeclaration> namedglobalbeans = new LinkedHashMap<String, BeanDeclaration>();
1538:
1539:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
1540:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
1541:                        null, null);
1542:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
1543:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
1544:                        "prefix_", null);
1545:
1546:                namedglobalbeans.put("inbean1", bean_declaration1);
1547:                namedglobalbeans.put("outbean1", bean_declaration2);
1548:
1549:                try {
1550:                    element_info.setNamedGlobalBeans(namedglobalbeans);
1551:                } catch (EngineException e) {
1552:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1553:                }
1554:
1555:                element_info = new ElementInfo("element/test2.xml",
1556:                        "text/html", TestElement2.class.getName(),
1557:                        ElementType.JAVA_CLASS);
1558:                element_info.addNamedInbean("inbean1", bean_declaration2);
1559:                try {
1560:                    element_info.setNamedGlobalBeans(namedglobalbeans);
1561:                    fail();
1562:                } catch (NamedInbeanGlobalBeanConflictException e) {
1563:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1564:                    assertEquals(e.getConflictName(), "inbean1");
1565:                } catch (EngineException e) {
1566:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1567:                }
1568:
1569:                element_info = new ElementInfo("element/test2.xml",
1570:                        "text/html", TestElement2.class.getName(),
1571:                        ElementType.JAVA_CLASS);
1572:                element_info.addNamedOutbean("outbean1", bean_declaration1);
1573:                try {
1574:                    element_info.setNamedGlobalBeans(namedglobalbeans);
1575:                    fail();
1576:                } catch (NamedOutbeanGlobalBeanConflictException e) {
1577:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1578:                    assertEquals(e.getConflictName(), "outbean1");
1579:                } catch (EngineException e) {
1580:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1581:                }
1582:            }
1583:
1584:            public void testNamedInbeanConflicts() throws EngineException {
1585:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1586:                        "text/html", TestElement2.class.getName(),
1587:                        ElementType.JAVA_CLASS);
1588:                LinkedHashMap<String, BeanDeclaration> namedglobalbeans = new LinkedHashMap<String, BeanDeclaration>();
1589:
1590:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
1591:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
1592:                        null, null);
1593:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
1594:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
1595:                        "prefix_", null);
1596:
1597:                namedglobalbeans.put("inbean1", bean_declaration1);
1598:
1599:                element_info = new ElementInfo("element/test2.xml",
1600:                        "text/html", TestElement2.class.getName(),
1601:                        ElementType.JAVA_CLASS);
1602:                element_info.setNamedGlobalBeans(namedglobalbeans);
1603:                try {
1604:                    element_info.addNamedInbean("inbean1", bean_declaration2);
1605:                    fail();
1606:                } catch (NamedInbeanGlobalBeanConflictException e) {
1607:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1608:                    assertEquals(e.getConflictName(), "inbean1");
1609:                } catch (EngineException e) {
1610:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1611:                }
1612:            }
1613:
1614:            public void testNamedOutbeanConflicts() throws EngineException {
1615:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1616:                        "text/html", TestElement2.class.getName(),
1617:                        ElementType.JAVA_CLASS);
1618:                LinkedHashMap<String, BeanDeclaration> namedglobalbeans = new LinkedHashMap<String, BeanDeclaration>();
1619:
1620:                BeanDeclaration bean_declaration1 = new BeanDeclaration(
1621:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
1622:                        null, null);
1623:                BeanDeclaration bean_declaration2 = new BeanDeclaration(
1624:                        "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
1625:                        "prefix_", null);
1626:
1627:                namedglobalbeans.put("outbean1", bean_declaration2);
1628:
1629:                element_info = new ElementInfo("element/test2.xml",
1630:                        "text/html", TestElement2.class.getName(),
1631:                        ElementType.JAVA_CLASS);
1632:                element_info.setNamedGlobalBeans(namedglobalbeans);
1633:                try {
1634:                    element_info.addNamedOutbean("outbean1", bean_declaration1);
1635:                    fail();
1636:                } catch (NamedOutbeanGlobalBeanConflictException e) {
1637:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
1638:                    assertEquals(e.getConflictName(), "outbean1");
1639:                } catch (EngineException e) {
1640:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1641:                }
1642:            }
1643:
1644:            public void testAddChildTriggerWithoutInput()
1645:                    throws EngineException {
1646:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1647:                        "text/html", TestElement2.class.getName(),
1648:                        ElementType.JAVA_CLASS);
1649:
1650:                try {
1651:                    element_info.addChildTrigger("childtrigger1");
1652:                } catch (ChildTriggerVariableUnknownException e) {
1653:                    assertEquals("childtrigger1", e.getChildTriggerName());
1654:                }
1655:                assertEquals(element_info.getChildTriggerNames().size(), 0);
1656:                assertTrue(false == element_info
1657:                        .containsChildTrigger("childtrigger1"));
1658:            }
1659:
1660:            public void testAddInputDefaultValues() throws EngineException {
1661:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1662:                        "text/html", TestElement2.class.getName(),
1663:                        ElementType.JAVA_CLASS);
1664:
1665:                assertTrue(false == element_info.hasInputDefaults());
1666:
1667:                element_info.addInput("input1", new String[] { "one", "two" });
1668:                element_info.addInput("input2", new String[] { "three" });
1669:                element_info.addInput("input3", null);
1670:
1671:                assertTrue(element_info.hasInputDefaults());
1672:
1673:                assertTrue(element_info.hasInputDefaultValues("input1"));
1674:                assertTrue(element_info.hasInputDefaultValues("input2"));
1675:                assertTrue(false == element_info
1676:                        .hasInputDefaultValues("input3"));
1677:
1678:                assertNotNull(element_info.getInputDefaultValues("input1"));
1679:                assertNotNull(element_info.getInputDefaultValues("input2"));
1680:                assertNull(element_info.getInputDefaultValues("input3"));
1681:
1682:                assertEquals(2,
1683:                        element_info.getInputDefaultValues("input1").length);
1684:                assertEquals(1,
1685:                        element_info.getInputDefaultValues("input2").length);
1686:
1687:                assertEquals("one", element_info
1688:                        .getInputDefaultValues("input1")[0]);
1689:                assertEquals("two", element_info
1690:                        .getInputDefaultValues("input1")[1]);
1691:                assertEquals("three", element_info
1692:                        .getInputDefaultValues("input2")[0]);
1693:            }
1694:
1695:            public void testAddOutputDefaultValues() throws EngineException {
1696:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1697:                        "text/html", TestElement2.class.getName(),
1698:                        ElementType.JAVA_CLASS);
1699:
1700:                assertTrue(false == element_info.hasOutputDefaults());
1701:
1702:                String[] defaults1 = new String[] { "one", "two" };
1703:                String[] defaults2 = new String[] { "three" };
1704:
1705:                element_info.addOutput("output1", defaults1);
1706:                element_info.addOutput("output2", defaults2);
1707:                element_info.addOutput("output3", null);
1708:
1709:                assertTrue(element_info.hasOutputDefaults());
1710:
1711:                assertTrue(element_info.hasOutputDefaultValues("output1"));
1712:                assertTrue(element_info.hasOutputDefaultValues("output2"));
1713:                assertTrue(false == element_info
1714:                        .hasOutputDefaultValues("output3"));
1715:
1716:                assertNotNull(element_info.getOutputDefaultValues("output1"));
1717:                assertNotNull(element_info.getOutputDefaultValues("output2"));
1718:                assertNull(element_info.getOutputDefaultValues("output3"));
1719:
1720:                assertEquals(defaults1.length, element_info
1721:                        .getOutputDefaultValues("output1").length);
1722:                assertEquals(defaults2.length, element_info
1723:                        .getOutputDefaultValues("output2").length);
1724:
1725:                assertEquals(defaults1[0], element_info
1726:                        .getOutputDefaultValues("output1")[0]);
1727:                assertEquals(defaults1[1], element_info
1728:                        .getOutputDefaultValues("output1")[1]);
1729:                assertEquals(defaults2[0], element_info
1730:                        .getOutputDefaultValues("output2")[0]);
1731:            }
1732:
1733:            public void testAddIncookieDefaultValues() throws EngineException {
1734:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1735:                        "text/html", TestElement2.class.getName(),
1736:                        ElementType.JAVA_CLASS);
1737:
1738:                assertTrue(false == element_info.hasIncookieDefaults());
1739:
1740:                element_info.addIncookie("incookie1", "one");
1741:                element_info.addIncookie("incookie3", null);
1742:
1743:                assertTrue(element_info.hasIncookieDefaults());
1744:
1745:                assertTrue(element_info.hasIncookieDefaultValue("incookie1"));
1746:                assertTrue(false == element_info
1747:                        .hasIncookieDefaultValue("incookie2"));
1748:
1749:                assertNotNull(element_info.getIncookieDefaultValue("incookie1"));
1750:                assertNull(element_info.getIncookieDefaultValue("incookie2"));
1751:
1752:                assertEquals("one", element_info
1753:                        .getIncookieDefaultValue("incookie1"));
1754:            }
1755:
1756:            public void testAddOutcookieDefaultValues() throws EngineException {
1757:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1758:                        "text/html", TestElement2.class.getName(),
1759:                        ElementType.JAVA_CLASS);
1760:
1761:                assertTrue(false == element_info.hasOutcookieDefaults());
1762:
1763:                element_info.addOutcookie("outcookie1", "one");
1764:                element_info.addOutcookie("outcookie3", null);
1765:
1766:                assertTrue(element_info.hasOutcookieDefaults());
1767:
1768:                assertTrue(element_info.hasOutcookieDefaultValue("outcookie1"));
1769:                assertTrue(false == element_info
1770:                        .hasOutcookieDefaultValue("outcookie2"));
1771:
1772:                assertNotNull(element_info
1773:                        .getOutcookieDefaultValue("outcookie1"));
1774:                assertNull(element_info.getOutcookieDefaultValue("outcookie2"));
1775:
1776:                assertEquals("one", element_info
1777:                        .getOutcookieDefaultValue("outcookie1"));
1778:            }
1779:
1780:            public void testEmptyInitialFlowLink() throws EngineException {
1781:                ElementInfo element_info = new ElementInfo("element/test2.xml",
1782:                        "text/html", TestElement2.class.getName(),
1783:                        ElementType.JAVA_CLASS);
1784:
1785:                element_info.addExit("exit1");
1786:
1787:                assertNull(element_info.getFlowLink("exit1"));
1788:            }
1789:
1790:            public void testSetFlowLink() throws EngineException {
1791:                ElementInfo element_info1 = new ElementInfo(
1792:                        "element/test2.xml", "text/html", TestElement2.class
1793:                                .getName(), ElementType.JAVA_CLASS);
1794:                ElementInfo element_info2 = new ElementInfo(
1795:                        "element/test3.xml", "text/html", TestElement3.class
1796:                                .getName(), ElementType.JAVA_CLASS);
1797:
1798:                element_info1.addExit("exit1");
1799:                element_info1.addExit("exit2");
1800:
1801:                element_info1.setFlowLink(new FlowLink("exit1", element_info2,
1802:                        false, false, false, true, false));
1803:                element_info1.setFlowLink(new FlowLink("exit2", element_info2,
1804:                        false, true, true, false, true));
1805:
1806:                assertSame(element_info1.getFlowLink("exit1").getTarget(),
1807:                        element_info2);
1808:                assertEquals(element_info1.getFlowLink("exit1")
1809:                        .cancelInheritance(), false);
1810:                assertSame(element_info1.getFlowLink("exit2").getTarget(),
1811:                        element_info2);
1812:                assertEquals(element_info1.getFlowLink("exit2")
1813:                        .cancelInheritance(), true);
1814:
1815:                Set<Map.Entry<String, FlowLink>> exit_entries = element_info1
1816:                        .getExitEntries();
1817:                assertEquals(exit_entries.size(), 2);
1818:                Iterator<Map.Entry<String, FlowLink>> exit_entries_it = exit_entries
1819:                        .iterator();
1820:                Map.Entry<String, FlowLink> exit_entry = null;
1821:                assertTrue(exit_entries_it.hasNext());
1822:                exit_entry = exit_entries_it.next();
1823:                assertNotNull(exit_entry);
1824:                assertEquals(exit_entry.getKey(), "exit1");
1825:                assertSame(exit_entry.getValue().getTarget(), element_info2);
1826:                assertEquals(exit_entry.getValue().cancelInheritance(), false);
1827:                assertEquals(exit_entry.getValue().isRedirect(), true);
1828:                assertEquals(exit_entry.getValue().cancelContinuations(), false);
1829:                assertTrue(exit_entries_it.hasNext());
1830:                exit_entry = exit_entries_it.next();
1831:                assertNotNull(exit_entry);
1832:                assertEquals(exit_entry.getKey(), "exit2");
1833:                assertSame(exit_entry.getValue().getTarget(), element_info2);
1834:                assertEquals(exit_entry.getValue().cancelInheritance(), true);
1835:                assertEquals(exit_entry.getValue().isRedirect(), false);
1836:                assertEquals(exit_entry.getValue().cancelContinuations(), true);
1837:                assertTrue(false == exit_entries_it.hasNext());
1838:            }
1839:
1840:            public void testSetInexistantFlowLink() throws EngineException {
1841:                ElementInfo element_info1 = new ElementInfo(
1842:                        "element/test2.xml", "text/html", TestElement2.class
1843:                                .getName(), ElementType.JAVA_CLASS);
1844:                ElementInfo element_info2 = new ElementInfo(
1845:                        "element/test3.xml", "text/html", TestElement3.class
1846:                                .getName(), ElementType.JAVA_CLASS);
1847:
1848:                try {
1849:                    element_info1.addExit("exit1");
1850:                    element_info1.addExit("exit2");
1851:                } catch (EngineException e) {
1852:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1853:                }
1854:
1855:                try {
1856:                    element_info2.setFlowLink(new FlowLink("exit3",
1857:                            element_info2, false, false, false, false, false));
1858:                } catch (ExitUnknownException e) {
1859:                    assertEquals(e.getDeclarationName(), "element/test3.xml");
1860:                    assertEquals(e.getExitName(), "exit3");
1861:                } catch (EngineException e) {
1862:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
1863:                }
1864:            }
1865:
1866:            public void testAddDataLink() throws EngineException {
1867:                ElementInfo element_info1 = new ElementInfo(
1868:                        "element/test2.xml", "text/html", TestElement2.class
1869:                                .getName(), ElementType.JAVA_CLASS);
1870:                ElementInfo element_info2 = new ElementInfo(
1871:                        "element/test3.xml", "text/html", TestElement3.class
1872:                                .getName(), ElementType.JAVA_CLASS);
1873:                ElementInfo element_info3 = new ElementInfo(
1874:                        "element/test3.xml", "text/html", TestElement4.class
1875:                                .getName(), ElementType.JAVA_CLASS);
1876:
1877:                element_info1.addOutput("output1", null);
1878:                element_info1.addOutput("output2", null);
1879:                element_info1.addOutput("output3", null);
1880:
1881:                element_info2.addInput("input1", null);
1882:                element_info2.addInput("input2", null);
1883:                element_info2.addInput("input3", null);
1884:
1885:                element_info3.addInput("input1", null);
1886:                element_info3.addInput("input2", null);
1887:                element_info3.addInput("input3", null);
1888:
1889:                element_info1.addExit("exit1");
1890:                element_info1.addExit("exit2");
1891:
1892:                FlowLink flowlink1 = new FlowLink("exit1", element_info2,
1893:                        false, false, false, false, false);
1894:                FlowLink flowlink2 = new FlowLink("exit2", null, true, false,
1895:                        false, false, false);
1896:                element_info1.setFlowLink(flowlink1);
1897:                element_info1.setFlowLink(flowlink2);
1898:
1899:                assertTrue(false == element_info1.hasDataLink(element_info2));
1900:                assertTrue(false == element_info1.hasDataLink(element_info3));
1901:                assertTrue(false == element_info1.hasSnapbackDataLinks());
1902:
1903:                element_info1.addDataLink(new DataLink("output1",
1904:                        element_info2, false, "input1", null));
1905:                element_info1.addDataLink(new DataLink("output1",
1906:                        element_info2, false, "input2", null));
1907:                element_info1.addDataLink(new DataLink("output1",
1908:                        element_info2, false, "input3", null));
1909:                element_info1.addDataLink(new DataLink("output2",
1910:                        element_info2, false, "input2", flowlink2));
1911:                element_info1.addDataLink(new DataLink("output2",
1912:                        element_info2, false, "input3", null));
1913:
1914:                element_info1.addDataLink(new DataLink("output1", null, true,
1915:                        "input1", null));
1916:                element_info1.addDataLink(new DataLink("output1", null, true,
1917:                        "input2", null));
1918:                element_info1.addDataLink(new DataLink("output1", null, true,
1919:                        "input3", null));
1920:                element_info1.addDataLink(new DataLink("output2", null, true,
1921:                        "input2", null));
1922:                element_info1.addDataLink(new DataLink("output2", null, true,
1923:                        "input3", null));
1924:
1925:                assertTrue(element_info1.hasDataLink(element_info2));
1926:                assertTrue(element_info1.hasSnapbackDataLinks());
1927:
1928:                Collection<String> inputs = null;
1929:
1930:                inputs = element_info1.getDataLinkInputs("output1",
1931:                        element_info2, false, null);
1932:                assertNotNull(inputs);
1933:                assertEquals(inputs.size(), 3);
1934:
1935:                boolean has_input1 = false;
1936:                boolean has_input2 = false;
1937:                boolean has_input3 = false;
1938:
1939:                for (String input : inputs) {
1940:                    if (input.equals("input1")) {
1941:                        assertFalse(has_input1);
1942:                        has_input1 = true;
1943:                    } else if (input.equals("input2")) {
1944:                        assertFalse(has_input2);
1945:                        has_input2 = true;
1946:                    } else if (input.equals("input3")) {
1947:                        assertFalse(has_input3);
1948:                        has_input3 = true;
1949:                    } else {
1950:                        fail();
1951:                    }
1952:                }
1953:                assertTrue(has_input1 && has_input2 && has_input3);
1954:
1955:                inputs = element_info1.getDataLinkInputs("output2",
1956:                        element_info2, false, null);
1957:                assertNotNull(inputs);
1958:                assertEquals(inputs.size(), 1);
1959:                assertEquals("input3", inputs.iterator().next());
1960:
1961:                has_input1 = false;
1962:                has_input2 = false;
1963:                has_input3 = false;
1964:
1965:                inputs = element_info1.getDataLinkInputs("output2",
1966:                        element_info2, false, flowlink2);
1967:                assertNotNull(inputs);
1968:                assertEquals(inputs.size(), 2);
1969:
1970:                for (String input : inputs) {
1971:                    if (input.equals("input2")) {
1972:                        assertFalse(has_input2);
1973:                        has_input2 = true;
1974:                    } else if (input.equals("input3")) {
1975:                        assertFalse(has_input3);
1976:                        has_input3 = true;
1977:                    } else {
1978:                        fail();
1979:                    }
1980:                }
1981:                assertTrue(!has_input1 && has_input2 && has_input3);
1982:
1983:                inputs = element_info1.getDataLinkInputs("output1",
1984:                        element_info3, false, null);
1985:                assertNull(inputs);
1986:
1987:                inputs = element_info1.getDataLinkInputs("output2",
1988:                        element_info3, false, null);
1989:                assertNull(inputs);
1990:
1991:                inputs = element_info1.getDataLinkInputs("output1",
1992:                        element_info3, true, null);
1993:                assertNotNull(inputs);
1994:                assertEquals(inputs.size(), 3);
1995:
1996:                has_input1 = false;
1997:                has_input2 = false;
1998:                has_input3 = false;
1999:
2000:                for (String input : inputs) {
2001:                    if (input.equals("input1")) {
2002:                        assertFalse(has_input1);
2003:                        has_input1 = true;
2004:                    } else if (input.equals("input2")) {
2005:                        assertFalse(has_input2);
2006:                        has_input2 = true;
2007:                    } else if (input.equals("input3")) {
2008:                        assertFalse(has_input3);
2009:                        has_input3 = true;
2010:                    } else {
2011:                        fail();
2012:                    }
2013:                }
2014:                assertTrue(has_input1 && has_input2 && has_input3);
2015:
2016:                has_input1 = false;
2017:                has_input2 = false;
2018:                has_input3 = false;
2019:
2020:                inputs = element_info1.getDataLinkInputs("output2",
2021:                        element_info3, true, null);
2022:                assertNotNull(inputs);
2023:                assertEquals(inputs.size(), 2);
2024:
2025:                for (String input : inputs) {
2026:                    if (input.equals("input2")) {
2027:                        assertFalse(has_input2);
2028:                        has_input2 = true;
2029:                    } else if (input.equals("input3")) {
2030:                        assertFalse(has_input3);
2031:                        has_input3 = true;
2032:                    } else {
2033:                        fail();
2034:                    }
2035:                }
2036:                assertTrue(has_input2 && has_input3);
2037:            }
2038:
2039:            public void testInexistantDataLinks() throws EngineException {
2040:                ElementInfo element_info1 = new ElementInfo(
2041:                        "element/test2.xml", "text/html", TestElement2.class
2042:                                .getName(), ElementType.JAVA_CLASS);
2043:                ElementInfo element_info2 = new ElementInfo(
2044:                        "element/test3.xml", "text/html", TestElement3.class
2045:                                .getName(), ElementType.JAVA_CLASS);
2046:
2047:                element_info1.addOutput("output1", null);
2048:                element_info1.addOutput("output2", null);
2049:                element_info1.addOutput("output3", null);
2050:
2051:                element_info2.addInput("input1", null);
2052:                element_info2.addInput("input2", null);
2053:                element_info2.addInput("input3", null);
2054:
2055:                element_info1.addExit("exit");
2056:                element_info1.setFlowLink(new FlowLink("exit", element_info2,
2057:                        false, false, false, false, false));
2058:
2059:                assertTrue(false == element_info1.hasDataLink(element_info2));
2060:                assertNull(element_info1.getDataLinkInputs("output3",
2061:                        element_info2, false, null));
2062:
2063:                element_info1.addDataLink(new DataLink("output1",
2064:                        element_info2, false, "input1", null));
2065:
2066:                assertTrue(element_info1.hasDataLink(element_info2));
2067:                assertNull(element_info1.getDataLinkInputs("output3",
2068:                        element_info2, false, null));
2069:            }
2070:
2071:            public void testAddDataLinkWithoutFlowLink() throws EngineException {
2072:                ElementInfo element_info1 = new ElementInfo(
2073:                        "element/test2.xml", "text/html", TestElement2.class
2074:                                .getName(), ElementType.JAVA_CLASS);
2075:                ElementInfo element_info2 = new ElementInfo(
2076:                        "element/test3.xml", "text/html", TestElement3.class
2077:                                .getName(), ElementType.JAVA_CLASS);
2078:
2079:                element_info1.addOutput("output1", null);
2080:                element_info2.addInput("input1", null);
2081:                try {
2082:                    element_info1.addDataLink(new DataLink("output1",
2083:                            element_info2, false, "input1", null));
2084:                } catch (FlowLinkMissingException e) {
2085:                    assertEquals(e.getSourceDeclarationName(),
2086:                            "element/test2.xml");
2087:                    assertEquals(e.getTargetDeclarationName(),
2088:                            "element/test3.xml");
2089:                } catch (EngineException e) {
2090:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
2091:                }
2092:            }
2093:
2094:            public void testAddSnapbackDataLinkWithoutSnapbackFlowLink()
2095:                    throws EngineException {
2096:                ElementInfo element_info1 = new ElementInfo(
2097:                        "element/test2.xml", "text/html", TestElement2.class
2098:                                .getName(), ElementType.JAVA_CLASS);
2099:                ElementInfo element_info2 = new ElementInfo(
2100:                        "element/test3.xml", "text/html", TestElement3.class
2101:                                .getName(), ElementType.JAVA_CLASS);
2102:
2103:                element_info1.addOutput("output1", null);
2104:                element_info2.addInput("input1", null);
2105:                try {
2106:                    element_info1.addDataLink(new DataLink("output1", null,
2107:                            true, "input1", null));
2108:                } catch (SnapbackFlowLinkMissingException e) {
2109:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
2110:                } catch (EngineException e) {
2111:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
2112:                }
2113:            }
2114:
2115:            public void testAddDataLinkErrors() throws EngineException {
2116:                ElementInfo element_info1 = new ElementInfo(
2117:                        "element/test2.xml", "text/html", TestElement2.class
2118:                                .getName(), ElementType.JAVA_CLASS);
2119:                ElementInfo element_info2 = new ElementInfo(
2120:                        "element/test3.xml", "text/html", TestElement3.class
2121:                                .getName(), ElementType.JAVA_CLASS);
2122:
2123:                element_info1.addOutput("output1", null);
2124:                element_info2.addInput("input1", null);
2125:
2126:                try {
2127:                    element_info1.addDataLink(new DataLink("output2",
2128:                            element_info2, false, "input1", null));
2129:                } catch (OutputUnknownException e) {
2130:                    assertEquals(e.getDeclarationName(), "element/test2.xml");
2131:                    assertEquals(e.getOutputName(), "output2");
2132:                } catch (EngineException e) {
2133:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
2134:                }
2135:
2136:                try {
2137:                    element_info1.addDataLink(new DataLink("output1",
2138:                            element_info2, false, "input2", null));
2139:                } catch (InputUnknownException e) {
2140:                    assertEquals(e.getDeclarationName(), "element/test3.xml");
2141:                    assertEquals(e.getInputName(), "input2");
2142:                } catch (EngineException e) {
2143:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
2144:                }
2145:            }
2146:        }
2147:
2148:        class TestElement2 extends Element {
2149:            public void processElement() throws EngineException {
2150:                print("the content");
2151:            }
2152:        }
2153:
2154:        class TestElement3 extends Element {
2155:            public void processElement() throws EngineException {
2156:                print("other content");
2157:            }
2158:        }
2159:
2160:        abstract class TestElementNotInstantiatable extends Element {
2161:            public void processElement() throws EngineException {
2162:                print("the content");
2163:            }
2164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.