Package com.nomagic.magicdraw.tests
Class MagicDrawTestCase
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- com.nomagic.magicdraw.tests.NamedTestCase
-
- com.nomagic.magicdraw.tests.MagicDrawTestCase
-
- All Implemented Interfaces:
junit.framework.Test
@OpenApi public abstract class MagicDrawTestCase extends com.nomagic.magicdraw.tests.NamedTestCaseBase class for JUnit3 Test Cases which should be run with MagicDraw Application started. Starts new MagicDraw application before each test. Provides methods for opening, saving, closing, and comparing projects.
-
-
Constructor Summary
Constructors Constructor Description MagicDrawTestCase()Default test case initialization for executing test* methods.MagicDrawTestCase(java.lang.String method)Creates MagicDrawTestCase for executing specific test method.MagicDrawTestCase(java.lang.String method, java.lang.String testName)Creates MagicDrawTestCase of specific name for executing specific test method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckMemoryLeaks()Force memory leaks test execution.voidcloseAllProjects()Close all currently opened MagicDraw projects with performing memory leaks test.voidcloseProject(Project project)Close opened MagicDraw project.protected ProjectsComparatorcreateProjectComparator(java.lang.String logText)Creates project comparator with default model and diagram comparators implementation.static java.io.FilegetFileWithExtension(java.io.File projectFile, java.lang.String extension)Computes test case specific properties file according given project file.protected org.apache.log4j.LoggergetLogger()Gets logger for Test related output logging.static java.io.FilegetPropertiesFile(java.io.File projectFile)Computes test case specific properties file according given project file.protected java.util.List<java.lang.String>getRequiredPlugins()Is used to specify plug-ins required by test case.protected java.lang.StringgetRequiredPluginsDescription()Formats textual message about available plug-ins status(loaded/enabled).static java.io.FilegetXmlFile(java.io.File projectFile)Computes test case specific properties file according given project file.static voidinvokeAndWaitOnDispatcher(java.lang.Runnable r)Executes runnable on dispatcher thread and waits till runnable is done.booleanisDoNotUseSilentMode()Check if silent mode is not used for starting MagicDraw.booleanisFailed()Check if test has failed because of JUnit assertion or any other exception.protected booleanisMemoryTestReady()Check if memory leaks test might be performed.protected booleanisRequiredPluginsLoaded()Check if all plug-ins required by this test case are loaded and enabled.static ProjectloadProject(java.lang.String file)Opens MagicDraw project by absolute project file name.static ProjectloadProject(java.lang.String projectPath, boolean failIfProjectHasErrors)Opens MagicDraw project by absolute project file name.static ProjectloadProject(java.lang.String projectPath, boolean failIfProjectHasErrors, boolean loadAllDiagrams)Opens MagicDraw project by absolute project file name.protected ProjectopenProject(java.lang.String projectFile)Opens MagicDraw project by its absolute file name.protected ProjectopenProject(java.lang.String projectFile, boolean loadAllDiagram)Opens MagicDraw project by its absolute file name.protected voidsaveProject(Project project, java.io.File file)Save opened MagicDraw project to specific file.voidsetDoNotUseSilentMode(boolean doNotUseSilentMode)Specify if MagicDraw should show GUI modal dialogs during startup and features testing.voidsetMemoryTestReady(boolean memoryTestReady)Specify if memory leaks test is ready, so it might be performed at the end of the test.voidsetRunOnEventDispatcher(boolean runOnEventDispatcher)Sets if test case should be executed on event dispatching thread.voidsetRunOnEventDispather(boolean runOnEventDispatcher)Deprecated.spelling error in name, use set #setRunOnEventDispatchervoidsetSkipMemoryTest(boolean skipMemoryTest)Set to true in order to skip memory leaks test.protected voidsetUpTest()Override to prepare test case after MagicDraw application started.protected voidtearDownTest()Tear down test case after it execution.-
Methods inherited from class com.nomagic.magicdraw.tests.NamedTestCase
getFullTestName, getMethodName, getTestName, getTestNamePrefix, isOverridingTestName, setMethodName, setTestName
-
Methods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, runBare, setName, toString
-
-
-
-
Constructor Detail
-
MagicDrawTestCase
@OpenApi public MagicDrawTestCase()
Default test case initialization for executing test* methods.
-
MagicDrawTestCase
@OpenApi public MagicDrawTestCase(java.lang.String method)
Creates MagicDrawTestCase for executing specific test method.- Parameters:
method- test method name to execute.
-
MagicDrawTestCase
@OpenApi public MagicDrawTestCase(java.lang.String method, @CheckForNull java.lang.String testName)Creates MagicDrawTestCase of specific name for executing specific test method.- Parameters:
method- test method name to execute.testName- name of created test. All none alpha numerical characters in name will be replaced by underscore character.
-
-
Method Detail
-
setMemoryTestReady
@OpenApi public final void setMemoryTestReady(boolean memoryTestReady)
Specify if memory leaks test is ready, so it might be performed at the end of the test. Set it false if you need to disable memory leaks test performing at the end of the test.- Parameters:
memoryTestReady- true if memory test is ready
-
setSkipMemoryTest
@OpenApi public final void setSkipMemoryTest(boolean skipMemoryTest)
Set to true in order to skip memory leaks test. Memory leaks test is always performed by default after MagicDraw project is closed and after each completed test.- Parameters:
skipMemoryTest- true if memory test should be skipped, false otherwise.
-
setRunOnEventDispather
@OpenApi @Deprecated public final void setRunOnEventDispather(boolean runOnEventDispatcher)
Deprecated.spelling error in name, use set #setRunOnEventDispatcherSets if test case should be executed on event dispatching thread. MagicDrawTestCase is run on event dispatcher thread by default.- Parameters:
runOnEventDispatcher- True if test case should be executed on event dispatching thread.
-
setRunOnEventDispatcher
@OpenApi public final void setRunOnEventDispatcher(boolean runOnEventDispatcher)
Sets if test case should be executed on event dispatching thread. MagicDrawTestCase is run on event dispatcher thread by default.- Parameters:
runOnEventDispatcher- True if test case should be executed on event dispatching thread.
-
setDoNotUseSilentMode
@OpenApi public final void setDoNotUseSilentMode(boolean doNotUseSilentMode)
Specify if MagicDraw should show GUI modal dialogs during startup and features testing. MagicDraw is started up in silent mode by default.- Parameters:
doNotUseSilentMode- provide true value if GUI dialogs need to be shown during MagicDraw testing.
-
isDoNotUseSilentMode
@OpenApi public final boolean isDoNotUseSilentMode()
Check if silent mode is not used for starting MagicDraw. Silent mode prevents confirmation dialogs pop-up during MagicDraw test. MagicDraw is started up in silent mode by default.- Returns:
- True if MagicDraw is started in Not silent mode.
-
isMemoryTestReady
@OpenApi protected final boolean isMemoryTestReady()
Check if memory leaks test might be performed.- Returns:
- True if memory leaks test is ready and might be performed, false otherwise.
-
getRequiredPlugins
@OpenApi protected java.util.List<java.lang.String> getRequiredPlugins()
Is used to specify plug-ins required by test case. Should be overridden in specific MagicDrawTestCase implementation. Default implementation returns empty List.- Returns:
- List of plug-in IDs required by this test case.
-
getRequiredPluginsDescription
@OpenApi protected java.lang.String getRequiredPluginsDescription()
Formats textual message about available plug-ins status(loaded/enabled).- Returns:
- String message about required plug-ins status.
-
isRequiredPluginsLoaded
@OpenApi protected boolean isRequiredPluginsLoaded()
Check if all plug-ins required by this test case are loaded and enabled.- Returns:
- True if all required plug-ins are loaded and enabled, false otherwise.
-
setUpTest
@OpenApi protected void setUpTest() throws java.lang.ExceptionOverride to prepare test case after MagicDraw application started. Test set up should be done here. Do not use default JUnit setUp() instead.- Throws:
java.lang.Exception- from default JUnit setUp()
-
tearDownTest
@OpenApi protected void tearDownTest() throws java.lang.ExceptionTear down test case after it execution. This method is called after test method execution completed but MagicDraw Application not closed yet. Test tear down should be done here. Do not use default JUnit tearDown() instead.- Throws:
java.lang.Exception- from default JUnit tearDown()
-
closeProject
@OpenApi public void closeProject(Project project)
Close opened MagicDraw project. Performs memory leaks test after project is closed, so all references to the elements of the closed project should be disposed before method execution.- Parameters:
project- MagicDraw Project to close.
-
closeAllProjects
@OpenApi public void closeAllProjects()
Close all currently opened MagicDraw projects with performing memory leaks test. All references to the elements of the closed projects should be disposed before method execution.
-
checkMemoryLeaks
@OpenApi protected void checkMemoryLeaks()
Force memory leaks test execution.
-
invokeAndWaitOnDispatcher
@OpenApi public static void invokeAndWaitOnDispatcher(java.lang.Runnable r)
Executes runnable on dispatcher thread and waits till runnable is done.- Parameters:
r- Runnable to execute.
-
getPropertiesFile
@OpenApi public static java.io.File getPropertiesFile(java.io.File projectFile)
Computes test case specific properties file according given project file. MagicDraw Project properties file pattern "project_name.properties".- Parameters:
projectFile- project file- Returns:
- test case properties file
-
getXmlFile
@OpenApi public static java.io.File getXmlFile(java.io.File projectFile)
Computes test case specific properties file according given project file. MagicDraw Project properties file pattern "project_name.xml".- Parameters:
projectFile- project file- Returns:
- test case properties file
-
getFileWithExtension
@OpenApi public static java.io.File getFileWithExtension(java.io.File projectFile, java.lang.String extension)Computes test case specific properties file according given project file. MagicDraw Project properties file pattern "project_name.[extension]".- Parameters:
projectFile- project file- Returns:
- test case properties file
-
loadProject
@OpenApi public static Project loadProject(java.lang.String file)
Opens MagicDraw project by absolute project file name.- Parameters:
file- absolute file name of project to open.- Returns:
- Opened project.
-
loadProject
@OpenApi public static Project loadProject(java.lang.String projectPath, boolean failIfProjectHasErrors)
Opens MagicDraw project by absolute project file name.- Parameters:
projectPath- absolute file name of project to open.failIfProjectHasErrors- Specifies if test should fail if loaded project has any model inconsistency errors. Recommended to run with silentMode turned on.- Returns:
- Opened project.
-
loadProject
@OpenApi public static Project loadProject(java.lang.String projectPath, boolean failIfProjectHasErrors, boolean loadAllDiagrams)
Opens MagicDraw project by absolute project file name.- Parameters:
projectPath- absolute file name of project to open.failIfProjectHasErrors- Specifies if test should fail if loaded project has any model inconsistency errors. Recommended to run with silentMode turned on.- Returns:
- Opened project.
-
getLogger
@OpenApi protected org.apache.log4j.Logger getLogger()
Gets logger for Test related output logging.- Returns:
- log4j Logger for TEST category.
- See Also:
Logger
-
isFailed
@OpenApi public boolean isFailed()
Check if test has failed because of JUnit assertion or any other exception.- Returns:
- True if this test has failed, false otherwise.
-
createProjectComparator
@OpenApi protected ProjectsComparator createProjectComparator(@CheckForNull java.lang.String logText)
Creates project comparator with default model and diagram comparators implementation. Comparator does not compare projects regarding their modules, author information, and diagram info data.- Parameters:
logText- information message which should be printed to log at the beginning of comparison.- Returns:
- new instance of ProjectsComparator with model and diagrams comparators initialized.
-
openProject
@OpenApi protected Project openProject(java.lang.String projectFile)
Opens MagicDraw project by its absolute file name. It reopens the project if project is already opened.- Parameters:
projectFile- absolute file name of project to open.- Returns:
- opened project or null if project cannot be opened.
-
openProject
@OpenApi protected Project openProject(java.lang.String projectFile, boolean loadAllDiagram)
Opens MagicDraw project by its absolute file name. It reopens the project if project is already opened.- Parameters:
projectFile- absolute file name of project to open.loadAllDiagram- load content of all diagrams in the opened project- Returns:
- opened project or null if project cannot be opened.
-
saveProject
@OpenApi protected void saveProject(Project project, java.io.File file)
Save opened MagicDraw project to specific file. S Save is done ins silent mode without any GUI confirmation messages.- Parameters:
project- MagicDraw opened project to save.file- File to save project.
-
-