tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Unit testing a CometProcessor Servlet
Date Fri, 01 Oct 2010 15:45:21 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To whom it may concern,

(FYI: It's usually polite to identify yourself)

On 9/27/2010 3:59 PM, Nabble User wrote:
> Does anyone have tips for unit testing a servlet that implements
> CometProcessor?

Can't you synthesize all the events you need? It should be as simple as
calling the methods on your Comet-enabled servlet, right?

I highly recommend the use of mock objects for this type of thing. JMock
is a great library that can masquerade as a particular object and allow
you to intercept the messages, take some action, and return whatever you
want.

> So, examples for testing that servlet code would be beneficial.

HttpServlet myServlet = new MyServlet();
myServlet.init();

MockEvent event = ...;

myServlet.event(event);

// Now, observe the event to see if you got what you expected

??

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

iEUEARECAAYFAkymAhEACgkQ9CaO5/Lv0PD7CACeN3v36Q6AzJte4dAgQczlpkrO
jc0AmLama9PY7Up54PUsDmS32yQxxeg=
=YUCL
-----END PGP SIGNATURE-----

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


Mime
View raw message