Re: Re: Re: Re: Basic JUnit Test

2012-08-28 Thread JCoder
What exactly do you mean by 'quickstart' ?

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



Re: Re: Re: Re: Basic JUnit Test

2012-08-28 Thread Martin Grigorov
A mini application that reproduces the problem. See
http://wicket.apache.org/start/quickstart.html

On Tue, Aug 28, 2012 at 8:21 AM, JCoder i...@jcoder.de wrote:
 What exactly do you mean by 'quickstart' ?

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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Re: Re: Re: Re: Basic JUnit Test

2012-08-28 Thread JCoder
What exactly do you mean by 'quickstart' ?


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



Re: Re: Re: Basic JUnit Test

2012-08-20 Thread JCoder
Hi Vineet,

thanks for the reply. The line 
tester.getServletRequest().setParameter(myParam, testParam);
But now Im breaking my head with the next issue. If you look at my first post, 
Im trying to do a test where a second page is rendered after a submit on an 
AjaxButton. The test code looks like this:

1. FirstPage page = (FirstPage) tester.startPage(FirstPage.class, 
pageParameters);
2. tester.assertRenderedPage(FirstPage.class);
3. page.getActionForm().setType(1); // where actionForm is a property/attribute 
of FirstPage.
4. FormTester formTester = tester.newFormTester(myForm);
5. tester.getServletRequest().setParameter(myParam, testParam);
6. tester.executeAjaxEvent(myForm:myAjaxButton, onclick);
7. tester.assertRenderedPage(SecondPage.class); 

The the test fails within the onSubmit(AjaxRequestTarget target, Form? 
form) saying that the attribute/property actionForm is null...
Obviously the second (Ajax-) request is not shipped with the attribute/property 
values of his containing panel. Is this correct? Who can help me out here?

Regards,
Yusuf

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



Re: Re: Re: Basic JUnit Test

2012-08-20 Thread vineet semwal
that test looks ok to me ,please attach a quickstart

On Mon, Aug 20, 2012 at 12:23 PM, JCoder i...@jcoder.de wrote:
 Hi Vineet,

 thanks for the reply. The line 
 tester.getServletRequest().setParameter(myParam, testParam);
 But now Im breaking my head with the next issue. If you look at my first 
 post, Im trying to do a test where a second page is rendered after a submit 
 on an AjaxButton. The test code looks like this:

 1. FirstPage page = (FirstPage) tester.startPage(FirstPage.class, 
 pageParameters);
 2. tester.assertRenderedPage(FirstPage.class);
 3. page.getActionForm().setType(1); // where actionForm is a 
 property/attribute of FirstPage.
 4. FormTester formTester = tester.newFormTester(myForm);
 5. tester.getServletRequest().setParameter(myParam, testParam);
 6. tester.executeAjaxEvent(myForm:myAjaxButton, onclick);
 7. tester.assertRenderedPage(SecondPage.class);

 The the test fails within the onSubmit(AjaxRequestTarget target, Form? 
 form) saying that the attribute/property actionForm is null...
 Obviously the second (Ajax-) request is not shipped with the 
 attribute/property values of his containing panel. Is this correct? Who can 
 help me out here?

 Regards,
 Yusuf

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




-- 
regards,

Vineet Semwal

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



Re: Re: Basic JUnit Test

2012-08-17 Thread JCoder
Hi Vineet,

wickettester#ajaxEvent(button,onclick)  is what I already tried. And it 
worked better but not finally finsihed.
The cause of the next problem is that I need to provide some request parameter 
for this request since my application reads request and throws an exception if 
it can't find special parameters.
Then I changed my code to provide some ajax request parameter because the 
button click is an instance of AjaxButton:


Component comp = tester

.getComponentFromLastRenderedPage(myForm:myAjaxButton);
AjaxEventBehavior behavior = new 
AjaxFormSubmitBehavior(onclick) {

@Override
protected void onSubmit(AjaxRequestTarget target) {
System.out.println(hh);
}

@Override
protected void onError(AjaxRequestTarget target) {
// TODO Auto-generated method stub

}
};

comp.add(behavior);
tester.executeAjaxEvent(comp, onclick);


Is this the correct to provide ajax request parameter?
If so, I guess I need to chance something in onSubmit(AjaxRequestTarget), 
true ?

Regards,
Y

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



Re: Re: Basic JUnit Test

2012-08-17 Thread vineet semwal
 why are you attaching a new ajaxformsubmitbehavior to an ajaxbutton
,it already has it's own ?
 if you want to pass some request parameter  ,you can set it to the
request by tester.getRequest().setParameter(key,value)

On Fri, Aug 17, 2012 at 12:09 PM, JCoder i...@jcoder.de wrote:
 Hi Vineet,

 wickettester#ajaxEvent(button,onclick)  is what I already tried. And it 
 worked better but not finally finsihed.
 The cause of the next problem is that I need to provide some request 
 parameter for this request since my application reads request and throws an 
 exception if it can't find special parameters.
 Then I changed my code to provide some ajax request parameter because the 
 button click is an instance of AjaxButton:

 
 Component comp = tester
 
 .getComponentFromLastRenderedPage(myForm:myAjaxButton);
 AjaxEventBehavior behavior = new 
 AjaxFormSubmitBehavior(onclick) {

 @Override
 protected void onSubmit(AjaxRequestTarget target) {
 System.out.println(hh);
 }

 @Override
 protected void onError(AjaxRequestTarget target) {
 // TODO Auto-generated method stub

 }
 };

 comp.add(behavior);
 tester.executeAjaxEvent(comp, onclick);
 

 Is this the correct to provide ajax request parameter?
 If so, I guess I need to chance something in onSubmit(AjaxRequestTarget), 
 true ?

 Regards,
 Y

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




-- 
regards,

Vineet Semwal

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



Re: Basic JUnit Test

2012-08-16 Thread JCoder
Well it turns out that reflective call of a method failes.
I run into WicketRuntimeException in RequestListenerInterface.invoke(Page, 
Component). 
The button to submit is an instance of AjaxButton. Does this make a difference 
in initializing the test?

Regards,
Y

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



Re: Basic JUnit Test

2012-08-16 Thread JCoder
Furthermore, I found out that my test code calls public void onSubmit(); 
instead of calling the overridden protected void onSubmit(AjaxRequestTarget 
target, Form? form);
These overriden methods reside in my anonymous inner subclass of AjaxButton.

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



Re: Basic JUnit Test

2012-08-16 Thread vineet semwal
 that is expected behavior try
wickettester#ajaxEvent(button,onclick) or it's path equivalent


On Thu, Aug 16, 2012 at 7:00 PM, JCoder i...@jcoder.de wrote:
 Furthermore, I found out that my test code calls public void onSubmit(); 
 instead of calling the overridden protected void onSubmit(AjaxRequestTarget 
 target, Form? form);
 These overriden methods reside in my anonymous inner subclass of AjaxButton.

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




-- 
regards,

Vineet Semwal

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



Re: Basic JUnit Test

2012-08-16 Thread vineet semwal
sorry typo  i meant wickettester#executeAjaxEvent(button,onclick)

On Thu, Aug 16, 2012 at 8:11 PM, vineet semwal vineetsemwa...@gmail.com wrote:
  that is expected behavior try
 wickettester#ajaxEvent(button,onclick) or it's path equivalent


 On Thu, Aug 16, 2012 at 7:00 PM, JCoder i...@jcoder.de wrote:
 Furthermore, I found out that my test code calls public void onSubmit(); 
 instead of calling the overridden protected void onSubmit(AjaxRequestTarget 
 target, Form? form);
 These overriden methods reside in my anonymous inner subclass of AjaxButton.

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




 --
 regards,

 Vineet Semwal



-- 
regards,

Vineet Semwal

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



Re: Basic JUnit Test

2012-08-13 Thread Martin Grigorov
Hi,

Put a breakpoint in the button's onSubmit() method and see whether it
is actually called.
It could be that you need to call formTester.submit(myForm:myButton);

On Mon, Aug 13, 2012 at 5:18 PM, JCoder i...@jcoder.de wrote:
 Hi all,

 Im working at a basic Unit Test that looks like this:

 1. tester.assertRenderedPage(FirstPage.class);
 2. FormTester formTester = tester.newFormTester(myForm);
 3. formTester.submit(myButton);
 4. tester.assertRenderedPage(SecondPage.class);

 All lines work as expected. Only line 4 fails. I just want to verify a click 
 on a button and after that a certain Page (SecondPage) should be rendered.

 The test fails with: junit.framework.AssertionFailedError: 
 expected:SecondPage but was:FirstPage
 What did I wrong?

 Cheers  Thanks in advance,
 Y

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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



RE: Basic JUnit Test

2012-08-13 Thread Paul Bors
Also get familiar with the API for the WicketTester that extends 
BaseWicketTester.

There are quite a few useful methods that can aid you during unit testing such 
as BaseWicketTester#debugComponentTrees() which will output the wicket 
component tree.

In our unit tests we extended from WicketTester and added a dumpPage() method 
that would give you both the output of BaseWicketTester#debugComponentTrees() 
and that of BaseWicketTester#getLastResponseAsString() so a developer can see 
both the Wicket component tree and the HTML or whatever the last response was 
(Ajax, etc).

When I write unit tests I use those two methods extensively as I would need to 
know both the component path in the tree and the expected output or the last 
response.

There are plenty of other helper methods there as well.

~ Thank you,
  Paul Bors

-Original Message-
From: Martin Grigorov [mailto:mgrigo...@apache.org] 
Sent: Monday, August 13, 2012 11:53 AM
To: users@wicket.apache.org
Subject: Re: Basic JUnit Test

Hi,

Put a breakpoint in the button's onSubmit() method and see whether it is 
actually called.
It could be that you need to call formTester.submit(myForm:myButton);

On Mon, Aug 13, 2012 at 5:18 PM, JCoder i...@jcoder.de wrote:
 Hi all,

 Im working at a basic Unit Test that looks like this:

 1. tester.assertRenderedPage(FirstPage.class);
 2. FormTester formTester = tester.newFormTester(myForm); 3. 
 formTester.submit(myButton); 4. 
 tester.assertRenderedPage(SecondPage.class);

 All lines work as expected. Only line 4 fails. I just want to verify a click 
 on a button and after that a certain Page (SecondPage) should be rendered.

 The test fails with: junit.framework.AssertionFailedError: 
 expected:SecondPage but was:FirstPage
 What did I wrong?

 Cheers  Thanks in advance,
 Y

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




--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



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