I am receiving the following error when attempting to inject my dao into a unit test class using spring.
UnitTest.DataAccess.FruitDaoTest.GetAllVitaminC:
SetUp : Spring.Objects.Factory.UnsatisfiedDependencyException : Error creating object with name 'FruitDaoTest' : Unsatisfied dependency expressed through object property 'FruitDao': Set this property value or disable dependency checking for this object.
Here is the segment of my spring config file that is relevant:
<db:provider
id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=stuff.group.stuff;Initial Catalog=zing;User ID=Marve; Password=stinky" />
<object id="transactionManager" type="Spring.Data.Core.AdoPlatformTransactionManager, Spring.Data">
<property name="DbProvider" ref="DbProvider" />
</object>
<object id="FruitDao" type="FruitBasket.DataAccess.FruitDao, FruitBasket">
<property name="DbProvider" ref="DbProvider"/>
<property name="user" value="apple" />
<property name="pass" value="orange" />
<property name="server" value="pear" />
</object>
I’m not very familiar with spring so I’m unsure of what the problem is here. Any ideas?
It seems your test does not use the context where you defined your FruitDao bean, thus preventing its autowiring… Check the GetContext/ConfigLocations methods to be sure you load the expected XML files.