-
Notifications
You must be signed in to change notification settings - Fork 26
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
Adding Spring StaticApplicationContext #21
base: master
Are you sure you want to change the base?
Conversation
The only problem with this approach is sharing the created instance in test class which we can use an annotation to do so e.g @springcontext WDYT ? |
…nd PackageToScan, SpringStaticContext
Hi, Thanks for the pull request! :) Also, I think that I don't understand entirely the idea of injecting the into the test class. How could it be used afterwards? BTW. would you mind creating a JIRA issue for this functionality. https://issues.jboss.org/browse/ARQ/component/12313437 |
Also, please take a look at https://github.com/jmnarloch/arquillian-extension-guice/blob/master/int-tests/src/test/java/org/jboss/arquillian/extension/guice/testsuite/CustomInjectorTestCase.java That's the Guice enricher. I added there custom @GuiceInjector which allows to "grab" the application context directly from the test. Maybe that's the direction we could also aproach with spring extension? |
As goes for other ideas: http://blog.springsource.com/2011/06/21/spring-3-1-m2-testing-with-configuration-classes-and-profiles/ Spring Test has nice capabilities, that were not yet implemented in Arquillian extension. I would especially favor having inner static class annoated with @configuration, that could be used by the extension for configuring the application context. That would be really neat to have. |
I've created a JIRA issue and explained it there. |
What is SpringAnnotationConfiguration and where is it? I wasn't aware there is such a thing |
The @SpringAnnotationConfiguration from arquillian-service-integration-spring-javaconfig is used for configuring the AnnotationConfigApplicationContext by providing the classes to scan or optional packages. The only drawback is that it requires Spring 3.x in order to be used. |
Hi again, Let's continue the hight level discusion in JIRA and here let's discuss only the details. I'm wondering how can be injected @springcontext StaticApplicationContext used afterwads? |
Hi, I found it useful to have spring context in your test for some occasions. it's like your test is ApplicationContextAware. for example :
|
But you know that this works, out of the box in Spring? You just @autowire the ApplicationContext. There is no need for special annotation that would inject it. |
There is a test example in integrations tests: https://github.com/arquillian/arquillian-extension-spring/blob/master/arquillian-service-integration-spring-3-int-tests/src/test/java/org/jboss/arquillian/spring/testsuite/test/ApplicationContextTestCase.java I have nothing against having the StaticApplicationContext as one of the implementations, altughout would mind having the annotations made consistent with the existing ones? I were thinking about one single annotation something like: @interface SpringStaticConfiguration { Class<?>[] classes(); You can choice different name if you like. |
that's fine with me. I totally agree. thanks for your help |
It is a common way that developers programmatically register beans into context specially in testing rather than reading bean definitions from external configuration sources, in this case, you need to use StaticApplicationContext.
I added it to arquillian. please see StaticSpringContext