public class JUnitTestUtil extends org.netbeans.modules.java.testrunner.CommonTestUtil
Modifier and Type | Method and Description |
---|---|
static boolean |
areAnnotationsSupported(FileObject file)
Checks whether Java annotations are applicable in the given file.
|
static boolean |
areAnnotationsSupported(String sourceLevel)
Determines whether Java annotations are supported by the given
Java source level.
|
static boolean |
canCreateTests(JUnitPlugin plugin,
FileObject... fileObjects)
Determines whether the given plugin is capable of creating tests
for the given files at the moment.
|
static String |
convertClass2TestName(String classFileName)
Converts given class filename to test filename, e.g.
|
static String |
convertPackage2ITSuiteName(String packageFileName)
Converts given package filename to integration test suite filename, e.g.
|
static String |
convertPackage2SuiteName(String packageFileName)
Converts given package filename to test suite filename, e.g.
|
static String |
createNewName(int i,
Set usedNames) |
static boolean |
createTestActionCalled(JUnitPlugin plugin,
FileObject[] filesToTest) |
static FileObject[] |
createTests(JUnitPlugin plugin,
FileObject[] filesToTest,
FileObject targetRoot,
Map<org.netbeans.modules.gsf.testrunner.plugin.CommonPlugin.CreateTestParam,Object> params)
Creates test classes for given source classes.
|
static ClassTree |
findMainClass(CompilationInfo compInfo)
Finds a main class.
|
static String |
getIntegrationTestClassName(String sourceClassName) |
static JUnitPlugin |
getITPluginForProject(Project project) |
static List<String> |
getJavaFileNames(FileObject packageFolder,
ClasspathInfo cpInfo)
Returns full names of all primary Java classes
withing the specified folder (non-recursive).
|
static JUnitPlugin |
getPluginForProject(Project project) |
static JUnitPlugin |
getPluginForProject(Project project,
JUnitVersion preferredVersion) |
static String |
getSimpleName(String fullName)
Gets the last part of a fully qualified Java name.
|
static String |
getSourceLevel(FileObject file)
Determines source level of the given file.
|
static String |
getTestClassFullName(String sourceClassName,
String packageName) |
static String |
getTestClassName(String sourceClassName) |
static boolean |
isClassException(CompilationInfo compilationInfo,
TypeElement classElem) |
static boolean |
isClassImplementingTestInterface(CompilationInfo compilationInfo,
TypeElement classElem) |
static boolean |
isClassTest(CompilationInfo compilationInfo,
TypeElement classElem) |
static boolean |
isValidPackageName(String str) |
static void |
notifyUser(String msg)
Show error message box.
|
static void |
notifyUser(String msg,
int messageType)
Show message box of the specified severity.
|
findSourceGroupOwner, findSourceGroupOwner, findSourceGroupOwners, getFileObject2SourceGroupMap, getSettingsMap, getTestTargets, isJavaFile, skipNulls
public static boolean canCreateTests(JUnitPlugin plugin, FileObject... fileObjects)
true
.plugin
- plugin to be queriedfileObjects
- FileObject
s for which the tests are about
to be createdtrue
if the given plugin is able of creating tests
for the given FileObject
s, false
otherwiseJUnitTestUtil.createTests(org.netbeans.modules.junit.plugin.JUnitPlugin, org.openide.filesystems.FileObject[], org.openide.filesystems.FileObject, java.util.Map<org.netbeans.modules.gsf.testrunner.plugin.CommonPlugin.CreateTestParam, java.lang.Object>)
public static FileObject[] createTests(JUnitPlugin plugin, FileObject[] filesToTest, FileObject targetRoot, Map<org.netbeans.modules.gsf.testrunner.plugin.CommonPlugin.CreateTestParam,Object> params)
filesToTest
- source files for which test classes should be
createdtargetRoot
- root folder of the target source rootparams
- parameters of creating test class
- each key is an Integer
whose value is equal
to some of the constants defined in the class;
the value is either
a String
(for key with value CLASS_NAME
)
or a Boolean
(for other keys)public static boolean createTestActionCalled(JUnitPlugin plugin, FileObject[] filesToTest)
public static String getTestClassFullName(String sourceClassName, String packageName)
public static String getIntegrationTestClassName(String sourceClassName)
public static String convertPackage2SuiteName(String packageFileName)
packageFileName
- package filename in form of "org/netbeans/foo"public static String convertPackage2ITSuiteName(String packageFileName)
packageFileName
- package filename in form of "org/netbeans/foo"public static String convertClass2TestName(String classFileName)
classFileName
- class filename in form of
"org/netbeans/Foo",
i.e. without extension, no inner classpublic static void notifyUser(String msg)
public static void notifyUser(String msg, int messageType)
public static boolean isClassTest(CompilationInfo compilationInfo, TypeElement classElem)
public static boolean isClassImplementingTestInterface(CompilationInfo compilationInfo, TypeElement classElem)
public static boolean isClassException(CompilationInfo compilationInfo, TypeElement classElem)
public static ClassTree findMainClass(CompilationInfo compInfo)
compInfo
- defines scope in which the class is to be foundnull
if the class was not
found (e.g. because of a broken source file)public static List<String> getJavaFileNames(FileObject packageFolder, ClasspathInfo cpInfo)
packageFolder
- folder to searchcpInfo
- classpath to be used for the searchpublic static boolean isValidPackageName(String str)
public static JUnitPlugin getPluginForProject(Project project)
public static JUnitPlugin getPluginForProject(Project project, JUnitVersion preferredVersion)
project
- preferredVersion
- public static JUnitPlugin getITPluginForProject(Project project)
public static String getSimpleName(String fullName)
public static String getSourceLevel(FileObject file)
file
- file whose source level is to be determined"1.5"
)
or null if the source level could not be determinedpublic static boolean areAnnotationsSupported(FileObject file)
file
- file to be checkedJUnitTestUtil.getSourceLevel(org.openide.filesystems.FileObject)
,
JUnitTestUtil.areAnnotationsSupported(String)
public static boolean areAnnotationsSupported(String sourceLevel)
sourceLevel
- Java source level (e.g. "1.5"
),
or null if the source level is unknownJUnitTestUtil.areAnnotationsSupported(FileObject)