You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sonny Sukumar <ah...@hotmail.com> on 2003/08/01 23:38:53 UTC

Topic for discussion...

Hi everyone,

This is partly a Cocoon question, partly a design best practices question, 
and partly I'm just plain curious. :-) Besides, I think we can all benefit 
in some way by discussing it.

Let's say I'm using Cocoon to build an admin interface for a product 
catalog.  So I have the following:

1.) An HTML form with entry fields corresponding to all the fields
2.) A Cocoon action that reads in the POSTed data from the request
3.) A Product backend Java class (just a regular bean).
4.) A backend database that stores the product data.

With this in mind, my first question is: Where would you validate product 
data?

Currently, I validate all of the product fields within my backend Product 
class and simply use my Cocoon action as a conduit through which data flows 
(into the server and then into the Product class).  I do this because I can 
easily unit test my Product class, but I have no idea how to unit test a 
Cocoon action.  On the other hand, this approach means that all data read 
out of the database is validated *again*, even though it should be valid 
since it was allowed to be stored there in the first place.

So my next set of questions are:
1.) Is it possible to unit test a Cocoon action in any meaningful way?
2.) Assuming it is, do you think it's a good idea to write 1 action 
dedicated to validating the incoming data and another for just for 
manipulating the data?
3.) Has anybody come across affordable (or, better yet, free!) tools to 
automate testing from a browser, at least with forms?  By this I mean I'd 
like to store several sets of form input data in some file and "replay" them 
by sending each in turn to the server and making sure I get the proper 
response.
4.) Do you think it's a good idea to validate data read out of the database? 
  I validate it before storing it and assume that nobody is touching the db 
except my app, so it seems rather foolhardy to validate it again.  But what 
do you think?

I think that's enough to discuss for now.  :-) Any thoughts?

I appreciate all of your time and input,

Sonny

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Topic for discussion...

Posted by Ryan Hoegg <rh...@isisnetworks.net>.
Hi,

I can speak to 3 and 4, but I'll leave 1 and 2 to the more experienced 
list members.

 > 3.) Has anybody come across affordable (or, better yet, free!) tools 
to automate testing from a browser, at least with forms?  By this I mean 
I'd like to store several sets of form input data in some file and 
"replay" them by sending each in turn to the server and making sure I 
get the proper response.

You might look at Latka, a project in the Apache Jakarta Commons 
http://jakarta.apache.org/commons .  It is a functional testing tool, 
which sounds like what you want.  Another idea is HTTPUnit, which is a 
bit lower level than latka.  Try Ward's wiki for current unit testing info.

4.) Do you think it's a good idea to validate data read out of the 
database?  I validate it before storing it and assume that nobody is 
touching the db except my app, so it seems rather foolhardy to validate 
it again.  But what do you think?

I agree with you, it seems redundant to validate the data again.  
However, if it is not a performance concern, why not leave it alone?  
Extra data vaidation doesn't hurt.

--
Ryan Hoegg
ISIS Networks
http://www.isisnetworks.net


Sonny Sukumar wrote:

>
> Hi everyone,
>
> This is partly a Cocoon question, partly a design best practices 
> question, and partly I'm just plain curious. :-) Besides, I think we 
> can all benefit in some way by discussing it.
>
> Let's say I'm using Cocoon to build an admin interface for a product 
> catalog.  So I have the following:
>
> 1.) An HTML form with entry fields corresponding to all the fields
> 2.) A Cocoon action that reads in the POSTed data from the request
> 3.) A Product backend Java class (just a regular bean).
> 4.) A backend database that stores the product data.
>
> With this in mind, my first question is: Where would you validate 
> product data?
>
> Currently, I validate all of the product fields within my backend 
> Product class and simply use my Cocoon action as a conduit through 
> which data flows (into the server and then into the Product class).  I 
> do this because I can easily unit test my Product class, but I have no 
> idea how to unit test a Cocoon action.  On the other hand, this 
> approach means that all data read out of the database is validated 
> *again*, even though it should be valid since it was allowed to be 
> stored there in the first place.
>
> So my next set of questions are:
> 1.) Is it possible to unit test a Cocoon action in any meaningful way?
> 2.) Assuming it is, do you think it's a good idea to write 1 action 
> dedicated to validating the incoming data and another for just for 
> manipulating the data?
> 3.) Has anybody come across affordable (or, better yet, free!) tools 
> to automate testing from a browser, at least with forms?  By this I 
> mean I'd like to store several sets of form input data in some file 
> and "replay" them by sending each in turn to the server and making 
> sure I get the proper response.
> 4.) Do you think it's a good idea to validate data read out of the 
> database?  I validate it before storing it and assume that nobody is 
> touching the db except my app, so it seems rather foolhardy to 
> validate it again.  But what do you think?
>
> I think that's enough to discuss for now.  :-) Any thoughts?
>
> I appreciate all of your time and input,
>
> Sonny
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org