File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Spring TestCase Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring TestCase Exception" Watch "Spring TestCase Exception" New topic
Author

Spring TestCase Exception

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Hallo All,

I'm trying to execute a simple JUnit test using Spring applicationContext: Below is my TestCase:



This is what I get when I run testCreateNewUser()???



SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Lino Larios
Greenhorn

Joined: Jun 27, 2008
Posts: 28
I think in Junit4 you must extneds from AbstractTransactionalJUnit4SpringContextTests

bye
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Lino Larios wrote:I think in Junit4 you must extneds from AbstractTransactionalJUnit4SpringContextTests

bye


Nope, that is for JUnit 3. With JUnit4 you use the @ContextConfiguration and @RunWith annotations.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Exactly like Mark pointed out I'm now using @RunWith and @ContextConfigLocation annotations. But I have some problems with running it. I have the context files in my src/main/resources/ folder and I'm running my tests from src/test folder and it complains that it cannot find the context file. I do not want to duplicate the context file again in the src/test/resources folder. Is there a way to get this out?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Ok it worked now. Changed to classpath:config/common/applicationContext-velocity-email.xml.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
Changed to classpath:config/common/applicationContext-velocity-email.xml.
What was the context path before ?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I did not have the classpath:.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring TestCase Exception
 
Similar Threads
JUnit and Spring
Exception when trying to run a test with Spring runner
Spring JUnit error
Spring - Connection Problem in some Unit Tests
Maven in Spring test