001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: TestSiteBuilder.java 3643 2007-01-12 15:29:45Z gbevin $
007: */
008: package com.uwyn.rife.engine;
009:
010: import com.uwyn.rife.config.Config;
011: import com.uwyn.rife.database.Datasources;
012: import com.uwyn.rife.ioc.PropertyValueObject;
013: import com.uwyn.rife.ioc.PropertyValueParticipant;
014: import com.uwyn.rife.ioc.PropertyValueTemplate;
015: import com.uwyn.rife.rep.BlockingRepository;
016: import com.uwyn.rife.rep.Rep;
017: import com.uwyn.rife.rep.Repository;
018: import com.uwyn.rife.resources.ResourceFinderClasspath;
019: import com.uwyn.rife.template.Template;
020: import com.uwyn.rife.template.TemplateFactory;
021: import java.util.Collection;
022: import junit.framework.TestCase;
023:
024: public class TestSiteBuilder extends TestCase {
025: public TestSiteBuilder(String name) {
026: super (name);
027: }
028:
029: public void testInstantiation() {
030: ResourceFinderClasspath resourcefinder = ResourceFinderClasspath
031: .getInstance();
032: SiteBuilder builder = new SiteBuilder("", resourcefinder);
033:
034: assertNotNull(builder);
035: }
036:
037: public void testRepProperties() {
038: BlockingRepository rep = new BlockingRepository();
039: Repository orig_rep = Rep.getDefaultRepository();
040: try {
041: Rep.setDefaultRepository(rep);
042:
043: rep.getProperties().put("prop1", "reppropval1").put(
044: "prop3", "reppropval2");
045:
046: ResourceFinderClasspath resourcefinder = ResourceFinderClasspath
047: .getInstance();
048: SiteBuilder builder = new SiteBuilder("test",
049: resourcefinder);
050: builder.enterElement("ELEMENT1").setImplementation(
051: "com.uwyn.rife.engine.testelements.outputs.Normal")
052: .setUrl("/test/element1").addProperty("prop1",
053: new PropertyValueObject("elementpropval"))
054: .addProperty(
055: "prop2",
056: new PropertyValueTemplate("enginehtml",
057: "noblocks_in")).leaveElement();
058:
059: Site site = builder.getSite();
060: ElementInfo element = site.resolveId(".ELEMENT1");
061: assertNotNull(element);
062: assertEquals(2 + 1 + System.getProperties().size(), element
063: .getPropertyNames().size());
064: assertEquals("elementpropval", element.getProperty("prop1"));
065: assertEquals("<html>\n" + " <head>\n"
066: + " <title>Template without blocks</title>\n"
067: + " </head>\n" + "\n" + " <body>\n"
068: + " <h1>This is a template without blocks.</h1>\n"
069: + " </body>\n" + "</html>", ((Template) element
070: .getProperty("prop2")).getContent());
071: assertEquals("reppropval2", element.getProperty("prop3"));
072: } finally {
073: Rep.setDefaultRepository(orig_rep);
074: }
075: }
076:
077: public void testManualBuild() {
078: ResourceFinderClasspath resourcefinder = ResourceFinderClasspath
079: .getInstance();
080: SiteBuilder builder = new SiteBuilder("test_xml2site",
081: resourcefinder);
082: builder
083: .setFallback("ELEMENT4")
084: .addGlobalExit("globalexit1", "ELEMENT6")
085: .addGlobalExit("globalexit2", "SUBSITE.ELEMENT2")
086: .addGlobalVar("globalvar1", null)
087: .addGlobalVar("globalvar2", null)
088: .addGlobalBean(
089: "com.uwyn.rife.engine.testelements.submission.BeanImpl",
090: "onemoreprefixgroup_", "globalbean1",
091: "anothergroup")
092: .addGlobalBean(
093: "com.uwyn.rife.engine.testelements.submission.BeanImpl",
094: null, null, "anothergroup")
095: .addProperty("prop1",
096: new PropertyValueObject("sitepropval"))
097: .addProperty(
098: "prop6",
099: new PropertyValueParticipant(
100: Datasources.DEFAULT_PARTICIPANT_NAME,
101: new PropertyValueObject(
102: "purgingunittestspgsql")))
103:
104: .enterSubsiteDeclaration("SUBSITE")
105: .setUrlPrefix("/subsite")
106: .addProperty("prop1",
107: new PropertyValueObject("subsitepropval"))
108: .addProperty(
109: "prop2",
110: new PropertyValueTemplate("enginehtml",
111: "noblocks_in"))
112: .addProperty(
113: "prop3",
114: new PropertyValueObject(Rep.getParticipant(
115: "configuration").getObject(
116: "EXPRESSION_CONFIG_VALUE")
117: + " 3"))
118: .addProperty(
119: "prop4",
120: new PropertyValueParticipant(
121: Datasources.DEFAULT_PARTICIPANT_NAME,
122: new PropertyValueObject(
123: "unittestspgsql")))
124: .addProperty(
125: "prop5",
126: new PropertyValueObject(
127: ""
128: + Rep
129: .getParticipant(
130: "configuration")
131: .getObject(
132: "DATASOURCE_USER")
133: + "\n "
134: + Rep
135: .getParticipant(
136: "configuration")
137: .getObject(
138: Config
139: .getRepInstance()
140: .getString(
141: "IOC_CONFIG"))))
142:
143: .enterSubsite()
144: .addGlobalExit("globalexit3", "ELEMENT3")
145: .setFallback("ELEMENT2")
146: .setInherits("ELEMENT4")
147: .addGlobalVar("globalvar3", null)
148: .addDeparture("ELEMENT3")
149:
150: .enterElement("ELEMENT2")
151: .setImplementation(
152: "com.uwyn.rife.engine.testelements.outputs.Normal")
153: .setUrl("/test/element2")
154: .addInput("input1", null)
155: .addInput("input2", null)
156: .addOutput("output1", null)
157: .addExit("exit1")
158: .leaveElement()
159:
160: .enterElement("ELEMENT3")
161: .setImplementation(
162: "com.uwyn.rife.engine.testelements.inputs.Normal")
163: .setUrl("/test/element3")
164: .leaveElement()
165:
166: .enterSubsiteDeclaration("SUBSITE2")
167: .setUrlPrefix("subsite2")
168: .enterSubsite()
169: .enterElement("ELEMENT8")
170: .setImplementation(
171: "com.uwyn.rife.engine.testelements.inputs.Normal")
172: .setUrl("test/element8")
173: .leaveElement()
174: .leaveSubsite()
175: .leaveSubsiteDeclaration()
176: .leaveSubsite()
177: .leaveSubsiteDeclaration()
178:
179: .enterGroup()
180: .setInherits("ELEMENT5")
181: .addGlobalVar("globalvar4", null)
182:
183: .enterElement("ELEMENT6")
184: .setImplementation(
185: "com.uwyn.rife.engine.testelements.outputs.Normal")
186: .setUrl("/test/element6")
187: .setInherits("ELEMENT3")
188: .addInput("input1", null)
189: .addInput("input2", null)
190: .addOutput("output1", null)
191: .addExit("exit1")
192: .leaveElement()
193:
194: .enterElement("ELEMENT7")
195: .setImplementation(
196: "com.uwyn.rife.engine.testelements.inputs.Normal")
197: .setUrl("/test/element7")
198: .leaveElement()
199: .leaveGroup()
200:
201: .enterElement("ELEMENT1")
202: .setImplementation(
203: "com.uwyn.rife.engine.testelements.engine.Simple")
204: .setUrl("/test/element1")
205: .addDataLink("output1", "ELEMENT2", "input1")
206: .addDataLink("output1", "ELEMENT2", "input2")
207: .addFlowLink("exit1", "ELEMENT2", false)
208: .enterFlowLink("exit3")
209: .destId("ELEMENT2")
210: .addDataLink("output3", "input1")
211: .leaveFlowLink()
212: .enterFlowLink("exit4")
213: .destId("ELEMENT2")
214: .addDataLink("output4", "input1")
215: .leaveFlowLink()
216: .addSnapbackFlowLink("exit2", false)
217: .addSnapbackDataLink("output2", "input2")
218: .addStaticProperty("property1", "value1")
219: .addStaticProperty("property2", "value2")
220: .addStaticProperty("property3", "value3")
221: .addStaticProperty("property4", "value4")
222: .addInput("input1", null)
223: .addInput("input2", null)
224: .addInput("input3", null)
225: .addOutput("output1", null)
226: /* .addOutput("output2", null) */// auto-added by datalink
227: .addIncookie("incookie1", null)
228: .addIncookie("incookie2", null)
229: .addOutcookie("outcookie1", null)
230: .addOutcookie("outcookie2", null)
231: .addOutcookie("outcookie3", null)
232: .addOutcookie("outcookie4", null)
233: .addInBean(
234: "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
235: null, "inbean1", null)
236: .addInBean(
237: "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
238: null, null, null)
239: .addInBean(
240: "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
241: "prefix_", null, null)
242: .addInBean(
243: "com.uwyn.rife.engine.testelements.submission.BeanImpl",
244: "prefixgroup_", "inbean2", "somegroup")
245: .addInBean(
246: "com.uwyn.rife.engine.testelements.submission.BeanImpl",
247: null, null, "somegroup")
248: .addOutBean(
249: "com.uwyn.rife.engine.testelements.exits.BeanImpl1",
250: null, null, null)
251: .addOutBean(
252: "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
253: null, null, null)
254: .addOutBean(
255: "com.uwyn.rife.engine.testelements.exits.BeanImpl2",
256: "prefix_", "outbean1", null)
257: .addOutBean(
258: "com.uwyn.rife.engine.testelements.submission.BeanImpl",
259: "prefixgroup_", null, "somegroup")
260: .addOutBean(
261: "com.uwyn.rife.engine.testelements.submission.BeanImpl",
262: null, "outbean2", "somegroup")
263: .addChildTrigger("input1")
264: .addChildTrigger("input2")
265: /* .addExit("exit1") */// auto-added by flowlink
266: .addExit("exit2")
267: .addExit("exit3")
268: .addExit("exit4")
269: .enterSubmission("submission1")
270: .addParameter("param1", null)
271: .addParameter("param2", null)
272: .addParameter("param3", null)
273: .addParameterRegexp("paramA(\\d+)")
274: .addParameterRegexp("paramB(\\d+)")
275: .addFile("file1")
276: .addFile("file2")
277: .leaveSubmission()
278: .enterSubmission("submission2")
279: .addParameter("param1", null)
280: .addParameter("param2", null)
281: .addParameterRegexp("paramC(\\d+)")
282: .addFile("file1")
283: .leaveSubmission()
284: .addProperty("prop1",
285: new PropertyValueObject("elementpropval"))
286: .addProperty(
287: "prop7",
288: new PropertyValueParticipant(
289: Datasources.DEFAULT_PARTICIPANT_NAME,
290: new PropertyValueObject(
291: "sessiondurationunittestspgsql")))
292: .leaveElement()
293:
294: .addProperty(
295: "prop2",
296: new PropertyValueTemplate("enginehtml",
297: "unsetvalues_output_in"))
298:
299: .enterElement("ELEMENT2")
300: .setImplementation(
301: "com.uwyn.rife.engine.testelements.outputs.Normal")
302: .setUrl("/test/element2")
303: .setInherits("ELEMENT3")
304: .addInput("input1", null)
305: .addInput("input2", null)
306: .addOutput("output1", null)
307: .addExit("exit1")
308: .leaveElement()
309:
310: .enterElement("ELEMENT3")
311: .setImplementation(
312: "com.uwyn.rife.engine.testelements.inputs.Normal")
313: .leaveElement()
314:
315: .enterElement("ELEMENT4")
316: .setImplementation(
317: "com.uwyn.rife.engine.testelements.submission.Normal")
318: .leaveElement()
319:
320: .enterElement("ELEMENT5")
321: .setImplementation(
322: "com.uwyn.rife.engine.testelements.exits.SimpleSource")
323: .leaveElement();
324:
325: Site site = builder.getSite();
326:
327: assertEquals(site.getUrls().size(), 7);
328: assertEquals(site.getIds().size(), 10);
329:
330: assertEquals("com.uwyn.rife.engine.testelements.engine.Simple",
331: site.resolveUrl("/test/element1", null)
332: .getImplementation());
333: assertNull(site.resolveUrl("/test/element1/path/info", null));
334: assertNull(site.resolveUrl("/test/element1_notthere", null));
335: assertEquals(
336: "com.uwyn.rife.engine.testelements.submission.Normal",
337: site.searchFallback("").getImplementation());
338: assertEquals(
339: "com.uwyn.rife.engine.testelements.submission.Normal",
340: site.searchFallback("/hskjhjdz").getImplementation());
341: assertEquals(
342: "com.uwyn.rife.engine.testelements.outputs.Normal",
343: site.searchFallback("/subsite").getImplementation());
344: assertEquals(
345: "com.uwyn.rife.engine.testelements.outputs.Normal",
346: site.searchFallback("/subsitedfzefze")
347: .getImplementation());
348: assertEquals(
349: "com.uwyn.rife.engine.testelements.outputs.Normal",
350: site.searchFallback("/subsite/kjdkfj")
351: .getImplementation());
352:
353: Collection<String> global_exits = null;
354: Collection<String> global_vars = null;
355:
356: ElementInfo elementinfo1 = site.resolveUrl("/test/element1",
357: null);
358: assertNotNull(elementinfo1);
359: assertSame(site.resolveId(".ELEMENT1"), elementinfo1);
360: assertEquals(elementinfo1.getImplementation(),
361: com.uwyn.rife.engine.testelements.engine.Simple.class
362: .getName());
363: assertTrue(elementinfo1.hasGlobalExits());
364: global_exits = elementinfo1.getGlobalExitNames();
365: assertNotNull(global_exits);
366: assertEquals(global_exits.size(), 2);
367: assertTrue(global_exits.contains("globalexit1"));
368: assertTrue(global_exits.contains("globalexit2"));
369: assertTrue(elementinfo1.hasGlobalVars());
370: global_vars = elementinfo1.getGlobalVarNames();
371: assertNotNull(global_vars);
372: assertEquals(global_vars.size(), 8);
373: assertTrue(global_vars.contains("globalvar1"));
374: assertTrue(global_vars.contains("globalvar2"));
375: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
376: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
377: assertTrue(global_vars
378: .contains("onemoreprefixgroup_shortObject"));
379: assertTrue(global_vars.contains("double"));
380: assertTrue(global_vars.contains("long"));
381: assertTrue(global_vars.contains("shortObject"));
382: assertEquals(elementinfo1.getNamedGlobalBeanNames().size(), 1);
383: assertEquals(elementinfo1.getNamedGlobalBeanInfo("globalbean1")
384: .getClassname(),
385: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
386: assertEquals(elementinfo1.getNamedGlobalBeanInfo("globalbean1")
387: .getPrefix(), "onemoreprefixgroup_");
388: assertEquals(elementinfo1.getNamedGlobalBeanInfo("globalbean1")
389: .getGroupName(), "anothergroup");
390: assertNull(elementinfo1.getInheritanceStack());
391: assertEquals(8 + Rep.getProperties().size(), elementinfo1
392: .getPropertyNames().size());
393: assertEquals("elementpropval", elementinfo1
394: .getProperty("prop1"));
395: assertTrue(elementinfo1.getProperty("prop2") instanceof Template);
396: assertEquals(((Template) elementinfo1.getProperty("prop2"))
397: .getContent(), TemplateFactory.ENGINEHTML.get(
398: "unsetvalues_output_in").getContent());
399: assertSame(Datasources.getRepInstance().getDatasource(
400: "purgingunittestspgsql"), elementinfo1
401: .getProperty("prop6"));
402: assertSame(Datasources.getRepInstance().getDatasource(
403: "sessiondurationunittestspgsql"), elementinfo1
404: .getProperty("prop7"));
405:
406: ElementInfo elementinfo2 = site.resolveUrl("/test/element2",
407: null);
408: assertNotNull(elementinfo2);
409: assertSame(site.resolveId(".ELEMENT2"), elementinfo2);
410: assertEquals(elementinfo2.getImplementation(),
411: com.uwyn.rife.engine.testelements.outputs.Normal.class
412: .getName());
413: assertTrue(elementinfo2.hasGlobalExits());
414: global_exits = elementinfo2.getGlobalExitNames();
415: assertNotNull(global_exits);
416: assertEquals(global_exits.size(), 2);
417: assertTrue(global_exits.contains("globalexit1"));
418: assertTrue(global_exits.contains("globalexit2"));
419: assertTrue(elementinfo2.hasGlobalVars());
420: global_vars = elementinfo2.getGlobalVarNames();
421: assertNotNull(global_vars);
422: assertEquals(global_vars.size(), 8);
423: assertTrue(global_vars.contains("globalvar1"));
424: assertTrue(global_vars.contains("globalvar2"));
425: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
426: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
427: assertTrue(global_vars
428: .contains("onemoreprefixgroup_shortObject"));
429: assertTrue(global_vars.contains("double"));
430: assertTrue(global_vars.contains("long"));
431: assertTrue(global_vars.contains("shortObject"));
432: assertEquals(elementinfo2.getNamedGlobalBeanNames().size(), 1);
433: assertEquals(elementinfo2.getNamedGlobalBeanInfo("globalbean1")
434: .getClassname(),
435: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
436: assertEquals(elementinfo2.getNamedGlobalBeanInfo("globalbean1")
437: .getPrefix(), "onemoreprefixgroup_");
438: assertEquals(elementinfo2.getNamedGlobalBeanInfo("globalbean1")
439: .getGroupName(), "anothergroup");
440: assertNotNull(elementinfo2.getInheritanceStack());
441: assertEquals(2, elementinfo2.getInheritanceStack().size());
442: assertEquals(elementinfo2.getInheritanceStack().get(0)
443: .getImplementation(),
444: com.uwyn.rife.engine.testelements.outputs.Normal.class
445: .getName());
446: assertEquals(elementinfo2.getInheritanceStack().get(1)
447: .getImplementation(),
448: com.uwyn.rife.engine.testelements.inputs.Normal.class
449: .getName());
450: assertEquals(3 + Rep.getProperties().size(), elementinfo2
451: .getPropertyNames().size());
452: assertEquals("sitepropval", elementinfo2.getProperty("prop1"));
453: assertTrue(elementinfo2.getProperty("prop2") instanceof Template);
454: assertEquals(((Template) elementinfo2.getProperty("prop2"))
455: .getContent(), TemplateFactory.ENGINEHTML.get(
456: "unsetvalues_output_in").getContent());
457: assertSame(Datasources.getRepInstance().getDatasource(
458: "purgingunittestspgsql"), elementinfo2
459: .getProperty("prop6"));
460:
461: ElementInfo elementinfo3 = site.resolveId(".ELEMENT3");
462: assertNotNull(elementinfo3);
463: assertEquals(elementinfo3.getImplementation(),
464: com.uwyn.rife.engine.testelements.inputs.Normal.class
465: .getName());
466: assertTrue(elementinfo3.hasGlobalExits());
467: global_exits = elementinfo3.getGlobalExitNames();
468: assertNotNull(global_exits);
469: assertEquals(global_exits.size(), 2);
470: assertTrue(global_exits.contains("globalexit1"));
471: assertTrue(global_exits.contains("globalexit2"));
472: assertTrue(elementinfo3.hasGlobalVars());
473: global_vars = elementinfo3.getGlobalVarNames();
474: assertNotNull(global_vars);
475: assertEquals(global_vars.size(), 8);
476: assertTrue(global_vars.contains("globalvar1"));
477: assertTrue(global_vars.contains("globalvar2"));
478: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
479: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
480: assertTrue(global_vars
481: .contains("onemoreprefixgroup_shortObject"));
482: assertTrue(global_vars.contains("double"));
483: assertTrue(global_vars.contains("long"));
484: assertTrue(global_vars.contains("shortObject"));
485: assertEquals(elementinfo3.getNamedGlobalBeanNames().size(), 1);
486: assertEquals(elementinfo3.getNamedGlobalBeanInfo("globalbean1")
487: .getClassname(),
488: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
489: assertEquals(elementinfo3.getNamedGlobalBeanInfo("globalbean1")
490: .getPrefix(), "onemoreprefixgroup_");
491: assertEquals(elementinfo3.getNamedGlobalBeanInfo("globalbean1")
492: .getGroupName(), "anothergroup");
493: assertNull(elementinfo3.getInheritanceStack());
494: assertEquals(3 + Rep.getProperties().size(), elementinfo3
495: .getPropertyNames().size());
496: assertEquals("sitepropval", elementinfo3.getProperty("prop1"));
497: assertTrue(elementinfo3.getProperty("prop2") instanceof Template);
498: assertEquals(((Template) elementinfo3.getProperty("prop2"))
499: .getContent(), TemplateFactory.ENGINEHTML.get(
500: "unsetvalues_output_in").getContent());
501: assertSame(Datasources.getRepInstance().getDatasource(
502: "purgingunittestspgsql"), elementinfo3
503: .getProperty("prop6"));
504:
505: ElementInfo elementinfo4 = site.resolveId(".ELEMENT4");
506: assertNotNull(elementinfo4);
507: assertEquals(
508: elementinfo4.getImplementation(),
509: com.uwyn.rife.engine.testelements.submission.Normal.class
510: .getName());
511: assertTrue(elementinfo4.hasGlobalExits());
512: global_exits = elementinfo4.getGlobalExitNames();
513: assertNotNull(global_exits);
514: assertEquals(global_exits.size(), 2);
515: assertTrue(global_exits.contains("globalexit1"));
516: assertTrue(global_exits.contains("globalexit2"));
517: assertTrue(elementinfo4.hasGlobalVars());
518: global_vars = elementinfo4.getGlobalVarNames();
519: assertNotNull(global_vars);
520: assertEquals(global_vars.size(), 8);
521: assertTrue(global_vars.contains("globalvar1"));
522: assertTrue(global_vars.contains("globalvar2"));
523: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
524: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
525: assertTrue(global_vars
526: .contains("onemoreprefixgroup_shortObject"));
527: assertTrue(global_vars.contains("double"));
528: assertTrue(global_vars.contains("long"));
529: assertTrue(global_vars.contains("shortObject"));
530: assertEquals(elementinfo4.getNamedGlobalBeanNames().size(), 1);
531: assertEquals(elementinfo4.getNamedGlobalBeanInfo("globalbean1")
532: .getClassname(),
533: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
534: assertEquals(elementinfo4.getNamedGlobalBeanInfo("globalbean1")
535: .getPrefix(), "onemoreprefixgroup_");
536: assertEquals(elementinfo4.getNamedGlobalBeanInfo("globalbean1")
537: .getGroupName(), "anothergroup");
538: assertNull(elementinfo4.getInheritanceStack());
539: assertEquals(3 + Rep.getProperties().size(), elementinfo4
540: .getPropertyNames().size());
541: assertEquals("sitepropval", elementinfo4.getProperty("prop1"));
542: assertTrue(elementinfo4.getProperty("prop2") instanceof Template);
543: assertEquals(((Template) elementinfo4.getProperty("prop2"))
544: .getContent(), TemplateFactory.ENGINEHTML.get(
545: "unsetvalues_output_in").getContent());
546: assertSame(Datasources.getRepInstance().getDatasource(
547: "purgingunittestspgsql"), elementinfo4
548: .getProperty("prop6"));
549:
550: ElementInfo subsite_elementinfo2 = site.resolveUrl(
551: "/subsite/test/element2", null);
552: assertNotNull(subsite_elementinfo2);
553: assertSame(site.resolveId(".SUBSITE.ELEMENT2"),
554: subsite_elementinfo2);
555: assertEquals(subsite_elementinfo2.getImplementation(),
556: com.uwyn.rife.engine.testelements.outputs.Normal.class
557: .getName());
558: assertTrue(subsite_elementinfo2.hasGlobalExits());
559: global_exits = subsite_elementinfo2.getGlobalExitNames();
560: assertNotNull(global_exits);
561: assertEquals(global_exits.size(), 3);
562: assertTrue(global_exits.contains("globalexit1"));
563: assertTrue(global_exits.contains("globalexit2"));
564: assertTrue(global_exits.contains("globalexit3"));
565: assertTrue(subsite_elementinfo2.hasGlobalVars());
566: global_vars = subsite_elementinfo2.getGlobalVarNames();
567: assertNotNull(global_vars);
568: assertEquals(global_vars.size(), 9);
569: assertTrue(global_vars.contains("globalvar1"));
570: assertTrue(global_vars.contains("globalvar2"));
571: assertTrue(global_vars.contains("globalvar3"));
572: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
573: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
574: assertTrue(global_vars
575: .contains("onemoreprefixgroup_shortObject"));
576: assertTrue(global_vars.contains("double"));
577: assertTrue(global_vars.contains("long"));
578: assertTrue(global_vars.contains("shortObject"));
579: assertEquals(subsite_elementinfo2.getNamedGlobalBeanNames()
580: .size(), 1);
581: assertEquals(subsite_elementinfo2.getNamedGlobalBeanInfo(
582: "globalbean1").getClassname(),
583: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
584: assertEquals(subsite_elementinfo2.getNamedGlobalBeanInfo(
585: "globalbean1").getPrefix(), "onemoreprefixgroup_");
586: assertEquals(subsite_elementinfo2.getNamedGlobalBeanInfo(
587: "globalbean1").getGroupName(), "anothergroup");
588: assertNotNull(subsite_elementinfo2.getInheritanceStack());
589: assertEquals(2, subsite_elementinfo2.getInheritanceStack()
590: .size());
591: assertEquals(subsite_elementinfo2.getInheritanceStack().get(0)
592: .getImplementation(),
593: com.uwyn.rife.engine.testelements.outputs.Normal.class
594: .getName());
595: assertEquals(
596: subsite_elementinfo2.getInheritanceStack().get(1)
597: .getImplementation(),
598: com.uwyn.rife.engine.testelements.submission.Normal.class
599: .getName());
600: assertEquals(6 + Rep.getProperties().size(),
601: subsite_elementinfo2.getPropertyNames().size());
602: assertEquals("subsitepropval", subsite_elementinfo2
603: .getProperty("prop1"));
604: assertTrue(subsite_elementinfo2.getProperty("prop2") instanceof Template);
605: assertEquals(((Template) subsite_elementinfo2
606: .getProperty("prop2")).getContent(),
607: TemplateFactory.ENGINEHTML.get("noblocks_in")
608: .getContent());
609: assertEquals("the value 3", subsite_elementinfo2
610: .getProperty("prop3"));
611: assertSame(Datasources.getRepInstance().getDatasource(
612: "unittestspgsql"), subsite_elementinfo2
613: .getProperty("prop4"));
614: assertEquals("unittests\n pgsql", subsite_elementinfo2
615: .getProperty("prop5"));
616: assertSame(Datasources.getRepInstance().getDatasource(
617: "purgingunittestspgsql"), subsite_elementinfo2
618: .getProperty("prop6"));
619:
620: ElementInfo subsite_elementinfo3 = site.resolveUrl(
621: "/subsite/test/element3", null);
622: assertNotNull(subsite_elementinfo3);
623: assertSame(site.resolveId(".SUBSITE.ELEMENT3"),
624: subsite_elementinfo3);
625: assertEquals(subsite_elementinfo3.getImplementation(),
626: com.uwyn.rife.engine.testelements.inputs.Normal.class
627: .getName());
628: assertTrue(subsite_elementinfo3.hasGlobalExits());
629: global_exits = subsite_elementinfo3.getGlobalExitNames();
630: assertNotNull(global_exits);
631: assertEquals(global_exits.size(), 3);
632: assertTrue(global_exits.contains("globalexit1"));
633: assertTrue(global_exits.contains("globalexit2"));
634: assertTrue(global_exits.contains("globalexit3"));
635: assertTrue(subsite_elementinfo3.hasGlobalVars());
636: global_vars = subsite_elementinfo3.getGlobalVarNames();
637: assertNotNull(global_vars);
638: assertEquals(global_vars.size(), 9);
639: assertTrue(global_vars.contains("globalvar1"));
640: assertTrue(global_vars.contains("globalvar2"));
641: assertTrue(global_vars.contains("globalvar3"));
642: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
643: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
644: assertTrue(global_vars
645: .contains("onemoreprefixgroup_shortObject"));
646: assertTrue(global_vars.contains("double"));
647: assertTrue(global_vars.contains("long"));
648: assertTrue(global_vars.contains("shortObject"));
649: assertEquals(subsite_elementinfo3.getNamedGlobalBeanNames()
650: .size(), 1);
651: assertEquals(subsite_elementinfo3.getNamedGlobalBeanInfo(
652: "globalbean1").getClassname(),
653: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
654: assertEquals(subsite_elementinfo3.getNamedGlobalBeanInfo(
655: "globalbean1").getPrefix(), "onemoreprefixgroup_");
656: assertEquals(subsite_elementinfo3.getNamedGlobalBeanInfo(
657: "globalbean1").getGroupName(), "anothergroup");
658: assertNotNull(subsite_elementinfo3.getInheritanceStack());
659: assertEquals(2, subsite_elementinfo3.getInheritanceStack()
660: .size());
661: assertEquals(subsite_elementinfo3.getInheritanceStack().get(0)
662: .getImplementation(),
663: com.uwyn.rife.engine.testelements.inputs.Normal.class
664: .getName());
665: assertEquals(
666: subsite_elementinfo3.getInheritanceStack().get(1)
667: .getImplementation(),
668: com.uwyn.rife.engine.testelements.submission.Normal.class
669: .getName());
670: assertTrue(subsite_elementinfo3.hasDepartureVars());
671: assertEquals(1, subsite_elementinfo3.getDepartureVars().size());
672: assertEquals("globalvar3", subsite_elementinfo3
673: .getDepartureVars().get(0));
674: assertEquals(6 + Rep.getProperties().size(),
675: subsite_elementinfo3.getPropertyNames().size());
676: assertEquals("subsitepropval", subsite_elementinfo3
677: .getProperty("prop1"));
678: assertTrue(subsite_elementinfo3.getProperty("prop2") instanceof Template);
679: assertEquals(((Template) subsite_elementinfo3
680: .getProperty("prop2")).getContent(),
681: TemplateFactory.ENGINEHTML.get("noblocks_in")
682: .getContent());
683: assertEquals("the value 3", subsite_elementinfo3
684: .getProperty("prop3"));
685: assertSame(Datasources.getRepInstance().getDatasource(
686: "unittestspgsql"), subsite_elementinfo3
687: .getProperty("prop4"));
688: assertEquals("unittests\n pgsql", subsite_elementinfo3
689: .getProperty("prop5"));
690: assertSame(Datasources.getRepInstance().getDatasource(
691: "purgingunittestspgsql"), subsite_elementinfo3
692: .getProperty("prop6"));
693:
694: ElementInfo elementinfo5 = site.resolveId(".ELEMENT5");
695: assertNotNull(elementinfo5);
696: assertEquals(
697: elementinfo5.getImplementation(),
698: com.uwyn.rife.engine.testelements.exits.SimpleSource.class
699: .getName());
700: assertTrue(elementinfo5.hasGlobalExits());
701: global_exits = elementinfo5.getGlobalExitNames();
702: assertNotNull(global_exits);
703: assertEquals(global_exits.size(), 2);
704: assertTrue(global_exits.contains("globalexit1"));
705: assertTrue(global_exits.contains("globalexit2"));
706: assertTrue(elementinfo5.hasGlobalVars());
707: global_vars = elementinfo5.getGlobalVarNames();
708: assertNotNull(global_vars);
709: assertEquals(global_vars.size(), 8);
710: assertTrue(global_vars.contains("globalvar1"));
711: assertTrue(global_vars.contains("globalvar2"));
712: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
713: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
714: assertTrue(global_vars
715: .contains("onemoreprefixgroup_shortObject"));
716: assertTrue(global_vars.contains("double"));
717: assertTrue(global_vars.contains("long"));
718: assertTrue(global_vars.contains("shortObject"));
719: assertNull(elementinfo5.getInheritanceStack());
720: assertEquals(3 + Rep.getProperties().size(), elementinfo5
721: .getPropertyNames().size());
722: assertEquals("sitepropval", elementinfo5.getProperty("prop1"));
723: assertTrue(elementinfo5.getProperty("prop2") instanceof Template);
724: assertEquals(((Template) elementinfo5.getProperty("prop2"))
725: .getContent(), TemplateFactory.ENGINEHTML.get(
726: "unsetvalues_output_in").getContent());
727: assertSame(Datasources.getRepInstance().getDatasource(
728: "purgingunittestspgsql"), elementinfo5
729: .getProperty("prop6"));
730:
731: ElementInfo elementinfo6 = site.resolveUrl("/test/element6",
732: null);
733: assertNotNull(elementinfo6);
734: assertSame(site.resolveId(".ELEMENT6"), elementinfo6);
735: assertEquals(elementinfo6.getImplementation(),
736: com.uwyn.rife.engine.testelements.outputs.Normal.class
737: .getName());
738: assertTrue(elementinfo6.hasGlobalExits());
739: global_exits = elementinfo6.getGlobalExitNames();
740: assertNotNull(global_exits);
741: assertEquals(global_exits.size(), 2);
742: assertTrue(global_exits.contains("globalexit1"));
743: assertTrue(global_exits.contains("globalexit2"));
744: assertTrue(elementinfo6.hasGlobalVars());
745: global_vars = elementinfo6.getGlobalVarNames();
746: assertNotNull(global_vars);
747: assertEquals(global_vars.size(), 9);
748: assertTrue(global_vars.contains("globalvar1"));
749: assertTrue(global_vars.contains("globalvar2"));
750: assertTrue(global_vars.contains("globalvar4"));
751: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
752: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
753: assertTrue(global_vars
754: .contains("onemoreprefixgroup_shortObject"));
755: assertTrue(global_vars.contains("double"));
756: assertTrue(global_vars.contains("long"));
757: assertTrue(global_vars.contains("shortObject"));
758: assertEquals(elementinfo6.getNamedGlobalBeanNames().size(), 1);
759: assertEquals(elementinfo6.getNamedGlobalBeanInfo("globalbean1")
760: .getClassname(),
761: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
762: assertEquals(elementinfo6.getNamedGlobalBeanInfo("globalbean1")
763: .getPrefix(), "onemoreprefixgroup_");
764: assertEquals(elementinfo6.getNamedGlobalBeanInfo("globalbean1")
765: .getGroupName(), "anothergroup");
766: assertNotNull(elementinfo6.getInheritanceStack());
767: assertEquals(3, elementinfo6.getInheritanceStack().size());
768: assertEquals(elementinfo6.getInheritanceStack().get(0)
769: .getImplementation(),
770: com.uwyn.rife.engine.testelements.outputs.Normal.class
771: .getName());
772: assertEquals(elementinfo6.getInheritanceStack().get(1)
773: .getImplementation(),
774: com.uwyn.rife.engine.testelements.inputs.Normal.class
775: .getName());
776: assertEquals(
777: elementinfo6.getInheritanceStack().get(2)
778: .getImplementation(),
779: com.uwyn.rife.engine.testelements.exits.SimpleSource.class
780: .getName());
781: assertEquals(3 + Rep.getProperties().size(), elementinfo6
782: .getPropertyNames().size());
783: assertEquals("sitepropval", elementinfo6.getProperty("prop1"));
784: assertTrue(elementinfo6.getProperty("prop2") instanceof Template);
785: assertEquals(((Template) elementinfo6.getProperty("prop2"))
786: .getContent(), TemplateFactory.ENGINEHTML.get(
787: "unsetvalues_output_in").getContent());
788: assertSame(Datasources.getRepInstance().getDatasource(
789: "purgingunittestspgsql"), elementinfo6
790: .getProperty("prop6"));
791:
792: ElementInfo elementinfo7 = site.resolveUrl("/test/element7",
793: null);
794: assertNotNull(elementinfo7);
795: assertSame(site.resolveId(".ELEMENT7"), elementinfo7);
796: assertEquals(elementinfo7.getImplementation(),
797: com.uwyn.rife.engine.testelements.inputs.Normal.class
798: .getName());
799: assertTrue(elementinfo7.hasGlobalExits());
800: global_exits = elementinfo7.getGlobalExitNames();
801: assertNotNull(global_exits);
802: assertEquals(global_exits.size(), 2);
803: assertTrue(global_exits.contains("globalexit1"));
804: assertTrue(global_exits.contains("globalexit2"));
805: assertTrue(elementinfo7.hasGlobalVars());
806: global_vars = elementinfo7.getGlobalVarNames();
807: assertNotNull(global_vars);
808: assertEquals(global_vars.size(), 9);
809: assertTrue(global_vars.contains("globalvar1"));
810: assertTrue(global_vars.contains("globalvar2"));
811: assertTrue(global_vars.contains("globalvar4"));
812: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
813: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
814: assertTrue(global_vars
815: .contains("onemoreprefixgroup_shortObject"));
816: assertTrue(global_vars.contains("double"));
817: assertTrue(global_vars.contains("long"));
818: assertTrue(global_vars.contains("shortObject"));
819: assertEquals(elementinfo7.getNamedGlobalBeanNames().size(), 1);
820: assertEquals(elementinfo7.getNamedGlobalBeanInfo("globalbean1")
821: .getClassname(),
822: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
823: assertEquals(elementinfo7.getNamedGlobalBeanInfo("globalbean1")
824: .getPrefix(), "onemoreprefixgroup_");
825: assertEquals(elementinfo7.getNamedGlobalBeanInfo("globalbean1")
826: .getGroupName(), "anothergroup");
827: assertNotNull(elementinfo7.getInheritanceStack());
828: assertEquals(2, elementinfo7.getInheritanceStack().size());
829: assertEquals(elementinfo7.getInheritanceStack().get(0)
830: .getImplementation(),
831: com.uwyn.rife.engine.testelements.inputs.Normal.class
832: .getName());
833: assertEquals(
834: elementinfo7.getInheritanceStack().get(1)
835: .getImplementation(),
836: com.uwyn.rife.engine.testelements.exits.SimpleSource.class
837: .getName());
838: assertEquals(3 + Rep.getProperties().size(), elementinfo7
839: .getPropertyNames().size());
840: assertEquals("sitepropval", elementinfo7.getProperty("prop1"));
841: assertTrue(elementinfo7.getProperty("prop2") instanceof Template);
842: assertEquals(((Template) elementinfo7.getProperty("prop2"))
843: .getContent(), TemplateFactory.ENGINEHTML.get(
844: "unsetvalues_output_in").getContent());
845: assertSame(Datasources.getRepInstance().getDatasource(
846: "purgingunittestspgsql"), elementinfo7
847: .getProperty("prop6"));
848:
849: ElementInfo elementinfo8 = site.resolveUrl(
850: "/subsite/subsite2/test/element8", null);
851: assertNotNull(elementinfo8);
852: assertSame(site.resolveId(".SUBSITE.SUBSITE2.ELEMENT8"),
853: elementinfo8);
854: assertEquals(elementinfo8.getImplementation(),
855: com.uwyn.rife.engine.testelements.inputs.Normal.class
856: .getName());
857: assertTrue(elementinfo8.hasGlobalExits());
858: global_exits = elementinfo8.getGlobalExitNames();
859: assertNotNull(global_exits);
860: assertEquals(global_exits.size(), 3);
861: assertTrue(global_exits.contains("globalexit1"));
862: assertTrue(global_exits.contains("globalexit2"));
863: assertTrue(global_exits.contains("globalexit3"));
864: assertTrue(elementinfo8.hasGlobalVars());
865: global_vars = elementinfo8.getGlobalVarNames();
866: assertNotNull(global_vars);
867: assertEquals(global_vars.size(), 9);
868: assertTrue(global_vars.contains("globalvar1"));
869: assertTrue(global_vars.contains("globalvar2"));
870: assertTrue(global_vars.contains("globalvar3"));
871: assertTrue(global_vars.contains("onemoreprefixgroup_double"));
872: assertTrue(global_vars.contains("onemoreprefixgroup_long"));
873: assertTrue(global_vars
874: .contains("onemoreprefixgroup_shortObject"));
875: assertTrue(global_vars.contains("double"));
876: assertTrue(global_vars.contains("long"));
877: assertTrue(global_vars.contains("shortObject"));
878: assertEquals(elementinfo7.getNamedGlobalBeanNames().size(), 1);
879: assertEquals(elementinfo7.getNamedGlobalBeanInfo("globalbean1")
880: .getClassname(),
881: "com.uwyn.rife.engine.testelements.submission.BeanImpl");
882: assertEquals(elementinfo7.getNamedGlobalBeanInfo("globalbean1")
883: .getPrefix(), "onemoreprefixgroup_");
884: assertEquals(elementinfo7.getNamedGlobalBeanInfo("globalbean1")
885: .getGroupName(), "anothergroup");
886: assertNotNull(elementinfo8.getInheritanceStack());
887: assertEquals(2, elementinfo8.getInheritanceStack().size());
888: assertEquals(elementinfo8.getInheritanceStack().get(0)
889: .getImplementation(),
890: com.uwyn.rife.engine.testelements.inputs.Normal.class
891: .getName());
892: assertEquals(
893: elementinfo8.getInheritanceStack().get(1)
894: .getImplementation(),
895: com.uwyn.rife.engine.testelements.submission.Normal.class
896: .getName());
897:
898: assertSame(elementinfo1.getFlowLink("exit1").getTarget(),
899: elementinfo2);
900: assertEquals(elementinfo1.getFlowLink("exit1").isSnapback(),
901: false);
902: assertNull(elementinfo1.getFlowLink("exit2").getTarget());
903: assertEquals(elementinfo1.getFlowLink("exit2").isSnapback(),
904: true);
905:
906: Collection<String> inputs = null;
907:
908: inputs = elementinfo1.getDataLinkInputs("output1",
909: elementinfo2, false, null);
910: assertNotNull(inputs);
911: assertEquals(inputs.size(), 2);
912: assertTrue(inputs.contains("input1"));
913: assertTrue(inputs.contains("input2"));
914:
915: inputs = elementinfo1.getDataLinkInputs("output1",
916: elementinfo3, false, null);
917: assertNull(inputs);
918:
919: inputs = elementinfo1.getDataLinkInputs("output1",
920: elementinfo3, true, null);
921: assertNull(inputs);
922:
923: inputs = elementinfo1.getDataLinkInputs("output2",
924: elementinfo2, false, null);
925: assertNull(inputs);
926:
927: inputs = elementinfo1.getDataLinkInputs("output2",
928: elementinfo3, false, null);
929: assertNull(inputs);
930:
931: inputs = elementinfo1.getDataLinkInputs("output2",
932: elementinfo3, true, null);
933: assertNotNull(inputs);
934: assertEquals(inputs.size(), 1);
935: assertTrue(inputs.contains("input2"));
936:
937: inputs = elementinfo1.getDataLinkInputs("output3",
938: elementinfo2, false, elementinfo1.getFlowLink("exit3"));
939: assertNotNull(inputs);
940: assertEquals(inputs.size(), 1);
941: assertTrue(inputs.contains("input1"));
942:
943: inputs = elementinfo1.getDataLinkInputs("output3",
944: elementinfo2, false, null);
945: assertNull(inputs);
946:
947: inputs = elementinfo1.getDataLinkInputs("output4",
948: elementinfo2, false, elementinfo1.getFlowLink("exit4"));
949: assertNotNull(inputs);
950: assertEquals(inputs.size(), 1);
951: assertTrue(inputs.contains("input1"));
952:
953: inputs = elementinfo1.getDataLinkInputs("output4",
954: elementinfo2, false, null);
955: assertNull(inputs);
956: }
957: }
|