Thank you Pavel,
your sample works great.
I had to adjust it a bit, because the default TestContainerFactory is
not supported by LowLevelAppDescriptor
public class ApplicationTest extends JerseyTest {
public ApplicationTest() {
super();
}
protected AppDescriptor configure() {
setTestContainerFactory(new GrizzlyTestContainerFactory());
return new LowLevelAppDescriptor.Builder(WrapperResource.class).build();
}
}
Mark
On Thu, Apr 7, 2011 at 5:15 PM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
> typo;
>
> constructor should be present in the test class, so..
>
>
> public ResTestResourceTest extends JerseyTest {
>
> @Path("/")
> public static class ResTestResource extends Res {
> public ResTestResource() {
> super("injected value");
> }
> }
>
> public ResTestResourceTest() {
> super(new LowLevelAppDescriptor.Builder(ResTestResource.class).
> contextPath("contextPath").
> build());
> }
>
> @Test
> public void testSomething() {
> ....
> }
>
>
> }
>
>
>
> On 04/07/2011 05:10 PM, Pavel Bucek wrote:
>>
>> something like this should work:
>>
>> public *ResTestResourceTest*() {
>> super(new LowLevelAppDescriptor.Builder(ResTestResource.class).
>> contextPath("contextPath").
>> build());
>> }
>>
>> Pavel
>>
>> On 04/07/2011 04:53 PM, Mark Engel wrote:
>>>
>>> Thank you for your quick reply.
>>> Boilerplate here we come :)
>>>
>>> How do I start ResTestResource within a JerseyTest without configuring
>>> its whole package?
>>> (So I could define the Wrapper Class inside the Test)
>>>
>>> Mark
>>>
>>> On Thu, Apr 7, 2011 at 4:39 PM, Pavel Bucek<pavel.bucek_at_oracle.com>
>>> wrote:
>>>>
>>>> Hello,
>>>>
>>>> it is not possible, jersey test framework always needs to start jersey
>>>> and
>>>> if you define just this class as only resource, it won't start because
>>>> there
>>>> is no root resource present.
>>>>
>>>> What you can do is create something like ResTestResource, which could
>>>> look
>>>> like:
>>>>
>>>> @Path("/")
>>>> public class ResTestResource extends Res {
>>>> public ResTestResource() {
>>>> super("injected value");
>>>> }
>>>> }
>>>>
>>>> and run your test(s) against it..
>>>>
>>>>
>>>> Pavel
>>>>
>>>> On 04/07/2011 04:29 PM, Mark Engel wrote:
>>>>>
>>>>> How is it possible to unit test just one resource at a time?
>>>>>
>>>>> For example I have this resource
>>>>>
>>>>> class Res {
>>>>> private final String injected;
>>>>> public Res(String injected) { this.injected = injected; }
>>>>> @GET public String get() { return injected; }
>>>>> }
>>>>>
>>>>> and want to unit test this resource with a custom stub (configured via
>>>>> setUp()) against real http calls from Client.
>>>>> I would expect that if I only test one resource it would be in the
>>>>> root of the server.
>>>>>
>>>>> Is this possible with Jersey? I only found options to configure a
>>>>> whole package of resource.
>>>>>
>>>>
>>
>>
>
>