01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: import junit.framework.TestCase;
24:
25: import org.junit.Before;
26:
27: /**
28: * Simple test that checks to see if the {@link ExpiringMap} can
29: * properly clean up itself.
30: *
31: * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32: * @version $Rev$, $Date$
33: */
34: public class ExpiringMapTest extends TestCase {
35: private ExpiringMap<String, String> theMap;
36:
37: /**
38: * Create the map, populate it and then kick off
39: * the Expirer, then sleep long enough so that the
40: * Expirer can clean up the map.
41: *
42: * @throws java.lang.Exception
43: */
44: @Before
45: public void setUp() throws Exception {
46: theMap = new ExpiringMap<String, String>(1, 2);
47: theMap.put("Apache", "MINA");
48: theMap.getExpirer().startExpiringIfNotStarted();
49: Thread.sleep(3000);
50: }
51:
52: /**
53: * Check to see if the map has been cleaned up.
54: *
55: */
56: public void testGet() {
57: assertNull(theMap.get("Apache"));
58: }
59: }
|