Package

Source Code of Bug974609_1

/*    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 java.util.Map;
import javax.util.jcache.Cache;
import javax.util.jcache.CacheAccessFactory;
import javax.util.jcache.CacheAttributes;
import junit.framework.TestCase;
/**
* Test to reproduce bug 974609.
* @author Frank Karlstr�m
*
*/
public class Bug974609_1  extends TestCase {
  /**
   * Tests the maxObjects. Sets the maximum number of objects to 5,
   * then tries to insert six.
   * @throws Exception if any faults occurs.
   */
    final public void testSetMaxObjects() throws Exception {
        CacheAttributes ca = CacheAttributes.getDefaultCacheAttributes();
        ca.setMaxObjects(5);
        ca.setLocal();
        CacheAccessFactory factory = CacheAccessFactory.getInstance();
        Cache cache = factory.getCache();
        cache.close();
        cache.init(ca);
        Map map = factory.getMapAccess();
        int max=5;
        for(int i=0; i<max; i++) {
            map.put(""+i, new Object());
        }
        //now it should be full.
        try {
            map.put("oi", new Object());
            fail("MaxObjects was "+max+" but we managed to put "+(max+1)+".");
        }catch(IllegalArgumentException e) {
            //this is good.
        }
    }
   
}
TOP

Related Classes of Bug974609_1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.