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.jetspeed.cache.general;
18:
19: import org.apache.jetspeed.components.MockComponent;
20: import org.apache.jetspeed.components.test.AbstractSpringTestCase;
21:
22: /**
23: * <p>
24: * TestCachingInterceptors
25: * </p>
26: * <p>
27: *
28: * </p>
29: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
30: * @version $Id: TestCachingInterceptors.java 516448 2007-03-09 16:25:47Z ate $
31: *
32: */
33: public class TestCachingInterceptors extends AbstractSpringTestCase {
34:
35: public void testInterceptors() throws Exception {
36: MockComponent mc = (MockComponent) ctx.getBean("mockComponent");
37: InvocationCountingCache cache = (InvocationCountingCache) ctx
38: .getBean("systemCache");
39: assertNotNull(mc);
40: assertNotNull(cache);
41:
42: assertNotNull(mc.getValue("2"));
43: assertEquals(1, cache.containsCount);
44: assertEquals(0, cache.getCount);
45: assertEquals(0, cache.successGetCount);
46: assertEquals(1, cache.putCount);
47: assertEquals(0, cache.removeCount);
48:
49: assertNotNull(mc.getValue("2"));
50: assertEquals(2, cache.containsCount);
51: assertEquals(1, cache.getCount);
52: assertEquals(1, cache.successGetCount);
53: assertEquals(1, cache.putCount);
54: assertEquals(0, cache.removeCount);
55:
56: mc.setValue("2", "some other value");
57: assertEquals(2, cache.containsCount);
58: assertEquals(1, cache.getCount);
59: assertEquals(1, cache.successGetCount);
60: assertEquals(1, cache.putCount);
61: assertEquals(1, cache.removeCount);
62:
63: assertEquals("some other value", mc.getValue("2"));
64: assertEquals(3, cache.containsCount);
65: assertEquals(1, cache.getCount);
66: assertEquals(1, cache.successGetCount);
67: assertEquals(2, cache.putCount);
68: assertEquals(1, cache.removeCount);
69: }
70:
71: protected String[] getConfigurations() {
72: return new String[] { "org/apache/jetspeed/cache/general/cache-test.xml" };
73: }
74: }
|