-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit test : spring context loaded several times #185
Comments
From alexis.t...@gmail.com on May 22, 2014 01:50:03 Another point, i think webscript test should also use annotation : The benefits is to @Autowired bean needed to setup the test data, and this will execute test in remote runner mode. |
From colum...@gmail.com on June 10, 2014 05:47:25 Labels: Milestone-Release-sdk-2.0.0 |
From colum...@gmail.com on June 10, 2014 05:47:57 Hey Alexis, would you be interested in committing this patch and testing it? I can give you commit access relatively easily. |
From alexis.t...@gmail.com on June 14, 2014 12:37:02 Hi gabriele, In my opinion, i think we should let unit test start the context in RemoteServer. I made some test : you first have to start the RemoteServer main method with a correct classpath, then you launch test class. Test class will connect to RemoteServer, and start, first time, the unit test context. For now, i start the RemoteServer with netbeans, but it should be possible to start this with maven exec plugin or someting else. Maybe you have another idea, or you already fix that ? |
@maoo Can you review this one on JRebel? |
Now the spring context is reloaded only once at the first remote testing invocation. So I think I can close this issue. On another note, Spring contexts are not reloaded at all right now with the new Spring Loaded approach and we need to work (as part of issue #158) to get that sorted. |
From alexis.t...@gmail.com on May 22, 2014 04:44:16
There a 2 ways to write test in alfresco :
-Extending BaseWebScriptTest when you need to test webscript. In this case, BaseWebscriptTest call TestWebScriptRepoServer.getTestServer(). This method use ApplicationContextHelper to load the context.
@RunWith(RemoteTestRunner.class)
@Remote(runnerClass = SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:alfresco/application-context.xml")
Context is loaded by spring, spring will not call ApplicationContextHelper to load the context.
Result : In a project, when you have both type of tests, context is loaded several times.
To fix, the issue, i wrote a customer loader (see attached file).
@ContextConfiguration(loader = AlfrescoContextLoader.class)
public class MyTestCase {
Attachment: AlfrescoContextLoader.java
Original issue: http://code.google.com/p/maven-alfresco-archetypes/issues/detail?id=185
The text was updated successfully, but these errors were encountered: