IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 1 Java Discussion :

ListRecordActionTest ne marche pas


Sujet :

Struts 1 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2006
    Messages : 241
    Par défaut ListRecordActionTest ne marche pas
    Bonjour,

    J'ai un souci avec un test; effet je voudrais faire un tests sur une action qui test si affiche les record pour cela j'ai ceci :
    mon fichier de struts :
    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
     
    <?xml version="1.0" encoding="ISO-8859-1" ?>
     
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
     
    <struts-config>
    		<form-beans>
    		</form-beans>
     
    		<action-mappings>
     
    			<action path="/listrecords"  
    				input="/listrecords.jsp" 
    				type="phoneBookAction.ListRecordAction" 
    				scope="session">
    			<forward name="page" path="/listrecords.jsp" />
    			<forward name="next" path="/resultlistrecord.jsp"  />
    			</action>
    		</action-mappings>
     
    </struts-config>
    mon test
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
     
    public void testListRecordHF() {
    		Map<String, phoneBookBo.Employee> map = new HashMap<String, phoneBookBo.Employee>();
    		map.put(...);
     
     
    		setRequestPathInfo("/listrecords");
    		actionPerform();
    		verifyForward("success");
    		verifyNoActionErrors();
    	}
    ma jsp qui contient un bouton sur lequel on doit cliquer si on veut afficher les records

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <html:form action="/listrecords">
    	<html:submit />
    </html:form>
    jsp de résultat :

    A remarquer que je n'ai pas de form vu que je n'en ai pas besoin...

    J'ai l'erreur suivante

    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
    java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
    	at servletunit.struts.MockStrutsTestCase.setRequestPathInfo(MockStrutsTestCase.java:378)
    	at servletunit.struts.MockStrutsTestCase.setRequestPathInfo(MockStrutsTestCase.java:355)
    	at test.ListRecordsActionTest.testListRecordHF(ListRecordsActionTest.java:17)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	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)

  2. #2
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Soit il manque le jar commons-collections.jar sous WEB-INF/lib, soit tu n'as pas la bonne version.

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2006
    Messages : 241
    Par défaut ListRecordActionTest ne marche pas
    effectivement, je ne l'ai pas mais comment ça se fait alors que j'ai pris tous les libs de struts-1.3.8

    Où je peux le trouver ?

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2006
    Messages : 241
    Par défaut ListRecordActionTest ne marche pas
    Je viens de faire une recherche sur mon pc, me disant que ce commons-collections.jar, je dois l'avoir quelque part. mais je viens de constater que ce jar se trouve dans la version de jakarta-stuts-1.1 et en l'incluant, j'ai cette erreur

    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
     
    junit.framework.AssertionFailedError: class "org.apache.commons.collections.ArrayStack"'s signer information does not match signer information of other classes in the same package
    	at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:244)
    	at servletunit.struts.MockStrutsTestCase.tearDown(MockStrutsTestCase.java:126)
    	at junit.framework.TestCase.runBare(TestCase.java:130)
    	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 junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	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)
    Je me doute bien que ça ne peut pas marcher vu que ce ne sont pas les même versions

  5. #5
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Tu peux le télécharger ici.

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2006
    Messages : 241
    Par défaut ListRecordActionTest ne marche pas
    J'ai bel bien mis la lib et mon problème s'est deplacé. En effet, j'ai maintenant ce genre d'erreur dans ma console.

    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
     
    servletunit.struts.ExceptionDuringTestError: An uncaught exception was thrown during actionExecute()
    	at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:305)
    	at test.ListRecordsActionTest.testListRecordHF(ListRecordsActionTest.java:18)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	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)
    ------------
    Root Cause:
    ------------
    javax.servlet.ServletException: java.lang.ClassCastException: phoneBookAction.ListRecordAction
    	at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
    	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.testListRecordHF(ListRecordsActionTest.java:18)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	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)
    Caused by: java.lang.ClassCastException: phoneBookAction.ListRecordAction
    	at org.apache.struts.chain.commands.servlet.CreateAction.createAction(CreateAction.java:98)
    	at org.apache.struts.chain.commands.servlet.CreateAction.getAction(CreateAction.java:68)
    	at org.apache.struts.chain.commands.AbstractCreateAction.execute(AbstractCreateAction.java:90)
    	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)
    	... 20 more
    ------------
    Root Cause:
    ------------
    java.lang.ClassCastException: phoneBookAction.ListRecordAction
    	at org.apache.struts.chain.commands.servlet.CreateAction.createAction(CreateAction.java:98)
    	at org.apache.struts.chain.commands.servlet.CreateAction.getAction(CreateAction.java:68)
    	at org.apache.struts.chain.commands.AbstractCreateAction.execute(AbstractCreateAction.java:90)
    	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.testListRecordHF(ListRecordsActionTest.java:18)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	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)
    L'erreur se produit lorsque mon test arrive sur la ma méthode : actionPerform();

    pour info voici mon fichier de struts config

    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
    <?xml version="1.0" encoding="ISO-8859-1" ?>
     
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
     
    <struts-config>
    		<form-beans>
    			<form-bean name="listrecordsForm" type="phoneBookForm.ListrecordsForm" />
    		</form-beans>
     
    		<global-exceptions>
     
    		</global-exceptions>
     
    		<action-mappings>
     
    			<action path="/listrecords" 
    				name="listrecordsForm"  
    				input="/listrecords.jsp" 
    				type="phoneBookAction.ListRecordAction"
    				scope="session">
    			<forward name="page" path="/listrecords.jsp" />
    			<forward name="next" path="/resultlistrecord.jsp" />
    			</action>
    		</action-mappings>
     
    </struts-config>
    mon test

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
     
    public void testListRecordHF() {
    		Map map = new HashMap();
    		map.put(...);
     
    		request.getSession().setAttribute("map", map);
    		setRequestPathInfo("/listrecords");
    		actionPerform();
    		verifyForward("success");
    		verifyNoActionErrors();
    	}
    J'ai été contrainte de créer un formulaire vide car mon test me exigeait alors que je n'en ai pas besoin. En effet, comme dit precedement mon form ne contient qu'un bouton qui lorsqu'on clique dessus affiche tous enregistrements se trouvant dans une map.

    Quelle est la meilleur façon de faire ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. 'SHOW TABLES' marche pas sous postgresql !?
    Par fet dans le forum PostgreSQL
    Réponses: 4
    Dernier message: 13/05/2004, 09h28
  2. Maximiser fenêtre ne marche pas
    Par sandrinec dans le forum Composants VCL
    Réponses: 2
    Dernier message: 12/06/2003, 12h02
  3. Réponses: 9
    Dernier message: 07/05/2003, 12h57
  4. [GifDecoder] marche pas dans applet avec IE
    Par formentor dans le forum Applets
    Réponses: 2
    Dernier message: 06/05/2003, 10h43
  5. Sysdate qui marche pas ??
    Par StouffR dans le forum Langage SQL
    Réponses: 4
    Dernier message: 28/08/2002, 13h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo