Package org.openbravo.test.base
Class BaseTest
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- org.openbravo.test.base.BaseTest
-
- All Implemented Interfaces:
junit.framework.Test
@Deprecated public class BaseTest extends junit.framework.TestCase
Deprecated.BaseTest class is deprecated. All test case that works with old notation, will be working normally. Any new test case will be linked to OBBaseTest that handles all the necessary steps to initialize the Data Access Layer from now.- Author:
- mtaal, iperdomo
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
QA_TEST_ADMIN_USER_ID
Deprecated.Record ID of the "Admin" user of QA Test clientprotected static String
QA_TEST_CLIENT_ID
Deprecated.Record ID of the QA Test clientprotected static String
QA_TEST_ORG_ID
Deprecated.Record ID of the Main organization of QA Test clientprotected static String
TEST_BP_CATEGORY_ID
Deprecated.Record ID of the "Customer" Business Partner Categoryprotected static String
TEST_CLIENT_ID
Deprecated.Record ID of Client "F&B International Group"protected static String
TEST_LOCATION_ID
Deprecated.Record ID of the geographical location "c\ de la Costa 54, San Sebastián 12784"protected static String
TEST_ORDER_ID
Deprecated.Record ID of a Order in Draft statusprotected static String
TEST_ORG_ID
Deprecated.Record ID of Organization "F&B España - Región Norte"protected static Map<String,String[]>
TEST_ORG_TREE
Deprecated.Map representation of current Organization tree for ClientTEST_CLIENT_ID
protected static String
TEST_PRODUCT_ID
Deprecated.Record ID of Product "Zumo de Fresa Bio 0,33L"protected static String
TEST_ROLE_ID
Deprecated.Record ID of Role "F&B International Group Admin"protected static String
TEST_US_ORG_ID
Deprecated.Record ID of Organization "F&B US West Coast"protected static String
TEST_USER_ID
Deprecated.Record ID of User "F&BAdmin"protected static String
TEST_WAREHOUSE_ID
Deprecated.Record ID of Warehouse "España Región Norte"protected static String
TEST2_USER_ID
Deprecated.Record ID of User "F&BESRNUser" - Any user with less privileges thanTEST_USER_ID
protected static List<User>
userIds
Deprecated.Record IDs of available users different thanTEST_USER_ID
Note: Initialized to null, need to callgetRandomUser()
at least once
-
Constructor Summary
Constructors Constructor Description BaseTest()
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addReadWriteAccess(Class<?> clz)
Deprecated.Extends the read and write access of the current user to also include the passed class.void
commitTransaction()
Deprecated.Commits the transaction to the database.protected <T extends BaseOBObject>
intcount(Class<T> clz)
Deprecated.Counts the total occurences in the database for the passed class.protected ConnectionProvider
getConnectionProvider()
Deprecated.protected <T extends BaseOBObject>
TgetOneInstance(Class<T> clz)
Deprecated.Convenience method, gets an instance for the passed Class from the database.protected User
getRandomUser()
Deprecated.Gets a random User (Record ID) from the available ones in the test client.protected void
initializeDalLayer()
Deprecated.Initializes the DALLayer, can be overridden to add specific initialization behavior.boolean
isErrorOccured()
Deprecated.protected void
reportException(Exception e)
Deprecated.Prints the stacktrace of the exception to System.err.void
rollback()
Deprecated.Does a rollback of the transaction;junit.framework.TestResult
run()
Deprecated.void
runTest()
Deprecated.Overridden to keep track if an exception was thrown, if not then errorOccurred is set to false, signaling to tearDown to commit the transaction.protected void
setBigBazaarAdminContext()
Deprecated.protected void
setBigBazaarUserContext()
Deprecated.protected void
setConfigPropertyFiles()
Deprecated.Behavior has been implemented in theOBPropertiesProvider
.void
setErrorOccured(boolean errorOccured)
Deprecated.protected void
setSystemAdministratorContext()
Deprecated.Set the current user to the 0 user.protected void
setTestAdminContext()
Deprecated.Sets the current user to the 100 user.protected void
setTestUserContext()
Deprecated.Sets the current user to theTEST_USER_ID
user.protected void
setUp()
Deprecated.Overridden to initialize the Dal layer, sets the current user to the the User:TEST_USER_ID
protected void
setUserContext(String userId)
Deprecated.Sets the current user.protected void
tearDown()
Deprecated.Performs rolling back of a transaction (in case setTestCompleted was not called by the subclass), or commits the transaction if the testcase passed without exception.-
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
-
-
-
-
Field Detail
-
TEST_CLIENT_ID
protected static final String TEST_CLIENT_ID
Deprecated.Record ID of Client "F&B International Group"- See Also:
- Constant Field Values
-
TEST_ORG_ID
protected static final String TEST_ORG_ID
Deprecated.Record ID of Organization "F&B España - Región Norte"- See Also:
- Constant Field Values
-
TEST_US_ORG_ID
protected static final String TEST_US_ORG_ID
Deprecated.Record ID of Organization "F&B US West Coast"- See Also:
- Constant Field Values
-
TEST_WAREHOUSE_ID
protected static final String TEST_WAREHOUSE_ID
Deprecated.Record ID of Warehouse "España Región Norte"- See Also:
- Constant Field Values
-
TEST_USER_ID
protected static final String TEST_USER_ID
Deprecated.Record ID of User "F&BAdmin"- See Also:
- Constant Field Values
-
TEST2_USER_ID
protected static final String TEST2_USER_ID
Deprecated.Record ID of User "F&BESRNUser" - Any user with less privileges thanTEST_USER_ID
- See Also:
- Constant Field Values
-
userIds
protected static List<User> userIds
Deprecated.Record IDs of available users different thanTEST_USER_ID
Note: Initialized to null, need to callgetRandomUser()
at least once
-
TEST_ROLE_ID
protected static final String TEST_ROLE_ID
Deprecated.Record ID of Role "F&B International Group Admin"- See Also:
- Constant Field Values
-
TEST_ORDER_ID
protected static final String TEST_ORDER_ID
Deprecated.Record ID of a Order in Draft status- See Also:
- Constant Field Values
-
TEST_PRODUCT_ID
protected static final String TEST_PRODUCT_ID
Deprecated.Record ID of Product "Zumo de Fresa Bio 0,33L"- See Also:
- Constant Field Values
-
TEST_ORG_TREE
protected static Map<String,String[]> TEST_ORG_TREE
Deprecated.Map representation of current Organization tree for ClientTEST_CLIENT_ID
-
QA_TEST_CLIENT_ID
protected static final String QA_TEST_CLIENT_ID
Deprecated.Record ID of the QA Test client- See Also:
- Constant Field Values
-
QA_TEST_ORG_ID
protected static final String QA_TEST_ORG_ID
Deprecated.Record ID of the Main organization of QA Test client- See Also:
- Constant Field Values
-
QA_TEST_ADMIN_USER_ID
protected static final String QA_TEST_ADMIN_USER_ID
Deprecated.Record ID of the "Admin" user of QA Test client- See Also:
- Constant Field Values
-
TEST_BP_CATEGORY_ID
protected static final String TEST_BP_CATEGORY_ID
Deprecated.Record ID of the "Customer" Business Partner Category- See Also:
- Constant Field Values
-
TEST_LOCATION_ID
protected static final String TEST_LOCATION_ID
Deprecated.Record ID of the geographical location "c\ de la Costa 54, San Sebastián 12784"- See Also:
- Constant Field Values
-
-
Method Detail
-
setUp
protected void setUp() throws Exception
Deprecated.Overridden to initialize the Dal layer, sets the current user to the the User:TEST_USER_ID
- Overrides:
setUp
in classjunit.framework.TestCase
- Throws:
Exception
-
initializeDalLayer
protected void initializeDalLayer() throws Exception
Deprecated.Initializes the DALLayer, can be overridden to add specific initialization behavior.- Throws:
Exception
-
getConnectionProvider
protected ConnectionProvider getConnectionProvider()
Deprecated.
-
setConfigPropertyFiles
@Deprecated protected void setConfigPropertyFiles()
Deprecated.Behavior has been implemented in theOBPropertiesProvider
. Is now done automatically when initializing the DAL layer.Reads the configuration properties from the property files.
-
setSystemAdministratorContext
protected void setSystemAdministratorContext()
Deprecated.Set the current user to the 0 user.
-
setBigBazaarAdminContext
@Deprecated protected void setBigBazaarAdminContext()
Deprecated.
-
setBigBazaarUserContext
@Deprecated protected void setBigBazaarUserContext()
Deprecated.
-
setTestUserContext
protected void setTestUserContext()
Deprecated.Sets the current user to theTEST_USER_ID
user.
-
setTestAdminContext
protected void setTestAdminContext()
Deprecated.Sets the current user to the 100 user.
-
setUserContext
protected void setUserContext(String userId)
Deprecated.Sets the current user. For the 0, 100 and 1000000 users this method should not be used. For these users one of the other context-set methods should be used:setTestAdminContext()
,setTestUserContext()
orsetSystemAdministratorContext()
.- Parameters:
userId
- the id of the user to use.
-
getRandomUser
protected User getRandomUser()
Deprecated.Gets a random User (Record ID) from the available ones in the test client. The ID is one different thanTEST_USER_ID
- Returns:
- A record ID of a available user
-
run
public junit.framework.TestResult run()
Deprecated.- Overrides:
run
in classjunit.framework.TestCase
-
runTest
public void runTest() throws Throwable
Deprecated.Overridden to keep track if an exception was thrown, if not then errorOccurred is set to false, signaling to tearDown to commit the transaction.- Overrides:
runTest
in classjunit.framework.TestCase
- Throws:
Throwable
-
tearDown
protected void tearDown() throws Exception
Deprecated.Performs rolling back of a transaction (in case setTestCompleted was not called by the subclass), or commits the transaction if the testcase passed without exception.- Overrides:
tearDown
in classjunit.framework.TestCase
- Throws:
Exception
-
reportException
protected void reportException(Exception e)
Deprecated.Prints the stacktrace of the exception to System.err. Handles the case that the exception is a SQLException which has the real causing exception in theSQLException.getNextException()
method.- Parameters:
e
- the exception to report.
-
isErrorOccured
public boolean isErrorOccured()
Deprecated.
-
rollback
public void rollback()
Deprecated.Does a rollback of the transaction;
-
commitTransaction
public void commitTransaction()
Deprecated.Commits the transaction to the database.
-
setErrorOccured
@Deprecated public void setErrorOccured(boolean errorOccured)
Deprecated.Deprecated, no need to call this method explicitly anymore. The BaseTest class overrides the runTest method which sets the internal flag, overriding any value passed in this method.- Parameters:
errorOccured
-
-
getOneInstance
protected <T extends BaseOBObject> T getOneInstance(Class<T> clz)
Deprecated.Convenience method, gets an instance for the passed Class from the database. If there are no records for that class then an exception is thrown. If there is more than one result then an arbitrary instance is returned (the first one in the un-ordered resultset).- Type Parameters:
T
- the specific class to query for.- Parameters:
clz
- instances- Returns:
- an instance of clz.
-
addReadWriteAccess
protected void addReadWriteAccess(Class<?> clz)
Deprecated.Extends the read and write access of the current user to also include the passed class. This can be used to circumvent restrictive access which is not usefull for the test itself.- Parameters:
clz
- after this call the current user (in theOBContext
) will have read/write access to this class.
-
count
protected <T extends BaseOBObject> int count(Class<T> clz)
Deprecated.Counts the total occurences in the database for the passed class. Note that active, client and organization filtering applies.- Type Parameters:
T
- a class type parameter- Parameters:
clz
- the class to count occurences for- Returns:
- the number of occurences which are active and belong to the current client/organization
-
-