Details
-
Task
-
Status: Closed (View Workflow)
-
Trivial
-
Resolution: Fixed
-
1.1.7
-
None
-
None
Description
I like JUnit tests and I frequently “messes” with them to try different things. I have MariaDB server 5.5 installed on my Windows computer as my normal database server. I have Mysql 5.1 installed on a different port. I also have a virtual Ubuntu machine with some other version. I frequently edit the database URL in BaseTest.java to change my IP, port and sometimes also to add connection properties.
I searched the source code and found 49 matches of the string “DriverManager.getConnection”. One is found in BaseTest.java and the others are found in other test files. It would be easier for me if there only was one place to change the database host and port in the test cases. I understand that some of the test cases need to create more than 1 Connection and also use other properties in the connection url.
I suggest that the connect mechanism in BaseTest.java is refactored so that the following things can be edited easily:
- Database host (ip)
- Port number (could be same configuration as host because they usually are groups together).
- Database name (“test” is always used)
- Database user and password
- Additional database properties that are appended
For test cases that needs a new Connection a getConnection()-method could be created in BaseTest.java. For test cases that need optional URL parameters it can be supplied as parameters to a getConnection()-method.