1 19 import java.util.Map ; 20 import javax.util.jcache.Cache; 21 import javax.util.jcache.CacheAccessFactory; 22 import javax.util.jcache.CacheAttributes; 23 import junit.framework.TestCase; 24 29 public class Bug974609_1 extends TestCase { 30 35 final public void testSetMaxObjects() throws Exception { 36 CacheAttributes ca = CacheAttributes.getDefaultCacheAttributes(); 37 ca.setMaxObjects(5); 38 ca.setLocal(); 39 CacheAccessFactory factory = CacheAccessFactory.getInstance(); 40 Cache cache = factory.getCache(); 41 cache.close(); 42 cache.init(ca); 43 Map map = factory.getMapAccess(); 44 int max=5; 45 for(int i=0; i<max; i++) { 46 map.put(""+i, new Object ()); 47 } 48 try { 50 map.put("oi", new Object ()); 51 fail("MaxObjects was "+max+" but we managed to put "+(max+1)+"."); 52 }catch(IllegalArgumentException e) { 53 } 55 } 56 57 } 58 | Popular Tags |