dbunit

Reset sequence in DBUnit?

白昼怎懂夜的黑 提交于 2019-12-03 14:20:59
I want to reset the Database AND sequences after each test in Java+DBUnit/. I've seen this question but doesn't have the code solution I am struggling to get. How to use Oracle Sequence Numbers in DBUnit? I've found the answer, it was in the Official Documentation . It was as easy as in the dataset you are using to prepare the database, add a reset_sequences attribute with a list of the ones you want to reset. <?xml version='1.0' encoding='UTF-8'?> <dataset reset_sequences="emp_seq, dept_seq"> <emp empno="1" ename="Scott" deptno="10" job="project manager" /> .... </dataset> This solution is

spring3,unitils 与dbunit整合问题记录

落花浮王杯 提交于 2019-12-03 12:47:03
unitils 3.3版本,spring3.2.4 1.Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/E:/user/.m2/repository/org/slf4j/slf4j-nop/1.4.3/slf4j-nop-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/E:/user/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple

Date relative to current in the DBUnit dataset

落花浮王杯 提交于 2019-12-03 09:02:43
问题 I'm wondering if there is any way to specify for example tomorrow as date in the DBUnit XML dataset. Sometimes code logic is different for dates in future and dates in the past and I want to test both cases. For sure I can specify something like the 5th of November 2239 and be sure that test will work till this date but are there more elegant way. I haven't yet faced such situation during my Java development but once I had experience when code logic was different for one day before dates, two

Reset sequence in DBUnit?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to reset the Database AND sequences after each test in Java+DBUnit/. I've seen this question but doesn't have the code solution I am struggling to get. How to use Oracle Sequence Numbers in DBUnit? 回答1: I've found the answer, it was in the Official Documentation . It was as easy as in the dataset you are using to prepare the database, add a reset_sequences attribute with a list of the ones you want to reset. <?xml version='1.0' encoding='UTF-8'?> <dataset reset_sequences="emp_seq, dept_seq"> <emp empno="1" ename="Scott" deptno="10"

Is there any way for DBUnit to automatically create tables?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 automatically create tables: private void createHsqldbTables(IDataSet dataSet, Connection connection) throws DataSetException, SQLException { String[] tableNames = dataSet.getTableNames(); String sql = ""; for

Date relative to current in the DBUnit dataset

╄→尐↘猪︶ㄣ 提交于 2019-12-02 23:08:50
I'm wondering if there is any way to specify for example tomorrow as date in the DBUnit XML dataset. Sometimes code logic is different for dates in future and dates in the past and I want to test both cases. For sure I can specify something like the 5th of November 2239 and be sure that test will work till this date but are there more elegant way. I haven't yet faced such situation during my Java development but once I had experience when code logic was different for one day before dates, two days before dates and more than two days before dates. In this case the only possible solution to

Expoting Dataset to a xml file giving error in DBunit

半腔热情 提交于 2019-12-02 05:21:15
Hi all i'm working using dbunit. I'm trying to export datset of db into a xml file. import java.sql.Connection; import java.sql.DriverManager; import org.dbunit.database.DatabaseConnection; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.xml.FlatXmlDataSet; import java.io.FileOutputStream; public class DatabaseExport { public static void main(String[] args) throws Exception { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver()); Connection

phpunit dbunit @dataProvider doesn't work

喜夏-厌秋 提交于 2019-12-01 13:31:36
I spent a lot of time by searching where is the problem, but i haven't find anything. It sais "testAdd caused an ERROR: Missing argument". Simply the dataProvider isn't executed, when I run the test. I tried to put die() into the dataProvider and it hasn't died. This is my code: class LabelEntityModelTest extends PHPUnit_Extensions_Database_TestCase { private static $connection = NULL; /** * @var \CXNS\DB\Connections\Connection */ private static $appConnection; private static $table; public function __construct() { if (self::$connection) { return; } $pdo = new \PDO($GLOBALS['DB_DSN'], $GLOBALS

phpunit dbunit @dataProvider doesn't work

微笑、不失礼 提交于 2019-12-01 11:26:11
问题 I spent a lot of time by searching where is the problem, but i haven't find anything. It sais "testAdd caused an ERROR: Missing argument". Simply the dataProvider isn't executed, when I run the test. I tried to put die() into the dataProvider and it hasn't died. This is my code: class LabelEntityModelTest extends PHPUnit_Extensions_Database_TestCase { private static $connection = NULL; /** * @var \CXNS\DB\Connections\Connection */ private static $appConnection; private static $table; public

DBunit; confusion over case sensitivity on table/column names

雨燕双飞 提交于 2019-12-01 07:08:25
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 upper case(even though the message insists this shouldn't be an issue) My table : mysql> describe CLIENT; +------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+----