Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:00:26+00:00 2026-06-11T18:00:26+00:00

Currently I need to create tests for my application. I used dbunit to achieve

  • 0

Currently I need to create tests for my application. I used “dbunit” to achieve that and now need to compare 2 datasets:

1) The records from the database I get with QueryDataSet
2) The expected results are written in the appropriate FlatXML in a file which I read in as a dataset as well

Basically 2 datasets can be compared this way.

Now the problem are columns with a Timestamp. They will never fit together with the expected dataset. I really would like to ignore them when comparing them, but it doesn’t work the way I want it.

It does work, when I compare each table for its own with adding a column filter and ignoreColumns. However, this approch is very cumbersome, as many tables are used in that comparison, and forces one to add so much code, it eventually gets bloated.
The same applies for fields which have null-values

A probable solution would also be, if I had the chance to only compare the very first column of all tables – and not by naming it with its column name, but only with its column index. But there’s nothing I can find.

Maybe I am missing something, or maybe it just doesn’t work any other way than comparing each table for its own?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:00:27+00:00Added an answer on June 11, 2026 at 6:00 pm

    For the sake of completion some additional information must be posted. Actually my previously posted solution will not work at all as the process reading data from the database got me trapped.

    The process using “QueryDataset” did read the data from the database and save it as a dataset, but the data couldn’t be accessed from this dataset anymore (although I could see the data in debug mode)!
    Instead the whole operation failed with an UnsupportedOperationException at org.dbunit.database.ForwardOnlyResultSetTable.getRowCount(ForwardOnlyResultSetTable.java:73)

    Example code to produce failure:

    QueryDataSet qds = new QueryDataSet(connection);
    qds.addTable(“specificTable”);
    qds.getTable(„specificTable“).getRowCount(); 
    

    Even if you try it this way it fails:

    IDataSet tmpDataset = connection.createDataSet(tablenames);
    tmpDataset.getTable("specificTable").getRowCount();
    

    In order to make extraction work you need to add this line (the second one):
    IDataSet tmpDataset = connection.createDataSet(tablenames);
    IDataSet actualDataset = new CachedDataSet(tmpDataset);

    Great, that this was nowhere documented…

    But that is not all: now you’d certainly think that one could add this line after doing a “QueryDataSet” as well… but no! This still doesn’t work! It will still throw the same Exception! It doesn’t make any sense to me and I wasted so much time with it…

    It should be noted that extracting data from a dataset which was read in from an xml file does work without any problem. This annoyance just happens when trying to get a dataset directly from the database.

    If you have done the above you can then continue as below which compares only the columns you got in the expected xml file:

        // put in here some code to read in the dataset from the xml file...
        // and name it "expectedDataset"
        // then get the tablenames from it...
        String[] tablenames = expectedDataset.getTableNames();
    
        // read dataset from database table using the same tables as from the xml
        IDataSet tmpDataset = connection.createDataSet(tablenames);
        IDataSet actualDataset = new CachedDataSet(tmpDataset);
    
        for(int i=0;i<tablenames.length;i++)
        {
            ITable expectedTable = expectedDataset.getTable(tablenames[i]);
            ITable actualTable = actualDataset.getTable(tablenames[i]);         
            ITable filteredActualTable = DefaultColumnFilter.includedColumnsTable(actualTable, expectedTable.getTableMetaData().getColumns());
            Assertion.assertEquals(expectedTable,filteredActualTable);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A database application that I'm currently working on, stores all sorts of settings in
We need to create a file management interface that integrates with the clients current
I need to create a gem, for my own use, that substitutes the current
I need to write a validation to make sure that new records created in
I'm currently in the process of writing an application that has quite a number
I've currently got four XML files that are used to build my Dependency Injection
I am trying to create a file with my android application. I need to
I have several files comprising a tomcat web application that I need to import
I'm currently writing a special client application to allow our unit tests to work
I need to create application shortcuts on 3 different mobile environments, WP7, Android and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.