xml - Integration test DBUnit NoSuchTableException Java -


when start test have nosuchtableexception. need set same name of in-memory data base in production ?

@runwith(springjunit4classrunner.class)     @contextconfiguration     @testexecutionlisteners({ dependencyinjectiontestexecutionlistener.class, dirtiescontexttestexecutionlistener.class,             transactionaltestexecutionlistener.class, dbunittestexecutionlistener.class })     @databasesetup(type = databaseoperation.clean_insert, value = "login.xml")     public class logincontrollertest {          private mockmvc mockmvc;          @before         public void setup() {             mockmvc = mockmvcbuilders.xmlconfigsetup("logincontrollertest-context.xml").build();         }          @test         @expecteddatabase("login.xml")         public void testshowform() throws exception {             mockmvc.perform(get("/login")).andexpect(status().isok()).andexpect(view().name("/login"))                     .andexpect(forwardedurl("/webcontent/j/login.jsp"))                     .andexpect(model().attribute("form", hasproperty("id", nullvalue())))                     .andexpect(model().attribute("form", hasproperty("email", isemptyornullstring())))                     .andexpect(model().attribute("form", hasproperty("username", isemptyornullstring())))                     .andexpect(model().attribute("form", hasproperty("hostname", isemptyornullstring())))                     .andexpect(model().attribute("form", hasproperty("pass", isemptyornullstring())));         }     } 

this here logincontrollertest-context.xml

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"     xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"     xsi:schemalocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/task     http://www.springframework.org/schema/task/spring-task-3.2.xsd     http://www.springframework.org/schema/mvc     http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.2.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-3.2.xsd     http://www.springframework.org/schema/tx      http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">      <tx:annotation-driven transaction-manager="transactionmanager" />     <context:component-scan base-package="com.profiles.controller.test" />      <bean id="datasource"         class="org.springframework.jdbc.datasource.drivermanagerdatasource">         <property name="driverclassname" value="org.hsqldb.jdbcdriver" />         <property name="url" value="jdbc:hsqldb:mem:login" />         <property name="username" value="sa" />         <property name="password" value="" />     </bean>  </beans> 

this here login.xml

<?xml version="1.0" encoding="utf-8"?> <dataset>     <person id="1" email="qwerty@asdf.com" username="qwerty"         hostname="asdf.com" pass="password1234" />      <person id="2" email="zxcvb@asdf.com" username="zxcvb"         hostname="asdf.com" pass="password1234" /> </dataset> 

at last not least stack trace

org.dbunit.dataset.nosuchtableexception: person     @ org.dbunit.database.databasedataset.gettablemetadata(databasedataset.java:288)     @ org.dbunit.operation.deletealloperation.execute(deletealloperation.java:109)     @ org.dbunit.operation.compositeoperation.execute(compositeoperation.java:79)     @ com.github.springtestdbunit.dbunitrunner.setuporteardown(dbunitrunner.java:159)     @ com.github.springtestdbunit.dbunitrunner.beforetestmethod(dbunitrunner.java:70)     @ com.github.springtestdbunit.dbunittestexecutionlistener.beforetestmethod(dbunittestexecutionlistener.java:136)     @ org.springframework.test.context.testcontextmanager.beforetestmethod(testcontextmanager.java:277)     @ org.springframework.test.context.junit4.springmethodroadie.runbefores(springmethodroadie.java:315)     @ org.springframework.test.context.junit4.springmethodroadie.runbeforesthentestthenafters(springmethodroadie.java:253)     @ org.springframework.test.context.junit4.springmethodroadie.runwithrepetitions(springmethodroadie.java:234)     @ org.springframework.test.context.junit4.springmethodroadie.runtest(springmethodroadie.java:204)     @ org.springframework.test.context.junit4.springmethodroadie.run(springmethodroadie.java:146)     @ org.springframework.test.context.junit4.springjunit4classrunner.invoketestmethod(springjunit4classrunner.java:151)     @ org.junit.internal.runners.junit4classrunner.runmethods(junit4classrunner.java:51)     @ org.junit.internal.runners.junit4classrunner$1.run(junit4classrunner.java:44)     @ org.junit.internal.runners.classroadie.rununprotected(classroadie.java:27)     @ org.junit.internal.runners.classroadie.runprotected(classroadie.java:37)     @ org.junit.internal.runners.junit4classrunner.run(junit4classrunner.java:42)     @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:86)     @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:459)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:675)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:382)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:192)  junit.framework.comparisonfailure: table count expected:<[1]> was:<[0]>     @ org.dbunit.assertion.junitfailurefactory.createfailure(junitfailurefactory.java:39)     @ org.dbunit.assertion.defaultfailurehandler.createfailure(defaultfailurehandler.java:105)     @ org.dbunit.assertion.dbunitassert.assertequals(dbunitassert.java:237)     @ org.dbunit.assertion.dbunitassert.assertequals(dbunitassert.java:205)     @ org.dbunit.assertion.assertequals(assertion.java:104)     @ com.github.springtestdbunit.assertion.defaultdatabaseassertion.assertequals(defaultdatabaseassertion.java:33)     @ com.github.springtestdbunit.dbunitrunner.verifyexpected(dbunitrunner.java:128)     @ com.github.springtestdbunit.dbunitrunner.aftertestmethod(dbunitrunner.java:80)     @ com.github.springtestdbunit.dbunittestexecutionlistener.aftertestmethod(dbunittestexecutionlistener.java:141)     @ org.springframework.test.context.testcontextmanager.aftertestmethod(testcontextmanager.java:340)     @ org.springframework.test.context.junit4.springmethodroadie.runafters(springmethodroadie.java:351)     @ org.springframework.test.context.junit4.springmethodroadie.runbeforesthentestthenafters(springmethodroadie.java:262)     @ org.springframework.test.context.junit4.springmethodroadie.runwithrepetitions(springmethodroadie.java:234)     @ org.springframework.test.context.junit4.springmethodroadie.runtest(springmethodroadie.java:204)     @ org.springframework.test.context.junit4.springmethodroadie.run(springmethodroadie.java:146)     @ org.springframework.test.context.junit4.springjunit4classrunner.invoketestmethod(springjunit4classrunner.java:151)     @ org.junit.internal.runners.junit4classrunner.runmethods(junit4classrunner.java:51)     @ org.junit.internal.runners.junit4classrunner$1.run(junit4classrunner.java:44)     @ org.junit.internal.runners.classroadie.rununprotected(classroadie.java:27)     @ org.junit.internal.runners.classroadie.runprotected(classroadie.java:37)     @ org.junit.internal.runners.junit4classrunner.run(junit4classrunner.java:42)     @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:86)     @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:459)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:675)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:382)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:192) 

for integration testing dataset should contain valid table names, yes need have same table names test executed successfully.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -