Menu

#368 Multi schema support in FlatXmlDataSets

v2.5.*
closed-fixed
None
2.5.2
5
2021-02-15
2015-04-20
warwing
No

Hello together,

I'm trying to import a FlatXmlDataSet that includes tables from multiple schemas.
To do that I activated the corresponding feature (DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES).

To my database I connect as user "dbunit", who has read/write permission on all schemas, while my tables are located in the schemas "A" and "B".

After debugging DatabaseDataSet, I learned, that once the dataset is initialized, no additional tables will be inserted in the known tables map. The user "dbunit" itself has no tables - but in the FlatXmlDataSet, the tables are stored with schema prefix - which has no effect and always leads to a NoSuchTableException.

I tried to enhance the DatabaseDataSet to incrementally accept further tables, when new schemas emerge.

Could you please review the attached patch if it has a chance to be included in DBUnit?

Best regards,

Alex

1 Attachments

Discussion

  • Jeff Jensen

    Jeff Jensen - 2015-04-25

    Thanks for debugging the issue and the patch!

    I have worked around this issue in the past by having two dbunit configurations in one test class.

    I assume that this patch works for you and no other side-effects found?

    The patch applies clean and the build is successful. Initial review seems fine too.

    Would you mind adding tests for this class? I realize a test class does not exist for this class yet and would greatly appreciate any tests you have time and interest to create for it. Since it is an old class with significant use, perhaps a strategy is to start with tests focusing on your changes and add any additional tests as you have time.

     
  • Jeff Jensen

    Jeff Jensen - 2015-04-25
    • status: open --> open-accepted
    • assigned_to: Jeff Jensen
     
  • warwing

    warwing - 2015-04-26

    Hi Jeff,

    please find attached a minimal test case - it focusses on permissions.
    Additionally you have to add the following method to H2Environment:


    public static Connection createJdbcConnection(String databaseName, String username, String password) throws Exception
    {
    Class.forName("org.h2.Driver");
    Connection connection = DriverManager.getConnection(
    "jdbc:h2:mem:" + databaseName, username, password);
    return connection;
    }

    Please review the last test - I personally think that this behavior is fine, but just to be sure :)

    And there has to be a corresponding sql-script for h2 in src/test/resources/sql/.

    Best regards,

    Alex

     

    Last edit: warwing 2015-04-26
  • Jeff Jensen

    Jeff Jensen - 2015-04-26

    Thanks Alex! Quickly done too :-)

    I committed your changes with some tweaks. Please review and consider further improvements.

    I also deployed a snapshot including this change, as usual.

    Thanks again!

     

    Last edit: Jeff Jensen 2015-04-26
  • Jeff Jensen

    Jeff Jensen - 2015-04-26
    • status: open-accepted --> closed-fixed
    • Fixed Release: (not fixed) --> 2.5.2
     

Log in to post a comment.