You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Magnus Mickelsson <ma...@telia.com> on 2003/09/02 18:46:22 UTC

Always execute a end method on the client-side?

Hi guys,
first off - sorry for the spam mail. I was too tired whan I read the
message. (DOH!)

Now to my point. I sent this to the list before, but was for some reason
refused by the moderator. Here goes again (this thing is really important to
me, so I'd be really grateful for any hints :-)
------

I just wanted to know if there is some way to guarantee that either the
end(WebResponse) or endXXX(WebResponse) method in Cactus 1.5 is always
executed (or similar functionality), regardless of assertion failure or
exceptions?

My problem is that I set up test data using DBUnit on the client in the
begin(WebRequest) method, and then want to clean it up after the test has
run, regardless of it has failed or not. I do not want the DBUnit JARs,
test-data etc. transported to the server unless I absolutely _have to_. :-)

Any ideas?

Thanks in advance!

/Magnus

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 2003-08-19


SV: Always execute a end method on the client-side?

Posted by Magnus Mickelsson <ma...@telia.com>.
Hi Vincent,
thanks a lot for the clarifications. And thanks for the effort, you're doing
a great job - I'm sorry I burdened you with my rookieness ;-)

> Not in the current sources. I don't think it would be a good idea. The
> reason is that endXXX is used to assert the HTTP response and there
> won't be any if the test has failed on the server side and thus for sure
> the assert will fail, and it will mask the original error....

Ok, then I understand the flow a bit better...

> On that point, my belief is that database cleaning should not be done as
> it is a waste of time. Why not better set up the database in the correct
> state *before* each test? This prevents side effects and is inline with
> the unit testing methodology which says that all tests are independent.
> It's also clearer for a reader as he will know what data needs to be set
> before the test.

I agree, the problem is just that we have a pretty complex data model with
lots and lots of constraints. If one test sets up some data, adds some data
that relies on constraints and then fails (not cleaning the inserted data
up), the following tests working against the same tables of test data might
fail because we can't cleanly insert or update our setup. (And it's not
pretty to let the tests depend on each other when cleaning up)

Furthermore, we can't always just change PK/FK's to make it work, as some
columns have "unique" constraints in them, and other data rules.

So, we could:

* Workaround this by changing our test data (so that no test has even
similar data, and that it is unique in some columns, and valid according to
rules - some data has pretty strict rules associated to it). Anyone know of
a really intelligent test-data producing tool, or should I write one myself?
;-)

* Clean it all away using a custom stored procedure for quick flushing of a
set of tables, disabling constraints. The test database should not be very
big data-wise anyway, so the operation should not take too much time...

* Do something else.

> Anyway, that wasn't your question... ;-)
>
> Back to your problem. If you still want to do cleanup, you should do
> that in a tearDown() method, which is the recommended place (one
> advantage is that you can benefit from the container's connection pool).

Yup, that is the alternative to the scenarios above. Even though I am not
too fond of the idea of DBUnit JARs and test-data on the server, I'll give
it a go.

Take care and thanks again for the input,
Magnus
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 2003-08-19


RE: Always execute a end method on the client-side?

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Magnus,

> -----Original Message-----
> From: Magnus Mickelsson [mailto:magnus.mickelsson@telia.com]
> Sent: 02 September 2003 18:46
> To: Cactus Users List
> Subject: Always execute a end method on the client-side?
> 
> Hi guys,
> first off - sorry for the spam mail. I was too tired whan I read the
> message. (DOH!)
> 
> Now to my point. I sent this to the list before, but was for some
reason
> refused by the moderator. Here goes again (this thing is really
important
> to
> me, so I'd be really grateful for any hints :-)
> ------
> 
> I just wanted to know if there is some way to guarantee that either
the
> end(WebResponse) or endXXX(WebResponse) method in Cactus 1.5 is always
> executed (or similar functionality), regardless of assertion failure
or
> exceptions?

Not in the current sources. I don't think it would be a good idea. The
reason is that endXXX is used to assert the HTTP response and there
won't be any if the test has failed on the server side and thus for sure
the assert will fail, and it will mask the original error....

> 
> My problem is that I set up test data using DBUnit on the client in
the
> begin(WebRequest) method, and then want to clean it up after the test
has
> run, regardless of it has failed or not. I do not want the DBUnit
JARs,
> test-data etc. transported to the server unless I absolutely _have
to_. :-
> )

On that point, my belief is that database cleaning should not be done as
it is a waste of time. Why not better set up the database in the correct
state *before* each test? This prevents side effects and is inline with
the unit testing methodology which says that all tests are independent.
It's also clearer for a reader as he will know what data needs to be set
before the test.

Anyway, that wasn't your question... ;-)

Back to your problem. If you still want to do cleanup, you should do
that in a tearDown() method, which is the recommended place (one
advantage is that you can benefit from the container's connection pool).

> 
> Any ideas?

Thanks
-Vincent



RE: Always execute a end method on the client-side?

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Magnus,

First, I don't recall refusing the email you mention. Second, the
procedure to send email to a Cactus list is to subscribe and the only to
send the email (please read http://jakarta.apache.org/site/mail.html).
If you don't subscribe then I have to manually accept your message,
which is a/ a pain and b/ leads to longer delay before the email makes
it to the list.

You have to understand that I am not paid to develop Cactus nor to
answer any question on the list... This is done in my free time (and
thus after work hours).

The last reason I can invoke is that I receive about 100 emails per day
on the cactus mailing list that I need to manually accept or reject. 99%
are spam emails.

Conclusion: please subscribe to the list (that will also make it easier
to follow when someone answers you).

Thanks
-Vincent

> -----Original Message-----
> From: Magnus Mickelsson [mailto:magnus.mickelsson@telia.com]
> Sent: 02 September 2003 18:46
> To: Cactus Users List
> Subject: Always execute a end method on the client-side?
> 
> Hi guys,
> first off - sorry for the spam mail. I was too tired whan I read the
> message. (DOH!)
> 
> Now to my point. I sent this to the list before, but was for some
reason
> refused by the moderator. Here goes again (this thing is really
important
> to
> me, so I'd be really grateful for any hints :-)
> ------
[snip]