Skip to content

Building the project from the source code

wmuron edited this page Sep 5, 2016 · 2 revisions

Building the project

The project consists of three main parts: the fixes for different entity mapping method and Hibernate versions, their testing modules and the utility classes for JPA.

DbAssistBuilder (root)

    DbAssist-4.2.21        |
    DbAssist-4.3.11        |
    ...                    | 
    DbAssist-5.2.2         } fixes
    DbAssist-hbm-3.3.2     |
    DbAssist-hbm-3.6.10    |


    DbAssist-test-commons  |
    DbAssist-hbm-tester    } testing modules
    DbAssist-jpa-tester    |


    DbAssist-jpa-commons   | utility classes ConditionsBuilder, AbstractRepository etc.
    

The project DbAssist-test-commons contains the shared code between two fixes (for annotations and .hbm files) and also uses Liquibase plugin to automatically setup the SQL test database with proper tables and fields, so that the unit tests can be run.

Step-by-step instruction

1. Set up a local database

The unit tests in DbAssist project use the external DB to test its functionality. Therefore you have to set it up before running them.

1.1 Create an empty database

Also make sure the user assigned to this database has read/write access.

1.2 Install a JDBC driver

Most JDBC drivers can be installed by simply adding an appropriate dependency into a pom file of DbAssist-test-commons project.

The exception is Microsoft JDBC driver which has to be installed manually. You can download it from the following link: https://www.microsoft.com/en-us/download/details.aspx?id=11774

1.3 Set up the project to work with the local database

Change the pom file in DbAssist-test-commons to use the correct JDBC driver corresponding to your installed DB.

Then update the following files with the current DB credentials, driver and url settings:

  • DbAssist-test-commons\src\main\resources\liquibase.properties (for creating schemas and tables)
  • DbAssist-hbm-tester\src\main\resources\hibernate.cfg.xml (for HBM test cases)
  • DbAssist-jpa-tester\src\test\resources\config\application.properties (for Spring settings in JPA testers)

The current configuration is set up to work with Microsoft SQL Server.

2. Set up Maven

Add mvn to the PATH environmental variable and run mvn -v from command line in order to verify it is set up correctly.

3. Build the project

In order to build the whole project and run the tests for all the supported Hibernate versions and both entity mapping methods, use the command

mvn install

in the root DbAssistBuilder project.

It will first build the projects for all the fixes, then build the projects for testing and their dependencies, and finally it will run the tests for each Hibernate and fix version separately.

We are using a Groovy script and Maven custom plugin to perform these steps correctly and in a proper order.

4. (Optional) Add a new fix version into the test suite

In order to add a new fix version to a test suite, you need to go to a correct tester project and edit the .pom file so that you specify it in a list of <projectNames>, which is read by the MavenTestAll plugin.

5. (Optional) Test a single version of the fix

The testing of a single version of the fix can be achieved by temporarily overriding for example DbAssist-jpa-tester .pom file (for JPA case) and changing the following line to refer to a version that we want to test.

<montrosesoftware.version>DbAssist-5.2.2</montrosesoftware.version>

Clone this wiki locally