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: * Test the CachingProcessingPipeline and CachingPointProcessingPipeline.
21: *
22: * Uses the test-suite/caching module in the Cocoon webapp. The pipelines
23: * invoke the IncrementGenerator and IncrementTransformer that both increment a
24: * value in an attribute of the Cocoon context.
25: *
26: * @version $Id: CachingPipelineTestCase.java 433543 2006-08-22 06:22:54Z crossley $
27: */
28: public class CachingPipelineTestCase extends HtmlUnitTestCase {
29: final String testPipeline = "/test-suite/caching/a";
30: final String clearCachePipeline = "/test-suite/caching/clear-cache";
31: final String checkPipeline = "/test-suite/caching/check";
32: final String resetPipeline = "/test-suite/caching/reset";
33: final String sitemapPath = "test-suite/caching/sitemap.xmap";
34: final String resultPath = "context/key[@name='count']";
35:
36: public void testCachingProcessingPipeline() throws Exception {
37: // replace @pipeline.type@ with caching
38: copyWebappFile(sitemapPath, "@pipeline.type@", "caching");
39: // clear cache
40: loadResponse(clearCachePipeline);
41: // reset count
42: loadResponse(resetPipeline);
43: // execute pipeline a1 and a2
44: loadResponse(testPipeline + "1");
45: loadResponse(testPipeline + "2");
46: // check that count is 2
47: loadXmlPage(checkPipeline);
48: String count = evalXPath(resultPath);
49: assertEquals("4", count);
50: // check that store has 2 objects
51: }
52:
53: public void testCachingPointProcessingPipeline() throws Exception {
54: // replace @pipeline.type@ with caching-point
55: copyWebappFile(sitemapPath, "@pipeline.type@", "caching-point");
56: // clear cache
57: loadResponse(clearCachePipeline);
58: // reset count
59: loadResponse(resetPipeline);
60: // execute pipeline a1 and a2
61: loadResponse(testPipeline + "1");
62: loadResponse(testPipeline + "2");
63: // check that count is 3
64: loadXmlPage(checkPipeline);
65: String count = evalXPath(resultPath);
66: assertEquals("3", count);
67: // check that store has 3 objects
68: }
69: }
|