dbunit

DBUnit Sybase unable to CLEAN_INSERT

馋奶兔 提交于 2019-12-06 15:14:19
According to the DBUnit docs link it should support using a CLEAN_INSERT when using a DatabaseSequenceFilter. I get the following exception when attempting this com.sybase.jdbc2.jdbc.SybSQLException: Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'my_db', table name = 'tbl_child', constraint name = 'fk_tbl_child_parentid'. My tables look like this: CREATE TABLE dbo.tbl_parent ( parent_id numeric(19,0) IDENTITY, ... ) CREATE TABLE dbo.tbl_child ( child_id numeric(19,0) IDENTITY, parent_id numeric(19,0) NOT NULL, ... ) ALTER TABLE dbo.tbl_child ADD

database restore to particular state for testing

一曲冷凌霜 提交于 2019-12-06 11:07:29
We use an Oracle(or postgres) database and an application server to execute integration tests. To isolate each test from another one , the database schema is dropped and re-created before each test. As you see this is a time taking process. The application uses 100+ tables. We are thinking of writing custom sql to delete unwanted data from each tables. Is there a better way to save and restore database state? ( It appears DBUnit could do this, I have not tried it yet. ) A single test involves: create database schema. Start app server. Start multiple client applications. Execute and verify. We

Getting DbUnit to Work with Hibernate Transaction

蓝咒 提交于 2019-12-06 00:34:24
问题 I'm having problem trying to push changes made within a Hibernate transaction to the database for DbUnit to work properly in my test case. It seems like DbUnit is not seeing the changes made by Hibernate because they are not committed at the end of the transaction yet... and I'm not sure how to restructure my test case to get this to work. Here's my over-simplified test case to demonstrate my problem:- @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath

JAXBException: “package” doesnt contain ObjectFactory.class or jaxb.index

前提是你 提交于 2019-12-05 11:04:40
I have been playing with JAXB / MOXy a lot lately, and it works great on all my tests and example codes . I exclusively using binding files, that's why I'm using MOXy. Please note that in all my examples, I'm NEVER using an ObjectFactory nor a jaxb.index, and it works GREAT . When I get back to my business, I get a nasty JAXB Exception saying that my package does not contain an ObjectFactory or jaxb.index. My project also invovles Spring and Hibernate, JUnit and DBUnit. Here is some sample code: I have an abstract class called AContributionPhysicalSupport. package org.pea.openVillages.pojo

Log Output in DBUnit

可紊 提交于 2019-12-05 08:08:39
I feel that this is something I could easily figure out but I'm having a hard time finding information on how to change the log level of DBUnit. Can anyone solve this problem for me? When using log4j add the following to your log4j.properties : # DbUnit log4j.logger.org.dbunit=ERROR KevinO After avoiding the problem for a while, I came to a solution. import org.slf4j.Logger import org.slf4j.LoggerFactory import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.core.util.StatusPrinter; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; Logger logger = (Logger

How to configure mutliple transaction managers with Spring + DBUnit + JUnit

风格不统一 提交于 2019-12-05 00:30:32
问题 In a nutshell My command line Java application copies data from one datasource to another without using XA. I have configured two separate datasources and would like a JUnit test that can rollback data on both datasources. I use DBUnit to load data into the "source" database, but I cannot get this to rollback. I can get the "target" datasource to rollback. My Code Given this config... <tx:annotation-driven /> <!-- note the default transactionManager name on this one --> <bean id=

Getting DbUnit to Work with Hibernate Transaction

半腔热情 提交于 2019-12-04 07:50:59
I'm having problem trying to push changes made within a Hibernate transaction to the database for DbUnit to work properly in my test case. It seems like DbUnit is not seeing the changes made by Hibernate because they are not committed at the end of the transaction yet... and I'm not sure how to restructure my test case to get this to work. Here's my over-simplified test case to demonstrate my problem:- @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext-test.xml" }) @TransactionConfiguration(transactionManager = "transactionManager")

Error setting database config property for IDatabaseConnection (HSQLDB)

假如想象 提交于 2019-12-04 04:08:00
问题 I've included fully testable code below, which generates the following error when supplied with a dataset xml containing empty fields. A sample dataset.xml is also below. java.lang.IllegalArgumentException: table.column=places.CITY value is empty but must contain a value (to disable this feature check, set DatabaseConfig.FEATURE_ALLOW_EMPTY_FIELDS to true) The thread here is similar but is different since it uses multiple dbTester.getConnection() whereas my code only uses one, yet has the

Spring Test DBunit Warning

前提是你 提交于 2019-12-04 00:30:32
I am using spring-test-dbunit and I get a warning in my Unit tests with this message: Code: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/context.xml"}) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) public class TestDB { @Autowired private ICourseService courseService; @Test @DatabaseSetup("sampleData.xml") public void testFind() throws Exception { List<Course> courseList = this.courseService.getAllCourses();

How to configure mutliple transaction managers with Spring + DBUnit + JUnit

眉间皱痕 提交于 2019-12-03 15:33:15
In a nutshell My command line Java application copies data from one datasource to another without using XA. I have configured two separate datasources and would like a JUnit test that can rollback data on both datasources. I use DBUnit to load data into the "source" database, but I cannot get this to rollback. I can get the "target" datasource to rollback. My Code Given this config... <tx:annotation-driven /> <!-- note the default transactionManager name on this one --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name=