Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
ApplicationContext returns null in Junit Test Case Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ApplicationContext returns null in Junit Test Case

    Hi All,
    I am new to spring framework , Just wanted to know if there is any plug in required for testing DAO component (uses both Spring & Hibernate ) in Junit Test class.

    For example spring provides Struts ContextLoaderPlugIn from where it gets the application context.
    org.springframework.web.struts.ContextLoaderPlugIn


    Basically I have written a abstract class which extends org.springframework.test.AbstractSpringContextTest s class and then I am calling my Junit Test class by extending the base class.

    In Junit test class construter , am trying to access the bean
    dao= (DAO) applicationContext.getBean("dao");

    Thanks in advance

  • #2
    How does your abstract class know what spring xml files to load?

    Comment


    • #3
      Try this
      XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("myFile.xml", getClass()));

      Replace 'myfile.xml' with your bean definition xml, and make availbale in the classpath

      Comment

      Working...
      X