# Facing pogress jdbc connectivity using the DbUnit library

**URL:** <https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702>\
**Category:** Development\
**Tags:** dev\
**Created:** [April 11, 2024, 1:04pm UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702 "2024-04-11T13:04:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![segujja\_joseph](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/segujja_joseph/32/78_2.png) [@segujja\_joseph](https://talk.openelis-global.org/u/segujja_joseph)\
**Post date:** [April 11, 2024, 1:04pm UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702/1 "2024-04-11T13:04:56Z")

</div>

hello Everyone. i am currently working on this ticket; [Add more integration tests to the Patient and Person service · Issue #902 · I-TECH-UW/OpenELIS-Global-2 · GitHub](https://github.com/I-TECH-UW/OpenELIS-Global-2/issues/902)  
aim is to

1. create dataset to provide dammy data for test at runtime and also create intergrations tests
2. my approach this query was to use the DbUnit liabray to actuall read and inject the dammy data from the xml files to the database at runtime

howeveri run into some challenges

1. Firstly I extend the `DdTestClass`

The data was not loaded to the database due postgres not running at port 5432. error: [DbTestCase error - Pastebin.com](https://pastebin.com/V8VHxmj9)  
2. Secondly another suggestion was to extent `DataSourceBasedDbTestCase` because it’s more flexible manageable while working with databases in test cases but still here I got a driver Class is null error ; [error - Pastebin.com](https://pastebin.com/fBDUQs4t)  
Let me share a link to my repository ; [creacted a utitlity classand a dataset postgres failures · josephbate/OpenELIS-Global-2@44e52e9 · GitHub](https://github.com/josephbate/OpenELIS-Global-2/commit/44e52e9ccc2e74838cd33c01d62d0dfeed2c8a9f) for when i extend the `DdTestCase` class

here are some screen shots for other class i extended

 ![Screenshot from 2024-04-11 13-28-51](https://canada1.discourse-cdn.com/flex030/uploads/openelisci/original/1X/71944f71b1629c5873311ae9a2f508eed6050bf8.png)  
 ![Screenshot from 2024-04-11 13-29-35](https://canada1.discourse-cdn.com/flex030/uploads/openelisci/original/1X/0ef5e9e8a2592913a90691be20f9f0fc6be6a5c2.png)

if there is any asistance or sugestions on this please share on this thread  
Cc. @mozzymutesa

---

<div class="post-metadata">

**Author:** ![valens](https://avatars.discourse-cdn.com/v4/letter/v/e0b2c6/32.png) [@valens](https://talk.openelis-global.org/u/valens)\
**Post date:** [April 15, 2024, 6:01am UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702/2 "2024-04-15T06:01:02Z")

</div>

Hello @segujja_joseph can you check @DataProvider functionality from TESTNG? this will help you to use dummy data parameterized into the test method.

How you do this?

Create a method and name it anything you want, annotate it with @DataProvider annotation from TESTNG and then return your dummy data you want from it to be used to different test classes dynamically.

Here is the example:

@DataProvider  
private static final object getMoney() {  
return new object {  
{10, “USD”},  
{20, “EUR”}  
};  
}

@Test(dataProvider = “getMoney”)  
public void constructorShouldSetAmountAndCurrency(int amount, String currency) {  
Money money = new Money(amount, currency);  
assertEquals(money.getAmount(), amount);  
assertEquals(money.getCurrency(), currency);  
}

This data provider can be dynamically used.

Kindly let me know if this helps.

---

<div class="post-metadata">

**Author:** ![segujja\_joseph](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/segujja_joseph/32/78_2.png) [@segujja\_joseph](https://talk.openelis-global.org/u/segujja_joseph)\
**Post date:** [April 15, 2024, 9:11am UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702/3 "2024-04-15T09:11:45Z")

</div>

hello @valens  
thank you for this sugestion, alhtough in making intergration we are testing the service class against an actual data base that is to say we need to load data to the actual data base then call all the service method  
unless i have got it correctly but using @DataProvider acts on in memory not the data base i may be wrong this but thats what i know of TestNG  
you can enlighten me more of if otherwise and how we can relate with an actual data base

---

<div class="post-metadata">

**Author:** ![valens](https://avatars.discourse-cdn.com/v4/letter/v/e0b2c6/32.png) [@valens](https://talk.openelis-global.org/u/valens)\
**Post date:** [April 15, 2024, 9:27am UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702/4 "2024-04-15T09:27:05Z")

</div>

Great !! I was confused by the point that you need access on dummy data, but for integration tests TESTNG can’t serve you.

---

<div class="post-metadata">

**Author:** ![segujja\_joseph](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/segujja_joseph/32/78_2.png) [@segujja\_joseph](https://talk.openelis-global.org/u/segujja_joseph)\
**Post date:** [April 15, 2024, 10:56am UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702/5 "2024-04-15T10:56:01Z")

</div>

alright then  
thank you @valens if you have any more suggestion please feel free to share  
Cc. @Moses_Mutesasira

---

<div class="post-metadata">

**Author:** ![sharif](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/sharif/32/85_2.png) [@sharif](https://talk.openelis-global.org/u/sharif)\
**Post date:** [April 26, 2024, 2:42am UTC](https://talk.openelis-global.org/t/facing-pogress-jdbc-connectivity-using-the-dbunit-library/702/6 "2024-04-26T02:42:31Z")

</div>

Hello @segujja_joseph , it would be helpfull if you provide any error, i believe when you hover onto line 33 to 47, you will see an error.
