I want to initialize Spring once and only once in my application/running code (and I do that in the main(String[] args method).
Now I am writing tests, I also want to init only once in my unit test code (but it should already be init'd for my application to run. How do I structure my code/classs so that I would not have to cut-copy-paste code from my app code into my test code and reuse the same Spring context that is init'd in main()?
In other words, I would have to be init'd in the application code and then somehow passed to my unit or system test code so that it has the same instance of 'context' throughout.
I am initializing the Spring context in a
public static void main(String[] args) {
...
ApplicationContext context =
new AnnotationConfigApplicationContext(SpringConfig.class);
...
}
Thanks
J.V.