Class 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
    • 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>
      int
      count​(Class<T> clz)
      Deprecated.
      Counts the total occurences in the database for the passed class.
      protected ConnectionProvider getConnectionProvider()
      Deprecated.
       
      protected <T extends BaseOBObject>
      T
      getOneInstance​(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 the OBPropertiesProvider.
      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 the TEST_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
      • userIds

        protected static List<User> userIds
        Deprecated.
        Record IDs of available users different than TEST_USER_ID Note: Initialized to null, need to call getRandomUser() 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 Client TEST_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
    • Constructor Detail

      • BaseTest

        public BaseTest()
        Deprecated.
    • 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 class junit.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 the OBPropertiesProvider. 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 the TEST_USER_ID user.
      • setTestAdminContext

        protected void setTestAdminContext()
        Deprecated.
        Sets the current user to the 100 user.
      • getRandomUser

        protected User getRandomUser()
        Deprecated.
        Gets a random User (Record ID) from the available ones in the test client. The ID is one different than TEST_USER_ID
        Returns:
        A record ID of a available user
      • run

        public junit.framework.TestResult run()
        Deprecated.
        Overrides:
        run in class junit.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 class junit.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 class junit.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 the SQLException.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 the OBContext) 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