1   /**
2    *  Copyright 2003-2007 Greg Luck
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.ehcache.store;
18  
19  import java.util.Map;
20  
21  
22  /**
23   * Test cases for the Apache version of LruMemoryStore.
24   * <p/>
25   * @author Greg Luck
26   * @version $Id: ApacheLruMemoryStoreTest.java 512 2007-07-10 09:18:45Z gregluck $
27   */
28  public class ApacheLruMemoryStoreTest extends LruMemoryStoreTest {
29  
30  
31      /**
32       * setup test
33       */
34      protected void setUp() throws Exception {
35          System.setProperty("net.sf.ehcache.useLRUMap", "true");
36          super.setUp();
37      }                                                                                      
38  
39  
40      /**
41       * Put back system default.
42       * @throws Exception
43       */
44      protected void tearDown() throws Exception {
45          System.getProperties().remove("net.sf.ehcache.useLRUMap");
46          super.tearDown();
47      }
48  
49      /**
50       * The LRU map implementation can be overridden by setting the "net.sf.ehcache.useLRUMap" System property.
51       */
52      public void testCorrectMapImplementation() throws Exception {
53          createMemoryStore(MemoryStoreEvictionPolicy.LRU, 5);
54  
55          Map map = ((MemoryStore)store).getBackingMap();
56          assertTrue(map instanceof org.apache.commons.collections.LRUMap);
57      }
58  }