You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2010/11/03 14:08:55 UTC

Trouble with writing TC 7.0.x unit tests

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I'm having trouble understanding the behavior of a unit test I'm writing
against TC 7.0.x trunk to prepare for testing a patch. I happen to be
working in org/apache/catalina/connector/TestRequest.java and my test
method contains the following code:

        // set up my test

        System.out.println("Checking assertions");
        assertTrue("Non-200 response for POST request",
                   client.isResponse200());
        assertEquals("Incorrect response for POST request",
                     "foo=bar,bar=baz",
                     client.getResponseBody());

        System.out.println("Looking good so far!");

I get this output when running the test:

    [lots of output from other tests, setup messages, etc]

    [junit] ===== INFO ======
    [junit] Response: HTTP/1.1 200 OK
    [junit] Headers: [Server: Apache-Coyote/1.1, Content-Type:
text/plain;charset=UTF-8, Content-Length: 7, Date: Wed, 03 Nov 2010
12:57:46 GMT, Connection: close]
    [junit] Response body: foo=bar
    [junit] Checking assertions
    [junit] Nov 3, 2010 8:57:47 AM
org.apache.coyote.http11.AbstractHttp11Protocol pause
    [junit] INFO: Pausing Coyote HTTP/1.1 on http-8006

    [lots more shutdown messages]

I'm confused as to why I'm not getting an AssertionError thrown from
this method, as I'm expecting client.getRequestBody() to return
"foo=bar,bar=baz" but I'm getting only "foo=bar". I never see the
message "Looking good so far!" so I suspect that the assertion is
actually failing, but it looks like it's being swallowed somewhere.

I have no try/catch blocks in my unit test method, and it looks like I'm
using the assert methods in the same way as other tests in the same file.

Can anyone offer any suggestions or pointers?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzRXucACgkQ9CaO5/Lv0PBbEQCgu8rdDthqYI5FgZFUIIoEx/kq
8DQAn1F3ikT7YHAEHvUv3jpPYUCjL4oa
=7ujU
-----END PGP SIGNATURE-----

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


Re: Trouble with writing TC 7.0.x unit tests

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

On 11/3/2010 9:08 AM, Christopher Schultz wrote:
> I'm having trouble understanding the behavior of a unit test I'm writing
> against TC 7.0.x trunk to prepare for testing a patch. I happen to be
> working in org/apache/catalina/connector/TestRequest.java and my test
> method contains the following code:

Circling back for those interested, I wasn't reading the log file of my
tests, which can be found in
build/logs/TEST-org.apache.catalina.connector.TestRequest.[connector].txt

Plus, I fixed the problem with my tests ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzRocUACgkQ9CaO5/Lv0PCbZQCfUgBdw4X0HEKONLEmGIsdP3Qf
M6cAn3Puz6G2Vtn6QfFHm3qEhRslTRRX
=UbPO
-----END PGP SIGNATURE-----

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


Re: Trouble with writing TC 7.0.x unit tests

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark,

On 11/3/2010 9:15 AM, Mark Thomas wrote:
> On 03/11/2010 09:08, Christopher Schultz wrote:
>> All,
>>
>> I'm having trouble understanding the behavior of a unit test I'm writing
>> against TC 7.0.x trunk to prepare for testing a patch. I happen to be
>> working in org/apache/catalina/connector/TestRequest.java and my test
>> method contains the following code:
> 
> Nothing obvious but if you find me at ApacheCon I'll take a look. I
> should be easy to find, I'm wearing an ASF infra t-shirt and baseball
> cap and have my (very) bright yellow Tomcat bag with me.

Sounds good. Maybe today at lunch? I'd be happy to have others join us
as well if they are interested. I'm wearing a black turtleneck and
really nothing eye-catching.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzRZmkACgkQ9CaO5/Lv0PAqLgCdHi/o/H/4H9wG4dNYkBdoxwFh
Hp4An0YM6K3jDQj1AzLusPq/+3HFItp3
=2Aih
-----END PGP SIGNATURE-----

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


Re: Trouble with writing TC 7.0.x unit tests

Posted by Mark Thomas <ma...@apache.org>.
On 03/11/2010 09:08, Christopher Schultz wrote:
> All,
> 
> I'm having trouble understanding the behavior of a unit test I'm writing
> against TC 7.0.x trunk to prepare for testing a patch. I happen to be
> working in org/apache/catalina/connector/TestRequest.java and my test
> method contains the following code:

Nothing obvious but if you find me at ApacheCon I'll take a look. I
should be easy to find, I'm wearing an ASF infra t-shirt and baseball
cap and have my (very) bright yellow Tomcat bag with me.

Mark



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