users@jersey.java.net

Re: [Jersey] Creating UriInfo in tests

From: tarjei <tarjei_at_nu.no>
Date: Wed, 12 Nov 2008 16:16:28 +0100

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

Paul Sandoz wrote:
>
> On Nov 12, 2008, at 11:46 AM, tarjei wrote:
>
> hi, is it possible to create UriBuilder in tests or do I have to use
> EasyMock?
>
>
>> It is possible to create a UrBuilder by doing:
>
>> UriBuilder.fromUri(...)
>
>> or using other static methods.
>
>> But i suspect you mean UriInfo as in the title.
>
>> The only way to create a Jersey-based instance is to deploy the tests
>> using an embedded server. Quite a lot of the functional tests use an
>> in-memory-based server, but still that is not the same as instantiating
>> the resource classes yourself. So it is necessary to use something like
>> EasyMock. If you have any ideas about how Jersey can make it easier in
>> this respect let me know.

Well, I don't know the Jersey internals, but I have often wished for a
simple application test class. Something like:

TestApp = new JerseyTest("http://baseuri/");

TestApp.addService(new MyService());

Response r = TestApp.GET("Http://baseuri/myservice/id/4", ..);

Response r = TestApp.POST("Http://baseuri/myservice/id/4",
"<?xml version="1.0" .. ", ..);

This would make it possible to verify most of the annotations in a
service without using some kind of webtest tool.

I would guess that most of this infrastructure exists in the functional
tests.

A simpler approach would be to have versions of the injectable contexts
that one can instantiate in unittests.


kind regards,
Tarjei


>
>> Paul.
>
>
> Regards,
> Tarjei
>>
- ---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJGvNMYVRKCnSvzfIRAp7NAJ0eLvkG/dSha1c5dgZkA4T0PTqr+ACffHDU
6WYJwRC3npAvOwBpCXDv8vA=
=CLz6
-----END PGP SIGNATURE-----