Class TestEnvironment
- java.lang.Object
-
- com.nomagic.magicdraw.tests.common.TestEnvironment
-
@OpenApi public class TestEnvironment extends java.lang.Object
The class which is used for initializing the MagicDraw test environment(starting the MagicDraw and specifying the necessary variables).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TestEnvironment.ProjectFilenameFilter
File name filter to filter MagicDraw loadable files (mdzip, mdxml, zip.xml, and etc).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.File
createFileNameWithPrefix(java.io.File file, java.lang.String prefix)
Insert specific prefix after file name before file extension.static java.util.List<java.io.File>
getFiles(java.io.File rootDirectory, java.io.FilenameFilter filter, java.util.Collection<java.lang.String> skipNames)
Collects files from root directory and inner directories recursively except those specified to skip.static java.io.File
getFileWithExtension(java.io.File file, java.lang.String extension)
Replace MagicDraw project file extension by the given one.static java.io.File
getOutputDir(java.lang.Class clazz)
Get default directory for specific test case output.static java.util.List<java.io.File>
getProjects(java.io.File rootDirectory)
Collects MagicDraw project files from specific directory and from its inner directories recursively.static java.util.List<java.io.File>
getProjects(java.io.File rootDirectory, java.util.Collection<java.lang.String> skipNames)
Collects MagicDraw projects files from root directory and inner directories recursively except those specified to skip.static java.util.List<java.io.File>
getProjects(java.lang.String directory)
Collects MagicDraw projects recursively from the given directory of resource directory.static java.io.File
getRelativeOutputFile(java.lang.Class clazz, java.io.File resourceFile)
Creates output file relative to given resource file in specific test case output directory.static java.io.File
getResourceDir()
Returns test framework resources directory specified by "tests.resources" system property.static java.lang.String[]
splitFileName(java.lang.String fileName)
Splits MagicDraw project file name to file name and extension.
-
-
-
Method Detail
-
getResourceDir
@OpenApi public static java.io.File getResourceDir()
Returns test framework resources directory specified by "tests.resources" system property. Resources directory is a central place for all resources required by test cases.- Returns:
- File representing test framework resources directory.
-
getRelativeOutputFile
@OpenApi public static java.io.File getRelativeOutputFile(java.lang.Class clazz, java.io.File resourceFile)
Creates output file relative to given resource file in specific test case output directory.- Parameters:
clazz
- test case class to create related output file for.resourceFile
- resource file to create related output file for.- Returns:
- output file in given test case output directory with name related to given resource file.
-
getOutputDir
@OpenApi public static java.io.File getOutputDir(java.lang.Class clazz)
Get default directory for specific test case output. Output directory is created if it does not exist. Output directory is located in parent directory if specified by "tests.output" system property or MagicDraw install root otherwise.- Parameters:
clazz
- Test case class to get output directory for.- Returns:
- File representing output directory for test case.
-
getProjects
@OpenApi public static java.util.List<java.io.File> getProjects(java.io.File rootDirectory)
Collects MagicDraw project files from specific directory and from its inner directories recursively.- Parameters:
rootDirectory
- Root directory to collect project files recursively from.- Returns:
- List of MagicDraw projects Files.
-
createFileNameWithPrefix
@OpenApi public static java.io.File createFileNameWithPrefix(java.io.File file, java.lang.String prefix)
Insert specific prefix after file name before file extension. For instance my_projectPREFIX.mdzip.- Parameters:
file
- file to insert prefix to.prefix
- prefix to insert.- Returns:
- File representing new file there name has prefix inserted.
-
getFileWithExtension
@OpenApi public static java.io.File getFileWithExtension(java.io.File file, java.lang.String extension)
Replace MagicDraw project file extension by the given one.- Parameters:
file
- File to replace extension.extension
- new extension.- Returns:
- new File with replaced given extension.
-
getFiles
@OpenApi public static java.util.List<java.io.File> getFiles(java.io.File rootDirectory, java.io.FilenameFilter filter, @CheckForNull java.util.Collection<java.lang.String> skipNames)
Collects files from root directory and inner directories recursively except those specified to skip. Files needed to skip might be also listed in skip.txt file located in root or nested directories.- Parameters:
rootDirectory
- Root directory to collect project files recursively from.filter
- only files matching this filter will be returnedskipNames
- the Collection of project file names to skip. Project file is skipped if it name contains any name defined in skipNames collection or skip.txt file.- Returns:
- The list of MagicDraw project files collected.
-
getProjects
@OpenApi public static java.util.List<java.io.File> getProjects(java.io.File rootDirectory, @CheckForNull java.util.Collection<java.lang.String> skipNames)
Collects MagicDraw projects files from root directory and inner directories recursively except those specified to skip. Projects needed to skip might be also listed in skip.txt file located in root or nested directories.- Parameters:
rootDirectory
- Root directory to collect project files recursively from.skipNames
- the Collection of project file names to skip. Project file is skipped if it name contains any name defined in skipNames collection or skip.txt file.- Returns:
- The list of MagicDraw project files collected.
-
getProjects
@OpenApi public static java.util.List<java.io.File> getProjects(java.lang.String directory)
Collects MagicDraw projects recursively from the given directory of resource directory.- Parameters:
directory
- directory name in the resource directory- Returns:
- List of MagicDraw project files found in the given resource directory and its nested directories.
-
splitFileName
@CheckForNull @OpenApi public static java.lang.String[] splitFileName(java.lang.String fileName)
Splits MagicDraw project file name to file name and extension.- Parameters:
fileName
- MagicDraw project file name to split.- Returns:
- String[2] = {fileName, fileExtension}
-
-