01: /*
02: * Created on Nov 15, 2004
03: */
04: package com.openedit.servlet;
05:
06: import com.openedit.BaseTestCase;
07: import com.openedit.WebPageRequest;
08: import com.openedit.page.Page;
09: import com.openedit.page.PageRequestKeys;
10:
11: /**
12: * @author Matthew Avery, mavery@einnovation.com
13: */
14: public class OpenEditEngineTest extends BaseTestCase {
15:
16: public OpenEditEngineTest(String name) {
17: super (name);
18: }
19:
20: public void testExecutePageActions() throws Exception {
21: WebPageRequest pageRequest = getFixture().createPageRequest(
22: "/actions/pagevalue.html");
23:
24: pageRequest.removePageValue(PageRequestKeys.USER);
25:
26: //FakeServletContext servletContext = new FakeServletContext();
27: //servletContext.setAttribute( "PageValue", new PageValueModule() );
28:
29: getEngine().beginRender(pageRequest);
30: String result = pageRequest.getWriter().toString();
31: //System.out.println(result);
32: assertNotNull(result);
33: assertTrue(result.indexOf("$date2") < 0);
34:
35: Page page = getPage("/actions/springpagevalue.html");
36:
37: pageRequest.getPageStreamer().stream(page);
38:
39: result = pageRequest.getWriter().toString();
40: //System.out.println(result);
41: assertTrue(result.indexOf("$date2") < 0);
42: assertTrue(result.indexOf("days") > 0);
43:
44: }
45:
46: public void testRender() throws Exception {
47: Page page = getPage("normal.html");
48: WebPageRequest pageRequest = getFixture().createPageRequest(
49: "normal.html");
50: //Remove the user, otherwise you could get a page decoration
51: pageRequest.removePageValue(PageRequestKeys.USER);
52: pageRequest.getPageStreamer().include(page);
53: String result = pageRequest.getWriter().toString();
54: //System.out.println(result);
55: result = result.replace("\r", "");
56: assertEquals(result, "<p>\nTest stuff $variable\n</p>");
57: }
58:
59: protected OpenEditEngine getEngine() {
60: return getFixture().getEngine();
61: }
62: }
|