Salut tout le monde,

Je vous remercierais si vous pouvez me dire qu'est ce qu il y a de mal dans mon code.
Voila le test que je veux faire:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class BebidaDaoHibernateTest extends AbstractTransactionalDataSourceSpringContextTests  {
 
	private Bebida bebida= null; 
	private BebidaDao bebidaDao= null; 
 
	public BebidaDaoHibernateTest() {		
		this.setDependencyCheck(false);
		this.setAutowireMode(AUTOWIRE_BY_NAME);
 
	}
 
	public void setBebidaDao(BebidaDao bebidaDao) {
		this.bebidaDao = bebidaDao;
	}
 
 
	@Override
	protected String[] getConfigLocations() {
 
		return new String[]{"classpath*:src/main/resources/applicationContext*.xml"};
 
	}
 
 
 
    public void testAltabebida() throws Exception {
        bebida = new Bebida();
        bebida.setIdtipobebida(1);        
        bebida.setAlcoholica(true);
        bebida.setIdcategoriaalimento(1);
        bebida.setIdproveedor(2);
        bebida.setNombrebebida("tequila");
        bebida.setNombrebodega("sur");
 
 
        this.bebidaDao.altaBebida(bebida);
        Assert.assertNotNull("primary key assigned", bebida.getId());
 
    }
}
Voila ce qu'il y dans mon fichier de configuration

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
  <!-- DAO Definition: Hibernate implementation -->
	<bean id="bebidaDao" class="com.bonetechnology.geo.dao.hibernate.BebidaDaoHibernate">
		<property name="hibernateTemplate">
			<ref bean="hibernateTemplate"/>
		</property>
	</bean>


Pour le code en java j'ai essaye d'obtenir bebidaDao avec Depency of Injection et d'autre part avec le code suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 /**
//         * Overridden method from base class which gets called automatically
//         */
//	  protected void onSetUpBeforeTransaction() throws Exception {
//	      super.onSetUpBeforeTransaction();	 	      	      
//	      this.bebidaDao = (BebidaDao) applicationContext.getBean("bebidaDao");	      
//	  }
Et je trouve l'erreur suivant:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bebidaDao' is defined: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans []; Root of BeanFactory hierarchy
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:242)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:498)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:143)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:399)
	at com.bonetechnology.geo.dao.hibernate.BebidaDaoHibernateTest.onSetUpBeforeTransaction(BebidaDaoHibernateTest.java:46)
	at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:102)
	at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:192)
	at junit.framework.TestCase.runBare(TestCase.java:125)
	at junit.framework.TestResult$1.protect(TestResult.java:106)