|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.NucleusTestUtils
public class NucleusTestUtils
NucleusTestUtils
Nested Class Summary | |
---|---|
static class |
NucleusTestUtils.NucleusStartupOptions
A class representing NucleusStartupOptions, used by startNucleusWithModules(). |
Field Summary | |
---|---|
static java.lang.String |
ATG_DUST_TESTCONFIG
|
static java.lang.String |
CLASS_VERSION
Class version string |
static org.apache.log4j.Logger |
log
|
static boolean |
sRemoveTempAtgServerDirectories
Whether or not to remove tempoary ATG server directories created by startNucleusWithModules(). |
Constructor Summary | |
---|---|
NucleusTestUtils()
|
Method Summary | |
---|---|
static void |
addComponent(atg.nucleus.Nucleus pNucleus,
java.lang.String pComponentPath,
java.lang.Object pComponent)
Adds the given object, pComponent to Nucleus, pNucleus at the path given by pComponentPath. |
static java.io.File |
createInitial(java.io.File pRoot,
java.util.List pInitialServices)
Creates an Initial.properties file pRoot The root directory of the configpath pInitialServices A list of initial services |
static java.io.File |
createProperties(java.lang.String pComponentName,
java.io.File pConfigDir,
java.lang.String pClass,
java.util.Properties pProps)
Creates a .properties file |
protected static java.io.File |
createTempServerDir()
Create a temporary, empty server directory. |
static int |
findFreePort()
This method returns a free port number on the current machine. |
static java.io.File |
getConfigpath(java.lang.Class pClassRelativeTo,
java.lang.String pBaseConfigDirectory)
A convenience method for returning the configpath for a test. |
static java.io.File |
getConfigpath(java.lang.Class pClassRelativeTo,
java.lang.String pBaseConfigDirectory,
boolean pCreate)
A convenience method for returning the configpath for a test. |
static java.io.File |
getConfigpath(java.lang.String pBaseConfigDirectory)
A convenience method for returning the configpath for a test. |
static java.io.File |
getConfigpath(java.lang.String pBaseConfigDirectory,
boolean pCreate)
A convenience method for returning the configpath for a test. |
static java.lang.String |
getGlobalTestConfig()
Look up the global testconfig path. |
static void |
setAbsoluteName(java.lang.String pName,
atg.nucleus.GenericService pService)
Allows the absoluteName of the given service to be explicitly defined. |
static void |
shutdownNucleus(atg.nucleus.Nucleus pNucleus)
Shutdown the specified Nucleus and try to delete the associated temporary server directory. |
static atg.nucleus.Nucleus |
startNucleus(java.io.File configpath)
Starts Nucleus using the given config directory |
static atg.nucleus.Nucleus |
startNucleus(java.lang.String pSingleConfigpathEntry)
Starts Nucleus using the given config directory |
static atg.nucleus.Nucleus |
startNucleusWithModules(NucleusTestUtils.NucleusStartupOptions pOptions)
This method starts nucleus with a config path calculated from the specified list of Dynamo modules ("DAS", "DPS", "DSS", "Publishing.base", etc). |
static atg.nucleus.Nucleus |
startNucleusWithModules(java.lang.String[] pModules,
java.lang.Class pClassRelativeTo,
java.lang.String pInitialService)
This method starts nucleus with a config path calculated from the specified list of Dynamo modules ("DAS", "DPS", "DSS", "Publishing.base", etc). |
static atg.nucleus.Nucleus |
startNucleusWithModules(java.lang.String[] pModules,
java.lang.Class pClassRelativeTo,
java.lang.String pBaseConfigDirectory,
java.lang.String pInitialService)
This method starts nucleus with a config path calculated from the specified list of Dynamo modules ("DAS", "DPS", "DSS", "Publishing.base", etc). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
public static final org.apache.log4j.Logger log
public static final java.lang.String ATG_DUST_TESTCONFIG
public static boolean sRemoveTempAtgServerDirectories
Constructor Detail |
---|
public NucleusTestUtils()
Method Detail |
---|
public static java.io.File createInitial(java.io.File pRoot, java.util.List pInitialServices) throws java.io.IOException
pRoot
- The root of the config path entry.pInitialServices
- initial services list
java.io.IOException
- if an error occurspublic static void setAbsoluteName(java.lang.String pName, atg.nucleus.GenericService pService)
pName
- The absolute name value to setpService
- The service whose absolute nameshould be set.public static void addComponent(atg.nucleus.Nucleus pNucleus, java.lang.String pComponentPath, java.lang.Object pComponent)
pNucleus
- The Nucleus instance to which the component should be addedpComponentPath
- the component path at which the component should be addedpComponent
- the component instance to addpublic static java.io.File createProperties(java.lang.String pComponentName, java.io.File pConfigDir, java.lang.String pClass, java.util.Properties pProps) throws java.io.IOException
pComponentName
- Name of the componentpConfigDir
- Name of the configuration directory. If null,
will add to the current working directory.pClass
- The class of the component (used for $class property).pProps
- Other properties of the component.
java.io.IOException
public static atg.nucleus.Nucleus startNucleus(java.io.File configpath)
configpath
- the config path directory entry
to use as the entire config path.
public static atg.nucleus.Nucleus startNucleus(java.lang.String pSingleConfigpathEntry)
pSingleConfigpathEntry
- the path name of the config path
entry to specify.
public static java.io.File getConfigpath(java.lang.String pBaseConfigDirectory)
pBaseConfigDirectory
- the base configuration directory.
public static java.io.File getConfigpath(java.lang.String pBaseConfigDirectory, boolean pCreate)
pBaseConfigDirectory
- the base configuration directory.pCreate
- whether to create the config/data subdirectory if
it does not exist.
public static java.io.File getConfigpath(java.lang.Class pClassRelativeTo, java.lang.String pBaseConfigDirectory)
The directory location is calculated as (in psuedocode):
(pClassRelativeTo's package location) + "/" + (pConfigDirectory or "data") + "/config"
This method always creates the config/data subdirectory if it does not
exist.
pClassRelativeTo
- the class whose package the config/data (or
pBaseConfigDirectory/data) should be relative in.pBaseConfigDirectory
- the base configuration directory If null, uses "config".
public static java.io.File getConfigpath(java.lang.Class pClassRelativeTo, java.lang.String pBaseConfigDirectory, boolean pCreate)
The directory location is calculated as (in psuedocode):
(pClassRelativeTo's package location) + "/" + (pConfigDirectory or "data") + "/config"
pClassRelativeTo
- the class whose package the config/data
(or pBaseConfigDirectory/data) should be relative in.pBaseConfigDirectory
- the base configuration directory If null,
uses "config".pCreate
- whether to create the config/data subdirectory if
it does not exist.
public static java.lang.String getGlobalTestConfig()
public static atg.nucleus.Nucleus startNucleusWithModules(java.lang.String[] pModules, java.lang.Class pClassRelativeTo, java.lang.String pInitialService) throws javax.servlet.ServletException
(pClassRelativeTo's package location) + "/data/" + (pClassRelativeTo's simpleClassName) + "/config"
and is only added if the directory exists.
You must specify a pInitialService
parameter, which
will be the initial service started by Nucleus (rather than the
normally Initial component, which would do a full Nucleus component
start-up).
This method also creates a temporary server directory, which is deleted when shutdownNucleus in invoked on the returned directory.
Note: If you need to start up a complete ATG instance, you should use DUST rather than a unit test.
Note: You may also wish to use a ConfigCreationFilter
. You can either set a value for
Nucleus.CREATION_FILTER_CLASS_PROPERTY_NAME
("atg.nucleus.Nucleus.creationFilterClass") as a DynamoEnv or System
property, or set the creationFilter property in Nucleus.properties in
your configuration. This allows on to block creation of referenced
components without having to make additional properties file changes.
Note 3: Nucleus's classReplacementMap can also be useful for replacing
a component instance with a subclass.
pModules
- the list of modules to use to calculate the
Nucleus configuration path.pClassRelativeTo
- the class whose name and package
will be used for the {packageName}/config/{ClassName}/data directorypInitialService
- the nucleus path of the Nucleus component
to start-up. This is a required property to prevent accidental
full start-up.
javax.servlet.ServletException
- if an error occurspublic static atg.nucleus.Nucleus startNucleusWithModules(java.lang.String[] pModules, java.lang.Class pClassRelativeTo, java.lang.String pBaseConfigDirectory, java.lang.String pInitialService) throws javax.servlet.ServletException
(pClassRelativeTo's package location) + "/data/" + (pBaseConfigDirectory or "config")
and is only added if the directory exists.
You must specify a pInitialService
parameter, which
will be the initial service started by Nucleus (rather than the
normally Initial component, which would do a full Nucleus component
start-up).
This method also creates a temporary server directory, which is deleted when shutdownNucleus in invoked on the returned directory.
Note: If you need to start up a complete ATG instance, you should use DUST rather than a unit test.
Note: You may also wish to use a ConfigCreationFilter
. You can either set a value for
Nucleus.CREATION_FILTER_CLASS_PROPERTY_NAME
("atg.nucleus.Nucleus.creationFilterClass") as a DynamoEnv or System
property, or set the creationFilter property in Nucleus.properties in
your configuration. This allows on to block creation of referenced
components without having to make additional properties file changes.
Note 3: Nucleus's classReplacementMap can also be useful for replacing
a component instance with a subclass.
pModules
- the list of modules to use to calculate the
Nucleus configuration path.pClassRelativeTo
- the class whose package the config/data
(or pBaseConfigDirectory/data) should be relative in.pBaseConfigDirectory
- the base configuration directory. If
this parameter is non-null, the relative configuration subdirectory will be
("data/" + pBaseConfigDirectory) rather than "data/config".pInitialService
- the nucleus path of the Nucleus component
to start-up. This is a required property to prevent accidental
full start-up.
javax.servlet.ServletException
- if an error occurspublic static atg.nucleus.Nucleus startNucleusWithModules(NucleusTestUtils.NucleusStartupOptions pOptions) throws javax.servlet.ServletException
(pClassRelativeTo's package location) + "/data/" + (pBaseConfigDirectory or "config")
and is only added if the directory exists.
You must specify a pInitialService
parameter, which
will be the initial service started by Nucleus (rather than the
normally Initial component, which would do a full Nucleus component
start-up).
This method also creates a temporary server directory, which is deleted when shutdownNucleus in invoked on the returned directory.
Note: If you need to start up a complete ATG instance, you should use DUST rather than a unit test.
Note: You may also wish to use a ConfigCreationFilter
. You can either set a value for
Nucleus.CREATION_FILTER_CLASS_PROPERTY_NAME
("atg.nucleus.Nucleus.creationFilterClass") as a DynamoEnv or System
property, or set the creationFilter property in Nucleus.properties in
your configuration. This allows on to block creation of referenced
components without having to make additional properties file changes.
Note 3: Nucleus's classReplacementMap can also be useful for replacing
a component instance with a subclass.
See NucleusStartupOptions for the effects of individual properties
of pOptions.
pOptions
- the startup Options for Nucleus.
javax.servlet.ServletException
- if an error occurspublic static void shutdownNucleus(atg.nucleus.Nucleus pNucleus) throws atg.nucleus.ServiceException, java.io.IOException
pNucleus
- the nucleus instance to shut down.
ServiceException
- if an error occurs
java.io.IOException
- if an error occurs (such as a failure
to remove the temporary server directory).protected static java.io.File createTempServerDir() throws java.io.IOException
java.io.IOException
- if an error occurspublic static int findFreePort()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |