Bonjour,

je voudrais écrire des tets unitaires pour lookupdispatchaction mon action. cette action etends une.

Dans mes tests, je n'arrive pas à savoir commment setter l'operation(add, delete, etc) ce qui fait que j'ai l'erreur suivant :

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
 
 
ATTENTION: Unhandled exception
javax.servlet.ServletException: Action[/lookup] missing resource in key method map
	at org.apache.struts.actions.LookupDispatchAction.getLookupMapName(LookupDispatchAction.java:232)
	at org.apache.struts.actions.LookupDispatchAction.getMethodName(LookupDispatchAction.java:272)
	at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:157)
	at org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:146)
	at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
	at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
	at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
	at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
	at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
	at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
	at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
	at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:290)
	at test.ListRecordsActionTest.addRecordsRecordHF(ListRecordsActionTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	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.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
16-oct.-2007 21:05:19 org.apache.struts.chain.commands.ExceptionCatcher postprocess
Dans mon action, j'ai ceci comme operation

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
 
	public static final String OPERATION_AJOUTER = "operation.ajouter";
 
	public static final String OPERATION_MODIFIER = "operation.modifier";
 
	public static final String OPERATION_SUPPRIMER = "operation.supprimer";
 
	public static final String OPERATION_TRIER = "operation.sort";
 
	public Map getKeyMethodMap() {
		Map<String, String> map = new HashMap<String, String>();
		map.put(OPERATION_AJOUTER, "ajouter");
		map.put(OPERATION_MODIFIER, "modifier");
		map.put(OPERATION_SUPPRIMER, "supprimer");
		map.put(OPERATION_TRIER, "trier");
		return map;
	}
fk04