on 07-28-2014 12:11 PM
Hi everyone,
I am using Hybris 4.5.x and I have problems creating Spring's web application context defined in myExtension-web-spring.xml when running an integration test using "ant yunitweb".
The problem has been posted in the wiki forum some time ago (https://wiki.hybris.com/display/forum/JUnit+using+spring+in+web+testsrc), but the answer given there is not satisfying, since it suggests to create beans manually one by one within the test, if I'm right. I'd rather prefer that the context is build based on the xml config file. Is there any way to accomplish this?
As an additional question, is there any way to debug tests running with "ant yunitweb" using Ee IDE?
Many thanks in advance!
With the wiki link you've provided, you can still use the xml to define the beans, and then use the following:
return (T) Registry.getApplicationContext().getBean(<YOUR_BEAN_ID>);
And it should inject the bean as intended. Not the most ideal solution ever, but at least you can turn this into a util that is similar to @Resource or @Autowired, perhaps even a custom annotation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you. Indeed that's how I assign the bean to the object in my test after I registered it using the suggested solution mentioned above.
I guess the test runner simply does not know about the xml config file (which, as far as I can see, is only mentioned in WEB-INF/web.xml) where the web application context is defined. So I am basically looking for a way to specify in the test the path to where I defined the web application context. I originally expected ant yunitweb
to process the information specified in web.xml concerning the application context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.