Asserting Nullness

e.g. testing for memory leak:

    public void testMemoryLeak() throws InterruptedException {
        Fraction a = Fraction.getFraction(1, 2);
        WeakReference ref = new WeakReference(a);
        a = null;
        System.gc();
        System.gc();
        System.gc();
        Thread.sleep(1000);
        assertNull(ref.get());
    }

Previous | Next | Top | Cafe con Leche | Cafe au Lait

Copyright 2005 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified September 6, 2005