View Full Version : Junit4 errors with Application Context and BlazeDS
Jun 27th, 2009, 10:33 AM
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?
Jun 27th, 2009, 11:02 AM
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.
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.
Jun 30th, 2009, 03:54 PM
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.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.