atg.adapter.gsa
Class GSATestUtils

java.lang.Object
  extended by atg.adapter.gsa.GSATestUtils

public class GSATestUtils
extends java.lang.Object

A utility class to simplify testing with GSARepositories inside of junit tests.

Version:
$Revision: #28 $
Author:
adamb

Field Summary
static java.util.List<java.io.File> mFilesCreated
           
static java.lang.String sClassName
           
static java.lang.String sVersionedClassName
           
 
Constructor Summary
GSATestUtils(boolean pB)
           
 
Method Summary
protected  java.util.Map<java.lang.String,java.lang.String> additionalVersionProperties(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String pRepositoryName)
           
 void assertEmptyRepository(DBUtils dbTwo, atg.adapter.gsa.GSARepository storeRepository)
          Given a repository, and the DBUtils object used to create the connection for that Repository, this method asserts that all the tables are empty
 void cleanup()
          Deletes any files created by initializing the configpath
 void copyToConfigpath(java.io.File pConfigRoot, java.lang.String pString)
           
 void copyToConfigpath(java.io.File pConfigRoot, java.lang.String pString, java.lang.String configPath)
           
 java.io.File createClientLockManager(java.io.File pRoot)
           
static java.io.File createFakeXADataSource(java.io.File pRoot, java.util.Properties pJDBCProperties, java.lang.String pName)
           
 java.io.File createGlobal(java.io.File pRoot)
          Creates a GLOBAL.properties
 java.io.File createIdGenerator(java.io.File pRoot)
           
 void createIDGeneratorTables(DBUtils db)
          Creates the das_id_generator tables using the given database
 java.io.File createIdSpaces(java.io.File pRoot)
          Writes the idspaces.xml file
static java.io.File createJTDataSource(java.io.File pRoot)
           
static java.io.File createJTDataSource(java.io.File pRoot, java.lang.String pName, java.lang.String pFakeXAName)
          Creates a new JTDataSource component.
 java.io.File createNucleus(java.io.File pRoot)
          Creates Nucleus' Nucleus.properties
 java.io.File createRepositoryPropertiesFile(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String[] pDefinitionFiles, java.lang.String pCreateSQLAbsolutePath, java.lang.String pDropSQLAbsolutePath, java.lang.String[] pImportFiles)
          Creates a .properties file for the given repository.
 java.io.File createRepositoryPropertiesFile(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String[] pDefinitionFiles, java.lang.String pCreateSQLAbsolutePath, java.lang.String pDropSQLAbsolutePath, java.lang.String[] pImportFiles, java.lang.String pJTDataSourceName)
          Creates a .properties file for the given repository.
 java.io.File createScreenLog(java.io.File pRoot, boolean pLogging)
          Creates a ScreenLog component
 java.io.File createSQLRepositoryEventServer(java.io.File pRoot)
          Creates a SQLRepositoryEventServer
 java.io.File createTransactionManager(java.io.File pRoot)
           
 java.io.File createUserTransaction(java.io.File pRoot)
          Creates the UserTransaction component
 java.io.File createVersionRepositoryPropertiesFile(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String[] pDefinitionFiles)
          Creates a .properties file for the given repository.
 java.io.File createXMLToolsFactory(java.io.File pRoot)
           
static void dumpTable(atg.adapter.gsa.Table pTable, java.util.Collection<java.lang.String> pPrintColumnNames)
          Dump all the data from a table to the console
static void dumpTables(atg.adapter.gsa.GSARepository pRepository, java.lang.String pItemDescriptorName)
           
static atg.repository.Repository[] duplicateRepositories(atg.adapter.gsa.GSARepository[] pRepositories, javax.sql.DataSource[] pDS)
          Duplicates the given array of repositories.
static atg.repository.Repository duplicateRepository(atg.adapter.gsa.GSARepository pRepository, javax.sql.DataSource pDS)
           
static atg.repository.Repository duplicateRepository(atg.adapter.gsa.GSARepository pRepository, javax.sql.DataSource pDS, boolean pStart)
          Duplicates the given repository, binds it into nucleus with the suffix "-Shadow"
static GSATestUtils getGSATestUtils()
           
 java.lang.String[] getTableNames(atg.adapter.gsa.GSARepository pRepository)
          Returns all the tables names used for the given repository.
static GSATestUtils getVersionedGSATestUtils()
           
static void importFiles(atg.adapter.version.VersionRepository pVerRep, java.lang.String[] pImportFiles, java.lang.String pWorkspaceName, boolean pDoWithoutTransaction, java.lang.String pWorkspaceComment, boolean pCheckin)
           
 void initializeMinimalConfigpath(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String[] pDefinitionFiles, java.util.Properties pJDBCProperties, java.lang.String pCreateSQLAbsolutePath, java.lang.String pDropSQLAbsolutePath, java.lang.String[] pImportFile)
          Given a directory, pRoot, this method creates the minimal .properties files required to startup a GSA Repository from Nucleus.
 void initializeMinimalConfigpath(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String[] pDefinitionFiles, java.util.Properties pJDBCProperties, java.lang.String pCreateSQLAbsolutePath, java.lang.String pDropSQLAbsolutePath, java.lang.String[] pImportFile, boolean pLogging)
          Given a directory, pRoot, this method creates the minimal .properties files required to startup a GSA Repository from Nucleus.
 void initializeMinimalConfigpath(java.io.File pRoot, java.lang.String pRepositoryPath, java.lang.String[] pDefinitionFiles, java.util.Properties pJDBCProperties, java.lang.String pCreateSQLAbsolutePath, java.lang.String pDropSQLAbsolutePath, java.lang.String[] pImportFile, boolean pLogging, java.lang.String pFakeXADataSourceComponentName, java.lang.String pJTDataSourceComponentName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mFilesCreated

public static java.util.List<java.io.File> mFilesCreated

sClassName

public static java.lang.String sClassName

sVersionedClassName

public static java.lang.String sVersionedClassName
Constructor Detail

GSATestUtils

public GSATestUtils(boolean pB)
Parameters:
pB -
Method Detail

duplicateRepositories

public static atg.repository.Repository[] duplicateRepositories(atg.adapter.gsa.GSARepository[] pRepositories,
                                                                javax.sql.DataSource[] pDS)
                                                         throws atg.nucleus.ServiceException
Duplicates the given array of repositories. This method first binds the repositories into nucleus under the name XXXX-Shadow, where XXXX is the original name. After all repositories are bound, then they are started. This allows for repositories with circular references to each other to be deplicated. The pRepositories array and pDS array should be in sync. That is the first item in the repository array, pRepositories, will use the first data source in the pDS array and so on.

Parameters:
pRepositories -
pDS -
Returns:
Throws:
atg.nucleus.ServiceException

duplicateRepository

public static atg.repository.Repository duplicateRepository(atg.adapter.gsa.GSARepository pRepository,
                                                            javax.sql.DataSource pDS)
                                                     throws atg.nucleus.ServiceException
Throws:
atg.nucleus.ServiceException

duplicateRepository

public static atg.repository.Repository duplicateRepository(atg.adapter.gsa.GSARepository pRepository,
                                                            javax.sql.DataSource pDS,
                                                            boolean pStart)
                                                     throws atg.nucleus.ServiceException
Duplicates the given repository, binds it into nucleus with the suffix "-Shadow"

Parameters:
pStart - If true, also starts the repository
Throws:
atg.nucleus.ServiceException

initializeMinimalConfigpath

public void initializeMinimalConfigpath(java.io.File pRoot,
                                        java.lang.String pRepositoryPath,
                                        java.lang.String[] pDefinitionFiles,
                                        java.util.Properties pJDBCProperties,
                                        java.lang.String pCreateSQLAbsolutePath,
                                        java.lang.String pDropSQLAbsolutePath,
                                        java.lang.String[] pImportFile)
                                 throws java.io.IOException,
                                        java.lang.Exception
Given a directory, pRoot, this method creates the minimal .properties files required to startup a GSA Repository from Nucleus. The pJDBCProperties parameter should contain the JDBC properties used to create a FakeXADataSource. Required Properties are: driver URL user password For example, driver=solid.jdbc.SolidDriver URL=jdbc:solid://localhost:1313 user=admin password=admin
One should call the cleanup() method to remove any files created by this method call.

Parameters:
pRoot - The root directory of the testing configpath
pRepositoryPath - The Nucleus path of your testing repository
pDefinitionFiles - Array of Nucleus paths to definition files
pJDBCProperties - properties object containing JDBC connection information
pImportFile -
Throws:
java.io.IOException
java.lang.Exception
See Also:
GSATestUtils.cleanup

initializeMinimalConfigpath

public void initializeMinimalConfigpath(java.io.File pRoot,
                                        java.lang.String pRepositoryPath,
                                        java.lang.String[] pDefinitionFiles,
                                        java.util.Properties pJDBCProperties,
                                        java.lang.String pCreateSQLAbsolutePath,
                                        java.lang.String pDropSQLAbsolutePath,
                                        java.lang.String[] pImportFile,
                                        boolean pLogging)
                                 throws java.io.IOException,
                                        java.lang.Exception
Given a directory, pRoot, this method creates the minimal .properties files required to startup a GSA Repository from Nucleus. The pJDBCProperties parameter should contain the JDBC properties used to create a FakeXADataSource. Required Properties are: driver URL user password For example, driver=solid.jdbc.SolidDriver URL=jdbc:solid://localhost:1313 user=admin password=admin
One should call the cleanup() method to remove any files created by this method call.

Parameters:
pRoot - The root directory of the testing configpath
pRepositoryPath - The Nucleus path of your testing repository
pDefinitionFiles - Array of Nucleus paths to definition files
pJDBCProperties - properties object containing JDBC connection information
pImportFile -
pLogging - if true log to stdout, else logging is disabled
Throws:
java.io.IOException
java.lang.Exception
See Also:
GSATestUtils.cleanup

initializeMinimalConfigpath

public void initializeMinimalConfigpath(java.io.File pRoot,
                                        java.lang.String pRepositoryPath,
                                        java.lang.String[] pDefinitionFiles,
                                        java.util.Properties pJDBCProperties,
                                        java.lang.String pCreateSQLAbsolutePath,
                                        java.lang.String pDropSQLAbsolutePath,
                                        java.lang.String[] pImportFile,
                                        boolean pLogging,
                                        java.lang.String pFakeXADataSourceComponentName,
                                        java.lang.String pJTDataSourceComponentName)
                                 throws java.io.IOException,
                                        java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception

cleanup

public void cleanup()
Deletes any files created by initializing the configpath


createIdSpaces

public java.io.File createIdSpaces(java.io.File pRoot)
                            throws java.io.IOException
Writes the idspaces.xml file

Throws:
java.io.IOException

createNucleus

public java.io.File createNucleus(java.io.File pRoot)
                           throws java.io.IOException
Creates Nucleus' Nucleus.properties

Throws:
java.io.IOException

createFakeXADataSource

public static java.io.File createFakeXADataSource(java.io.File pRoot,
                                                  java.util.Properties pJDBCProperties,
                                                  java.lang.String pName)
                                           throws java.io.IOException
Throws:
java.io.IOException

createJTDataSource

public static java.io.File createJTDataSource(java.io.File pRoot)
                                       throws java.io.IOException
Parameters:
pRoot -
Throws:
java.io.IOException

createJTDataSource

public static java.io.File createJTDataSource(java.io.File pRoot,
                                              java.lang.String pName,
                                              java.lang.String pFakeXAName)
                                       throws java.io.IOException
Creates a new JTDataSource component. The name of the component may be specified by passing in a non null value for pName. Also the name of the FakeXADataSource may be specified by passing in a non null name. Otherwise the defaults are JTDataSource and FakeXADataSource.

Parameters:
pRoot -
pName -
pFakeXAName -
Returns:
Throws:
java.io.IOException

createSQLRepositoryEventServer

public java.io.File createSQLRepositoryEventServer(java.io.File pRoot)
                                            throws java.io.IOException
Creates a SQLRepositoryEventServer

Parameters:
pRoot -
Returns:
Throws:
java.io.IOException

createScreenLog

public java.io.File createScreenLog(java.io.File pRoot,
                                    boolean pLogging)
                             throws java.io.IOException
Creates a ScreenLog component

Parameters:
pRoot -
pLogging - TODO
Returns:
Throws:
java.io.IOException

createGlobal

public java.io.File createGlobal(java.io.File pRoot)
                          throws java.io.IOException
Creates a GLOBAL.properties

Parameters:
pRoot -
pJDBCProperties -
Returns:
Throws:
java.io.IOException

createClientLockManager

public java.io.File createClientLockManager(java.io.File pRoot)
                                     throws java.io.IOException
Parameters:
pRoot -
Throws:
java.io.IOException

createIdGenerator

public java.io.File createIdGenerator(java.io.File pRoot)
                               throws java.io.IOException
Parameters:
pRoot -
Throws:
java.io.IOException

createXMLToolsFactory

public java.io.File createXMLToolsFactory(java.io.File pRoot)
                                   throws java.io.IOException
Parameters:
pRoot -
Throws:
java.io.IOException

createTransactionManager

public java.io.File createTransactionManager(java.io.File pRoot)
                                      throws java.io.IOException
Parameters:
pRoot -
Throws:
java.io.IOException

createUserTransaction

public java.io.File createUserTransaction(java.io.File pRoot)
                                   throws java.io.IOException
Creates the UserTransaction component

Throws:
java.io.IOException

createRepositoryPropertiesFile

public java.io.File createRepositoryPropertiesFile(java.io.File pRoot,
                                                   java.lang.String pRepositoryPath,
                                                   java.lang.String[] pDefinitionFiles,
                                                   java.lang.String pCreateSQLAbsolutePath,
                                                   java.lang.String pDropSQLAbsolutePath,
                                                   java.lang.String[] pImportFiles)
                                            throws java.io.IOException
Creates a .properties file for the given repository. The actual repository implementation is a atg.adapter.gsa.InitializingGSA class. This implementation is used instead because it has the ability to create tables and import data before the repository starts.

Parameters:
pRoot -
pRepositoryPath -
pDefinitionFiles -
pSQLAbsolutePath -
pDropSQLAbsolutePath -
pImportFiles -
Throws:
java.io.IOException

createRepositoryPropertiesFile

public java.io.File createRepositoryPropertiesFile(java.io.File pRoot,
                                                   java.lang.String pRepositoryPath,
                                                   java.lang.String[] pDefinitionFiles,
                                                   java.lang.String pCreateSQLAbsolutePath,
                                                   java.lang.String pDropSQLAbsolutePath,
                                                   java.lang.String[] pImportFiles,
                                                   java.lang.String pJTDataSourceName)
                                            throws java.io.IOException
Creates a .properties file for the given repository. The actual repository implementation is a atg.adapter.gsa.InitializingGSA class. This implementation is used instead because it has the ability to create tables and import data before the repository starts.

Parameters:
pRoot -
pRepositoryPath -
pDefinitionFiles -
pSQLAbsolutePath -
pDropSQLAbsolutePath -
pImportFiles -
Throws:
java.io.IOException

additionalVersionProperties

protected java.util.Map<java.lang.String,java.lang.String> additionalVersionProperties(java.io.File pRoot,
                                                                                       java.lang.String pRepositoryPath,
                                                                                       java.lang.String pRepositoryName)
                                                                                throws java.io.IOException
Parameters:
pRoot -
pRepositoryPath -
pRepositoryName -
Returns:
Throws:
java.io.IOException

copyToConfigpath

public void copyToConfigpath(java.io.File pConfigRoot,
                             java.lang.String pString)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Parameters:
prop -
Throws:
java.io.FileNotFoundException
java.io.IOException

copyToConfigpath

public void copyToConfigpath(java.io.File pConfigRoot,
                             java.lang.String pString,
                             java.lang.String configPath)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Parameters:
prop -
configPath - where in config path the file must be copied.
Throws:
java.io.FileNotFoundException
java.io.IOException

createVersionRepositoryPropertiesFile

public java.io.File createVersionRepositoryPropertiesFile(java.io.File pRoot,
                                                          java.lang.String pRepositoryPath,
                                                          java.lang.String[] pDefinitionFiles)
                                                   throws java.io.IOException
Creates a .properties file for the given repository. The actual repository implementation is a atg.adapter.gsa.InitializingGSA class. This implementation is used instead because it has the ability to create tables and import data before the repository starts.

Parameters:
pRoot -
pRepositoryPath -
pDefinitionFiles -
Throws:
java.io.IOException

getTableNames

public java.lang.String[] getTableNames(atg.adapter.gsa.GSARepository pRepository)
                                 throws java.lang.Exception
Returns all the tables names used for the given repository.

Throws:
java.lang.Exception

assertEmptyRepository

public void assertEmptyRepository(DBUtils dbTwo,
                                  atg.adapter.gsa.GSARepository storeRepository)
                           throws java.lang.Exception,
                                  java.sql.SQLException
Given a repository, and the DBUtils object used to create the connection for that Repository, this method asserts that all the tables are empty

Parameters:
dbTwo -
storeRepository -
Throws:
java.lang.Exception
java.sql.SQLException

createIDGeneratorTables

public void createIDGeneratorTables(DBUtils db)
                             throws java.sql.SQLException
Creates the das_id_generator tables using the given database

Parameters:
db -
Throws:
java.sql.SQLException

importFiles

public static void importFiles(atg.adapter.version.VersionRepository pVerRep,
                               java.lang.String[] pImportFiles,
                               java.lang.String pWorkspaceName,
                               boolean pDoWithoutTransaction,
                               java.lang.String pWorkspaceComment,
                               boolean pCheckin)
                        throws atg.versionmanager.exceptions.VersionException
Parameters:
pVerRep -
pImportFiles -
pWorkspaceName -
pDoWithoutTransaction -
pWorkspaceComment -
Throws:
atg.versionmanager.exceptions.VersionException

getGSATestUtils

public static GSATestUtils getGSATestUtils()
Returns:

getVersionedGSATestUtils

public static GSATestUtils getVersionedGSATestUtils()
Returns:

dumpTable

public static void dumpTable(atg.adapter.gsa.Table pTable,
                             java.util.Collection<java.lang.String> pPrintColumnNames)
                      throws java.sql.SQLException
Dump all the data from a table to the console

Parameters:
pTable -
Throws:
java.sql.SQLException

dumpTables

public static void dumpTables(atg.adapter.gsa.GSARepository pRepository,
                              java.lang.String pItemDescriptorName)
                       throws atg.repository.RepositoryException,
                              java.sql.SQLException
Parameters:
pVersionRepository -
pString -
Throws:
atg.repository.RepositoryException
java.sql.SQLException


Copyright © 2009. All Rights Reserved.