Re: how to test what radio is checked in a radiogroup?

2011-08-22 Thread Mathilde Pellerin
It works well when I don't provide the complete path !

Thank you a lot Mike !


Re: how to test what radio is checked in a radiogroup?

2011-08-22 Thread Kent Tong
> In my unit test, I try to check what radio is selected, but I don't find
> how...

You may check out http://wicketpagetest.sourceforge.net which will work
for this use case.



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: how to test what radio is checked in a radiogroup?

2011-08-22 Thread Mike Mander

Am 22.08.2011 13:27, schrieb Mike Mander:

Am 22.08.2011 09:45, schrieb Mathilde Pellerin:

Hi all,

thanks for your answers.
So, Ajax can be a problem with tagTester. Ok, so I don't use Ajax 
response

anymore to render my page :

 public void 
testStory23_TA21_VerificationInitialisationBoutonsRadio(){

 Questionnaire questionnaire =
serviceQuestionnaire.findBytitre("Questionnaire pour Femme").get(0);
 CreationQuestionnairePage creationQuestionnairePage = new
CreationQuestionnairePage(
 new PageParameters("p=2"), questionnaire);
 tester.startPage(creationQuestionnairePage);
 tester.assertRenderedPage(CreationQuestionnairePage.class);

then, I checked my markup by tester.dumpPage() :
Questionnaires


{ }.bind(this),function() { }.bind(this), function() {return
Wicket.$('retourRecapitulatif3') != null;}.bind(this));return
!wcall;">Retour à la liste
 des questionnaires

Création d'un nouveau questionnaire :

action="?wicket:interface=:0:formCreationQuestionnaire::IFormSubmitListener::" 


enctype="multipart/form-data">style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden">

type="hidden" name="formCreationQuestionnaire4_hf_0"
id="formCreationQuestionnaire4_hf_0" />








Titre du nouveau questionnaire
:




Numéro :




Genre des destinataires :

  wicket:id="femme" id="femme6" name="genre" value="radio0" 
checked="checked"

class="wicket-genre7"/>  Femme
    Homme
    Mixte




we can see that radio button with wicket:id="femme" have tag "checked".
But in my test :
 TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
 TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
 TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
 //tester.debugComponentTrees();
 tester.dumpPage();
 Assert.assertNotNull(tagFemme);

tagFemme is still null.

I checked my path for this radio button with 
tester.debugComponentTrees() :
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre

 org.apache.wicket.markup.html.form.RadioGroup [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:femme
org.apache.wicket.markup.html.form.Radio [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:homme
org.apache.wicket.markup.html.form.Radio [h]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:mixte
org.apache.wicket.markup.html.form.Radio [b]

I really don't understand what am I doing wrong...


Where is genre? Try

formCreationQuestionnaire:homme

. Did that help?
Mike

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Ähm sorry for my stupidity but i didn't used this for a long time.
Try to use homme (and other radios) only!!! TagTester is searching for 
the wicket:id. Parent components are not relevant. So you don't have to 
provide the complete path.


Sorry,
Mike

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: how to test what radio is checked in a radiogroup?

2011-08-22 Thread Mike Mander

Am 22.08.2011 09:45, schrieb Mathilde Pellerin:

Hi all,

thanks for your answers.
So, Ajax can be a problem with tagTester. Ok, so I don't use Ajax response
anymore to render my page :

 public void testStory23_TA21_VerificationInitialisationBoutonsRadio(){
 Questionnaire questionnaire =
serviceQuestionnaire.findBytitre("Questionnaire pour Femme").get(0);
 CreationQuestionnairePage creationQuestionnairePage = new
CreationQuestionnairePage(
 new PageParameters("p=2"), questionnaire);
 tester.startPage(creationQuestionnairePage);
 tester.assertRenderedPage(CreationQuestionnairePage.class);

then, I checked my markup by tester.dumpPage() :
Questionnaires
 
 Retour à la liste
 des questionnaires
 
 Création d'un nouveau questionnaire :
 
 
 
 
 


 
 
 
 Titre du nouveau questionnaire
:
 
 
 
 
 Numéro :
 
 
 
 
 Genre des destinataires :
 
     Femme
     Homme
     Mixte

 
 

we can see that radio button with wicket:id="femme" have tag "checked".
But in my test :
 TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
 TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
 TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
 //tester.debugComponentTrees();
 tester.dumpPage();
 Assert.assertNotNull(tagFemme);

tagFemme is still null.

I checked my path for this radio button with tester.debugComponentTrees() :
INFO  - BaseWicketTester   - pathformCreationQuestionnaire:genre
 org.apache.wicket.markup.html.form.RadioGroup [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:femme
org.apache.wicket.markup.html.form.Radio [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:homme
org.apache.wicket.markup.html.form.Radio [h]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:mixte
org.apache.wicket.markup.html.form.Radio [b]

I really don't understand what am I doing wrong...


Where is genre? Try

formCreationQuestionnaire:homme

. Did that help?
Mike

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: how to test what radio is checked in a radiogroup?

2011-08-22 Thread Mathilde Pellerin
Hi all,

thanks for your answers.
So, Ajax can be a problem with tagTester. Ok, so I don't use Ajax response
anymore to render my page :

public void testStory23_TA21_VerificationInitialisationBoutonsRadio(){
Questionnaire questionnaire =
serviceQuestionnaire.findBytitre("Questionnaire pour Femme").get(0);
CreationQuestionnairePage creationQuestionnairePage = new
CreationQuestionnairePage(
new PageParameters("p=2"), questionnaire);
tester.startPage(creationQuestionnairePage);
tester.assertRenderedPage(CreationQuestionnairePage.class);

then, I checked my markup by tester.dumpPage() :
Questionnaires

Retour à la liste
des questionnaires

Création d'un nouveau questionnaire :










Titre du nouveau questionnaire
:




Numéro :




Genre des destinataires :

     Femme
     Homme
     Mixte




we can see that radio button with wicket:id="femme" have tag "checked".
But in my test :
TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
//tester.debugComponentTrees();
tester.dumpPage();
Assert.assertNotNull(tagFemme);

tagFemme is still null.

I checked my path for this radio button with tester.debugComponentTrees() :
INFO  - BaseWicketTester   - pathformCreationQuestionnaire:genre
org.apache.wicket.markup.html.form.RadioGroup [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:femme
org.apache.wicket.markup.html.form.Radio [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:homme
org.apache.wicket.markup.html.form.Radio [h]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:mixte
org.apache.wicket.markup.html.form.Radio [b]

I really don't understand what am I doing wrong...


Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Per Newgro

Welcome to wicket Shunmuga

Did you check the website http://wicket.apache.org already. It's all there.
Check the wiki, component examples and books section.

Hope you have fun with wicket

Cheers
Per

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Shunmuga Raj
Hi all,

  I'm new to Wicket. Can you help me to know what is wicket & how it
works? pls ppl's mail me the links for it's tutorials and learning path. Now
i'm using Netbeans 6.9,7.0 so pls share the plugins for it too, Thanks in
advance

On Fri, Aug 19, 2011 at 11:28 PM, "Mike Müller"  wrote:

> If i'm not completely wrong is tester.clickLink(path) a wrapper for
> tester.clickLink(path, isAjax = true). So you get an ajax response.
> You can check that by calling tester.dumpPage().
>
> The problem is that wicket tester only works on page markup. It is not
> working on ajax response markup (at least i didn't get it to work.
> Once i've wrote an extractor. Maybe that helps you to.
>
> 
> package de.frontend.wicket.testtools;
>
> public final class AjaxResponseComponentMarkup {
>
>private final String _ajaxResponseMarkup;
>private final int _componentTagStartPosition;
>private final int _componentTagEndPosition;
>
>public AjaxResponseComponentMarkup(String ajaxResponseMarkup) {
>_ajaxResponseMarkup = ajaxResponseMarkup;
>_componentTagStartPosition =
> _ajaxResponseMarkup.indexOf("_componentTagEndPosition =
> _ajaxResponseMarkup.indexOf("");
>}
>
>public String extract() {
>StringBuilder result = new StringBuilder();
>if (hasComponentTag()) {
>
>  
> result.append(_ajaxResponseMarkup.substring(startOfAjaxResponseComponentMarkup(),
> endOfAjaxResponseComponentMarkup()));
>}
>return result.toString();
>}
>
>private int startOfAjaxResponseComponentMarkup() {
>String cdataTag = "";
>return
> _ajaxResponseMarkup.substring(_componentTagStartPosition,
> _componentTagEndPosition).lastIndexOf(cdataTag) +
> _componentTagStartPosition;
>}
>
>private boolean hasComponentTag() {
>return _componentTagStartPosition != -1;
>}
> }
> 
> This is only extracting the markup in CDATA of ajax response.
> Use it this way:
>
> 
>
>private void assertExpandedNodeAt(int row) {
>List t = TagTester.createTagsByAttribute(new
> AjaxResponseComponentMarkup(_tester.getServletResponse().getDocument()).extract(),
> "wicketpath",
>"brdPage_availability_tariffTable_rows_" +
> row + "_cells_1_cell_junction", true);
>Assert.assertTrue("Node " + row + " is collapsed",
> t.get(0).getAttributeIs("class", "tree-junction-expanded"));
>}
> 
>
> Please see TagTester.createTagsByAttribute for concrete parameters
> required.
>
> Maybe someone else has a better approach. But for me this was working.
>
> Hth
> Mike
>
>  Original-Nachricht 
> > Datum: Fri, 19 Aug 2011 18:38:43 +0200
> > Von: Mathilde Pellerin 
> > An: users@wicket.apache.org
> > Betreff: Re: how to test what radio is checked in a radiogroup?
>
> > hum, yes and no... I mean, page is loaded by an ajax response (AjaxLink),
> > but then there is no Ajax.
> > This is the entire test, maybe it can help :
> >
> > @SuppressWarnings("unchecked")
> > @Test @Transactional @Rollback
> > public void
> testStory23_TA21_VerificationInitialisationBoutonsRadio(){
> > tester.startPage(RecapitulatifQuestionnairePage.class);
> > tester.assertRenderedPage(RecapitulatifQuestionnairePage.class);
> > tester.clickLink("questionnaireEnCours:1:modifier");
> > tester.assertRenderedPage(CreationQuestionnairePage.class);
> >
> > Form form = (Form)
> > tester.getComponentFromLastRenderedPage(
> > "formCreationQuestionnaire");
> >
> > //On vérifie que le formulaire est préremplie avec le
> > questionnaire
> > sélectionné
> > Questionnaire qObtenu = form.getModelObject();
> > Assert.assertNotNull(qObtenu);
> >
> > //Vérification du sexe des destinataires
> > String genreAttendu = qObtenu.getSexeDestinataire().toString();
> > String genreObtenu =
> > ((RadioGroup)form.get("genre")).getDefaultModelObjectAsString();
> > Assert.assertEquals(genreAttendu, genreObtenu);
> >
> > TagTester tagFemme =
> > tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
> > Ta

Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mike Müller
If i'm not completely wrong is tester.clickLink(path) a wrapper for 
tester.clickLink(path, isAjax = true). So you get an ajax response.
You can check that by calling tester.dumpPage().

The problem is that wicket tester only works on page markup. It is not
working on ajax response markup (at least i didn't get it to work.
Once i've wrote an extractor. Maybe that helps you to.


package de.frontend.wicket.testtools;

public final class AjaxResponseComponentMarkup {

private final String _ajaxResponseMarkup;
private final int _componentTagStartPosition;
private final int _componentTagEndPosition;

public AjaxResponseComponentMarkup(String ajaxResponseMarkup) {
_ajaxResponseMarkup = ajaxResponseMarkup;
_componentTagStartPosition = 
_ajaxResponseMarkup.indexOf("");
}

public String extract() {
StringBuilder result = new StringBuilder();
if (hasComponentTag()) {

result.append(_ajaxResponseMarkup.substring(startOfAjaxResponseComponentMarkup(),
 endOfAjaxResponseComponentMarkup()));
}
return result.toString();
}

private int startOfAjaxResponseComponentMarkup() {
String cdataTag = "";
return 
_ajaxResponseMarkup.substring(_componentTagStartPosition, 
_componentTagEndPosition).lastIndexOf(cdataTag) + _componentTagStartPosition;
}

private boolean hasComponentTag() {
return _componentTagStartPosition != -1;
}
}
 
This is only extracting the markup in CDATA of ajax response.
Use it this way:



private void assertExpandedNodeAt(int row) {
List t = TagTester.createTagsByAttribute(new 
AjaxResponseComponentMarkup(_tester.getServletResponse().getDocument()).extract(),
 "wicketpath",
"brdPage_availability_tariffTable_rows_" + row 
+ "_cells_1_cell_junction", true);
Assert.assertTrue("Node " + row + " is collapsed", 
t.get(0).getAttributeIs("class", "tree-junction-expanded"));
}


Please see TagTester.createTagsByAttribute for concrete parameters required.

Maybe someone else has a better approach. But for me this was working.

Hth
Mike

 Original-Nachricht 
> Datum: Fri, 19 Aug 2011 18:38:43 +0200
> Von: Mathilde Pellerin 
> An: users@wicket.apache.org
> Betreff: Re: how to test what radio is checked in a radiogroup?

> hum, yes and no... I mean, page is loaded by an ajax response (AjaxLink),
> but then there is no Ajax.
> This is the entire test, maybe it can help :
> 
> @SuppressWarnings("unchecked")
> @Test @Transactional @Rollback
> public void testStory23_TA21_VerificationInitialisationBoutonsRadio(){
> tester.startPage(RecapitulatifQuestionnairePage.class);
> tester.assertRenderedPage(RecapitulatifQuestionnairePage.class);
> tester.clickLink("questionnaireEnCours:1:modifier");
> tester.assertRenderedPage(CreationQuestionnairePage.class);
> 
> Form form = (Form)
> tester.getComponentFromLastRenderedPage(
> "formCreationQuestionnaire");
> 
> //On vérifie que le formulaire est préremplie avec le
> questionnaire
> sélectionné
> Questionnaire qObtenu = form.getModelObject();
> Assert.assertNotNull(qObtenu);
> 
> //Vérification du sexe des destinataires
> String genreAttendu = qObtenu.getSexeDestinataire().toString();
> String genreObtenu =
> ((RadioGroup)form.get("genre")).getDefaultModelObjectAsString();
> Assert.assertEquals(genreAttendu, genreObtenu);
> 
> TagTester tagFemme =
> tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
> TagTester tagHomme =
> tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
> TagTester tagMixte =
> tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
> tester.debugComponentTrees();
> Assert.assertNotNull(tagFemme);
> 
> Assert.assertTrue(tagFemme.hasAttribute("checked"));
> Assert.assertFalse(tagHomme.hasAttribute("checked"));
> Assert.assertFalse(tagMixte.hasAttribute("checked"));
> }

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mathilde Pellerin
hum, yes and no... I mean, page is loaded by an ajax response (AjaxLink),
but then there is no Ajax.
This is the entire test, maybe it can help :

@SuppressWarnings("unchecked")
@Test @Transactional @Rollback
public void testStory23_TA21_VerificationInitialisationBoutonsRadio(){
tester.startPage(RecapitulatifQuestionnairePage.class);
tester.assertRenderedPage(RecapitulatifQuestionnairePage.class);
tester.clickLink("questionnaireEnCours:1:modifier");
tester.assertRenderedPage(CreationQuestionnairePage.class);

Form form = (Form)
tester.getComponentFromLastRenderedPage(
"formCreationQuestionnaire");

//On vérifie que le formulaire est préremplie avec le questionnaire
sélectionné
Questionnaire qObtenu = form.getModelObject();
Assert.assertNotNull(qObtenu);

//Vérification du sexe des destinataires
String genreAttendu = qObtenu.getSexeDestinataire().toString();
String genreObtenu =
((RadioGroup)form.get("genre")).getDefaultModelObjectAsString();
Assert.assertEquals(genreAttendu, genreObtenu);

TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
tester.debugComponentTrees();
Assert.assertNotNull(tagFemme);

Assert.assertTrue(tagFemme.hasAttribute("checked"));
Assert.assertFalse(tagHomme.hasAttribute("checked"));
Assert.assertFalse(tagMixte.hasAttribute("checked"));
}


Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mike Mander

Am 19.08.2011 16:38, schrieb Mathilde Pellerin:

  I add WicketTester.debugComponentTrees() in my test juste before
assertNotNull which failed like this :

 TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
 TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
 TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
 tester.debugComponentTrees();
 Assert.assertNotNull(tagFemme);

and this is the output (lines relatives to radiogroup are in bold) :

INFO  - BaseWicketTester   - debugging
--
INFO  - BaseWicketTester   - pathlogo
org.apache.wicket.markup.html.link.BookmarkablePageLink []
INFO  - BaseWicketTester   - pathdeconnexion
org.apache.wicket.markup.html.link.Link []
INFO  - BaseWicketTester   - pathtableaubord
org.apache.wicket.markup.html.link.BookmarkablePageLink []
INFO  - BaseWicketTester   - pathrecapitulatifQuestionnaire
org.apache.wicket.markup.html.link.BookmarkablePageLink []
INFO  - BaseWicketTester   - pathretourRecapitulatif
org.apache.wicket.ajax.markup.html.AjaxLink []
INFO  - BaseWicketTester   - pathfenetreModale
fr.statlife.protoE4N.pages.ModalWindowE4N []
INFO  - BaseWicketTester   - pathfenetreModale:content
fr.statlife.protoE4N.pages.questionnaire.QuestionnaireContentPanel []
INFO  - BaseWicketTester   - pathfenetreModale:content:qForm
org.apache.wicket.markup.html.form.Form []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qErrorMsg
org.apache.wicket.markup.html.panel.FeedbackPanel []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qErrorMsg:feedbackul
org.apache.wicket.markup.html.WebMarkupContainer []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qErrorMsg:feedbackul:messages
org.apache.wicket.markup.html.list.ListView [[]]
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qRepeating
org.apache.wicket.markup.repeater.RepeatingView []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qRepeating:1
org.apache.wicket.markup.html.WebMarkupContainer []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qRepeating:1:question
org.apache.wicket.markup.html.basic.Label [vide :(]
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:ajaxSubmitQuestionnaire
org.apache.wicket.ajax.markup.html.form.AjaxButton [Fermer]
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qCancelbutton
org.apache.wicket.ajax.markup.html.form.AjaxButton []
INFO  - BaseWicketTester   - pathformCreationQuestionnaire
org.apache.wicket.markup.html.form.Form [Questionnaire
[idQuestionnaire=26, numero=Q2, titre=Questionnaire pour Femme,
sexeDestinataire=f, publie=null, listeQuestionnaires=[],
listeQuestions=[Question [idQuestion=27, numQuestion=1, question=Type liste
:, typeReponse=LISTE, legende=null,
reponsesPossibles=0g,30g,60g,90g,120g,150g,200g,250g et +,
idQuestionnaire=26], Question [idQuestion=28, numQuestion=2, question=Type
champsTexte :, typeReponse=TEXTE, legende=null, reponsesPossibles=null,
idQuestionnaire=26], Question [idQuestion=29, numQuestion=3, question=Type
date :, typeReponse=DATE, legende=null, reponsesPossibles=null,
idQuestionnaire=26], Question [idQuestion=30, numQuestion=4, question=Type
radio :, typeReponse=RADIO, legende=null,
reponsesPossibles=rouge,vert,jaune,bleu, idQuestionnaire=26], Question
[idQuestion=31, numQuestion=5, question=Type checkbox :,
typeReponse=CHECKBOX, legende=null, reponsesPossibles=rouge,vert,jaune,bleu,
idQuestionnaire=26]], listeReponses=[]]]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:feedback
org.apache.wicket.markup.html.panel.FeedbackPanel [No get method defined
for class: class fr.statlife.protoE4N.data.entites.Questionnaire expression:
feedback]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:feedback:feedbackul
org.apache.wicket.markup.html.WebMarkupContainer [No get method defined
for class: class fr.statlife.protoE4N.data.entites.Questionnaire expression:
feedbackul]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:feedback:feedbackul:messages
org.apache.wicket.markup.html.list.ListView [[]]
INFO  - BaseWicketTester   - pathformCreationQuestionnaire:titre
 org.apache.wicket.markup.html.form.TextField [Questionnaire pour
Femme]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:numero
org.apache.wicket.markup.html.form.TextField [Q2]
*INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre
org.apache.wicket.markup.html.form.RadioGroup [f]
INFO  - BaseWicketTester   - path
formCreationQuestio

Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mathilde Pellerin
 I add WicketTester.debugComponentTrees() in my test juste before
assertNotNull which failed like this :

TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
tester.debugComponentTrees();
Assert.assertNotNull(tagFemme);

and this is the output (lines relatives to radiogroup are in bold) :

INFO  - BaseWicketTester   - debugging
--
INFO  - BaseWicketTester   - pathlogo
org.apache.wicket.markup.html.link.BookmarkablePageLink []
INFO  - BaseWicketTester   - pathdeconnexion
org.apache.wicket.markup.html.link.Link []
INFO  - BaseWicketTester   - pathtableaubord
org.apache.wicket.markup.html.link.BookmarkablePageLink []
INFO  - BaseWicketTester   - pathrecapitulatifQuestionnaire
org.apache.wicket.markup.html.link.BookmarkablePageLink []
INFO  - BaseWicketTester   - pathretourRecapitulatif
org.apache.wicket.ajax.markup.html.AjaxLink []
INFO  - BaseWicketTester   - pathfenetreModale
fr.statlife.protoE4N.pages.ModalWindowE4N []
INFO  - BaseWicketTester   - pathfenetreModale:content
fr.statlife.protoE4N.pages.questionnaire.QuestionnaireContentPanel []
INFO  - BaseWicketTester   - pathfenetreModale:content:qForm
org.apache.wicket.markup.html.form.Form []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qErrorMsg
org.apache.wicket.markup.html.panel.FeedbackPanel []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qErrorMsg:feedbackul
org.apache.wicket.markup.html.WebMarkupContainer []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qErrorMsg:feedbackul:messages
org.apache.wicket.markup.html.list.ListView [[]]
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qRepeating
org.apache.wicket.markup.repeater.RepeatingView []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qRepeating:1
org.apache.wicket.markup.html.WebMarkupContainer []
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qRepeating:1:question
org.apache.wicket.markup.html.basic.Label [vide :(]
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:ajaxSubmitQuestionnaire
org.apache.wicket.ajax.markup.html.form.AjaxButton [Fermer]
INFO  - BaseWicketTester   - path
fenetreModale:content:qForm:qCancelbutton
org.apache.wicket.ajax.markup.html.form.AjaxButton []
INFO  - BaseWicketTester   - pathformCreationQuestionnaire
org.apache.wicket.markup.html.form.Form [Questionnaire
[idQuestionnaire=26, numero=Q2, titre=Questionnaire pour Femme,
sexeDestinataire=f, publie=null, listeQuestionnaires=[],
listeQuestions=[Question [idQuestion=27, numQuestion=1, question=Type liste
:, typeReponse=LISTE, legende=null,
reponsesPossibles=0g,30g,60g,90g,120g,150g,200g,250g et +,
idQuestionnaire=26], Question [idQuestion=28, numQuestion=2, question=Type
champsTexte :, typeReponse=TEXTE, legende=null, reponsesPossibles=null,
idQuestionnaire=26], Question [idQuestion=29, numQuestion=3, question=Type
date :, typeReponse=DATE, legende=null, reponsesPossibles=null,
idQuestionnaire=26], Question [idQuestion=30, numQuestion=4, question=Type
radio :, typeReponse=RADIO, legende=null,
reponsesPossibles=rouge,vert,jaune,bleu, idQuestionnaire=26], Question
[idQuestion=31, numQuestion=5, question=Type checkbox :,
typeReponse=CHECKBOX, legende=null, reponsesPossibles=rouge,vert,jaune,bleu,
idQuestionnaire=26]], listeReponses=[]]]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:feedback
org.apache.wicket.markup.html.panel.FeedbackPanel [No get method defined
for class: class fr.statlife.protoE4N.data.entites.Questionnaire expression:
feedback]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:feedback:feedbackul
org.apache.wicket.markup.html.WebMarkupContainer [No get method defined
for class: class fr.statlife.protoE4N.data.entites.Questionnaire expression:
feedbackul]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:feedback:feedbackul:messages
org.apache.wicket.markup.html.list.ListView [[]]
INFO  - BaseWicketTester   - pathformCreationQuestionnaire:titre
org.apache.wicket.markup.html.form.TextField [Questionnaire pour
Femme]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:numero
org.apache.wicket.markup.html.form.TextField [Q2]
*INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre
org.apache.wicket.markup.html.form.RadioGroup [f]
INFO  - BaseWicketTester   - path
formCreationQuestionnaire:genre:femme
org.apache.wicket.markup.html.form.Rad

Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mike Mander

Am 19.08.2011 15:35, schrieb Mathilde Pellerin:

Thank you for your answer Mike.

I didn't find out how could I try with Radio.onComponentTag, so I tried with
tagTester.

I think it could be a good solution, so I did that :
 TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
 TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
 TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
 Assert.assertNotNull(tagFemme);
 Assert.assertTrue(tagFemme.hasAttribute("checked"));
 Assert.assertFalse(tagHomme.hasAttribute("checked"));
 Assert.assertFalse(tagMixte.hasAttribute("checked"));

but my tagTester are always null ! I checked path many times, and I tried
other way to instantiate tagTester, but without success.
I already used TagTester in other test before without problem, and I really
don't understand why it is always null here...


Can you provide output from WicketTester.debugComponentTree()?

Mike

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mathilde Pellerin
Thank you for your answer Mike.

I didn't find out how could I try with Radio.onComponentTag, so I tried with
tagTester.

I think it could be a good solution, so I did that :
TagTester tagFemme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:femme");
TagTester tagHomme =
tester.getTagByWicketId("formCreationQuestionnaire:genre:homme");
TagTester tagMixte =
tester.getTagByWicketId("formCreationQuestionnaire:genre:mixte");
Assert.assertNotNull(tagFemme);
Assert.assertTrue(tagFemme.hasAttribute("checked"));
Assert.assertFalse(tagHomme.hasAttribute("checked"));
Assert.assertFalse(tagMixte.hasAttribute("checked"));

but my tagTester are always null ! I checked path many times, and I tried
other way to instantiate tagTester, but without success.
I already used TagTester in other test before without problem, and I really
don't understand why it is always null here...


Re: how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mike Mander

Am 19.08.2011 14:21, schrieb Mathilde Pellerin:

Hi all,

I have a form with a Radiogroup :

In my form, I have a radiogroup like this :
 RadioGroup  genre = new
RadioGroup("genreDestinataire");
 genre.setRequired(true);
 genre.setLabel(new Model("Genre destinataire"));
 genre.add(new Radio("femme", new Model("f")));
 genre.add(new Radio("homme", new Model("h")));
 genre.add(new Radio("mixte", new Model("b")));
 form.add(genre);

This radiogroup match the genreDestinataire field in Questionnaire Entity
(with a CompoundPropertyModel).

In my unit test, I try to check what radio is selected, but I don't find
how...
I can get Model Object from radioGroup like this :
 String genreObtenu =
((RadioGroup)form.get("genreDestinataire")).getDefaultModelObjectAsString();

but it works even if none of radio is checked. It happen when I fill the
form with existant Questionnaire : radiogroup model is ok, but none of radio
is checked.
Before correct this bug, I want to reproduce it in test, but I didn't find
how to see if a radio is checked or not : I didn't find any method like
"isChecked" or "isSelected" on Radio Component.

Is there any way to check that ?

Thanks.
M.

Maybe you can get the component from last renderered page (by path to 
component) and cast it to radio.
Then you can compare raw input of group with the radio value (see 
Radio.onComponentTag).


Other option would be to use the tag tester provided by WicketTester. See

/**
 * Modified version of BaseWicketTester#getTagByWicketId(String) 
that returns all matching tags

 * instead of just the first.
 *
 * @see BaseWicketTester#getTagByWicketId(String)
 */
public static List getTagsByWicketId(WicketTester 
tester, String wicketId)

{
return 
TagTester.createTagsByAttribute(tester.getServletResponse().getDocument(),

"wicket:id", wicketId, false);
}

Hth
Mike

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



how to test what radio is checked in a radiogroup?

2011-08-19 Thread Mathilde Pellerin
Hi all,

I have a form with a Radiogroup :

In my form, I have a radiogroup like this :
RadioGroup genre = new
RadioGroup("genreDestinataire");
genre.setRequired(true);
genre.setLabel(new Model("Genre destinataire"));
genre.add(new Radio("femme", new Model("f")));
genre.add(new Radio("homme", new Model("h")));
genre.add(new Radio("mixte", new Model("b")));
form.add(genre);

This radiogroup match the genreDestinataire field in Questionnaire Entity
(with a CompoundPropertyModel).

In my unit test, I try to check what radio is selected, but I don't find
how...
I can get Model Object from radioGroup like this :
String genreObtenu =
((RadioGroup)form.get("genreDestinataire")).getDefaultModelObjectAsString();

but it works even if none of radio is checked. It happen when I fill the
form with existant Questionnaire : radiogroup model is ok, but none of radio
is checked.
Before correct this bug, I want to reproduce it in test, but I didn't find
how to see if a radio is checked or not : I didn't find any method like
"isChecked" or "isSelected" on Radio Component.

Is there any way to check that ?

Thanks.
M.

-- 
*Mathilde Pellerin*
Ingénieur en développement de logiciel

STATLIFE
tel : 01.42.11.64.88
mail : mathilde.pelle...@statlife.fr