java - Unable to unit test - Unitils, Hibernate -


i'm trying setup unit test application, i'd test unitils datasets, far i'm encountered many problems. i'm convinced have wrong setup can review problems.

i have hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration    public "-//hibernate/hibernate configuration dtd 3.0//en"    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">  <hibernate-configuration>     <session-factory>        <!-- database connection settings -->        <property name="hibernate.dialect">org.hibernate.dialect.hsqldialect</property>        <property name="hibernate.connection.driver_class">org.hsqldb.jdbc.jdbcdriver</property>         <property name="hibernate.connection.url">jdbc:hsqldb:mem:testdb</property>        <!--<property name="hibernate.hbm2ddl.auto">create</property>-->           <!-- enable hibernate's second level cache -->        <property name="hibernate.cache.use_second_level_cache">false</property>        <property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.ehcacheprovider</property>         <!-- helper debug settings -->        <property name="hibernate.show_sql">true</property>        <property name="hibernate.format_sql">true</property>         <mapping class="cz.test.request"/>      </session-factory>  </hibernate-configuration> 

unitils properties follows

database.dialect=hsqldb database.driverclassname=org.hsqldb.jdbc.jdbcdriver  database.url=jdbc:hsqldb:mem:testdb database.schemanames=public 

and test is

@dataset("daotest.xml") @hibernatesessionfactory({"test_hibernate.cfg.xml"}) public class daotest extends unitilsjunit4 {      private sessionfactory sessionfactory;      private session session = null;      @test     public void testmappingtodatabase() {         hibernateunitils.assertmappingwithdatabaseconsistent();     } } 

i'm getting

severe: table 'trnrequest' not found in tablemap=org.dbunit.dataset.orderedtablenamemap[_tablenames=[], _tablemap={}, _casesensitivetablenames=false] caused by: org.dbunit.dataset.nosuchtableexception: request 

i guess schema not created, setting in hibernate.cfg.xml doesn't creation done after error , fails anyway with

x 15, 2015 9:44:19 dop. org.hibernate.tool.hbm2ddl.schemaexport execute info: exporting generated schema database x 15, 2015 9:44:19 dop. org.hibernate.tool.hbm2ddl.schemaexport create severe: unsuccessful: create table request (id bigint generated default identity (start 1), amount bigint, amountcbk bigint, applicationid varchar(4), batch integer, cardissuer varchar(20), cardseq integer, currency varchar(3), emvdata varchar(1024), entrymode varchar(3), exp varchar(4), maskedpan varchar(32), originaltime timestamp, originaltime_utc timestamp, pan varchar(64), pankey varchar(64), posdata varchar(512), repeated number(1,0) default 0  not null, reqflag varchar(255), reqprocessing varchar(255), reqtype varchar(255), requesttime timestamp, requesttime_utc timestamp, sequencenumber varchar(10), stan bigint, termid varchar(16), transactiontime timestamp, primary key (id)) x 15, 2015 9:44:19 dop. org.hibernate.tool.hbm2ddl.schemaexport create severe: type not found or user lacks privilege: number x 15, 2015 9:44:19 dop. org.hibernate.tool.hbm2ddl.schemaexport create severe: unsuccessful: alter table trnreleatedtrn add constraint fk135128224355ccd7 foreign key (releatedrequest_id) references trnrequest x 15, 2015 9:44:19 dop. org.hibernate.tool.hbm2ddl.schemaexport create severe: user lacks privilege or object not found: request x 15, 2015 9:44:19 dop. org.hibernate.tool.hbm2ddl.schemaexport execute info: schema export complete 

so made work test looks that

public class settlementdaotest extends unitilsjunit4{      @hibernatesessionfactory("test_hibernate.cfg.xml")     sessionfactory hsflocal;      @before     public void before(){         sessionfactoryprovider.setsessionfactory(hsflocal);     }      @test     @dataset     public void testgettransaction() throws exception {           sessionfactoryprovider.getsessionfactory().getcurrentsession().begintransaction();          list<long> customerids = factory.getatfilesettlementdao().getcustomerids("tb01");         assert.assertnotnull(customerids);         assert.assertequals(4924l , (long)customerids.get(0));         sessionfactoryprovider.getsessionfactory().getcurrentsession().gettransaction().commit();       } } 

the settings changed in unitils.properties unitils.module.dbunit.runafter=spring - postponed loading of datasets after schema created according

<property name="hibernate.hbm2ddl.auto">create-drop</property> 

databasemodule.transactional.value.default=disabled somehow disabled transactional deadlock, caused because i'm using

<property name="hibernate.current_session_context_class">thread</property> 

databasemodule.transactional.value.default=disabled


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -