1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 21 package org.apache.mina.util; 22 23 24 import junit.framework.TestCase; 25 26 import org.junit.Before; 27 28 /** 29 * Simple test that checks to see if the {@link ExpiringMap} can 30 * properly clean up itself. 31 * 32 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 33 */ 34 public class ExpiringMapTest extends TestCase 35 { 36 private ExpiringMap<String,String> theMap; 37 38 /** 39 * Create the map, populate it and then kick off 40 * the Expirer, then sleep long enough so that the 41 * Expirer can clean up the map. 42 * 43 * @throws java.lang.Exception 44 */ 45 @Before 46 public void setUp() throws Exception 47 { 48 theMap = new ExpiringMap<String,String>(1, 2); 49 theMap.put( "Apache", "MINA" ); 50 theMap.getExpirer().startExpiringIfNotStarted(); 51 Thread.sleep(3000); 52 } 53 54 /** 55 * Check to see if the map has been cleaned up. 56 * 57 */ 58 public void testGet(){ 59 assertNull( theMap.get( "Apache" ) ); 60 } 61 }