Package org.jboss.util.collection

Examples of org.jboss.util.collection.SoftSet$ComparableSoftReference


    * Tests of the SoftSet
    * @throws Exception
    */
   public void testSoftValueSet() throws Exception
   {
      SoftSet set = new SoftSet();
      StringBuffer akey = new StringBuffer("Key#");
      for(int n = 0; n < 1000; n ++)
      {
         String key = "Key#"+n;
         set.add(key);
         assertTrue("set has key", set.contains(key));
         akey.setLength(4);
         akey.append(""+n);
         String key2 = akey.toString();
         assertEquals(key, key2);
         assertEquals(key.hashCode(), key2.hashCode());
         assertTrue("set has akey", set.contains(key2));
      }
      assertEquals("Size == 1000", 1000, set.size());
      assertEquals("Set.isEmpty is false", false, set.isEmpty());
      String[] keys = new String[1000];
      set.toArray(keys);
      for(int n = 0; n < 1000; n ++)
      {
         String key = keys[n];
         assertTrue("set has key", set.contains(key));
      }

      HashSet set2 = new HashSet();
      set2.add("Key#1000");
      assertFalse("set has not Key#1000", set.contains("Key#1000"));
      assertTrue("Key#1000 was added", set.addAll(set2));
      assertEquals("Size == 1001", 1001, set.size());
      assertTrue("Key#1000 was removed", set.removeAll(set2));
      assertEquals("Size == 1000", 1000, set.size());
      set.add("Key#1000");
      assertTrue("Key#1000 was removed", set.retainAll(set2));
      assertEquals("Size == 1", 1, set.size());
      assertTrue("set contains [Key#1000]", set.containsAll(set2));
     
      set.clear();
      assertEquals("Size == 0", 0, set.size());
      assertEquals("Size is empty", true, set.isEmpty());
      for(int n = 0; n < 1000; n ++)
      {
         String key = keys[n];
         set.add(key);
         assertTrue("set has key", set.contains(key));
      }

      for(int n = 0; n < 1000; n ++)
      {
         String key = "Key#"+n;
         set.remove(key);
         assertFalse("key was removed", set.contains(key));
      }

      for(int n = 0; n < 1000; n ++)
      {
         String key = "Key#"+n;
         set.add(key);
         assertTrue("set has key", set.contains(key));
      }
      Iterator iter = set.iterator();
      while( iter.hasNext() )
      {
         Object o = iter.next();
         assertTrue("o instanceof String", o instanceof String);
      }

      forceSoftRefCollection();
      assertEquals("Size == 0 after gc", 0, set.size());
   }
View Full Code Here


/* 118 */       this.classBlackList = Collections.synchronizedSet(new HashSet());
/* 119 */       this.resourceBlackList = Collections.synchronizedSet(new HashSet());
/*     */     }
/* 121 */     else if (mode.equalsIgnoreCase("SoftSet"))
/*     */     {
/* 123 */       this.classBlackList = Collections.synchronizedSet(new SoftSet());
/* 124 */       this.resourceBlackList = Collections.synchronizedSet(new SoftSet());
/*     */     }
/*     */   }
View Full Code Here

/* 112 */       this.classBlackList = Collections.synchronizedSet(new HashSet());
/* 113 */       this.resourceBlackList = Collections.synchronizedSet(new HashSet());
/*     */     }
/* 115 */     else if (mode.equalsIgnoreCase("SoftSet"))
/*     */     {
/* 117 */       this.classBlackList = Collections.synchronizedSet(new SoftSet());
/* 118 */       this.resourceBlackList = Collections.synchronizedSet(new SoftSet());
/*     */     }
/*     */   }
View Full Code Here

         classBlackList = Collections.synchronizedSet(new HashSet());
         resourceBlackList = Collections.synchronizedSet(new HashSet());
      }
      else if( mode.equalsIgnoreCase("SoftSet") )
      {
         classBlackList = Collections.synchronizedSet(new SoftSet());
         resourceBlackList = Collections.synchronizedSet(new SoftSet());
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.util.collection.SoftSet$ComparableSoftReference

Copyright © 2018 www.massapicom. 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.