I want to create a test table that is empty. Using the Example from digitalsandwich, I want something like:
require_once 'PHPUnit/Extensions/Database/TestCase.php';
class BankAccountDBTest extends PHPUnit_Extensions_Database_TestCase
{
protected $pdo;
public function __construct()
{
$this->pdo = new PDO('sqlite::me...
I am trying to use DBUnit with plain JDBC and HSQLDB, and can't quite get it to work -- even though I've used DBUnit with Hibernate earlier with great success. Here's the code:
import java.sql.PreparedStatement;
import org.dbunit.IDatabaseTester;
import org.dbunit.JdbcDatabaseTester;
import org.dbunit.dataset.IDataSet;
import org.dbuni...
I just realized that DBUnit doesn't create tables by itself (see How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?).
Is there any way for DBUnit to automatically create tables from a dataset or dtd?
EDIT: For simple testing of an in-memory database like HSQLDB, a crude approach can be used to ...
Hi, I have a strange problem with dbUnit.
I use dbUnit 2.4.4, java 1.6, Spring (as db connection pool), Oracle 9 for my project with about 50 unit tests.
For some of them (when I run whole set of tests) I get such exception:
Closed Statement
[junit] junit.framework.AssertionFailedError: Closed Statement
[junit] at com.myproj.DataAcc...
Hi,
I use DbUnit to load data into a DB for some integration tests. The data is specified in a flat XML file like so:
<user id="2" name="bob" type="user">
<user id="1" name="john" type="admin">
However in the case of one table, the rows I wish to insert are based on rows already inserted into other tables. The most convenient way for...
I am currently updating a java-based web application which allows database developers to create stored procedure regression test suites for database testing.
Currently, for test setup, execution and clean-up stages, the user is provided with text boxes where they are able to enter SQL code which is executed by the isql command.
I would...
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 lik...
dbunit-maven-plugin 1.0-SNAPSHOT release supported expressing multiple src files under sources tag, how do you do the same on 1.0-beta-3 version which supports only a single src tag
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<ver...
Hi,
I'm following some guidelines in a tutorial for setting up Stripes MVC with Spring integration, and I'm trying to integrate DBUnit to initialise my DB on startup so I don't have to waste time manually inserting data each time. Unfortunately I can't link the tutorial as its from a paid for eBook.
In my web.xml I have referenced Spri...
Hi,
I'm getting this error when I start up my application
Caused by: org.dbunit.dataset.NoSuchColumnException: CLIENT.ID - (Non-uppercase input column: ID) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive
I'm not too sure why I'm getting this, since my table/column names all all referenced in...
I am using DbUnit together with Unitils, which works great most of the time.
Today I found a strange problem.
Situation is:
I use Hibernate, and have id with "increment" generator:
<id name="Id">
<generator class="increment"/>
</id>
I prepare test dataset, where maximal id is 5.
I use clean-insert loading strategy.
I ha...
I've been enjoying Hibernate's "yes_no" notation for a while now. I use it a lot on active fields like so:
@Column(name = "active")
@Type(type = "true_false")
public boolean getActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
Recently I added a new field called processable, to a dif...
I've recently been asked to, effectively, sell my department on unit testing. I can't tell you how excited this makes me, but I do have one concern. We're using JUnit with Spring and Maven, and this means that each time mvn test is called, it rebuilds the database. Obviously, we can't integrate that with our production server -- it w...
dbunit data has been populated with lower case table names as per schema definition. Why do you get a corrected table warning every time, I run the scripts for all databases (h2, mysql ..)
[INFO] [dbunit:operation {execution: seed data}]
120 [main] INFO org.dbunit.database.DatabaseDataSet -
database name=H2
database vers...
When I am testing a method using dbunit, it persisted into the table. I am using MySQL and my code is -
@DBUnitConfiguration(locations = "/TestResources/testCampaignRequestServiceImpl-data.xml")
public class TestCampaignRequestServiceImpl extends AbstractDataAccessTest {
@Test
public void testConvertToCampaign(){
try {
...
I'm getting NoPrimaryKeyException when I try to run one of my unit tests which uses DBUnit. The datatable is created using Hibernate and is a join table between two classes mapping a many to many relationship. The annotations that define the relationship are as follows:
@Override
@ManyToMany
@JoinTable(name="offset_file_offset_entries",...
I have seen a couple of question regarding creating datasets in DbUnit here on StackOverflow, but all of them were regarding export data from existing tables.
My question is, can DBUnit create some dummy dataset basing on my database schema? I don't care whether the strings would be like "ZDSFFDSDGF" and BLOBS would be just garbage. I j...
I am using the latest version of DBUnit (2.4.7), on Oracle 11GR2. I'm using Java 6 (1.6.0_15) and the latest version of Oracle's client jar (jdbc6.jar)
I've been unable to successfully load any data referenced by a CLOB Oracle field from an XML file into the database.
I've used all sorts of combinations of versions of the:
Oracle JDB...
Hi
I am trying to do unit testing of database access layer of my project.
But thing is i need to test this layer using apache derby database and during production testing i need to do it on oracle.
So can i use same xml representation of database to do so using dbunit ?
...
Hi,
I'm writing some integrations tests in JUnit. What happens here is that when i run all the tests together in a row (and not separately), the data persisted in the database always changes and the tests find unexpected data (inserted by the previous test) during their execution.
I was thinking to use DbUnit, but i wonder if it resets...