Examples of IdTable


Examples of nextapp.echo2.webcontainer.util.IdTable

     * <code>System.gc()</code> actually causing weak references to
     * be collected.  It is not technically safe to rely on this,
     * thus this test may randomly fail.
     */
    public void testReferenceRelease() {
        IdTable idManager = new IdTable();
        TestObject testObject = new TestObject();
        String id = testObject.getRenderId();
        idManager.register(testObject);
        assertNotNull(idManager.getObject(id));
       
        testObject = null;
        for (int i = 0; i < 10; ++i) {
            System.gc();
        }
       
        assertNull(idManager.getObject(id));
    }
View Full Code Here

Examples of nextapp.echo2.webcontainer.util.IdTable

    /**
     * Tests serialization of an <code>IdTable</code>.
     */
    public void testSerialization()
    throws Exception {
        IdTable idTable = new IdTable();
        TestObject testObject = new TestObject();
        String id = testObject.getRenderId();
        idTable.register(testObject);
       
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        ObjectOutputStream objectOut = new ObjectOutputStream(byteOut);
        objectOut.writeObject(idTable);
        objectOut.close();
       
        byte[] data = byteOut.toByteArray();
       
        ByteArrayInputStream byteIn = new ByteArrayInputStream(data);
        ObjectInputStream objectIn = new ObjectInputStream(byteIn);
        IdTable newIdTable = (IdTable) objectIn.readObject();
        TestObject newTestObject = (TestObject) newIdTable.getObject(id);
        assertEquals(id, newTestObject.getRenderId());
        objectIn.close();
       
        testObject = null;
        for (int i = 0; i < 10; ++i) {
            System.gc();
        }
       
        assertNull(idTable.getObject(id));
        assertNotNull(newIdTable.getObject(id));
       
        newTestObject = null;
        for (int i = 0; i < 10; ++i) {
            System.gc();
        }

        assertNull(newIdTable.getObject(id));
    }
View Full Code Here

Examples of nextapp.echo2.webcontainer.util.IdTable

     *
     * @return the <code>IdTable</code>
     */
    public IdTable getIdTable() {
        if (idTable == null) {
            idTable = new IdTable();
        }
        return idTable;
    }
View Full Code Here
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.