Announcement Announcement Module
Collapse
No announcement yet.
Testing business logic outside of the servlet container Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing business logic outside of the servlet container

    I'm faced with the following question :

    I would like to do extensive testing on my service objects , and i'd like to do it if possible outside the servlet container . The problem is that , if I do it outside of the container , spring isn't really alive to pass the dependency objects arround , and load the application-Context files .

    Is there any way to have all of these facilities outside of the container , so I can run simple Junit tests on them ?

    Thanks

  • #2
    The problem is that , if I do it outside of the container , spring isn't really alive to pass the dependency objects arround , and load the application-Context files
    Absolutely. Spring is in no way tied to the servlet container or any other environment. Look for example at ClasspathXmlApplicationContext, which you can use in a plain JUnit test.

    Look also at the spring-mock.jar. The org.springframework.test package has convenient superclasses you can use that will load your context files in JUnit tests.

    But remember also that you should do thorough unit testing with no dependence even on the Spring container.

    Comment


    • #3
      Maybe ContextTestCase--in following post--would be helpful for your integration testing needs?

      http://forum.springframework.org/sho...d.php?t=10273=
      Last edited by robyn; May 14th, 2006, 05:21 PM.

      Comment


      • #4
        We run most of our back-end server processes using Spring outside of a J2EE or servlet container.

        Our application contains a service locator implementation (a well-documented J2EE pattern) that is basically just a wrapper around a ClasspathXmlApplicationContext. Works great in and out of a container. All someone has to do to bootstrap the business service and persistence layers in a main() method or JUnit fixture is to instantiate the service locator.

        Comment

        Working...
        X