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: TestEngineInheritance.java 3634 2007-01-08 21:42:24Z gbevin $
0007: */
0008: package com.uwyn.rife.engine;
0009:
0010: import com.meterware.httpunit.*;
0011:
0012: import com.uwyn.rife.TestCaseServerside;
0013: import com.uwyn.rife.engine.exceptions.ExitTargetUrlMissingException;
0014: import com.uwyn.rife.engine.exceptions.RequestAccessDeniedException;
0015: import com.uwyn.rife.engine.exceptions.SubmissionInheritanceUrlMissingException;
0016:
0017: public class TestEngineInheritance extends TestCaseServerside {
0018: public TestEngineInheritance(int siteType, String name) {
0019: super (siteType, name);
0020: }
0021:
0022: public void testInheritanceSimple() throws Exception {
0023: setupSite("site/inheritance.xml");
0024: WebConversation conversation = new WebConversation();
0025: WebRequest request = null;
0026: WebResponse response = null;
0027: WebLink link = null;
0028:
0029: request = new GetMethodWebRequest(
0030: "http://localhost:8181/inheritance/simple");
0031: response = conversation.getResponse(request);
0032: link = response.getLinkWith("activate child");
0033: response = link.click();
0034: assertEquals("This is the child", response.getText());
0035: }
0036:
0037: public void testInheritanceBean() throws Exception {
0038: setupSite("site/inheritance.xml");
0039: WebConversation conversation = new WebConversation();
0040: WebRequest request = null;
0041: WebResponse response = null;
0042: WebLink link = null;
0043:
0044: request = new GetMethodWebRequest(
0045: "http://localhost:8181/inheritance/bean");
0046: response = conversation.getResponse(request);
0047: link = response.getLinkWith("activate child");
0048: response = link.click();
0049: assertEquals("This is the child", response.getText());
0050: }
0051:
0052: public void testInheritanceSimpleOutjection() throws Exception {
0053: setupSite("site/inheritance.xml");
0054: WebConversation conversation = new WebConversation();
0055: WebRequest request = null;
0056: WebResponse response = null;
0057: WebLink link = null;
0058:
0059: request = new GetMethodWebRequest(
0060: "http://localhost:8181/inheritance/bean/outjection");
0061: response = conversation.getResponse(request);
0062: link = response.getLinkWith("activate child");
0063: response = link.click();
0064: assertEquals("This is the child", response.getText());
0065: }
0066:
0067: public void testInheritanceBeanOutjection() throws Exception {
0068: setupSite("site/inheritance.xml");
0069: WebConversation conversation = new WebConversation();
0070: WebRequest request = null;
0071: WebResponse response = null;
0072: WebLink link = null;
0073:
0074: request = new GetMethodWebRequest(
0075: "http://localhost:8181/inheritance/simple/outjection");
0076: response = conversation.getResponse(request);
0077: link = response.getLinkWith("activate child");
0078: response = link.click();
0079: assertEquals("This is the child", response.getText());
0080: }
0081:
0082: public void testInheritanceInterface() throws Exception {
0083: setupSite("site/inheritance.xml");
0084: WebConversation conversation = new WebConversation();
0085: WebRequest request = null;
0086: WebResponse response = null;
0087: WebLink link = null;
0088:
0089: request = new GetMethodWebRequest(
0090: "http://localhost:8181/inheritance/interface");
0091: response = conversation.getResponse(request);
0092: link = response.getLinkWith("activate child");
0093: response = link.click();
0094: assertEquals("This is the interface child", response.getText());
0095: }
0096:
0097: public void testInheritanceGlobalvar() throws Exception {
0098: setupSite("site/inheritance.xml");
0099: WebConversation conversation = new WebConversation();
0100: WebRequest request = null;
0101: WebResponse response = null;
0102: WebLink link = null;
0103:
0104: request = new GetMethodWebRequest(
0105: "http://localhost:8181/inheritance/globalvar");
0106: response = conversation.getResponse(request);
0107: link = response.getLinkWith("activate child");
0108: response = link.click();
0109: assertEquals("This is the child", response.getText());
0110: }
0111:
0112: public void testInheritanceTargetRetrievel() throws Exception {
0113: setupSite("site/inheritance.xml");
0114: WebConversation conversation = new WebConversation();
0115: WebRequest request = null;
0116: WebResponse response = null;
0117: WebLink link = null;
0118:
0119: request = new GetMethodWebRequest(
0120: "http://localhost:8181/inheritance/targetretrieval");
0121: response = conversation.getResponse(request);
0122: assertTrue(0 == response.getText().indexOf(
0123: "element/inheritance/targetretrieval_child.xml"));
0124: link = response.getLinkWith("activate child");
0125: response = link.click();
0126: assertEquals(
0127: "element/inheritance/targetretrieval_child.xml : this is the child",
0128: response.getText());
0129: }
0130:
0131: public void testInheritanceCookie() throws Exception {
0132: setupSite("site/inheritance.xml");
0133: WebConversation conversation = new WebConversation();
0134: WebRequest request = null;
0135: WebResponse response = null;
0136: WebLink link = null;
0137:
0138: // check if the child trigger is activated by an output cookie
0139: request = new GetMethodWebRequest(
0140: "http://localhost:8181/inheritance/cookie");
0141: response = conversation.getResponse(request);
0142: link = response.getLinkWith("activate child");
0143: response = link.click();
0144: assertEquals("This is the child", response.getText());
0145:
0146: // check if the child trigger is activated through an existing cookie
0147: conversation.addCookie("trigger", "ok");
0148: request = new GetMethodWebRequest(
0149: "http://localhost:8181/inheritance/cookie");
0150: response = conversation.getResponse(request);
0151: assertEquals("This is the child", response.getText());
0152: }
0153:
0154: public void testInheritanceCookieOutjection() throws Exception {
0155: setupSite("site/inheritance.xml");
0156: WebConversation conversation = new WebConversation();
0157: WebRequest request = null;
0158: WebResponse response = null;
0159: WebLink link = null;
0160:
0161: // check if the child trigger is activated by an output cookie
0162: request = new GetMethodWebRequest(
0163: "http://localhost:8181/inheritance/cookie/outjection");
0164: response = conversation.getResponse(request);
0165: link = response.getLinkWith("activate child");
0166: response = link.click();
0167: assertEquals("This is the child", response.getText());
0168:
0169: // check if the child trigger is activated through an existing cookie
0170: conversation.addCookie("trigger", "ok");
0171: request = new GetMethodWebRequest(
0172: "http://localhost:8181/inheritance/cookie/outjection");
0173: response = conversation.getResponse(request);
0174: assertEquals("This is the child", response.getText());
0175: }
0176:
0177: public void testInheritanceGlobalCookie() throws Exception {
0178: setupSite("site/inheritance.xml");
0179: WebConversation conversation = new WebConversation();
0180: WebRequest request = null;
0181: WebResponse response = null;
0182: WebLink link = null;
0183:
0184: // check if the child trigger is activated by an output cookie
0185: request = new GetMethodWebRequest(
0186: "http://localhost:8181/inheritance/globalcookie");
0187: response = conversation.getResponse(request);
0188: link = response.getLinkWith("activate child");
0189: response = link.click();
0190: assertEquals("This is the child", response.getText());
0191:
0192: // check if the child trigger is activated through an existing cookie
0193: conversation.addCookie("trigger", "ok");
0194: request = new GetMethodWebRequest(
0195: "http://localhost:8181/inheritance/globalcookie");
0196: response = conversation.getResponse(request);
0197: assertEquals("This is the child", response.getText());
0198: }
0199:
0200: public void testInheritanceGlobalCookieOutjection()
0201: throws Exception {
0202: setupSite("site/inheritance.xml");
0203: WebConversation conversation = new WebConversation();
0204: WebRequest request = null;
0205: WebResponse response = null;
0206: WebLink link = null;
0207:
0208: // check if the child trigger is activated by an output cookie
0209: request = new GetMethodWebRequest(
0210: "http://localhost:8181/inheritance/globalcookie/outjection");
0211: response = conversation.getResponse(request);
0212: link = response.getLinkWith("activate child");
0213: response = link.click();
0214: assertEquals("This is the child", response.getText());
0215:
0216: // check if the child trigger is activated through an existing cookie
0217: conversation.addCookie("trigger", "ok");
0218: request = new GetMethodWebRequest(
0219: "http://localhost:8181/inheritance/globalcookie/outjection");
0220: response = conversation.getResponse(request);
0221: assertEquals("This is the child", response.getText());
0222: }
0223:
0224: public void testInheritanceInputdefault() throws Exception {
0225: setupSite("site/inheritance.xml");
0226: WebConversation conversation = new WebConversation();
0227: WebRequest request = null;
0228: WebResponse response = null;
0229:
0230: request = new GetMethodWebRequest(
0231: "http://localhost:8181/inheritance/inputdefault");
0232: response = conversation.getResponse(request);
0233: assertEquals("This is the child", response.getText());
0234:
0235: request = new GetMethodWebRequest(
0236: "http://localhost:8181/inheritance/inputdefault");
0237: request.setParameter("trigger", "dontdoit");
0238: response = conversation.getResponse(request);
0239: assertEquals("This is the parent", response.getText());
0240: }
0241:
0242: public void testInheritanceIncookiedefault() throws Exception {
0243: setupSite("site/inheritance.xml");
0244: WebConversation conversation = new WebConversation();
0245: WebRequest request = null;
0246: WebResponse response = null;
0247:
0248: request = new GetMethodWebRequest(
0249: "http://localhost:8181/inheritance/incookiedefault");
0250: response = conversation.getResponse(request);
0251: assertEquals("This is the child", response.getText());
0252:
0253: conversation.addCookie("trigger", "dontdoit");
0254: request = new GetMethodWebRequest(
0255: "http://localhost:8181/inheritance/incookiedefault");
0256: response = conversation.getResponse(request);
0257: assertEquals("This is the parent", response.getText());
0258: }
0259:
0260: public void testInheritanceOutputdefault() throws Exception {
0261: setupSite("site/inheritance.xml");
0262: WebConversation conversation = new WebConversation();
0263: WebRequest request = null;
0264: WebResponse response = null;
0265:
0266: request = new GetMethodWebRequest(
0267: "http://localhost:8181/inheritance/outputdefault");
0268: response = conversation.getResponse(request);
0269: assertEquals("This is the parentThis is the child", response
0270: .getText());
0271:
0272: request = new GetMethodWebRequest(
0273: "http://localhost:8181/inheritance/outputdefault");
0274: request.setParameter("trigger", "noinfluence");
0275: response = conversation.getResponse(request);
0276: assertEquals("This is the parentThis is the child", response
0277: .getText());
0278: }
0279:
0280: public void testInheritanceOutcookiedefault() throws Exception {
0281: setupSite("site/inheritance.xml");
0282: WebConversation conversation = new WebConversation();
0283: WebRequest request = null;
0284: WebResponse response = null;
0285:
0286: request = new GetMethodWebRequest(
0287: "http://localhost:8181/inheritance/outcookiedefault");
0288: response = conversation.getResponse(request);
0289: assertEquals("This is the parentThis is the child", response
0290: .getText());
0291:
0292: conversation.addCookie("trigger", "noinfluence");
0293: request = new GetMethodWebRequest(
0294: "http://localhost:8181/inheritance/outcookiedefault");
0295: response = conversation.getResponse(request);
0296: assertEquals("This is the parentThis is the child", response
0297: .getText());
0298: }
0299:
0300: public void testInheritanceInputoutputdefault() throws Exception {
0301: setupSite("site/inheritance.xml");
0302: WebConversation conversation = new WebConversation();
0303: WebRequest request = null;
0304: WebResponse response = null;
0305:
0306: request = new GetMethodWebRequest(
0307: "http://localhost:8181/inheritance/inputoutputdefault");
0308: response = conversation.getResponse(request);
0309: assertEquals("This is the parentThis is the child", response
0310: .getText());
0311:
0312: request = new GetMethodWebRequest(
0313: "http://localhost:8181/inheritance/inputoutputdefault");
0314: request.setParameter("trigger", "doit");
0315: response = conversation.getResponse(request);
0316: assertEquals("This is the child", response.getText());
0317:
0318: request = new GetMethodWebRequest(
0319: "http://localhost:8181/inheritance/inputoutputdefault");
0320: request.setParameter("trigger", "dontdoit");
0321: response = conversation.getResponse(request);
0322: assertEquals("This is the parentThis is the child", response
0323: .getText());
0324: }
0325:
0326: public void testInheritanceIncookieoutcookiedefault()
0327: throws Exception {
0328: setupSite("site/inheritance.xml");
0329: WebConversation conversation = new WebConversation();
0330: WebRequest request = null;
0331: WebResponse response = null;
0332:
0333: conversation = new WebConversation();
0334: request = new GetMethodWebRequest(
0335: "http://localhost:8181/inheritance/incookieoutcookiedefault");
0336: response = conversation.getResponse(request);
0337: assertEquals("This is the parentThis is the child", response
0338: .getText());
0339:
0340: conversation = new WebConversation();
0341: conversation.addCookie("trigger", "doit");
0342: request = new GetMethodWebRequest(
0343: "http://localhost:8181/inheritance/incookieoutcookiedefault");
0344: response = conversation.getResponse(request);
0345: assertEquals("This is the child", response.getText());
0346:
0347: conversation = new WebConversation();
0348: conversation.addCookie("trigger", "dontdoit");
0349: request = new GetMethodWebRequest(
0350: "http://localhost:8181/inheritance/incookieoutcookiedefault");
0351: response = conversation.getResponse(request);
0352: assertEquals("This is the parentThis is the child", response
0353: .getText());
0354: }
0355:
0356: public void testInheritanceGlobaldefault() throws Exception {
0357: setupSite("site/inheritance.xml");
0358: WebConversation conversation = new WebConversation();
0359: WebRequest request = null;
0360: WebResponse response = null;
0361:
0362: request = new GetMethodWebRequest(
0363: "http://localhost:8181/inheritance/globaldefault");
0364: response = conversation.getResponse(request);
0365: assertEquals("This is the child", response.getText());
0366:
0367: request = new GetMethodWebRequest(
0368: "http://localhost:8181/inheritance/globaldefault");
0369: request.setParameter("globaltrigger", "dontdoit");
0370: response = conversation.getResponse(request);
0371: assertEquals("This is the parent", response.getText());
0372: }
0373:
0374: public void testInheritanceGlobalcookiedefault() throws Exception {
0375: setupSite("site/inheritance.xml");
0376: WebConversation conversation = new WebConversation();
0377: WebRequest request = null;
0378: WebResponse response = null;
0379:
0380: request = new GetMethodWebRequest(
0381: "http://localhost:8181/inheritance/globalcookiedefault");
0382: response = conversation.getResponse(request);
0383: assertEquals("This is the child", response.getText());
0384:
0385: conversation = new WebConversation();
0386: conversation.addCookie("trigger", "dontdoit");
0387: request = new GetMethodWebRequest(
0388: "http://localhost:8181/inheritance/globalcookiedefault");
0389: response = conversation.getResponse(request);
0390: assertEquals("This is the parentThis is the child", response
0391: .getText());
0392: }
0393:
0394: public void testInheritanceNoTrigger() throws Exception {
0395: setupSite("site/inheritance.xml");
0396: WebConversation conversation = new WebConversation();
0397: WebRequest request = null;
0398: WebResponse response = null;
0399: WebLink link = null;
0400:
0401: request = new GetMethodWebRequest(
0402: "http://localhost:8181/inheritance/notrigger");
0403: response = conversation.getResponse(request);
0404: link = response.getLinkWith("activate child");
0405: response = link.click();
0406: assertEquals("This is the child", response.getText());
0407: }
0408:
0409: public void testInheritanceAccessDenied() throws Exception {
0410: setupSite("site/inheritance.xml");
0411: WebConversation conversation = new WebConversation();
0412: WebRequest request = null;
0413: WebResponse response = null;
0414:
0415: request = new GetMethodWebRequest(
0416: "http://localhost:8181/inheritance/accessdenied");
0417: request.setParameter("trigger", "ok");
0418: try {
0419: response = conversation.getResponse(request);
0420: fail();
0421: assertNotNull(response);
0422: } catch (HttpInternalErrorException e) {
0423: assertTrue(getLogSink().getInternalException() instanceof RequestAccessDeniedException);
0424: }
0425: }
0426:
0427: public void testInheritanceParampreserve() throws Exception {
0428: setupSite("site/inheritance.xml");
0429: WebConversation conversation = new WebConversation();
0430: WebRequest request = null;
0431: WebResponse response = null;
0432: WebForm form = null;
0433:
0434: request = new GetMethodWebRequest(
0435: "http://localhost:8181/inheritance/parampreserve");
0436: request.setParameter("input1", "will this");
0437: request.setParameter("input2", "arrive");
0438: response = conversation.getResponse(request);
0439:
0440: form = response.getForms()[0];
0441: form.setParameter("param1", "don't go to child");
0442: response = form.submit();
0443:
0444: form = response.getForms()[0];
0445: form.setParameter("param1", "go to child");
0446: response = form.submit();
0447:
0448: assertEquals("will this,arrive", response.getText());
0449: }
0450:
0451: public void testInheritanceInputpreserve() throws Exception {
0452: setupSite("site/inheritance.xml");
0453: WebConversation conversation = new WebConversation();
0454: WebRequest request = null;
0455: WebResponse response = null;
0456: WebLink link = null;
0457:
0458: request = new GetMethodWebRequest(
0459: "http://localhost:8181/inheritance/inputpreserve");
0460: request.setParameter("input1", "will this");
0461: request.setParameter("input2", "arrive");
0462: response = conversation.getResponse(request);
0463: link = response.getLinkWith("activate child");
0464: response = link.click();
0465:
0466: assertEquals("will this,arrive\n", response.getText());
0467: }
0468:
0469: public void testInheritancePathinfopreserve() throws Exception {
0470: setupSite("site/inheritance.xml");
0471: WebConversation conversation = new WebConversation();
0472: WebRequest request = null;
0473: WebResponse response = null;
0474: WebLink link = null;
0475:
0476: request = new GetMethodWebRequest(
0477: "http://localhost:8181/inheritance/pathinfopreserve/will/this/arrive");
0478: response = conversation.getResponse(request);
0479: link = response.getLinkWith("activate child");
0480: response = link.click();
0481:
0482: assertEquals("/will/this/arrive", response.getText());
0483: }
0484:
0485: public void testInheritanceParamspreserveDirectTrigger()
0486: throws Exception {
0487: setupSite("site/inheritance.xml");
0488: WebConversation conversation = new WebConversation();
0489: WebRequest request = null;
0490: WebResponse response = null;
0491:
0492: request = new GetMethodWebRequest(
0493: "http://localhost:8181/inheritance/paramspreserve/directtrigger");
0494: request.setParameter("submission", "testsubmission");
0495: request.setParameter("param1", "will this");
0496: request.setParameter("param2", "arrive");
0497: response = conversation.getResponse(request);
0498:
0499: assertEquals("will this,arrive\n", response.getText());
0500: }
0501:
0502: public void testInheritanceInputpreserveDirectTrigger()
0503: throws Exception {
0504: setupSite("site/inheritance.xml");
0505: WebConversation conversation = new WebConversation();
0506: WebRequest request = null;
0507: WebResponse response = null;
0508:
0509: request = new GetMethodWebRequest(
0510: "http://localhost:8181/inheritance/inputpreserve/directtrigger");
0511: request.setParameter("input1", "will this");
0512: request.setParameter("input2", "arrive");
0513: response = conversation.getResponse(request);
0514:
0515: assertEquals("will this,arrive\n", response.getText());
0516: }
0517:
0518: public void testInheritancePathinfopreserveDirectTrigger()
0519: throws Exception {
0520: setupSite("site/inheritance.xml");
0521: WebConversation conversation = new WebConversation();
0522: WebRequest request = null;
0523: WebResponse response = null;
0524:
0525: request = new GetMethodWebRequest(
0526: "http://localhost:8181/inheritance/pathinfopreserve/directtrigger/will/this/arrive");
0527: response = conversation.getResponse(request);
0528:
0529: assertEquals("/will/this/arrive", response.getText());
0530: }
0531:
0532: public void testInheritanceParamspreserveMiddle() throws Exception {
0533: setupSite("site/inheritance.xml");
0534: WebConversation conversation = new WebConversation();
0535: WebRequest request = null;
0536: WebResponse response = null;
0537:
0538: request = new GetMethodWebRequest(
0539: "http://localhost:8181/inheritance/paramspreserve/middle");
0540: request.setParameter("submission", "testsubmission");
0541: request.setParameter("param1", "will this");
0542: request.setParameter("param2", "arrive");
0543: response = conversation.getResponse(request);
0544:
0545: assertEquals("will this,arrive\n", response.getText());
0546: }
0547:
0548: public void testInheritanceDeep() throws Exception {
0549: setupSite("site/inheritance.xml");
0550: WebConversation conversation = new WebConversation();
0551: WebRequest request = null;
0552: WebResponse response = null;
0553: WebForm form = null;
0554:
0555: request = new GetMethodWebRequest(
0556: "http://localhost:8181/inheritance/deep");
0557: request.setParameter("childinput1", "will this");
0558: request.setParameter("childinput2", "arrive");
0559: response = conversation.getResponse(request);
0560:
0561: form = response.getFormWithName("formparent3");
0562: form.setParameter("activationparent3", "don't go to child");
0563: response = form.submit();
0564:
0565: form = response.getFormWithName("formparent3");
0566: form.setParameter("activationparent3", "go to child");
0567: response = form.submit();
0568:
0569: form = response.getFormWithName("formparent2");
0570: form.setParameter("activationparent2", "don't go to child");
0571: response = form.submit();
0572:
0573: form = response.getFormWithName("formparent2");
0574: form.setParameter("activationparent2", "go to child");
0575: response = form.submit();
0576:
0577: form = response.getFormWithName("formparent1");
0578: form.setParameter("activationparent1", "don't go to child");
0579: response = form.submit();
0580:
0581: form = response.getFormWithName("formparent1");
0582: form.setParameter("activationparent1", "go to child");
0583: response = form.submit();
0584:
0585: assertEquals("will this,arrive", response.getText());
0586: }
0587:
0588: public void testInheritanceExits() throws Exception {
0589: setupSite("site/inheritance.xml");
0590: WebConversation conversation = new WebConversation();
0591: WebRequest request = null;
0592: WebResponse response = null;
0593: WebForm form = null;
0594:
0595: request = new GetMethodWebRequest(
0596: "http://localhost:8181/inheritance/exits");
0597: request.setParameter("childinput1", "will this");
0598: request.setParameter("childinput2", "arrive too");
0599: response = conversation.getResponse(request);
0600:
0601: form = response.getFormWithName("formparent2");
0602: form.setParameter("activationparent2", "don't go to child");
0603: response = form.submit();
0604:
0605: form = response.getFormWithName("formparent2");
0606: form.setParameter("activationparent2", "go to child");
0607: response = form.submit();
0608:
0609: form = response.getFormWithName("formparent1");
0610: form.setParameter("activationparent1", "don't go to exit");
0611: response = form.submit();
0612:
0613: form = response.getFormWithName("formparent1");
0614: form.setParameter("activationparent1", "go to exit");
0615: response = form.submit();
0616:
0617: form = response.getFormWithName("formparent1exit1");
0618: form.setParameter("activationparent1exit1", "don't go to exit");
0619: response = form.submit();
0620:
0621: form = response.getFormWithName("formparent1exit1");
0622: form.setParameter("activationparent1exit1", "go to exit");
0623: response = form.submit();
0624:
0625: form = response.getFormWithName("formparent1exit2");
0626: form
0627: .setParameter("activationparent1exit2",
0628: "don't go to child");
0629: response = form.submit();
0630:
0631: form = response.getFormWithName("formparent1exit2");
0632: form.setParameter("activationparent1exit2", "go to child");
0633: response = form.submit();
0634:
0635: form = response.getFormWithName("formparent2");
0636: form.setParameter("activationparent2", "don't go to child");
0637: response = form.submit();
0638:
0639: form = response.getFormWithName("formparent2");
0640: form.setParameter("activationparent2", "go to child");
0641: response = form.submit();
0642:
0643: assertEquals("will this,arrive too", response.getText());
0644: }
0645:
0646: public void testInheritanceExitsCancelInheritance()
0647: throws Exception {
0648: setupSite("site/inheritance.xml");
0649: WebConversation conversation = new WebConversation();
0650: WebRequest request = null;
0651: WebResponse response = null;
0652: WebForm form = null;
0653:
0654: request = new GetMethodWebRequest(
0655: "http://localhost:8181/inheritance/exits/cancelinheritance");
0656: request.setParameter("childinput1", "will this");
0657: request.setParameter("childinput2", "arrive too");
0658: response = conversation.getResponse(request);
0659:
0660: form = response.getFormWithName("formparent2");
0661: form.setParameter("activationparent2", "don't go to child");
0662: response = form.submit();
0663:
0664: form = response.getFormWithName("formparent2");
0665: form.setParameter("activationparent2", "go to child");
0666: response = form.submit();
0667:
0668: form = response.getFormWithName("formparent1");
0669: form.setParameter("activationparent1", "don't go to exit");
0670: response = form.submit();
0671:
0672: form = response.getFormWithName("formparent1");
0673: form.setParameter("activationparent1", "go to exit");
0674: response = form.submit();
0675:
0676: form = response.getFormWithName("formparent1exit1");
0677: form.setParameter("activationparent1exit1", "don't go to exit");
0678: response = form.submit();
0679:
0680: form = response.getFormWithName("formparent1exit1");
0681: form.setParameter("activationparent1exit1", "go to exit");
0682: response = form.submit();
0683:
0684: form = response.getFormWithName("formparent1exit2");
0685: form
0686: .setParameter("activationparent1exit2",
0687: "don't go to child");
0688: response = form.submit();
0689:
0690: form = response.getFormWithName("formparent1exit2");
0691: form.setParameter("activationparent1exit2", "go to child");
0692: try {
0693: // the current inheritance structure will get cancelled
0694: // and a new one will be created for the EXITS_CANCELINHERITANCE_PARENT1
0695: // element which inherits from EXITS_CANCELINHERITANCE_PARENT2
0696: // since the latter has no url in the site structure, an error will
0697: // occur when it generates a submission url
0698: response = form.submit();
0699: fail();
0700: } catch (Throwable e) {
0701: Throwable internal_exception = getLogSink()
0702: .getInternalException();
0703: assertTrue(internal_exception instanceof SubmissionInheritanceUrlMissingException);
0704: SubmissionInheritanceUrlMissingException internal_exception2 = (SubmissionInheritanceUrlMissingException) internal_exception;
0705: assertEquals(internal_exception2.getDeclarationName(),
0706: "element/inheritance/exits_parent1.xml");
0707: assertEquals(
0708: internal_exception2.getTargetDeclarationName(),
0709: "element/inheritance/exits_parent2.xml");
0710: }
0711: }
0712:
0713: public void testInheritanceGlobalexitsCancelInheritance()
0714: throws Exception {
0715: setupSite("site/inheritance.xml");
0716: WebConversation conversation = new WebConversation();
0717: WebRequest request = null;
0718: WebResponse response = null;
0719: WebForm form = null;
0720:
0721: request = new GetMethodWebRequest(
0722: "http://localhost:8181/inheritance/globalexits/cancelinheritance");
0723: request.setParameter("childinput1", "will this");
0724: request.setParameter("childinput2", "arrive too");
0725: response = conversation.getResponse(request);
0726:
0727: form = response.getFormWithName("formparent2");
0728: form.setParameter("activationparent2", "don't go to child");
0729: response = form.submit();
0730:
0731: form = response.getFormWithName("formparent2");
0732: form.setParameter("activationparent2", "go to child");
0733: response = form.submit();
0734:
0735: form = response.getFormWithName("formparent1");
0736: form.setParameter("activationparent1", "don't go to exit");
0737: response = form.submit();
0738:
0739: form = response.getFormWithName("formparent1");
0740: form.setParameter("activationparent1", "go to exit");
0741: response = form.submit();
0742:
0743: form = response.getFormWithName("formparent1exit1");
0744: form.setParameter("activationparent1exit1", "don't go to exit");
0745: response = form.submit();
0746:
0747: form = response.getFormWithName("formparent1exit1");
0748: form.setParameter("activationparent1exit1", "go to exit");
0749: response = form.submit();
0750:
0751: form = response.getFormWithName("formparent1exit2");
0752: form
0753: .setParameter("activationparent1exit2",
0754: "don't go to child");
0755: response = form.submit();
0756:
0757: form = response.getFormWithName("formparent1exit2");
0758: form.setParameter("activationparent1exit2", "go to child");
0759: try {
0760: // the current inheritance structure will get cancelled
0761: // and a new one will be created for the EXITS_CANCELINHERITANCE_PARENT1
0762: // element which inherits from EXITS_CANCELINHERITANCE_PARENT2
0763: // since the latter has no url in the site structure, an error will
0764: // occur when it generates a submission url
0765: response = form.submit();
0766: fail();
0767: } catch (Throwable e) {
0768: Throwable internal_exception = getLogSink()
0769: .getInternalException();
0770: assertTrue(internal_exception instanceof SubmissionInheritanceUrlMissingException);
0771: SubmissionInheritanceUrlMissingException internal_exception2 = (SubmissionInheritanceUrlMissingException) internal_exception;
0772: assertEquals(internal_exception2.getDeclarationName(),
0773: "element/inheritance/globalexits_parent1.xml");
0774: assertEquals(
0775: internal_exception2.getTargetDeclarationName(),
0776: "element/inheritance/globalexits_parent2.xml");
0777: }
0778: }
0779:
0780: public void testInheritanceExitlinks() throws Exception {
0781: setupSite("site/inheritance.xml");
0782: WebConversation conversation = new WebConversation();
0783: WebRequest request = null;
0784: WebResponse response = null;
0785: WebLink link = null;
0786: WebForm form = null;
0787:
0788: request = new GetMethodWebRequest(
0789: "http://localhost:8181/inheritance/exitlinks");
0790: request.setParameter("childinput1", "will this also");
0791: request.setParameter("childinput2", "arrive too");
0792: response = conversation.getResponse(request);
0793:
0794: link = response.getLinkWith("direct link");
0795: WebResponse response_no_form = link.click();
0796: assertEquals("no form", response_no_form.getText());
0797:
0798: link = response.getLinkWith("direct link with form");
0799: response = link.click();
0800:
0801: form = response.getFormWithName("formparent1exit1");
0802: form.setParameter("activationparent1exit1", "dont go to child");
0803: response = form.submit();
0804:
0805: form = response.getFormWithName("formparent1exit1");
0806: form.setParameter("activationparent1exit1", "go to child");
0807: response = form.submit();
0808:
0809: assertEquals("will this also,arrive too", response.getText());
0810: }
0811:
0812: public void testInheritanceExitlinksCancelInheritance()
0813: throws Exception {
0814: setupSite("site/inheritance.xml");
0815: WebConversation conversation = new WebConversation();
0816: WebRequest request = null;
0817:
0818: request = new GetMethodWebRequest(
0819: "http://localhost:8181/inheritance/exitlinks/cancelinheritance");
0820: request.setParameter("childinput1", "will this also");
0821: request.setParameter("childinput2", "arrive too");
0822: try {
0823: conversation.getResponse(request);
0824: fail();
0825: } catch (Throwable e) {
0826: Throwable internal_exception = getLogSink()
0827: .getInternalException();
0828: assertTrue(internal_exception instanceof ExitTargetUrlMissingException);
0829: ExitTargetUrlMissingException internal_exception2 = (ExitTargetUrlMissingException) internal_exception;
0830: assertEquals(
0831: internal_exception2.getSourceDeclarationName(),
0832: "element/inheritance/exitlinks_parent1.xml");
0833: assertEquals(internal_exception2.getExitName(), "exit1");
0834: assertEquals(
0835: internal_exception2.getTargetDeclarationName(),
0836: "element/inheritance/exitlinks_parent1_exit1.xml");
0837: }
0838: }
0839:
0840: public void testInheritanceExitDataflow() throws Exception {
0841: setupSite("site/inheritance.xml");
0842: WebConversation conversation = new WebConversation();
0843: WebRequest request = null;
0844: WebResponse response = null;
0845:
0846: request = new GetMethodWebRequest(
0847: "http://localhost:8181/inheritance/exitdataflow");
0848: request.setParameter("input1", "invalid");
0849: request.setParameter("childinput1", "some more data");
0850: request.setParameter("childinput2", "that has to arrive");
0851: response = conversation.getResponse(request);
0852:
0853: assertEquals("child not triggered", response.getText());
0854:
0855: request = new GetMethodWebRequest(
0856: "http://localhost:8181/inheritance/exitdataflow");
0857: request.setParameter("input1", "validoutputs");
0858: request.setParameter("childinput1", "some more data");
0859: request.setParameter("childinput2", "that has to arrive");
0860: response = conversation.getResponse(request);
0861:
0862: assertEquals("some more data,that has to arrive", response
0863: .getText());
0864: }
0865:
0866: public void testInheritanceParampass() throws Exception {
0867: setupSite("site/inheritance.xml");
0868: WebConversation conversation = new WebConversation();
0869: WebRequest request = null;
0870: WebResponse response = null;
0871: WebForm form = null;
0872:
0873: request = new GetMethodWebRequest(
0874: "http://localhost:8181/inheritance/parampass");
0875: request.setParameter("childinput1", "will this");
0876: request.setParameter("childinput2", "arrive");
0877: response = conversation.getResponse(request);
0878:
0879: form = response.getFormWithName("formparent3");
0880: form.setParameter("activationparent3", "don't go to child");
0881: response = form.submit();
0882:
0883: form = response.getFormWithName("formparent3");
0884: form.setParameter("activationparent3", "go to child");
0885: response = form.submit();
0886:
0887: form = response.getFormWithName("formparent2");
0888: form.setParameter("activationparent2", "don't go to child");
0889: response = form.submit();
0890:
0891: form = response.getFormWithName("formparent2");
0892: form.setParameter("activationparent2", "go to child");
0893: response = form.submit();
0894:
0895: form = response.getFormWithName("formparent1");
0896: form.setParameter("activationparent1", "don't go to child");
0897: response = form.submit();
0898:
0899: form = response.getFormWithName("formparent1");
0900: form.setParameter("activationparent1", "go to child");
0901: response = form.submit();
0902:
0903: assertEquals("will this,arrive", response.getText());
0904: }
0905:
0906: public void testInheritanceSuccessive() throws Exception {
0907: setupSite("site/inheritance.xml");
0908: WebConversation conversation = new WebConversation();
0909: WebRequest request = null;
0910: WebResponse response = null;
0911: WebForm form = null;
0912:
0913: request = new GetMethodWebRequest(
0914: "http://localhost:8181/inheritance/successive");
0915: request.setParameter("childinput1", "will this succession");
0916: request.setParameter("childinput2", "arrive too");
0917: response = conversation.getResponse(request);
0918:
0919: form = response.getFormWithName("formparent1");
0920: form.setParameter("activationparent1", "don't go to exit");
0921: response = form.submit();
0922:
0923: form = response.getFormWithName("formparent1");
0924: form.setParameter("activationparent1", "go to exit");
0925: response = form.submit();
0926:
0927: form = response.getFormWithName("formparent2");
0928: form.setParameter("activationparent2", "don't go to child");
0929: response = form.submit();
0930:
0931: form = response.getFormWithName("formparent2");
0932: form.setParameter("activationparent2", "go to child");
0933: response = form.submit();
0934:
0935: form = response.getFormWithName("formparent1exit");
0936: form.setParameter("activationparent1exit", "don't go to child");
0937: response = form.submit();
0938:
0939: form = response.getFormWithName("formparent1exit");
0940: form.setParameter("activationparent1exit", "go to child");
0941: response = form.submit();
0942:
0943: assertEquals("will this succession,arrive too", response
0944: .getText());
0945: }
0946:
0947: public void testInheritanceArrival() throws Exception {
0948: setupSite("site/inheritance.xml");
0949: WebConversation conversation = new WebConversation();
0950: WebRequest request = null;
0951: WebResponse response = null;
0952: WebLink link = null;
0953:
0954: request = new GetMethodWebRequest(
0955: "http://localhost:8181/inheritance/arrival/");
0956: response = conversation.getResponse(request);
0957: link = response.getLinkWith("activate child");
0958: response = link.click();
0959: assertEquals("This is the child", response.getText());
0960: }
0961:
0962: public void testInheritanceGlobalScopeAbsolute() throws Exception {
0963: setupSite("site/inheritance.xml");
0964: WebConversation conversation = new WebConversation();
0965: WebRequest request = null;
0966: WebResponse response = null;
0967: WebLink link = null;
0968:
0969: request = new GetMethodWebRequest(
0970: "http://localhost:8181/inheritance/globalscope/absolute");
0971: response = conversation.getResponse(request);
0972: link = response.getLinkWith("activate child");
0973: response = link.click();
0974: assertEquals("This is the child", response.getText());
0975: }
0976:
0977: public void testInheritanceGlobalScopeRelative() throws Exception {
0978: setupSite("site/inheritance.xml");
0979: WebConversation conversation = new WebConversation();
0980: WebRequest request = null;
0981: WebResponse response = null;
0982: WebLink link = null;
0983:
0984: request = new GetMethodWebRequest(
0985: "http://localhost:8181/inheritance/globalscope/relative");
0986: response = conversation.getResponse(request);
0987: link = response.getLinkWith("activate child");
0988: response = link.click();
0989: assertEquals("This is the child", response.getText());
0990: }
0991:
0992: public void testInheritanceDifferentParentSameChild()
0993: throws Exception {
0994: setupSite("site/inheritance.xml");
0995:
0996: WebConversation conversation = new WebConversation();
0997: WebRequest request = null;
0998: WebResponse response = null;
0999: WebLink link = null;
1000:
1001: request = new GetMethodWebRequest(
1002: "http://localhost:8181/inheritance/differentparent_samechild1");
1003: response = conversation.getResponse(request);
1004: link = response.getLinkWith("activate child");
1005: response = link.click();
1006: assertEquals("This is parent1." + "This is the child", response
1007: .getText());
1008:
1009: request = new GetMethodWebRequest(
1010: "http://localhost:8181/inheritance/differentparent_samechild2");
1011: response = conversation.getResponse(request);
1012: link = response.getLinkWith("activate child");
1013: response = link.click();
1014: assertEquals("This is parent2." + "This is the child", response
1015: .getText());
1016: }
1017:
1018: public void testInheritanceGroup() throws Exception {
1019: setupSite("site/inheritance.xml");
1020: WebConversation conversation = new WebConversation();
1021: WebRequest request = null;
1022: WebResponse response = null;
1023: WebLink link = null;
1024:
1025: request = new GetMethodWebRequest(
1026: "http://localhost:8181/inheritance/group");
1027: response = conversation.getResponse(request);
1028: link = response.getLinkWith("activate child");
1029: response = link.click();
1030: assertEquals("This is the child", response.getText());
1031: }
1032:
1033: public void testInheritanceGroupArrival() throws Exception {
1034: setupSite("site/inheritance.xml");
1035: WebConversation conversation = new WebConversation();
1036: WebRequest request = null;
1037: WebResponse response = null;
1038: WebLink link = null;
1039:
1040: request = new GetMethodWebRequest("http://localhost:8181");
1041: response = conversation.getResponse(request);
1042: link = response.getLinkWith("activate child");
1043: response = link.click();
1044: assertEquals("This is the child", response.getText());
1045: }
1046:
1047: public void testInheritanceMultipleSubmissions() throws Exception {
1048: setupSite("site/inheritance.xml");
1049: WebConversation conversation = new WebConversation();
1050: WebRequest request = null;
1051: WebResponse response = null;
1052: WebLink link = null;
1053:
1054: request = new GetMethodWebRequest(
1055: "http://localhost:8181/inheritance/severalsubmissions");
1056: response = conversation.getResponse(request);
1057: link = response.getLinkWith("activate child");
1058: response = link.click();
1059:
1060: link = response.getLinkWith("submit");
1061: response = link.click();
1062:
1063: assertFalse("the child received its submission".equals(response
1064: .getText()));
1065:
1066: request = new GetMethodWebRequest(
1067: "http://localhost:8181/inheritance/severalsubmissions?submission=activatechild&submission=childsubmission");
1068: response = conversation.getResponse(request);
1069:
1070: assertEquals("the child received its submission", response
1071: .getText());
1072: }
1073:
1074: public void testInheritanceGroupSubsite() throws Exception {
1075: setupSite("site/inheritance.xml");
1076: WebConversation conversation = new WebConversation();
1077: WebRequest request = null;
1078: WebResponse response = null;
1079:
1080: request = new GetMethodWebRequest(
1081: "http://localhost:8181/inheritance/child1");
1082: response = conversation.getResponse(request);
1083: assertEquals(".GROUP_SUBSITE_PARENT1\n"
1084: + ".GROUP_SUBSITE_PARENT2\n"
1085: + ".GROUP_SUBSITE_PARENT3\n" + ".CHILD1\n", response
1086: .getText());
1087:
1088: request = new GetMethodWebRequest(
1089: "http://localhost:8181/inheritance/group_subsite/child2");
1090: response = conversation.getResponse(request);
1091: assertEquals(".GROUP_SUBSITE_PARENT1\n"
1092: + ".GROUP_SUBSITE_PARENT2\n"
1093: + ".GROUP_SUBSITE_PARENT3\n"
1094: + ".GROUP_SUBSITE_PARENT4\n"
1095: + ".GROUP_SUBSITE_SUBSITE.CHILD2\n", response.getText());
1096:
1097: request = new GetMethodWebRequest(
1098: "http://localhost:8181/inheritance/group_subsite/child3");
1099: response = conversation.getResponse(request);
1100: assertEquals(".GROUP_SUBSITE_PARENT1\n"
1101: + ".GROUP_SUBSITE_PARENT2\n"
1102: + ".GROUP_SUBSITE_PARENT3\n"
1103: + ".GROUP_SUBSITE_PARENT4\n"
1104: + ".GROUP_SUBSITE_PARENT5\n"
1105: + ".GROUP_SUBSITE_SUBSITE.CHILD3\n", response.getText());
1106:
1107: request = new GetMethodWebRequest(
1108: "http://localhost:8181/inheritance/group_subsite/child4");
1109: response = conversation.getResponse(request);
1110: assertEquals(".GROUP_SUBSITE_PARENT1\n"
1111: + ".GROUP_SUBSITE_PARENT2\n"
1112: + ".GROUP_SUBSITE_PARENT3\n"
1113: + ".GROUP_SUBSITE_PARENT4\n"
1114: + ".GROUP_SUBSITE_PARENT5\n"
1115: + ".GROUP_SUBSITE_PARENT6\n"
1116: + ".GROUP_SUBSITE_SUBSITE.CHILD4\n", response.getText());
1117:
1118: request = new GetMethodWebRequest(
1119: "http://localhost:8181/inheritance/group_subsite/child5");
1120: response = conversation.getResponse(request);
1121: assertEquals(".GROUP_SUBSITE_PARENT1\n"
1122: + ".GROUP_SUBSITE_PARENT2\n"
1123: + ".GROUP_SUBSITE_PARENT3\n"
1124: + ".GROUP_SUBSITE_PARENT7\n"
1125: + ".GROUP_SUBSITE_PARENT8\n"
1126: + ".GROUP_SUBSITE_PARENT9\n"
1127: + ".GROUP_SUBSITE_SUBSITE.CHILD5\n", response.getText());
1128: }
1129: }
|