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 Je...@nlgroup.ca on 2003/12/23 20:30:22 UTC

Odd output with servlet redirector and assert

Greetings:

      I am using cactus 1.5/jboss3.0.4/tomcat4.0.6 and trying to using the
most simple config option that I can until I get he hang of writing tests.

So I have both the client and server side Jars in on the serverside and am
running tests with a browser.

I noticed the output from assertEquals() does not show the expected and
actual values.
Improper Key: expected:<...e> but was:<...>  should be:
Expected: businessrule.customer.invalid.dat
Actual:businessrule.customer.invalid.date

The xml output is:
<failure message="Improper Key: expected:<...e> but was:<...>" type="junit.framework.ComparisonFailure">
junit.framework.ComparisonFailure: Improper Key: expected:<...e> but was:<...>
at com.nlg.ar.web.common.LogNoteTest.testValidationSaveNewLogNoteWithPastFollowup

I get the same type of output if I have &transform=yes in my url

In this case I am only testing two strings that are message resource keys.

The passes when the value is the same but when I test for a failure, I get the output above.

The test code is.
      //Check for proper key
      String msgKey = e.getMessageKey();
      if(log.isDebugEnabled()) log.debug("Exception Key: " + msgKey);

      //Should be the proper key
      assertEquals("Improper Key: ","businessrule.customer.invalid.date",msgKey);

I am very new to Cactus and Junit style testing, so please forgive me if this a dumb question..



Re: Odd output with servlet redirector and assert

Posted by "J. B. Rainsberger" <jb...@rogers.com>.
Jeff_Mychasiw@nlgroup.ca wrote:

> Greetings:
> 
>       I am using cactus 1.5/jboss3.0.4/tomcat4.0.6 and trying to using the
> most simple config option that I can until I get he hang of writing tests.
> 
> So I have both the client and server side Jars in on the serverside and am
> running tests with a browser.
> 
> I noticed the output from assertEquals() does not show the expected and
> actual values.
> Improper Key: expected:<...e> but was:<...>  should be:
> Expected: businessrule.customer.invalid.dat
> Actual:businessrule.customer.invalid.date

Google "JUnit string comparison patch". I think that'll help you.
-- 
J. B. Rainsberger,
Diaspar Software Services
http://www.diasparsoftware.com :: +1 416 791-8603
Let's write software that people understand


RE: Odd output with servlet redirector and assert

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

> -----Original Message-----
> From: Jeff_Mychasiw@nlgroup.ca [mailto:Jeff_Mychasiw@nlgroup.ca]
> Sent: 23 December 2003 20:30
> To: cactus-user@jakarta.apache.org
> Subject: Odd output with servlet redirector and assert
> 
> Greetings:
> 
>       I am using cactus 1.5/jboss3.0.4/tomcat4.0.6 and trying to using
the
> most simple config option that I can until I get he hang of writing
tests.
> 
> So I have both the client and server side Jars in on the serverside
and am
> running tests with a browser.
> 
> I noticed the output from assertEquals() does not show the expected
and
> actual values.
> Improper Key: expected:<...e> but was:<...>  should be:
> Expected: businessrule.customer.invalid.dat
> Actual:businessrule.customer.invalid.date
> 
> The xml output is:
> <failure message="Improper Key: expected:<...e> but was:<...>"
> type="junit.framework.ComparisonFailure">
> junit.framework.ComparisonFailure: Improper Key: expected:<...e> but
> was:<...>
> at
>
com.nlg.ar.web.common.LogNoteTest.testValidationSaveNewLogNoteWithPastFo
ll
> owup
> 

This means that the 2 values compared are not the same. The difference
is "e". The fact that the full expected and actual values are not fully
shown is a feature of JUnit 3.8.x.

> I get the same type of output if I have &transform=yes in my url

This is different. Transform=yes means that the XML will be transformed
into HTML using a stylesheet (see
http://jakarta.apache.org/cactus/integration/integration_browser.html).

> 
> In this case I am only testing two strings that are message resource
keys.
> 
> The passes when the value is the same but when I test for a failure, I
get
> the output above.
> 
> The test code is.
>       //Check for proper key
>       String msgKey = e.getMessageKey();
>       if(log.isDebugEnabled()) log.debug("Exception Key: " + msgKey);
> 
>       //Should be the proper key
>       assertEquals("Improper Key:
> ","businessrule.customer.invalid.date",msgKey);
> 
> I am very new to Cactus and Junit style testing, so please forgive me
if
> this a dumb question..

-Vincent