dbunit

POI Appending .0 while reading numeric data from excel

十年热恋 提交于 2019-12-01 04:48:33
I am using POI HSSF to read excel data and I am using JUnit to check the data against database proc RefCursor. The Junit test fails as the numeric data from the Refcursor for example 100 are compared against the data in the excel sheet 100 but it fails as the POI reads it as 100.0. InputStream fileInputStream = Testdb.class.getClassLoader().getResourceAsStream(fileName); //retrieve number of columns and rows int numRows=0, numCols=0, i, j, minColIndex=0, maxColIndex=0; POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream); HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem);

DB Unit should ignore order of rows

≡放荡痞女 提交于 2019-11-30 15:19:27
Is there a way telling DB-Unit to ignore the order in which rows should be compared? My problem is, that I do not know in which order the rows will be written to the database, but DB-Unit forces me to give an ordered list. What I want dbunit to do is: check that number of rows in database and expected dataset match (Solved: Works out of the box check whether each rows will be found only once in the result-set. (NOT SOLVED) Any ideas? EhmKah Solved this issue for me. I'm sorting the rows of the actual and expected tables. Therefore I use all columns which can be found in expected table. This

Oracle + dbunit gets AmbiguousTableNameException

最后都变了- 提交于 2019-11-30 13:40:28
I am using dbunit to create database backups, which can be imported and exported. My application can use several database engines: MySQL, PostgreSQL, SQLServer, H2 and Oracle. All of the above work fine with the following code: // Connect to the database conn =BackupManager.getInstance().getConnection(); IDatabaseConnection connection = new DatabaseConnection(conn); InputSource xmlSource = new InputSource(new FileInputStream(new File(nameXML))); FlatXmlProducer flatXmlProducer = new FlatXmlProducer(xmlSource); flatXmlProducer.setColumnSensing(true); DatabaseOperation.CLEAN_INSERT.execute

DAO Unit testing

十年热恋 提交于 2019-11-30 11:03:51
问题 I have been looking at EasyMock and tutorials/examples around using it for Unit Testing DAO classes, for an "outside container" test. However, I think most of them talk about testing the Service Layer instead, mocking the DAO class. I am a bit confused, is it really how you Unit Test the DAO layer? Some would say that the tests interacting with DB & EJBs are actually Integration tests and not Unit tests but then how would you know if your SQL is correct (assuming no ORM) and your DAO inserts

How do I reference a file that is placed in the WEB-INF folder when using Arquillian?

不打扰是莪最后的温柔 提交于 2019-11-30 07:25:15
I am using maven and the standard directory layout. So I have added a testdata.xml file in the src/test/resources folder, and I also added it as: .addAsWebInfResource("testdata.xml", "testdata.xml") in the deployment method, and I have confirmed that it is there. This will make the file appear in /WEB-INF/testdata.xml . Now I need to have a reference to this file in my code and I tried several different getClass().getResourceAsStream(...) and failing again and again so I need some advise now. I need it for my DBUnit integration test. Is this not possible? Glen Best Option A) Use ServletContext

DbUnit and binary data

前提是你 提交于 2019-11-30 05:04:15
I use DbUnit for unit-testing of my DAO objects. It works great so far. I have a problem, I have field ob type byte[] which is stored as BLOB in the database. The column is not-null. How can I specify the value for this column in the XML dataset file, that DbUnit uses? The value can be nothing fancy, 5 bytes will be enough. I would like to avoid necessity to create extra binary files just for this. Any suggestions? After all I solved it like that: XML dataset file: <?xml version="1.0" encoding="UTF-8"?> <dataset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <!-- image_content is

DAO Unit testing

旧时模样 提交于 2019-11-29 23:07:47
I have been looking at EasyMock and tutorials/examples around using it for Unit Testing DAO classes, for an "outside container" test. However, I think most of them talk about testing the Service Layer instead, mocking the DAO class. I am a bit confused, is it really how you Unit Test the DAO layer? Some would say that the tests interacting with DB & EJBs are actually Integration tests and not Unit tests but then how would you know if your SQL is correct (assuming no ORM) and your DAO inserts/queries the right data from your real (read, local database which is similar to that in production)

DB Unit should ignore order of rows

送分小仙女□ 提交于 2019-11-29 22:29:18
问题 Is there a way telling DB-Unit to ignore the order in which rows should be compared? My problem is, that I do not know in which order the rows will be written to the database, but DB-Unit forces me to give an ordered list. What I want dbunit to do is: check that number of rows in database and expected dataset match (Solved: Works out of the box check whether each rows will be found only once in the result-set. (NOT SOLVED) Any ideas? 回答1: Solved this issue for me. I'm sorting the rows of the

Is there a dbunit-like framework that doesn't suck for java/scala?

我的未来我决定 提交于 2019-11-29 19:14:16
I was thinking of making a new, light-weight database population framework. I absolutely hate dbunit. Before I do, I want to know if someone already did it. Things i dislike about dbunit: 1) The simplest format to write and get started is deprecated. They want you to use formats that are bloated. Some even require xml schemas. Yeah, whatever. 2) They populate rows not in the order you write them, but in the order tables are defined in the xml file. This is really bad because you can't order your data in such a way that foreign key constraints won't cause problems. This just forces you to go

Oracle + dbunit gets AmbiguousTableNameException

好久不见. 提交于 2019-11-29 18:29:54
问题 I am using dbunit to create database backups, which can be imported and exported. My application can use several database engines: MySQL, PostgreSQL, SQLServer, H2 and Oracle. All of the above work fine with the following code: // Connect to the database conn =BackupManager.getInstance().getConnection(); IDatabaseConnection connection = new DatabaseConnection(conn); InputSource xmlSource = new InputSource(new FileInputStream(new File(nameXML))); FlatXmlProducer flatXmlProducer = new