I can help you. When I get home tonight can send you some base test
classes that will do what you want.
On May 15, 2009, at 2:01 PM, wkbutler <kent.but...@gmail.com> wrote:
Right, we're using Struts2. I'll investigate further, it would be
nice to
have the option. I'll post back if I find something useful. Thanks
Matt -
mraible wrote:
I'm guessing you're using Struts 2? If so, this won't work because
in a
normal (web.xml) environment, the filters handle wiring up the
dependencies.
Hopefully setting the dependencies manually isn't too much of a
pain. If
it
is, I'd suggest talking to the Struts 2 developers and see if
there's a
way
to enable autowiring (or the struts2-spring-plugin) during unit
testing.
Matt
On Fri, May 15, 2009 at 2:36 PM, wkbutler <kent.but...@gmail.com>
wrote:
Thanks dusty. Yes, you are correct -- test/resources contains a
couple
Spring configs that came default with AF2 (thanks Matt & group!)
and I
don't
believe I have changed them at all.
Sorry, I should have said - I'm testing our Actions, and the beans
are
declared in standard beans xml files. I verified that the
BaseActionTestCase is pulling in all of our expected appContexts,
and
indeed
it is setting AUTOWIRE_BY_NAME explicitly. Hmmmmm......
Here's an example action bean, FWIW:
<bean id="addressAction"
class="com.e3.webapp.action.AddressAction"
scope="prototype"/>
This bean should be picking up an 'addressManager' and a
'localSecurityContext' reference during testing, but it's not. Both
collaborators are defined as beans, and the names line up. The same
config
files work when executing jetty:run.
I have not tried used annotations for testing, BTW - ours is still
an old
school configuration.
I don't see any bit of the Spring configs under test/resources
that look
at
all relevant, either. It's all specific to User management and
datasource
configuration.
Thanks again -
dusty wrote:
Hey kent,
Autowiring should work for your unit tests. You likely have a
spring
configuration file in your test/resources directory. If you are
using
Spring annotations, you can make sure that they are configured to
be
scanned in your test applicationContext.xml.
There is a base test class, BaseDaoTestCase that gets things
setup and
fires up Spring for your tests. If you changed your Spring config
file names or locations you need to update this test class since it
has the Spring config file locations as a static array of Strings
if I
remember correctly.
Other than that what are you trying to wire? What are you trying
to
test, DAO, Manager or Controller?
-D
On May 14, 2009, at 8:58 PM, wkbutler wrote:
Hi all -
We're using Spring bean autowiring during the regular execution of
our app.
I believe this is a feature of the ContextLoaderListener which is
specified
in the web.xml. That works great.
In unit testing however, autowiring is not automatically
enabled. Our
Spring contexts are getting picked up from the classpath however,
same as
always.
Does anyone know how I can enable autowiring for unit testing?
Seems like a
configuration to the context currently being used by the unit
tester, but to
be honest I have not yet figured out how the unit testing mojo is
configured. Thanks for any pointers.
Kent
--
View this message in context:
http://www.nabble.com/Spring-Autowiring-during-Unit-testing-tp23553006s2369p23553006.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---
------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net
---
------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net
--
View this message in context:
http://www.nabble.com/Spring-Autowiring-during-Unit-testing-tp23553006s2369p23566907.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---
------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net
--
View this message in context:
http://www.nabble.com/Spring-Autowiring-during-Unit-testing-tp23553006s2369p23567226.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net