This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
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 Soft Skills this week in the Jobs Discussion 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: 9622
    
    2

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, Certified Scrum Master
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: 17260
    
    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: 9622
    
    2

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: 9622
    
    2

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

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

Joined: Sep 26, 2006
Posts: 9622
    
    2

I did not have the classpath:.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring TestCase Exception