alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.web.context;

import java.beans.PropertyVetoException;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.ref.WeakReference;

import junit.framework.*;
import org.netbeans.core.ExLocalFileSystem;
import org.netbeans.junit.*;
import org.openide.filesystems.Repository;

/** JUnit test suite with Jemmy support
 *
 * @author Radim Kubacki
 */
public class WebModuleTest extends NbTestCase {
    
    /** method used for explicit testsuite definition
     */
    public static junit.framework.Test suite() {
        TestSuite suite = new NbTestSuite();
        suite.addTest(new WebModuleTest("testLocalFsUnmount"));
        suite.addTest(new WebModuleTest("testWebModuleUnmountGC"));
        return suite;
    }
    
    
    /** constructor required by JUnit
     * @param testName method name to be used as testcase
     */
    public WebModuleTest(String testName) {
        super(testName);
    }
    
    /** method called before each testcase
     */
    protected void setUp() throws IOException {
    }
    
    /** method called after each testcase
* resets Jemmy WaitComponentTimeout */ protected void tearDown() { } /** Use for internal test execution inside IDE * @param args command line arguments */ public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } /** * test for memory leak during web module unmounting */ public void testWebModuleUnmountGC() { File dir = new File (System.getProperty("xtest.sketchpad"), "webdir"); dir.mkdir(); ExLocalFileSystem fs = new ExLocalFileSystem (); try { Repository r = Repository.getDefault(); fs.setRootDirectory(dir); WebContextObject.checkOrCreateWebContext(fs); r.addFileSystem(fs); WeakReference ref = new WeakReference (fs); r.removeFileSystem(fs); fs = null; assertGC ("Web module can disappear", ref); } catch (IOException ioe) { fail ("Filesystem mounting failed - "+ioe.getLocalizedMessage()); } catch (PropertyVetoException ioe) { fail ("Filesystem mounting failed - "+ioe.getLocalizedMessage()); } } public void testLocalFsUnmount() { File dir = new File (System.getProperty("xtest.sketchpad"), "localfs"); dir.mkdir(); ExLocalFileSystem fs = new ExLocalFileSystem (); try { Repository r = Repository.getDefault(); fs.setRootDirectory(dir); r.addFileSystem(fs); WeakReference ref = new WeakReference (fs); r.removeFileSystem(fs); fs = null; assertGC ("Web module can disappear", ref); } catch (IOException ioe) { fail ("Filesystem mounting failed - "+ioe.getLocalizedMessage()); } catch (PropertyVetoException ioe) { fail ("Filesystem mounting failed - "+ioe.getLocalizedMessage()); } } public void testFail () { fail("blabla"); } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.