I keep getting this error , when trying to unit test my service.
my applicationContext.xml
Code:<bean id="rssService" class="org.springframework.aop.framework.ProxyFactoryBean"> <!-- define target of proxy--> <property name="target"> <ref local ="rssServiceTarget"/> </property> <property name="proxyInterfaces"> <value>com.vanitysoft.griffin.service.rss.IRSSService</value> </property> <property name="interceptorNames"> <list> <value>hibernateInterceptor</value> <value>cacheInterceptor</value> </list> </property> </bean> <bean id="rssServiceTarget" class="com.vanitysoft.griffin.service.rss.impl.RSSServiceImpl" > <property name="channelDAO"> <ref bean="channelDAO"/> </property> <property name="rssExtensionDAO"> <ref bean="rssExtensionDAO"/> </property> <property name="persistenceManager"> <ref bean="persistenceManagerHibernate"/> </property> <property name="cacheProvider"> <ref bean="cacheProvider"/> </property> <property name="translationService"> <ref bean="translationService"/> </property> <property name="scheduler"> <ref bean="scheduler"/> </property> <property name="poller"><ref bean="poller"/></property> </bean>
I am setting my Unit test up correctly im sure..
Code:package com.vanitysoft.griffin.service.rss.impl; import org.quartz.Scheduler; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import com.vanitysoft.griffin.service.rss.IRSSService; import de.nava.informa.utils.manager.PersistenceManagerIF; public abstract class AbstractServiceTest extends AbstractTransactionalDataSourceSpringContextTests{ protected IRSSService rssService = null; public void setRssService(IRSSService rssService) { this.rssService = rssService; } }
my unit test that extends the above class.
Code:public class RSSServiceTest extends AbstractServiceTest { //~ Static fields/initializers --------------------------------------------- //~ Instance fields -------------------------------------------------------- Logger logger = Logger.getLogger( RSSServiceTest.class ); //~ Constructors ----------------------------------------------------------- //~ Methods ---------------------------------------------------------------- public void testConvert( ) { rssService.doStuff(); }
my error is this,
Code:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.vanitysoft.griffin.service.rss.impl.RSSServiceTest' defined in null: Unsatisfied dependency expressed through bean property 'rssService': There are 4 beans of type [interface com.vanitysoft.griffin.service.rss.IRSSService] for autowire by type. There should have been 1 to be able to autowire property 'rssService' of bean 'com.vanitysoft.griffin.service.rss.impl.RSSServiceTest'. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:800) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:720) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:188) at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:141) at junit.framework.TestCase.runBare(TestCase.java:125) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Reply With Quote