You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Gilberto <gi...@gmail.com> on 2011/03/17 18:38:25 UTC
How to test Table load?
Hi, all!
In this [1] simple test I'm using the table.getRowList() - I've set the data
provider on ViewVehicle constructor - method to check the data load. But the
test don't pass because that method is triggered after onDestroy() method :
<quote>
ViewVehicle() method
findByLicensePlate() method
[EL Fine]: 2011-03-17
14:26:00.708--ServerSession(1706726)--Connection(29441291)--Thread(Thread[main,5,main])--SELECT
license_plate, color, customer_id, price_table_id, v_type FROM vehicle WHERE
license_plate LIKE ?
bind => [%%]
[Click] [info ] renderTemplate:
/view-vehicle.htm,/assets/common/template.htm - 82 ms
onDestroy() method
[Click] [info ] handleRequest: /view-vehicle.htm - 6386 ms
findByLicensePlate() method
</quote>
In the onDestroy() method I close the EntityManager - I'm using the one
EntityManager per Request pattern.
Is there another way I can check if the table control was set up correctly?
Regards,
Gilberto Caetano de Andrade
Analista de Sistemas/DBA
www.secad.to.gov.br
blog.gilbertoca.com
[1]
http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/test/java/park/web/page/ViewVehicleTest.java
Re: How to test Table load?
Posted by Bob Schellink <sa...@gmail.com>.
If you don't want to execute the page flow (which is what MockContainer is all about) then create a
MockContext and test the Page methods individually.
Or use MockContainer and test the output that the page spits out. In other words do your asserts on
the markup rendered by the page:
container.testPage...
String markup = container.getHtml();
assert(....);
If you generate XHTML you can even convert the markup to XML and use XPath to perform the assertions.
regards
Bob
On 2011/03/24 22:41 PM, Gilberto wrote:
> Now I see what is happening[1]. When I do this call:
>
> container.testPage(ViewVehicle.class);
>
> All the page sequence is done and I can't make any assertion after that(this ocurrs for controls
> that uses DP interface), right? The trace[2].
> Can you show us another way to test page with form and table data?
>
> Regards,
>
> Gilberto
>
> [1] http://dl.dropbox.com/u/9093640/debug-1.png
> [2] http://dl.dropbox.com/u/9093640/trace_1.txt
>
>
> 2011/3/24 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
>
> I just tested a page using Table and DP and printed to output in the onDestroy and getData methods.
> Here is the result:
>
> ON DATA PROVIDER
> ON DESTROY
>
> So DP is called before onDestroy. I'm not sure why you are seeing the rendering the other way
> around. Have you printed to the output stream and verified it?
>
> regards
>
> Bob
>
>
> On 2011/03/23 22:56 PM, Gilberto wrote:
> > 2011/3/17 Bob Schellink <sabob1@gmail.com <ma...@gmail.com> <mailto:sabob1@gmail.com
> <ma...@gmail.com>>>
> >
> > Hi,
> >
> > Does your page have an associated template containing $table? The provider is only called
> when the
> > table is rendered.
> >
> > Yes, it is! [1]
> >
> >
> > Also, why not close EM in a filter instead?
> >
> > Not needed.
> >
> >
> > Alternatively use Selenium to perform live testing of your site.
> >
> > This is a unit test and I'm using it to test page controller and the jpa integration.
> >
> > One thing to note[2] : using table's setRowList() method the test pass. That because, as I've
> said,
> > that method is
> > triggered after onDestroy() method.[3]
> >
> > Regards,
> >
> > Gilberto
> >
> > [1]
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/main/webapp/view-vehicle.htm
> > [2] http://dl.dropbox.com/u/9093640/log_1.txt
> > [3] http://dl.dropbox.com/u/9093640/log_2.txt
> >
> >
> > regards
> >
> > Bob
> >
> > On 2011/03/17 19:38 PM, Gilberto wrote:
> > > Hi, all!
> > >
> > > In this [1] simple test I'm using the table.getRowList() - I've set the data provider on
> > ViewVehicle
> > > constructor - method to check the data load. But the test don't pass because that method is
> > > triggered after onDestroy() method :
> > > <quote>
> > > ViewVehicle() method
> > >
> > >
> > > findByLicensePlate() method
> > >
> > > [EL Fine]: 2011-03-17
> > >
> 14:26:00.708--ServerSession(1706726)--Connection(29441291)--Thread(Thread[main,5,main])--SELECT
> > > license_plate, color, customer_id, price_table_id, v_type FROM vehicle WHERE
> license_plate LIKE ?
> > > bind => [%%]
> > > [Click] [info ] renderTemplate: /view-vehicle.htm,/assets/common/template.htm - 82 ms
> > >
> > > onDestroy() method
> > >
> > > [Click] [info ] handleRequest: /view-vehicle.htm - 6386 ms
> > >
> > > findByLicensePlate() method
> > > </quote>
> > > In the onDestroy() method I close the EntityManager - I'm using the one EntityManager
> per Request
> > > pattern.
> > >
> > > Is there another way I can check if the table control was set up correctly?
> > >
> > > Regards,
> > >
> > > Gilberto Caetano de Andrade
> > > Analista de Sistemas/DBA
> > > www.secad.to.gov.br <http://www.secad.to.gov.br> <http://www.secad.to.gov.br>
> <http://www.secad.to.gov.br>
> > > blog.gilbertoca.com <http://blog.gilbertoca.com> <http://blog.gilbertoca.com>
> <http://blog.gilbertoca.com>
> > >
> > >
> > > [1]
> > >
> >
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/test/java/park/web/page/ViewVehicleTest.java
> >
> >
>
>
Re: How to test Table load?
Posted by Gilberto <gi...@gmail.com>.
Now I see what is happening[1]. When I do this call:
container.testPage(ViewVehicle.class);
All the page sequence is done and I can't make any assertion after that(this
ocurrs for controls that uses DP interface), right? The trace[2].
Can you show us another way to test page with form and table data?
Regards,
Gilberto
[1] http://dl.dropbox.com/u/9093640/debug-1.png
[2] http://dl.dropbox.com/u/9093640/trace_1.txt
2011/3/24 Bob Schellink <sa...@gmail.com>
> I just tested a page using Table and DP and printed to output in the
> onDestroy and getData methods.
> Here is the result:
>
> ON DATA PROVIDER
> ON DESTROY
>
> So DP is called before onDestroy. I'm not sure why you are seeing the
> rendering the other way
> around. Have you printed to the output stream and verified it?
>
> regards
>
> Bob
>
>
> On 2011/03/23 22:56 PM, Gilberto wrote:
> > 2011/3/17 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
> >
> > Hi,
> >
> > Does your page have an associated template containing $table? The
> provider is only called when the
> > table is rendered.
> >
> > Yes, it is! [1]
> >
> >
> > Also, why not close EM in a filter instead?
> >
> > Not needed.
> >
> >
> > Alternatively use Selenium to perform live testing of your site.
> >
> > This is a unit test and I'm using it to test page controller and the jpa
> integration.
> >
> > One thing to note[2] : using table's setRowList() method the test pass.
> That because, as I've said,
> > that method is
> > triggered after onDestroy() method.[3]
> >
> > Regards,
> >
> > Gilberto
> >
> > [1]
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/main/webapp/view-vehicle.htm
> > [2] http://dl.dropbox.com/u/9093640/log_1.txt
> > [3] http://dl.dropbox.com/u/9093640/log_2.txt
> >
> >
> > regards
> >
> > Bob
> >
> > On 2011/03/17 19:38 PM, Gilberto wrote:
> > > Hi, all!
> > >
> > > In this [1] simple test I'm using the table.getRowList() - I've set
> the data provider on
> > ViewVehicle
> > > constructor - method to check the data load. But the test don't
> pass because that method is
> > > triggered after onDestroy() method :
> > > <quote>
> > > ViewVehicle() method
> > >
> > >
> > > findByLicensePlate() method
> > >
> > > [EL Fine]: 2011-03-17
> > >
> 14:26:00.708--ServerSession(1706726)--Connection(29441291)--Thread(Thread[main,5,main])--SELECT
> > > license_plate, color, customer_id, price_table_id, v_type FROM
> vehicle WHERE license_plate LIKE ?
> > > bind => [%%]
> > > [Click] [info ] renderTemplate:
> /view-vehicle.htm,/assets/common/template.htm - 82 ms
> > >
> > > onDestroy() method
> > >
> > > [Click] [info ] handleRequest: /view-vehicle.htm - 6386 ms
> > >
> > > findByLicensePlate() method
> > > </quote>
> > > In the onDestroy() method I close the EntityManager - I'm using the
> one EntityManager per Request
> > > pattern.
> > >
> > > Is there another way I can check if the table control was set up
> correctly?
> > >
> > > Regards,
> > >
> > > Gilberto Caetano de Andrade
> > > Analista de Sistemas/DBA
> > > www.secad.to.gov.br <http://www.secad.to.gov.br> <
> http://www.secad.to.gov.br>
> > > blog.gilbertoca.com <http://blog.gilbertoca.com> <
> http://blog.gilbertoca.com>
> > >
> > >
> > > [1]
> > >
> >
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/test/java/park/web/page/ViewVehicleTest.java
> >
> >
>
>
Re: How to test Table load?
Posted by Bob Schellink <sa...@gmail.com>.
I just tested a page using Table and DP and printed to output in the onDestroy and getData methods.
Here is the result:
ON DATA PROVIDER
ON DESTROY
So DP is called before onDestroy. I'm not sure why you are seeing the rendering the other way
around. Have you printed to the output stream and verified it?
regards
Bob
On 2011/03/23 22:56 PM, Gilberto wrote:
> 2011/3/17 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
>
> Hi,
>
> Does your page have an associated template containing $table? The provider is only called when the
> table is rendered.
>
> Yes, it is! [1]
>
>
> Also, why not close EM in a filter instead?
>
> Not needed.
>
>
> Alternatively use Selenium to perform live testing of your site.
>
> This is a unit test and I'm using it to test page controller and the jpa integration.
>
> One thing to note[2] : using table's setRowList() method the test pass. That because, as I've said,
> that method is
> triggered after onDestroy() method.[3]
>
> Regards,
>
> Gilberto
>
> [1] http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/main/webapp/view-vehicle.htm
> [2] http://dl.dropbox.com/u/9093640/log_1.txt
> [3] http://dl.dropbox.com/u/9093640/log_2.txt
>
>
> regards
>
> Bob
>
> On 2011/03/17 19:38 PM, Gilberto wrote:
> > Hi, all!
> >
> > In this [1] simple test I'm using the table.getRowList() - I've set the data provider on
> ViewVehicle
> > constructor - method to check the data load. But the test don't pass because that method is
> > triggered after onDestroy() method :
> > <quote>
> > ViewVehicle() method
> >
> >
> > findByLicensePlate() method
> >
> > [EL Fine]: 2011-03-17
> > 14:26:00.708--ServerSession(1706726)--Connection(29441291)--Thread(Thread[main,5,main])--SELECT
> > license_plate, color, customer_id, price_table_id, v_type FROM vehicle WHERE license_plate LIKE ?
> > bind => [%%]
> > [Click] [info ] renderTemplate: /view-vehicle.htm,/assets/common/template.htm - 82 ms
> >
> > onDestroy() method
> >
> > [Click] [info ] handleRequest: /view-vehicle.htm - 6386 ms
> >
> > findByLicensePlate() method
> > </quote>
> > In the onDestroy() method I close the EntityManager - I'm using the one EntityManager per Request
> > pattern.
> >
> > Is there another way I can check if the table control was set up correctly?
> >
> > Regards,
> >
> > Gilberto Caetano de Andrade
> > Analista de Sistemas/DBA
> > www.secad.to.gov.br <http://www.secad.to.gov.br> <http://www.secad.to.gov.br>
> > blog.gilbertoca.com <http://blog.gilbertoca.com> <http://blog.gilbertoca.com>
> >
> >
> > [1]
> >
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/test/java/park/web/page/ViewVehicleTest.java
>
>
Re: How to test Table load?
Posted by Gilberto <gi...@gmail.com>.
2011/3/17 Bob Schellink <sa...@gmail.com>
> Hi,
>
> Does your page have an associated template containing $table? The provider
> is only called when the
> table is rendered.
>
> Yes, it is! [1]
> Also, why not close EM in a filter instead?
>
> Not needed.
> Alternatively use Selenium to perform live testing of your site.
>
> This is a unit test and I'm using it to test page controller and the jpa
integration.
One thing to note[2] : using table's setRowList() method the test pass. That
because, as I've said, that method is
triggered after onDestroy() method.[3]
Regards,
Gilberto
[1]
http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/main/webapp/view-vehicle.htm
[2] http://dl.dropbox.com/u/9093640/log_1.txt
[3] http://dl.dropbox.com/u/9093640/log_2.txt
regards
>
> Bob
>
> On 2011/03/17 19:38 PM, Gilberto wrote:
> > Hi, all!
> >
> > In this [1] simple test I'm using the table.getRowList() - I've set the
> data provider on ViewVehicle
> > constructor - method to check the data load. But the test don't pass
> because that method is
> > triggered after onDestroy() method :
> > <quote>
> > ViewVehicle() method
> >
> >
> > findByLicensePlate() method
> >
> > [EL Fine]: 2011-03-17
> >
> 14:26:00.708--ServerSession(1706726)--Connection(29441291)--Thread(Thread[main,5,main])--SELECT
> > license_plate, color, customer_id, price_table_id, v_type FROM vehicle
> WHERE license_plate LIKE ?
> > bind => [%%]
> > [Click] [info ] renderTemplate:
> /view-vehicle.htm,/assets/common/template.htm - 82 ms
> >
> > onDestroy() method
> >
> > [Click] [info ] handleRequest: /view-vehicle.htm - 6386 ms
> >
> > findByLicensePlate() method
> > </quote>
> > In the onDestroy() method I close the EntityManager - I'm using the one
> EntityManager per Request
> > pattern.
> >
> > Is there another way I can check if the table control was set up
> correctly?
> >
> > Regards,
> >
> > Gilberto Caetano de Andrade
> > Analista de Sistemas/DBA
> > www.secad.to.gov.br <http://www.secad.to.gov.br>
> > blog.gilbertoca.com <http://blog.gilbertoca.com>
> >
> >
> > [1]
> >
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/test/java/park/web/page/ViewVehicleTest.java
>
>
Re: How to test Table load?
Posted by Bob Schellink <sa...@gmail.com>.
Hi,
Does your page have an associated template containing $table? The provider is only called when the
table is rendered.
Also, why not close EM in a filter instead?
Alternatively use Selenium to perform live testing of your site.
regards
Bob
On 2011/03/17 19:38 PM, Gilberto wrote:
> Hi, all!
>
> In this [1] simple test I'm using the table.getRowList() - I've set the data provider on ViewVehicle
> constructor - method to check the data load. But the test don't pass because that method is
> triggered after onDestroy() method :
> <quote>
> ViewVehicle() method
>
>
> findByLicensePlate() method
>
> [EL Fine]: 2011-03-17
> 14:26:00.708--ServerSession(1706726)--Connection(29441291)--Thread(Thread[main,5,main])--SELECT
> license_plate, color, customer_id, price_table_id, v_type FROM vehicle WHERE license_plate LIKE ?
> bind => [%%]
> [Click] [info ] renderTemplate: /view-vehicle.htm,/assets/common/template.htm - 82 ms
>
> onDestroy() method
>
> [Click] [info ] handleRequest: /view-vehicle.htm - 6386 ms
>
> findByLicensePlate() method
> </quote>
> In the onDestroy() method I close the EntityManager - I'm using the one EntityManager per Request
> pattern.
>
> Is there another way I can check if the table control was set up correctly?
>
> Regards,
>
> Gilberto Caetano de Andrade
> Analista de Sistemas/DBA
> www.secad.to.gov.br <http://www.secad.to.gov.br>
> blog.gilbertoca.com <http://blog.gilbertoca.com>
>
>
> [1]
> http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/test/java/park/web/page/ViewVehicleTest.java