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: TestEngineExpressionElement.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.engine;
009:
010: import com.meterware.httpunit.GetMethodWebRequest;
011: import com.meterware.httpunit.WebConversation;
012: import com.meterware.httpunit.WebRequest;
013: import com.meterware.httpunit.WebResponse;
014: import com.uwyn.rife.TestCaseServerside;
015:
016: public class TestEngineExpressionElement extends TestCaseServerside {
017: public TestEngineExpressionElement(int siteType, String name) {
018: super (siteType, name);
019: }
020:
021: public void testInputsOgnl() throws Exception {
022: setupSite("site/expressionelement.xml");
023:
024: WebConversation conversation = new WebConversation();
025: WebRequest request = null;
026: WebResponse response = null;
027:
028: request = new GetMethodWebRequest(
029: "http://localhost:8181/inputs_ognl?input1=value1");
030: response = conversation.getResponse(request);
031: assertEquals("this is value 1\n\n\n", response.getText());
032:
033: request = new GetMethodWebRequest(
034: "http://localhost:8181/inputs_ognl?input1=value2");
035: response = conversation.getResponse(request);
036: assertEquals("this is value 2\n\n\n", response.getText());
037:
038: request = new GetMethodWebRequest(
039: "http://localhost:8181/inputs_ognl?input1=value3");
040: response = conversation.getResponse(request);
041: assertEquals("<!--V 'OGNL:value'/-->\n\n\n", response.getText());
042: }
043:
044: public void testInputsMvel() throws Exception {
045: setupSite("site/expressionelement.xml");
046:
047: WebConversation conversation = new WebConversation();
048: WebRequest request = null;
049: WebResponse response = null;
050:
051: request = new GetMethodWebRequest(
052: "http://localhost:8181/inputs_mvel?input1=value1");
053: try {
054: response = conversation.getResponse(request);
055: } catch (Throwable e) {
056: getLogSink().getInternalException().printStackTrace();
057: }
058: assertEquals("this is value 1\n\n\n", response.getText());
059:
060: request = new GetMethodWebRequest(
061: "http://localhost:8181/inputs_mvel?input1=value2");
062: response = conversation.getResponse(request);
063: assertEquals("this is value 2\n\n\n", response.getText());
064:
065: request = new GetMethodWebRequest(
066: "http://localhost:8181/inputs_mvel?input1=value3");
067: response = conversation.getResponse(request);
068: assertEquals("<!--V 'MVEL:value'/-->\n\n\n", response.getText());
069: }
070:
071: public void testInputsGroovy() throws Exception {
072: setupSite("site/expressionelement.xml");
073:
074: WebConversation conversation = new WebConversation();
075: WebRequest request = null;
076: WebResponse response = null;
077:
078: request = new GetMethodWebRequest(
079: "http://localhost:8181/inputs_groovy?input1=value1");
080: response = conversation.getResponse(request);
081: assertEquals("this is value 1\n\n\n", response.getText());
082:
083: request = new GetMethodWebRequest(
084: "http://localhost:8181/inputs_groovy?input1=value2");
085: response = conversation.getResponse(request);
086: assertEquals("this is value 2\n\n\n", response.getText());
087:
088: request = new GetMethodWebRequest(
089: "http://localhost:8181/inputs_groovy?input1=value3");
090: response = conversation.getResponse(request);
091: assertEquals("<!--V 'GROOVY:value'/-->\n\n\n", response
092: .getText());
093: }
094:
095: public void testInputsJanino() throws Exception {
096: setupSite("site/expressionelement.xml");
097:
098: WebConversation conversation = new WebConversation();
099: WebRequest request = null;
100: WebResponse response = null;
101:
102: request = new GetMethodWebRequest(
103: "http://localhost:8181/inputs_janino?input1=value1");
104: try {
105: response = conversation.getResponse(request);
106: } catch (Throwable e) {
107: getLogSink().getInternalException().printStackTrace();
108: }
109: assertEquals("this is value 1\n\n\n", response.getText());
110:
111: request = new GetMethodWebRequest(
112: "http://localhost:8181/inputs_janino?input1=value2");
113: response = conversation.getResponse(request);
114: assertEquals("this is value 2\n\n\n", response.getText());
115:
116: request = new GetMethodWebRequest(
117: "http://localhost:8181/inputs_janino?input1=value3");
118: response = conversation.getResponse(request);
119: assertEquals("<!--V 'JANINO:value'/-->\n\n\n", response
120: .getText());
121: }
122: }
|