Bonjour à tous,

Soit la déclaration des mes beans mocks :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
    <!-- Factory de Mock pour les Tests Unitaires spécifique à Junit4-->
    <bean id="myContext" 
      class="org.jmock.integration.junit4.JUnit4Mockery"></bean>
 
 
<!-- Définition des mocks de DAO -->
	<bean id="rfcteDao" 
      factory-bean="myContext"
      factory-method="mock">
      <constructor-arg value="data.dao.IRfocteDao" />
      </bean>
et le code suivant (classe de test!) :

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
@RunWith( JMock.class )
@ContextConfiguration(locations="classpath:/metadata/applicationContextTest.xml")
	public class TestRetraRfoperBH extends TestMain_BH  //qui étend bien de l'abstract context de spring...
{
 
	public final static String REVISION = "$LastChangedRevision: 7514 $";
	public final static String ND_DEB = "#ND_DEB#";
	public final static String ND_FIN = "#ND_FIN#";
 
	@Autowired JUnit4Mockery myContext;
 
	@Autowired private IRfocteDao rfocteDao = null;
 
        @Autowired private IRetraRfoperBH retraRfoperBH = null;
 
 
private Rfocte rfoCte= null;
 
@Test
	public void testCreatePeriodes() throws UnexpectedDaoException, DataFormMapException
	{
 
		 ds = new SDataSet();
		rfoCte = ds.createWithNullKey(Rfocte.meta);
		rfoCte.setInt(Rfocte.rfoctecal, 0);
	//lTpe.add(rfoTpe);
	//lTpe.add(rfoTpe);
	tabArgFind1[0]= "testRef";
	tabArgFind1[1]= "testCte";
 
 
		myContext.checking(new Expectations() {{
 
			oneOf(rfocteDao).find(with(any(SDataSet.class)), with(equal(tabArgFind1))); will(returnValue(rfoCte)); //ERREUR A CETTE LIGNE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
		}});
 
 
		try {
			retraRfoperBH.createPeriodes(DefaultDates.debutRfoper(), DefaultDates.finRfoper(), "testRef", "testCte", logger, new JobState("test"));
		} catch (BusinessException e) {
			logger.debug(e.getMessage());
			fail("Business Exception");		
		} catch(AssumptionViolatedException e) {
			fail("Mock Exeception");
		}
		  catch (Exception e) {
			fail("Exception non gérée");
		} 
 
 
		myContext.assertIsSatisfied();
 
	}
 
 
}


J'obtient le message d'erreur décris dans le titre (venant d'une verification du type d'objet dans le code de Jmock, je suis aller voir dans les sources) ! Un soucis d'injection ? Je débute en Spring et Tests unitaires, je vous laisse imaginer.

J'utilise Junit 4.6(qui ne semble pas vraiment intervenir dans ce cas)
Jmock 2.5.1
et Spring 2.5 (avec spring-test)

Toute supposition, axe de réfléxion ou autre est la bienvenue.

Bonne soirée.