/* Open Source Java Caching Service
* Copyright (C) 2002 Frank Karlstr�m
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* The author can be contacted by email: fjankk@users.sourceforge.net
*/
import javax.util.jcache.Cache;
import javax.util.jcache.CacheAccessFactory;
import javax.util.jcache.CacheAttributes;
import junit.framework.TestCase;
import org.fjank.jcache.CacheSweeper;
public class Bug1037611 extends TestCase {
public void testResetCache() throws Exception {
CacheAccessFactory factory = CacheAccessFactory.getInstance();
CacheAttributes catt = CacheAttributes.getDefaultCacheAttributes();
catt.setLocal();
catt.setCleanInterval(1);
Cache cache = factory.getCache(false);
//
cache.init(catt);
// CacheSweeper.startSweeper executes
// within CacheSweeper.getInstance
//
CacheSweeper instance = CacheSweeper.getInstance();
cache.close();
// CacheSweeper.stopSweeper executes
//
cache = factory.getCache(false);
//
cache.init(catt);
CacheSweeper instance2= CacheSweeper.getInstance();
assertNotSame(instance, instance2);
// CacheSweeper.startSweeper does not
// execute within CacheSweeper.getInstance
// because CacheSweeper instance is not null
}
}