01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon;
18:
19: /**
20: * Check the reloading of flowscript source files.
21: *
22: * @version $Id: $
23: */
24: public class FlowscriptReloadTestCase extends HtmlUnitTestCase {
25: final String pageurl = "/samples/flow/test/";
26: final String flowscriptPath = "samples/flow/test/sendpage.js";
27: final String paramToken = "@REPLACEME@";
28: final String resultXPath = "html/body/p[1]";
29:
30: protected void copyWebappFile(String filename, String param,
31: String value) throws Exception {
32: super .copyWebappFile(filename, param, value);
33: // AG: Default javacript check-reload time in cocoon.xconf is 4 seconds
34: // Let's wait 1 ms more, 4001 ms seems to be ok.
35: Thread.sleep(4001);
36: }
37:
38: public void testFlowscriptReload() throws Exception {
39: // Copy the flowscript from its source directory to the destination
40: // area, and replace the parameter value with 'abc'
41: final String expected1 = "replaceme-abc";
42: copyWebappFile(flowscriptPath, paramToken, expected1);
43: loadHtmlPage(pageurl + "showString");
44: String result1 = evalXPath(resultXPath);
45: assertEquals("Original request", expected1, result1);
46:
47: // Copy the flowscript from its source directory to the destination
48: // area, and replace the parameter value with '123'
49: final String expected2 = "replaceme-123";
50: copyWebappFile(flowscriptPath, paramToken, expected2);
51: loadHtmlPage(pageurl + "showString");
52: String result2 = evalXPath(resultXPath);
53: assertEquals("After flowscript was modified", expected2,
54: result2);
55: }
56: }
|