Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-112

Better structure of database URL for connect in JUnit test cases

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Trivial
    • Resolution: Fixed
    • 1.1.7
    • 1.1.8
    • 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:

      1. Database host (ip)
      2. Port number (could be same configuration as host because they usually are groups together).
      3. Database name (“test” is always used)
      4. Database user and password
      5. 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.

      Attachments

        Activity

          People

            massimo.siani Massimo Siani (Inactive)
            lennartschedin Lennart Schedin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.