Morning!
I have a issue during use TestContext Framework.
------------------------------
My environment:
OS: Gentoo Linux x86 and x86-64
- kernel: 2.6.23-gentoo-r6
JVM: Sun JDK 1.6.0_04-b12 and BEA JRockIt R27.4.0-jdk1.6.0_02
Build engines:
- Apache Ant version 1.7.0 compiled on November 30 2007
- Apache Maven version: 2.0.8
AS: JBoss-4.2.2.GA.
ORM: Hibernate 3.2.5.GA
IDE: Eclipse-3.3.1.1
Test Engine: TestNG 5.7
Spring Framework 2.5.1
--------------------------------
I have two datasource in my configuration file:
--------------------------------
....
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource"
p:driverClassName="org.postgresql.Driver" p:url="jdbcostgresql://localhost:5432/myDB"
p:username="johnbat26" password="" />
<bean id="dataSource2" class="org.springframework.jdbc.datasource.DriverM anagerDataSource"
p:driverClassName="org.postgresql.Driver" p:url="jdbcostgresql://localhost:5432/myDB2"
p:username="johnbat26" password="" />
...
----------------------------
So I use TestNG 5.7, than extend AbstractTransactionalTestNGSpringContextTests class.
But this class use autowire byType (@Autowired annotation) for dataSource property:
------------------------
.....
@Autowired
public void setDataSource(final DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
......
------------------------
But I need inject dataSource2 in my bean too !
During start of test appear next exception:
-------------
Autowiring of methods failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire method: public void org.springframework.test.context.testng.AbstractTr ansactionalTestNGSpringContextTests.setDataSource( javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: [dataSource, dataSource2]
-------------
I understand that need use @Resourse annotation for autowire byName.
But this don't help (((
I don't overide annotation in AbstractTransactionalTestNGSpringContextTests class at dataSource property.
What I must do for resolve this problem ?
Thanks in advance!


ostgresql://localhost:5432/myDB"
Reply With Quote

