| org.netbeans.modules.web.core.test.TestUtil
TestUtil | final public class TestUtil extends ProxyLookup (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 EditableProperties | loadProjectProperties(FileObject projectDir) | 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 String | registerSunAppServer(NbTestCase test) Register Sun Application Server in the "IDE" to be used by unit test.
This method creates dummy userdir as well as dummy NetBeans home
in test's working directory. | public static String | registerSunAppServer(NbTestCase test, Object[] additionalLookupItems) | 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 void | storeProjectProperties(FileObject projectDir, EditableProperties props) | public static ProjectFactory | testProjectFactory() Create a testing project factory which recognizes directories containing
a subdirectory called "testproject". |
BROKEN_PROJECT_LOAD_LOCK | public static Object BROKEN_PROJECT_LOAD_LOCK(Code) | | If set to something non-null, loading a broken project will wait for
notification on this monitor before throwing an exception.
See Also: ProjectManagerTest.testLoadExceptionWithConcurrentLoad |
TestUtil | public TestUtil()(Code) | | Do not call directly
|
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.
|
loadProjectProperties | public static EditableProperties loadProjectProperties(FileObject projectDir) throws IOException(Code) | | |
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 |
registerSunAppServer | public static String registerSunAppServer(NbTestCase test) throws Exception(Code) | | Register Sun Application Server in the "IDE" to be used by unit test.
This method creates dummy userdir as well as dummy NetBeans home
in test's working directory. Both properties - netbeans.home
and netbeans.user - will be set by this method if they are
not already defined.
Parameters: test - a test which requires SunAppServer id of registered server |
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.
|
setLookup | public static void setLookup(Object[] instances)(Code) | | Set the global default lookup with some fixed instances including META-INF/services/*.
|
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 |
storeProjectProperties | public static void storeProjectProperties(FileObject projectDir, EditableProperties props) throws IOException(Code) | | |
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.
|
|
|