|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.zmicer.utils.junit.ZmicerTestUtils
public class ZmicerTestUtils
This utility class contains functionality helping us in creating unit tests for the all kind of functionality where zmicer.utils could
be used. For now it contains the 1. functionality for obtaining resources for testing classes 2. methods for working with JVM params -
for settings the JVM params and then for restoring the default JVM params composition.
todo [zmicer]: potentially this class would be the part of the framework allowing users to deal with the configuration for the unit tests
easily.
$Author:: zmicer $
$Rev:: 70 $
* $Date:: 2007-08-29 09:09:13 #$
Nested Class Summary | |
---|---|
static interface |
ZmicerTestUtils.CommonTestCases
Common test cases to be used. |
Field Summary | |
---|---|
static String |
JUST_METHOD_NAME
Used below. please review the approptiate code. |
static org.apache.log4j.Logger |
LOG
Logger instance. |
static String |
METHOD_NAME_FOLDER_PREFIX
Used for the constructing the full name of the folder where the tests data for the concrete method of the concrete class is stored |
static Map<String,Pattern> |
TEST_BASE_FOLDER_PATTERNS
This storage is necessary for avoiding creating the patterns everytime - the method com.zmicer.utils.junit.ZmicerTestUtils#getFolderWithTestData() would put here the patterns and check if they are exist Use com.zmicer.utils.junit.ZmicerTestUtils#clearPatterns() for cleaning the set of the patterns |
static String |
TEST_DATA_FOLDER
TEST_DATA_FOLDER string |
static Pattern |
TEST_DATA_FOLDER_PATTERN
The folder where the test data is stored. |
Constructor Summary | |
---|---|
ZmicerTestUtils()
|
Method Summary | |
---|---|
static void |
clearPatterns()
Clean the current set of the patterns used for the retrieving the full name to the folder with the data for tests |
static String |
getFolderWithCommonTestData()
|
static String |
getFolderWithTestData()
Please be noticed this method is a main one for the creating unit tests basing on the environment configuration. |
static String |
getFolderWithTestData(String testDataFolderBaseName)
Study the Java Doc to the method above placed. |
static String |
getFullTestDataFileName(Class claz,
boolean considerMethodName,
String testCase,
String fileName,
boolean checkIfExists)
Get the full file name using the provided data. |
static String |
getFullTestDataFileName(String testCaseFolderName,
String fileName)
Get full file name using the test case folder and file name. |
static String |
getFullTestDataFolderName(Class claz,
boolean considerMethodName,
String testCase,
boolean checkIfExists)
Get full folder name where test data for the provided class and for the certain test case is stored. |
static String |
getFullTestDataFolderName(String testCaseFolderName)
Get full folder name using the test case folder and file name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.log4j.Logger LOG
public static final String TEST_DATA_FOLDER
public static final Pattern TEST_DATA_FOLDER_PATTERN
public static final Map<String,Pattern> TEST_BASE_FOLDER_PATTERNS
com.zmicer.utils.junit.ZmicerTestUtils#clearPatterns()
for cleaning the set of the patterns
public static final String METHOD_NAME_FOLDER_PREFIX
public static final String JUST_METHOD_NAME
Constructor Detail |
---|
public ZmicerTestUtils()
Method Detail |
---|
public static String getFolderWithTestData()
ZmicerTestUtils.TEST_DATA_FOLDER
is set to the classpath. Otherwise this method would return null
as it won't find the necessary folder.
ZmicerTestUtils.TEST_DATA_FOLDER_PATTERN
. For all the cases the check that this
directory exists is performed.
public static String getFolderWithCommonTestData()
%test data folder% + File.separator + CommonTestCases.COMMON_PROPS
public static String getFolderWithTestData(String testDataFolderBaseName)
testDataFolderBaseName
- the base name of the folder where test configurations/files and other stuff is stored.
Can not be null (otherwise IllegalArgumentException
would appear).
public static String getFullTestDataFolderName(String testCaseFolderName)
testCaseFolderName
- test case folder name. Could be null.
IllegalArgumentException
would appear).public static String getFullTestDataFileName(String testCaseFolderName, String fileName)
com.zmicer.utils.FileUtilsTest.getFolderWithTestData()
is used here.
testCaseFolderName
- test case folder name. Could be null.fileName
- file name. Can not be null (otherwise IllegalArgumentException
would appear).
public static String getFullTestDataFileName(Class claz, boolean considerMethodName, String testCase, String fileName, boolean checkIfExists)
claz
- class name should be used as the test case folder name.
Can not be null (otherwise IllegalArgumentException
would appear).considerMethodName
- says that we should construct the full file name using the assumption after the folder with test data for
class there is folder with the tests data for the method running currenctly. naming convention is "method_%id%",
%id% lis a name of the method currently running. It could be null. This param allows to organize the structures of
folders for the testing in the structure:
class base name folder/method name/test case/file name
note [zmicer]: true should be set only for the test purposes (for JPatterns test engine allowing to setup the
props/xml environment per the folders)testCase
- the test case for the certain class - the concept is: each classes could have lots of tests cases where the
the different sets of configuration for the tests is stored. E.g. above mentioned
***\testdata\ZmicerTestUtilsTest could store folders "case1", "case2" etc. This param could be
null. In that case we would consider the the root forlder (for ZmicerTestUtilsTest it is mentioned
***\testdata\ZmicerTestUtilsTest folder)fileName
- file name to be used
Can not be null (otherwise IllegalArgumentException
would appear).checkIfExists
- makes the check if resource is exists.
public static String getFullTestDataFolderName(Class claz, boolean considerMethodName, String testCase, boolean checkIfExists)
claz
- Class for which we would search for folder with the test data. In the case of ZmicerTestUtilsTest
class
this folder would be ***\testdata\ZmicerTestUtilsTest where *** is a file system specific path to
the the test data folder where all the test data is stored.
Can not be null (otherwise IllegalArgumentException
would appear).considerMethodName
- says that we should construct the full file name using the assumption after the folder with test data for
class there is folder with the tests data for the method running currenctly. naming convention is "method_%id%",
%id% lis a name of the method currently running. It could be null. This param allows to organize the structures of
folders for the testing in the structure:
class base name folder/method name/test case/file name
note [zmicer]: true should be set only for the test purposes (for JPatterns test engine allowing to setup the
props/xml environment per the folders)testCase
- the test case for the certain class - the concept is: each classes could have lots of tests cases where the
the different sets of configuration for the tests is stored. E.g. above mentioned
***\testdata\ZmicerTestUtilsTest could store folders "case1", "case2" etc. This param could be
null. In that case we would consider the the root forlder (for ZmicerTestUtilsTest it is mentioned
***\testdata\ZmicerTestUtilsTest folder)checkIfExists
- makes the check if resource is exists.
public static void clearPatterns()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |