| java.lang.Object org.netbeans.api.java.source.TestUtilities
TestUtilities | final public class TestUtilities (Code) | | Utilities to aid unit testing java.source module.
author: Jaroslav Tulach author: Tom Ball author: Tomas Zezula |
Method Summary | |
final public static String | copyFileToString(java.io.File f) Returns a string which contains the contents of a file. | final public static String | copyGZipFileToString(java.io.File f) Returns a string which contains the contents of a GZIP compressed file. | final public static File | copyStringToFile(File f, String content) Copies a string to a specified file.
Parameters: f - the file to use. Parameters: content - the contents of the returned file. | final public static FileObject | copyStringToFile(FileObject f, String content) Copies a string to a specified file.
Parameters: f - the FilObject to use. Parameters: content - the contents of the returned file. | public static ClassPath | createBootClassPath() Creates boot
ClassPath for platform the test is running on,
it uses the sun.boot.class.path property to find out the boot path roots. | public static CountDownLatch | scheduleCompilation(FileObject folder, FileObject root) Schedules compilation of the folder inside the source root. | public static CountDownLatch | scheduleCompilation(File folder, File root) Schedules compilation of the folder inside the source root. | public static boolean | scheduleCompilationAndWait(FileObject folder, FileObject root, long timeout, TimeUnit unit) Schedules compilation of the folder inside the source root and blocks until it finishes. | public static boolean | scheduleCompilationAndWait(File folder, File root, long timeout, TimeUnit unit) Schedules compilation of the folder inside the source root and blocks until it finishes. | public static void | setCacheFolder(File cacheFolder) Sets a root folder of the java source caches. | public static void | setUseLibraries(boolean use) Disables use of
LibraryManager in the
GlobalSourcePath . | public static boolean | waitScanFinished(long timeout, TimeUnit unit) Waits for the end of the background scan, this helper method
is designed for tests which require to wait for the end of initial scan.
The method can be used as a barrier but it is not garanted that the
backgoud scan will not start again after return from this method, the
test is responsible for it itself. |
copyFileToString | final public static String copyFileToString(java.io.File f) throws java.io.IOException(Code) | | Returns a string which contains the contents of a file.
Parameters: f - the file to be read the contents of the file(s). |
copyGZipFileToString | final public static String copyGZipFileToString(java.io.File f) throws java.io.IOException(Code) | | Returns a string which contains the contents of a GZIP compressed file.
Parameters: f - the file to be read the contents of the file(s). |
copyStringToFile | final public static File copyStringToFile(File f, String content) throws Exception(Code) | | Copies a string to a specified file.
Parameters: f - the file to use. Parameters: content - the contents of the returned file. the created file |
copyStringToFile | final public static FileObject copyStringToFile(FileObject f, String content) throws Exception(Code) | | Copies a string to a specified file.
Parameters: f - the FilObject to use. Parameters: content - the contents of the returned file. the created file |
createBootClassPath | public static ClassPath createBootClassPath() throws IOException(Code) | | Creates boot
ClassPath for platform the test is running on,
it uses the sun.boot.class.path property to find out the boot path roots.
ClassPath throws: java.io.IOException - when boot path property conatins non valid path |
scheduleCompilation | public static CountDownLatch scheduleCompilation(FileObject folder, FileObject root) throws IOException(Code) | | Schedules compilation of the folder inside the source root. May be used by tests
which need to fill data into
ClassIndex or need to work on the group of java files.
Parameters: folder - to be compiled, has to be either the root itself or must be subfolder of the root. Parameters: root - owning the folder. There must be boot, compile and source ClassPath for itavailable by ClassPath.getClassPah method - there must be ClassPathProvider handlingthe root registered in the global Lookup. There must be also source level provided for the root - SourceLevelImplementation registered in the global Lookup. CountDownLatch which may be used to wait to the end of asynchronous compilation, See Also: CountDownLatch#await throws: java.io.IOException - when folder or root is not valid |
scheduleCompilation | public static CountDownLatch scheduleCompilation(File folder, File root) throws IOException(Code) | | Schedules compilation of the folder inside the source root. May be used by tests
which need to fill data into
ClassIndex or need to work on the group of java files.
Parameters: folder - to be compiled, has to be either the root itself or must be subfolder of the root. Parameters: root - owning the folder. There must be boot, compile and source ClassPath for itavailable by ClassPath.getClassPah method - there must be ClassPathProvider handlingthe root registered in the global Lookup. There must be also source level provided for the root - SourceLevelImplementation registered in the global Lookup. CountDownLatch which may be used to wait to the end of asynchronous compilation, See Also: CountDownLatch#await throws: java.io.IOException - when folder or root is not valid |
scheduleCompilationAndWait | public static boolean scheduleCompilationAndWait(FileObject folder, FileObject root, long timeout, TimeUnit unit) throws IOException, InterruptedException(Code) | | Schedules compilation of the folder inside the source root and blocks until it finishes. May be used by tests
which need to fill data into
ClassIndex or need to work on the group of java files.
Parameters: folder - to be compiled, has to be either the root itself or must be subfolder of the root. Parameters: root - owning the folder. There must be boot, compile and source ClassPath for itavailable by ClassPath.getClassPah method - there must be ClassPathProvider handlingthe root registered in the global Lookup. There must be also source level provided for the root - a SourceLevelImplementation registered in the global Lookup. Parameters: timeout - the maximum time to wait Parameters: unit - the time unit of the timeout argument false if the timeout elapsed before the end of compilation throws: java.io.IOException - when folder or root is not valid throws: InterruptedException - when the thread is interrupted |
scheduleCompilationAndWait | public static boolean scheduleCompilationAndWait(File folder, File root, long timeout, TimeUnit unit) throws IOException, InterruptedException(Code) | | Schedules compilation of the folder inside the source root and blocks until it finishes. May be used by tests
which need to fill data into
ClassIndex or need to work on the group of java files.
Parameters: folder - to be compiled, has to be either the root itself or must be subfolder of the root. Parameters: root - owning the folder. There must be boot, compile and source ClassPath for itavailable by ClassPath.getClassPah method - there must be ClassPathProvider handlingthe root registered in the global Lookup. There must be also source level provided for the root - a SourceLevelImplementation registered in the global Lookup. Parameters: timeout - the maximum time to wait Parameters: unit - the time unit of the timeout argument false if the timeout elapsed before the end of compilation throws: java.io.IOException - when folder or root is not valid throws: InterruptedException - when the thread is interrupted |
setCacheFolder | public static void setCacheFolder(File cacheFolder)(Code) | | Sets a root folder of the java source caches. This method may be used by tests
which need to do an initial compilation, they require either
ClassIndex or
need to work with a group of related java files.
Parameters: cacheFolder - the folder used by java infrastructure as a cache,has to exist and must be a folder. |
setUseLibraries | public static void setUseLibraries(boolean use)(Code) | | Disables use of
LibraryManager in the
GlobalSourcePath . The tests
which don't register
LibraryProvider or
LibraryTypeProvider may
use this method to disable use of
LibraryManager in the
GlobalSourcePath .
Parameters: use - false value disables use of LibraryManager |
waitScanFinished | public static boolean waitScanFinished(long timeout, TimeUnit unit) throws InterruptedException(Code) | | Waits for the end of the background scan, this helper method
is designed for tests which require to wait for the end of initial scan.
The method can be used as a barrier but it is not garanted that the
backgoud scan will not start again after return from this method, the
test is responsible for it itself. In general it's safer to use
JavaSource.runWhenScanFinished method and do the critical action inside the run methed.
Parameters: timeout - the maximum time to wait Parameters: unit - the time unit of the timeout argument true if the scan finished, false when the timeout elapsed before the end of the scan. throws: InterruptedException - is thrown when the waiting thread is interrupted. |
|
|