1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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         
36      
37      
38      public void testInterceptors() throws Exception
39      {
40          MockComponent mc = (MockComponent) ctx.getBean("mockComponent");
41          InvocationCountingCache cache = (InvocationCountingCache) ctx.getBean("systemCache");
42          assertNotNull(mc);
43          assertNotNull(cache);
44          
45          assertNotNull(mc.getValue("2"));
46          assertEquals(1, cache.containsCount);
47          assertEquals(0, cache.getCount);
48          assertEquals(0, cache.successGetCount);
49          assertEquals(1, cache.putCount);
50          assertEquals(0, cache.removeCount);
51          
52          assertNotNull(mc.getValue("2"));
53          assertEquals(2, cache.containsCount);
54          assertEquals(1, cache.getCount);
55          assertEquals(1, cache.successGetCount);
56          assertEquals(1, cache.putCount);
57          assertEquals(0, cache.removeCount);
58          
59          mc.setValue("2", "some other value");
60          assertEquals(2, cache.containsCount);
61          assertEquals(1, cache.getCount);
62          assertEquals(1, cache.successGetCount);
63          assertEquals(1, cache.putCount);
64          assertEquals(1, cache.removeCount);
65          
66          assertEquals("some other value", mc.getValue("2"));
67          assertEquals(3, cache.containsCount);
68          assertEquals(1, cache.getCount);
69          assertEquals(1, cache.successGetCount);
70          assertEquals(2, cache.putCount);
71          assertEquals(1, cache.removeCount);
72      }
73      
74      
75      protected String[] getConfigurations()
76      {
77          return new String[] {"org/apache/jetspeed/cache/general/cache-test.xml"};
78      }
79  }