• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing the spring configuration file

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic