Announcement Announcement Module
Collapse
No announcement yet.
Junit4 errors with Application Context and BlazeDS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Junit4 errors with Application Context and BlazeDS

    Is anyone using the spring junit4 class: AbstractJUnit4SpringContextTests and able to run tests. I have a test class setup that is testing my services and daos that loads in the applicationContext.xml and throws an error when I try to run tests. This is the error: Error creating bean with name '_messageBrokerDefaultHandlerMapping':

    That is part of it, it is essentially a context load failure. The server will start up fine and create the blazeds message broker. If I comment out the flex stuff in app context the junit tests will run fine.

    So, the question is, is there anything that needs to be done so junit can load in the app context without having to comment out the flex stuff?

    thanks

  • #2
    Work around

    I did find a work around for this problem. I broke the flex config out into its own context file. Then I have the web.xml load that context file in addition to the main application file. So, essentially this.

    HTML Code:
    <param-value>
    	classpath:/config/applicationContext.xml
    	classpath:/config/blazeContext.xml
    </param-value>
    Now the server will still start and create the flex message broker and junit can load the application context without being confused by the message broker piece. However, I'm concerned that this may introduce other problems having it configured this way. Also, this does seem hackish. Any other suggestions would be appreciated.

    Comment


    • #3
      Originally posted by gabron View Post
      However, I'm concerned that this may introduce other problems having it configured this way. Also, this does seem hackish. Any other suggestions would be appreciated.
      Breaking the application context up into multiple files by general area of function is considered best practice for any non-trivial Spring application. Take a look at how we've done it in the testdrive app, for example.

      If you really want to integration test the full context including the BlazeDS pieces, you will need to properly set up mocks for the Servlet API. Take a look at AbstractFlexConfigurationTests from the project source for an example. This is using the old JUnit 3 test class hierarchy, but the same techniques should be able to be applied with JUnit 4.

      Comment

      Working...
      X