tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nabble User <homerlex.nab...@gmail.com>
Subject Re: Unit testing a CometProcessor Servlet
Date Mon, 04 Oct 2010 11:43:51 GMT
Thank you for taking the time to reply Chris!

Yes, I understand that I could just make direct calls to events.  However,
since we are talking about long blocking requests that don't return until
some action is taken by other users (or the connection times out of course)
I was curious to see what other people do to test these situations. A unit
test that spawns multiple threads?

Again, I appreciate your response.

On Fri, Oct 1, 2010 at 11:45 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message