File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Testing the spring configuration file 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 » Other Application Frameworks
Bookmark "Testing the spring configuration file" Watch "Testing the spring configuration file" New topic
Author

Testing the spring configuration file

Joshua Antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 254
I am working in an application consisting of 3 to 4 spring configuration file.
Each file has many bean definitions.

I am using JBoss to deploy the application. But if there occurs some problem in the bean instantion from the spring configuration file, my application is not getting deployed.

Is there any way by which we can test configuration file which consist spring bean definitions, so that I can confidently deploy in JBoss?

Regards,
Joshua


SCJP,SCWCD, Into ATG now!
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
A unit test that loads the ApplicationContext ought to do it. While you are at it you could attempt to pull each Bean and make sure you get them and they are of the correct type.
akrem asaed
Greenhorn

Joined: Jun 16, 2011
Posts: 1
I agree with Tim that a unit test should load it. But that being said, it won't test everything because unit test will detect problems involving the beans that you try to load in your test . The best way i found to test the configuration is using JUnit with an open-source project called Beanoh and it's in github it was extremely easy to use

e.g.


and this basically will go through all the beans defined in a bootstrap spring context (by default it looks for com.somepackage.SomeTest-BeanohContext.xml ) and one by one it attempts to load them which will throw an exception if spring cannot load the beans correctly .... Beanoh also has another test for @component annotated classes and detecting duplicate bean ids ... really helpful
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing the spring configuration file
 
Similar Threads
Exception when webservice is invoked
Application properties
Tiles definitions in xml:working sample code in war
JBOSS takes more time to deploy my war file.
Deploye Enterprise application in Server