Package com.mchange.v2.util

Examples of com.mchange.v2.util.DoubleWeakHashMap$UserEntrySet


       
        String poop = new String("poop");
        String scoop = new String("scoop");
        String doop = new String("dcoop");
       
        Map m = new DoubleWeakHashMap();
        m.put(a, poop);
        m.put(b, scoop);
        m.put(c, doop);
        assertEquals("Size should be three, viewed via Map directly.", m.size(), 3);
        assertEquals("Size should be three, viewed via keySet .", m.keySet().size(), 3);
        assertEquals("Size should be three, viewed via values Collection.", m.values().size(), 3);
       
        int count = 0;
        for (Iterator ii = m.keySet().iterator(); ii.hasNext();)
        {
            count += ((Integer) ii.next()).intValue();
        }
        assertEquals("Count should be six, viewed via values Collection.", count, 6);
       
        Integer d = new Integer(4);
        m.put(d, poop);
        m.values().remove(poop);
        assertEquals("After removing a doubled value, size should be 2", m.size(), 2);
    }
View Full Code Here


        Integer b = new Integer(2);
        Integer c = new Integer(3);
       
        String poop = new String("poop");

        Map m = new DoubleWeakHashMap();
        m.put(a, poop);
        m.put(b, new Object());
        m.put(c, new Object());
       
        //race condition... b & c might already have been removed... but i doubt it
        assertEquals("1) Weak values should not yet have been removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 3);
       
        // we are relying that a full, synchronous GC occurs,
        // which is not guaranteed in all VMs
        System.gc();
       
        // let's see if we can force a deeper gc via a big array creation
        byte[] bArray = new byte[1024 * 1024];
       
        assertEquals("2) Weak values should have been automatically removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 1);
       
        m.put( new Object(), b);
       
        //race condition... b & c might already have been removed... but i doubt it
        assertEquals("3) Weak key should not yet have been removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 2);

        System.gc();
        // let's see if we can force a deeper gc via a big array creation
        bArray = new byte[1024 * 1024];

        assertEquals("4) Weak key should have been automatically removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 1);
    }
View Full Code Here

public class DoubleWeakHashMapJUnitTestCase extends TestCase
{
    public void testGetNeverAdded()
    {
        Map m = new DoubleWeakHashMap();
        assertNull( m.get("foo") );
    }
View Full Code Here

       
        String poop = new String("poop");
        String scoop = new String("scoop");
        String doop = new String("dcoop");
       
        Map m = new DoubleWeakHashMap();
        m.put(a, poop);
        m.put(b, scoop);
        m.put(c, doop);
        assertEquals("Size should be three, viewed via Map directly.", m.size(), 3);
        assertEquals("Size should be three, viewed via keySet .", m.keySet().size(), 3);
        assertEquals("Size should be three, viewed via values Collection.", m.values().size(), 3);
       
        int count = 0;
        for (Iterator ii = m.keySet().iterator(); ii.hasNext();)
        {
            count += ((Integer) ii.next()).intValue();
        }
        assertEquals("Count should be six, viewed via values Collection.", count, 6);
       
        Integer d = new Integer(4);
        m.put(d, poop);
        m.values().remove(poop);
        assertEquals("After removing a doubled value, size should be 2", m.size(), 2);
    }
View Full Code Here

        Integer b = new Integer(2);
        Integer c = new Integer(3);
       
        String poop = new String("poop");

        Map m = new DoubleWeakHashMap();
        m.put(a, poop);
        m.put(b, new Object());
        m.put(c, new Object());
       
        //race condition... b & c might already have been removed... but i doubt it
        assertEquals("1) Weak values should not yet have been removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 3);
       
        // we are relying that a full, synchronous GC occurs,
        // which is not guaranteed in all VMs
        System.gc();
       
        // let's see if we can force a deeper gc via a big array creation
        byte[] bArray = new byte[1024 * 1024];
       
        assertEquals("2) Weak values should have been automatically removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 1);
       
        m.put( new Object(), b);
       
        //race condition... b & c might already have been removed... but i doubt it
        assertEquals("3) Weak key should not yet have been removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 2);

        System.gc();
        // let's see if we can force a deeper gc via a big array creation
        bArray = new byte[1024 * 1024];

        assertEquals("4) Weak key should have been automatically removed (but not guaranteed! sometimes fails without a defect!)", m.size(), 1);
    }
View Full Code Here

                if (logger.isLoggable(MLevel.FINE))
                    logger.log( MLevel.FINE,
                                "A client attempted to work with a closed Statement cache, " + "" +
                                "provoking a NullPointerException. c3p0 recovers, but this should be rare.",
                                npe);
                throw new ResourceClosedException( npe );
            }
            else
                throw npe;
        }
    }
View Full Code Here

    if ( Debug.DEBUG )
        {
      if ( logger.isLoggable( MLevel.FINE ) )
          logger.log( MLevel.FINE, "NullPointerException while posting Runnable -- Probably we're closed.", e );
        }
    throw new ResourceClosedException("Attempted to use a ThreadPoolAsynchronousRunner in a closed or broken state.");
      }
    }
View Full Code Here

      {
    queue.add( r );
    this.notifyAll();
      }
  else
      throw new ResourceClosedException("Attempted to use a ThreadPerTaskAsynchronousRunner in a closed or broken state.");

    }
View Full Code Here

        {
      if ( logger.isLoggable( MLevel.FINE ) )
          logger.log( MLevel.FINE, "NullPointerException while posting Runnable -- Probably we're closed.", e );
        }
    this.close( true );
    throw new ResourceClosedException("Attempted to use a RoundRobinAsynchronousRunner in a closed or broken state.");
      }
    }
View Full Code Here

        {
      if ( logger.isLoggable( MLevel.FINE ) )
          logger.log( MLevel.FINE, "NullPointerException in asRunnableQueue() -- Probably we're closed.", e );
        }
    this.close( true );
    throw new ResourceClosedException("Attempted to use a RoundRobinAsynchronousRunner in a closed or broken state.");
      }
    }
View Full Code Here

TOP

Related Classes of com.mchange.v2.util.DoubleWeakHashMap$UserEntrySet

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.