You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by devillina <on...@delaware.be> on 2006/08/04 13:56:06 UTC

[m2] DBunit test work in eclipse not with maven

Hi i have a project with some Junit tests, when i run these in eclipse
(clicking on them --> run as --> Junittest) thing work fine. No failed
tests.

When i run mvn test, all my DBunit tests fail (the junit tests that are not
dbunit test work fine)

i see the following error in my log:

-------------------------------------------------------------------------------
Test set:
be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest
-------------------------------------------------------------------------------
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 0.1 sec <<<
FAILURE!
testGetAccountString(be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest) 
Time elapsed: 0.01 sec  <<< ERROR!
org.dbunit.dataset.DataSetException: java.net.MalformedURLException
	at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:169)
	at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:71)
	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:200)
	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:187)
	at
be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.getDataSet(SqlMapAccountDaoTest.java:45)
	at org.dbunit.DatabaseTestCase.executeOperation(DatabaseTestCase.java:87)
	at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:104)
	at
be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.setUp(SqlMapAccountDaoTest.java:24)
	at junit.framework.TestCase.runBare(TestCase.java:125)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
	at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
java.net.MalformedURLException
	at java.net.URL.<init>(Unknown Source)
	at java.net.URL.<init>(Unknown Source)
	at java.net.URL.<init>(Unknown Source)
	at
org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:796)
	at
org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:741)
	at
org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:260)
	at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:498)
	at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580)
	at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
	at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1169)
	at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:145)
	at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:71)
	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:200)
	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:187)
	at
be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.getDataSet(SqlMapAccountDaoTest.java:45)
	at org.dbunit.DatabaseTestCase.executeOperation(DatabaseTestCase.java:87)
	at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:104)
	at
be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.setUp(SqlMapAccountDaoTest.java:24)
	at junit.framework.TestCase.runBare(TestCase.java:125)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
	at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)




i don't understand how the url can be wrong if it works in eclipse?

This is one of the files where the url is specified:

http://www.nabble.com/user-files/193/SqlMapAccountDaoTest.java
SqlMapAccountDaoTest.java 

//Methods for database-setup
	private FileSystemXmlApplicationContext ac;
	
	public void setUp() throws Exception {
		super.setUp();
		ac = new
FileSystemXmlApplicationContext("src/test/resources/shared/dataAccessContext-local.xml");
		}


my pom looks like this :

http://www.nabble.com/user-files/194/pom.xml pom.xml 

maybe it's important to invision the directory structure of my project
so here's a quick snapshot:

http://www.nabble.com/user-files/195/directory%2Bstructure.bmp directory
structure.bmp 

The file that i'm trying to refer to with the url is
src/test/resources/shared/dataAccessContext.xml 
(ow yeah if you examin the pom you'll see that after compilation it 
does end up under target/{profile.name}/classes
(and not target/{profile.name}/classes/shared))

THx for the help!!!
-- 
View this message in context: http://www.nabble.com/-m2--DBunit-test-work-in-eclipse-not-with-maven-tf2050767.html#a5648971
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] DBunit test work in eclipse not with maven

Posted by devillina <on...@delaware.be>.
i applied the structure you suggested to my testresources and that worked
excellent !
thx a million!
-- 
View this message in context: http://www.nabble.com/-m2--DBunit-test-work-in-eclipse-not-with-maven-tf2050767.html#a5650018
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] DBunit test work in eclipse not with maven

Posted by Martin van den Bemt <ml...@mvdb.net>.
 From a quick look (and based on your observation), the xml file ends up in the wrong place. It is 
probably better to set the resourcedir in your profile to test/resources and add an includes 
directive to include the shared directory, instead of specifying the directory shared being the 
resources directory.

So instead of :

(this is in your default profile)
<build>
  <directory>target/test</directory>
  <finalName>${artifactId}-${version}-test</finalName>
  <resources>
    <resource>
      <directory>src/main/resources/shared</directory>
         <excludes>
           <exclude>**/_svn/**</exclude>
         </excludes>
     </resource>

try something like this :

<resource>
   <directory>src/main/resources</directory>
   <includes>
     <include>shared/**</include>
   </includes>
   <excludes>blahdieblah</excludes>
</resource>

Mvgr,
Martin

devillina wrote:
> Hi i have a project with some Junit tests, when i run these in eclipse
> (clicking on them --> run as --> Junittest) thing work fine. No failed
> tests.
> 
> When i run mvn test, all my DBunit tests fail (the junit tests that are not
> dbunit test work fine)
> 
> i see the following error in my log:
> 
> -------------------------------------------------------------------------------
> Test set:
> be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest
> -------------------------------------------------------------------------------
> Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 0.1 sec <<<
> FAILURE!
> testGetAccountString(be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest) 
> Time elapsed: 0.01 sec  <<< ERROR!
> org.dbunit.dataset.DataSetException: java.net.MalformedURLException
> 	at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:169)
> 	at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:71)
> 	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:200)
> 	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:187)
> 	at
> be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.getDataSet(SqlMapAccountDaoTest.java:45)
> 	at org.dbunit.DatabaseTestCase.executeOperation(DatabaseTestCase.java:87)
> 	at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:104)
> 	at
> be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.setUp(SqlMapAccountDaoTest.java:24)
> 	at junit.framework.TestCase.runBare(TestCase.java:125)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 	at junit.framework.TestSuite.run(TestSuite.java:203)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at
> org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
> 	at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
> 	at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
> 	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
> 	at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
> java.net.MalformedURLException
> 	at java.net.URL.<init>(Unknown Source)
> 	at java.net.URL.<init>(Unknown Source)
> 	at java.net.URL.<init>(Unknown Source)
> 	at
> org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:796)
> 	at
> org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:741)
> 	at
> org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:260)
> 	at
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:498)
> 	at
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580)
> 	at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
> 	at
> org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1169)
> 	at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:145)
> 	at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:71)
> 	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:200)
> 	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:187)
> 	at
> be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.getDataSet(SqlMapAccountDaoTest.java:45)
> 	at org.dbunit.DatabaseTestCase.executeOperation(DatabaseTestCase.java:87)
> 	at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:104)
> 	at
> be.delaware.samples.jpetstore.source.dao.ibatis.SqlMapAccountDaoTest.setUp(SqlMapAccountDaoTest.java:24)
> 	at junit.framework.TestCase.runBare(TestCase.java:125)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 	at junit.framework.TestSuite.run(TestSuite.java:203)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at
> org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
> 	at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
> 	at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
> 	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
> 	at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
> 
> 
> 
> 
> i don't understand how the url can be wrong if it works in eclipse?
> 
> This is one of the files where the url is specified:
> 
> http://www.nabble.com/user-files/193/SqlMapAccountDaoTest.java
> SqlMapAccountDaoTest.java 
> 
> //Methods for database-setup
> 	private FileSystemXmlApplicationContext ac;
> 	
> 	public void setUp() throws Exception {
> 		super.setUp();
> 		ac = new
> FileSystemXmlApplicationContext("src/test/resources/shared/dataAccessContext-local.xml");
> 		}
> 
> 
> my pom looks like this :
> 
> http://www.nabble.com/user-files/194/pom.xml pom.xml 
> 
> maybe it's important to invision the directory structure of my project
> so here's a quick snapshot:
> 
> http://www.nabble.com/user-files/195/directory%2Bstructure.bmp directory
> structure.bmp 
> 
> The file that i'm trying to refer to with the url is
> src/test/resources/shared/dataAccessContext.xml 
> (ow yeah if you examin the pom you'll see that after compilation it 
> does end up under target/{profile.name}/classes
> (and not target/{profile.name}/classes/shared))
> 
> THx for the help!!!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org