| java.lang.Object org.netbeans.api.project.TestUtil
TestUtil | final public class TestUtil (Code) | | Help set up org.netbeans.api.project.*Test.
author: Jesse Glick |
Field Summary | |
public static Object | BROKEN_PROJECT_LOAD_LOCK If set to something non-null, loading a broken project will wait for
notification on this monitor before throwing an exception. |
Method Summary | |
public static FileObject | createFileFromContent(URL content, FileObject parent, String path) Open a URL of content (for example from
Class.getResource ) and copy it to a named file. | public static void | deleteRec(File f) Delete a file and all subfiles. | public static void | gc() Try to force a GC. | public static FileObject | makeScratchDir(NbTestCase test) Create a scratch directory for tests. | public static void | modify(Project p) Mark a test project as modified. | public static void | notifyDeleted(Project p) Mark a test project as modified. | public static int | projectLoadCount(FileObject dir) Check how many times
ProjectFactory.loadProject has been called
(with any outcome) on a given project directory. | public static int | projectSaveCount(Project p) Get the number of times a test project was successfully saved with no error. | public static void | setLookup(Lookup l) Set the global default lookup.
Caution: if you don't include Lookups.metaInfServices, you may have trouble,
e.g. | public static void | setLookup(Object... instances) Set the global default lookup with some fixed instances including META-INF/services/*. | public static void | setProjectSaveWillFail(Project p, Throwable error) Mark a test project to fail with a given error when it is next saved. | public static ProjectFactory | testProjectFactory() Create a testing project factory which recognizes directories containing
a subdirectory called "testproject". |
createFileFromContent | public static FileObject createFileFromContent(URL content, FileObject parent, String path) throws IOException(Code) | | Open a URL of content (for example from
Class.getResource ) and copy it to a named file.
The new file can be given as a parent directory plus a relative (slash-separated) path.
The file may not already exist, but intermediate directories may or may not.
If the content URL is null, the file is just created, no more; if it already existed
it is touched (timestamp updated) and its contents are cleared.
the file object |
gc | public static void gc()(Code) | | Try to force a GC.
|
makeScratchDir | public static FileObject makeScratchDir(NbTestCase test) throws IOException(Code) | | Create a scratch directory for tests.
Will be in /tmp or whatever, and will be empty.
If you just need a java.io.File use clearWorkDir + getWorkDir.
|
modify | public static void modify(Project p)(Code) | | Mark a test project as modified.
Parameters: p - a test project |
notifyDeleted | public static void notifyDeleted(Project p)(Code) | | Mark a test project as modified.
Parameters: p - a test project |
projectLoadCount | public static int projectLoadCount(FileObject dir)(Code) | | Check how many times
ProjectFactory.loadProject has been called
(with any outcome) on a given project directory.
|
projectSaveCount | public static int projectSaveCount(Project p)(Code) | | Get the number of times a test project was successfully saved with no error.
Parameters: p - a test project the save count |
setLookup | public static void setLookup(Lookup l)(Code) | | Set the global default lookup.
Caution: if you don't include Lookups.metaInfServices, you may have trouble,
e.g.
TestUtil.makeScratchDir will not work.
MockLookup |
setLookup | public static void setLookup(Object... instances)(Code) | | Set the global default lookup with some fixed instances including META-INF/services/*.
MockLookup |
setProjectSaveWillFail | public static void setProjectSaveWillFail(Project p, Throwable error)(Code) | | Mark a test project to fail with a given error when it is next saved.
The error only applies to the next save, not subsequent ones.
Parameters: p - a test project Parameters: error - an error to throw (IOException or Error or RuntimeException),or null if it should succeed |
testProjectFactory | public static ProjectFactory testProjectFactory()(Code) | | Create a testing project factory which recognizes directories containing
a subdirectory called "testproject".
If that subdirectory contains a file named "broken" then loading the project
will fail with an IOException.
|
|
|