|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase atg.test.AtgDustCase
public class AtgDustCase
Replacement base class for AtgDustTestCase
. Extend this class and use
the following 'pattern' whenever you want to junit test some atg components:
copyConfigurationFiles(String[], String, String...)
.
The staging directory will automatically be used as the configuration
directory. Copying all needed priorities to a location outside of the source
tree is the preferred method, because this frameworks creates properties on
the fly and that could pollute your current source tree.prepareRepository(String, String...)
for
testing against an default in-memory hsql database or
AtgDustCase#prepareRepository(String, Properties, boolean, String...)
for testing against an existing database.Example usage can be found in test.SongsRepositoryTest.
This class overrides Junit 3 and not Junit 4 because currently Junit 4 has some test runner/eclipse related bugs which makes it impossible for me to use it.
Field Summary | |
---|---|
static java.io.File |
GLOBAL_FORCE_SER
|
static java.io.File |
TIMESTAMP_SER
|
Constructor Summary | |
---|---|
AtgDustCase()
|
Method Summary | |
---|---|
protected void |
copyConfigurationFiles(java.lang.String[] srcDirs,
java.lang.String dstDir,
java.lang.String... excludes)
Every *.properties file copied using this method will have it's scope (if one is available) set to global. |
protected void |
createPropertyFile(java.lang.String configurationStagingLocation,
java.lang.String nucleusComponentPath,
java.lang.Class<?> clazz)
|
protected void |
manageConfigurationFiles(java.util.Properties properties)
Donated by Remi Dupuis |
protected void |
prepareRepository(java.lang.String repositoryPath,
java.util.Properties connectionProperties,
boolean dropTables,
boolean createTables,
java.lang.String... definitionFiles)
Prepares a test against an existing database. |
protected void |
prepareRepository(java.lang.String repoPath,
java.lang.String... definitionFiles)
Prepares a test against an default in-memory hsql database. |
protected java.lang.Object |
resolveNucleusComponent(java.lang.String nucleusComponentPath)
Method for retrieving a fully injected atg component |
protected void |
setConfigurationLocation(java.lang.String configurationLocation)
Call this method to set the configuration location. |
protected void |
setDebug(boolean isDebug)
Enables or disables the debug level of nucleus components. |
protected void |
tearDown()
Always make sure to call this because it will do necessary clean up actions (shutting down in-memory database (if it was used) and the nucleus) so he next test can run safely. |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, toString |
Methods inherited from class junit.framework.Assert |
---|
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, fail, fail, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.io.File TIMESTAMP_SER
public static final java.io.File GLOBAL_FORCE_SER
Constructor Detail |
---|
public AtgDustCase()
Method Detail |
---|
protected final void copyConfigurationFiles(java.lang.String[] srcDirs, java.lang.String dstDir, java.lang.String... excludes) throws java.io.IOException
srcDirs
- One or more directories containing needed configuration files.dstDir
- where to copy the above files to. This will also be the
configuration location.excludes
- One or more directories not to include during the copy
process. Use this one to speeds up the test cycle
considerably. You can also call it with an empty
String[]
or null
if nothing should be
excluded
java.io.IOException
- Whenever some file related error's occur.protected final void manageConfigurationFiles(java.util.Properties properties) throws java.io.IOException
properties
-
java.io.IOException
protected final void createPropertyFile(java.lang.String configurationStagingLocation, java.lang.String nucleusComponentPath, java.lang.Class<?> clazz) throws java.io.IOException
configurationStagingLocation
- The location where the property file should be created. This
will also set the configurationLocation
.nucleusComponentPath
- Nucleus component path (e.g /Some/Service/Impl).clazz
- The Class
implementing the nucleus component specified
in previous argument.
java.io.IOException
- If we have some File related errorsprotected final void prepareRepository(java.lang.String repoPath, java.lang.String... definitionFiles) throws java.sql.SQLException, java.io.IOException
repoPath
- the nucleus component path of the repository to be tested.definitionFiles
- one or more repository definition files.
java.io.IOException
- The moment we have some properties/configuration related
error
java.sql.SQLException
- Whenever there is a database related errorprotected final void prepareRepository(java.lang.String repositoryPath, java.util.Properties connectionProperties, boolean dropTables, boolean createTables, java.lang.String... definitionFiles) throws java.sql.SQLException, java.io.IOException
repositoryPath
- The the repository to be tested, specified as nucleus
component path.connectionProperties
- A Properties
instance with the following values (in
this example the properties are geared towards an mysql
database):
final Properties properties = new Properties(); properties.put("driver", "com.mysql.jdbc.Driver"); properties.put("url", "jdbc:mysql://localhost:3306/someDb"); properties.put("user", "someUserName"); properties.put("password", "somePassword");
dropTables
- If true
then existing tables will be dropped and
re-created, if set to false
the existing tables
will be used.createTables
- if set to true
all non existing tables needed for
the current test run will be created, if set to
false
this class expects all needed tables for
this test run to be already createddefinitionFiles
- One or more needed repository definition files.
java.io.IOException
- The moment we have some properties/configuration related
error
java.sql.SQLException
- Whenever there is a database related errorprotected java.lang.Object resolveNucleusComponent(java.lang.String nucleusComponentPath) throws java.io.IOException
nucleusComponentPath
- Path to a nucleus component (e.g. /Some/Service/Impl).
null
if there is an error.
java.io.IOException
protected final void setConfigurationLocation(java.lang.String configurationLocation)
configurationLocation
- The configuration location to set. Most of the time this
location is a directory containing all repository definition
files and component property files which are needed for the
test.protected void tearDown() throws java.lang.Exception
tearDown
in class junit.framework.TestCase
java.lang.Exception
protected void setDebug(boolean isDebug)
isDebug
- Setting this to true
will enable debug on all
(currently only on repository related) components, setting it
to false
turn's the debug off again.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |