Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-24 Thread Timo Rantalaiho
On Fri, 20 Jul 2007, Craig Lenzen wrote:
 And how are you overriding the goToPageB method in the test?  Using
 WicketTester you never actually create an instance of PageB, that is you as
 the developer.

Like this, in 1.3

wicket.startPage(new ITestPageSource(){
public Page getTestPage() {
return new PageA()...
}

though I'm not sure if it's in 1.2.

There's also TestPanelSource that you can use 
similarly with startPanel.

- Timo

-- 
Timo Rantalaiho   
Reaktor Innovations OyURL: http://www.ri.fi/ 

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-20 Thread Craig Lenzen

I've come up with a possible solution to this issue or at least a start that
can be discussed a bit more.

My solution is to implement my own implementation of wicket's IPageFactory. 
This implementation is really just a wrapper around the default one since
the default one is final.

I then created a simple singleton class that allows developers to call
mockPage(MyPage.class) within their unit tests.  The singleton just keeps a
map of page classes that should be mocked up.  One thing you need to
remember is to provide a way to clear the map after a test runs.

I then created a Page object called MockPage that takes the class of the
page being mocked and a corresponding .html that contains no markup. 

private final Class? mockedPageClass;

public MockPage(Class? mockedPageClass) {
this.mockedPageClass = mockedPageClass;
}

Then within the IPageFactory methods I check if the pageClass parameter is
mockable given the singleton and return an instance of MockPage if it is, if
not then I just delegate to the default factory.

Then finally I created an extension to WicketTester and overrode the
assertRenderedPage method to first check if the last page rendered is an
instance of MockPage and if so then compare the pageClass parameter to the
mockedPageClass that was set on the MockPage.  If the last page rendered is
not of instance MockPage then simply delegate to your parent method.

The only other thing you need to do is to set the new IPageFactory up in the
application being used my your WicketTester.

Thoughts?

-Craig


Ingram Chen-2 wrote:
 
 We also suffer the same issues here. But due to unmanaged nature of
 Wicket,
 there is no chance to intercept construction of page B unless you build
 your
 own factory for page.
 
 class Page A {
  MyFactory myFactory ;
  public Page A {
 add(new Link(toBPage) {
  setResponsePage(myFactory.newBPage());
 });
  }
 }
 
 and swapping mock MyFactory while testing.
 
 But such extra indirection make code slight complex and MyFactory is still
 hard to test, either.
 
 
 On 7/17/07, Craig Lenzen [EMAIL PROTECTED] wrote:


 I'm looking for some feedback as to an issue I'm having with the
 WicketTester.  To start I'd like to point out that I'm using Spring and
 injecting my pages / components via the wicket spring project's component
 injector.

 Here is the situation, I have page A that has a link to page B.  In the
 test
 of page A I test that the click in fact goes to page B.  This is fine but
 the problem is, is that page B relies on a Spring service during its
 construction and the fact that the WicketTester actually tries to render
 page B which calls the service.  The easy fix to this is to simply create
 a
 mock implementation of that service and set it in the mock context when
 testing page A, and don't forget you need to also setup the expected
 calls

 and returns.

 The problem here is that fact that I'm only testing page A, I don't care
 about the functionality of page B nor which services it might call.  So
 is
 there a better way?  Is there a way that you can mock the rendering of
 page
 B?  Has anyone else ran into this issue and  or questioned it, or has
 someone came up with a solution?

 To get a little more advanced you could also say that when testing a Page
 that added a number of panels I don't want those panels to render during
 the
 testing of the page, I only want to know the panels where added to the
 page.

 Thanks for everyone's help,
 Craig
 --
 View this message in context:
 http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11641094
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user

 
 
 
 -- 
 Ingram Chen
 online share order: http://dinbendon.net
 blog: http://www.javaworld.com.tw/roller/page/ingramchen
 
 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 

-- 
View this message in context: 
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11715146
Sent from the Wicket - User mailing list archive at Nabble.com.



Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-20 Thread Craig Lenzen

Tim,

And how are you overriding the goToPageB method in the test?  Using
WicketTester you never actually create an instance of PageB, that is you as
the developer.

-Craig


Timo Rantalaiho wrote:
 
 On Tue, 17 Jul 2007, Ingram Chen wrote:
 
 We also suffer the same issues here. But due to unmanaged nature of
 Wicket,
 there is no chance to intercept construction of page B unless you build
 your
 own factory for page.
 
 class Page A {
 MyFactory myFactory ;
 public Page A {
add(new Link(toBPage) {
 setResponsePage(myFactory.newBPage());
});
 }
 }
 
 I might do
 
   class PageA extends Page {
   public PageA() {
   add(new Link(toBPage) {
 @Override
 public void onLinkClicked() {
 goToPageB();
   }
 );
   }
 
   protected goToPageB() {
   ...
 
 and overriding goToPageB() in the test. 
 
 This technique has even a fancy name in the excellent
 _Working Effectively with Legacy Code_ by Michael Feathers, 
 so maybe it's a kludge to use it in non-legacy code. But 
 it's simple and it works.
 
 - Timo
 
 
 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 

-- 
View this message in context: 
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11715824
Sent from the Wicket - User mailing list archive at Nabble.com.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-19 Thread Timo Rantalaiho
On Tue, 17 Jul 2007, Ingram Chen wrote:

 We also suffer the same issues here. But due to unmanaged nature of Wicket,
 there is no chance to intercept construction of page B unless you build your
 own factory for page.
 
 class Page A {
 MyFactory myFactory ;
 public Page A {
add(new Link(toBPage) {
 setResponsePage(myFactory.newBPage());
});
 }
 }

I might do

  class PageA extends Page {
  public PageA() {
  add(new Link(toBPage) {
  @Override
  public void onLinkClicked() {
  goToPageB();
  }
  );
  }

  protected goToPageB() {
  ...

and overriding goToPageB() in the test. 

This technique has even a fancy name in the excellent
_Working Effectively with Legacy Code_ by Michael Feathers, 
so maybe it's a kludge to use it in non-legacy code. But 
it's simple and it works.

- Timo


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-17 Thread Jean-Baptiste Quenot
* Craig Lenzen:

 I'm looking for some feedback as to an issue I'm having with the
 WicketTester.  To start  I'd like  to point  out that  I'm using
 Spring and injecting my pages / components via the wicket spring
 project's component injector.

 Here is the situation, I have page  A that has a link to page B.
 In the test of page A I test that the click in fact goes to page
 B. This is fine  but the problem is, is that page  B relies on a
 Spring service  during its  construction and  the fact  that the
 WicketTester actually  tries to  render page  B which  calls the
 service.

And   is  the   service   properly  injected   by  the   component
instantiation listener? Have you setup Spring for your tests?
-- 
 Jean-Baptiste Quenot
aka  John Banana   Qwerty
http://caraldi.com/jbq/

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-17 Thread Craig Lenzen

The Spring injection is setup properly, for functional use and unit testing. 
The issue is, is that I should not have to worry about setting up page B
dependencies when I'm testing page A.  I should only have to worry about
that dependency when it comes to actually testing page B.

-Craig


Jean-Baptiste Quenot-3 wrote:
 
 * Craig Lenzen:
 
 I'm looking for some feedback as to an issue I'm having with the
 WicketTester.  To start  I'd like  to point  out that  I'm using
 Spring and injecting my pages / components via the wicket spring
 project's component injector.

 Here is the situation, I have page  A that has a link to page B.
 In the test of page A I test that the click in fact goes to page
 B. This is fine  but the problem is, is that page  B relies on a
 Spring service  during its  construction and  the fact  that the
 WicketTester actually  tries to  render page  B which  calls the
 service.
 
 And   is  the   service   properly  injected   by  the   component
 instantiation listener? Have you setup Spring for your tests?
 -- 
  Jean-Baptiste Quenot
 aka  John Banana   Qwerty
 http://caraldi.com/jbq/
 
 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 

-- 
View this message in context: 
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11649825
Sent from the Wicket - User mailing list archive at Nabble.com.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-17 Thread Craig Lenzen

I guess saying I don't care about page B is a little harsh.  I care that
when the link is clicked that the next page to be rendered is page B, what I
don't care about is that page B was actually rendered.

So I don't think mocking up the page is the proper solution.  Instead I
would want to mock up an internal component in wicket that skips the
rendering of that page.  It is been a while since I looked at the guts of
wicket but I'm sure there is a way to do this, the question would be how
much of the testing functionality have you bypassed by doing something like
this.  Maybe instead of testing that the last rendered page was page B, you
have method that say something like nextPageToBeRendered.

Thoughts?

-Craig


Eelco Hillenius wrote:
 
 The problem here is that fact that I'm only testing page A, I don't care
 about the functionality of page B nor which services it might call.  So
 is
 there a better way?  Is there a way that you can mock the rendering of
 page
 B?  Has anyone else ran into this issue and  or questioned it, or has
 someone came up with a solution?
 
 If you don't care about page B, why not soft code the link and just
 test that it executes? For testing you let the link point to some mock
 page. Would that help?
 
 Eelco
 
 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 

-- 
View this message in context: 
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11649927
Sent from the Wicket - User mailing list archive at Nabble.com.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-17 Thread Craig Lenzen

This concept might work ok if the link only goes to the same page every time
it is clicked, but what if the link goes to a different page depending on
presentation logic with in the page.  I think you would be SOL in that case.

-Craig


Ingram Chen-2 wrote:
 
 We also suffer the same issues here. But due to unmanaged nature of
 Wicket,
 there is no chance to intercept construction of page B unless you build
 your
 own factory for page.
 
 class Page A {
  MyFactory myFactory ;
  public Page A {
 add(new Link(toBPage) {
  setResponsePage(myFactory.newBPage());
 });
  }
 }
 
 and swapping mock MyFactory while testing.
 
 But such extra indirection make code slight complex and MyFactory is still
 hard to test, either.
 
 
 On 7/17/07, Craig Lenzen [EMAIL PROTECTED] wrote:


 I'm looking for some feedback as to an issue I'm having with the
 WicketTester.  To start I'd like to point out that I'm using Spring and
 injecting my pages / components via the wicket spring project's component
 injector.

 Here is the situation, I have page A that has a link to page B.  In the
 test
 of page A I test that the click in fact goes to page B.  This is fine but
 the problem is, is that page B relies on a Spring service during its
 construction and the fact that the WicketTester actually tries to render
 page B which calls the service.  The easy fix to this is to simply create
 a
 mock implementation of that service and set it in the mock context when
 testing page A, and don't forget you need to also setup the expected
 calls

 and returns.

 The problem here is that fact that I'm only testing page A, I don't care
 about the functionality of page B nor which services it might call.  So
 is
 there a better way?  Is there a way that you can mock the rendering of
 page
 B?  Has anyone else ran into this issue and  or questioned it, or has
 someone came up with a solution?

 To get a little more advanced you could also say that when testing a Page
 that added a number of panels I don't want those panels to render during
 the
 testing of the page, I only want to know the panels where added to the
 page.

 Thanks for everyone's help,
 Craig
 --
 View this message in context:
 http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11641094
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user

 
 
 
 -- 
 Ingram Chen
 online share order: http://dinbendon.net
 blog: http://www.javaworld.com.tw/roller/page/ingramchen
 
 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 

-- 
View this message in context: 
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11657439
Sent from the Wicket - User mailing list archive at Nabble.com.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] WicketTester and mocking up next page rendered.

2007-07-16 Thread Craig Lenzen

I'm looking for some feedback as to an issue I'm having with the
WicketTester.  To start I'd like to point out that I'm using Spring and
injecting my pages / components via the wicket spring project's component
injector.

Here is the situation, I have page A that has a link to page B.  In the test
of page A I test that the click in fact goes to page B.  This is fine but
the problem is, is that page B relies on a Spring service during its
construction and the fact that the WicketTester actually tries to render
page B which calls the service.  The easy fix to this is to simply create a
mock implementation of that service and set it in the mock context when
testing page A, and don't forget you need to also setup the expected calls
and returns.

The problem here is that fact that I'm only testing page A, I don't care
about the functionality of page B nor which services it might call.  So is
there a better way?  Is there a way that you can mock the rendering of page
B?  Has anyone else ran into this issue and  or questioned it, or has
someone came up with a solution?

To get a little more advanced you could also say that when testing a Page
that added a number of panels I don't want those panels to render during the
testing of the page, I only want to know the panels where added to the page.

Thanks for everyone's help,
Craig
-- 
View this message in context: 
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11641094
Sent from the Wicket - User mailing list archive at Nabble.com.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-16 Thread Ingram Chen

We also suffer the same issues here. But due to unmanaged nature of Wicket,
there is no chance to intercept construction of page B unless you build your
own factory for page.

class Page A {
MyFactory myFactory ;
public Page A {
   add(new Link(toBPage) {
setResponsePage(myFactory.newBPage());
   });
}
}

and swapping mock MyFactory while testing.

But such extra indirection make code slight complex and MyFactory is still
hard to test, either.


On 7/17/07, Craig Lenzen [EMAIL PROTECTED] wrote:



I'm looking for some feedback as to an issue I'm having with the
WicketTester.  To start I'd like to point out that I'm using Spring and
injecting my pages / components via the wicket spring project's component
injector.

Here is the situation, I have page A that has a link to page B.  In the
test
of page A I test that the click in fact goes to page B.  This is fine but
the problem is, is that page B relies on a Spring service during its
construction and the fact that the WicketTester actually tries to render
page B which calls the service.  The easy fix to this is to simply create
a
mock implementation of that service and set it in the mock context when
testing page A, and don't forget you need to also setup the expected calls

and returns.

The problem here is that fact that I'm only testing page A, I don't care
about the functionality of page B nor which services it might call.  So is
there a better way?  Is there a way that you can mock the rendering of
page
B?  Has anyone else ran into this issue and  or questioned it, or has
someone came up with a solution?

To get a little more advanced you could also say that when testing a Page
that added a number of panels I don't want those panels to render during
the
testing of the page, I only want to know the panels where added to the
page.

Thanks for everyone's help,
Craig
--
View this message in context:
http://www.nabble.com/WicketTester-and-mocking-up-next-page-rendered.-tf4093923.html#a11641094
Sent from the Wicket - User mailing list archive at Nabble.com.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user





--
Ingram Chen
online share order: http://dinbendon.net
blog: http://www.javaworld.com.tw/roller/page/ingramchen
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-16 Thread Eelco Hillenius
 But due to unmanaged nature of Wicket, there is no chance to intercept 
 construction of page B unless you build your own factory for page.

Not entirely true as there is IComponentInstantiationListener.

Eelco

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] WicketTester and mocking up next page rendered.

2007-07-16 Thread Eelco Hillenius
 The problem here is that fact that I'm only testing page A, I don't care
 about the functionality of page B nor which services it might call.  So is
 there a better way?  Is there a way that you can mock the rendering of page
 B?  Has anyone else ran into this issue and  or questioned it, or has
 someone came up with a solution?

If you don't care about page B, why not soft code the link and just
test that it executes? For testing you let the link point to some mock
page. Would that help?

Eelco

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user