users@jersey.java.net

[Jersey] Re: Catch all requests under a specific path

From: Erik Holstad <erikholstad_at_gmail.com>
Date: Mon, 24 Mar 2014 14:45:06 -0700

Basically I want to run integration tests on the "deployed" code and not
just a unit test where I don't write to the correct table in the db, but a
special test table.

The way I see it I have at least 2 options and I'm having issues with both:


1. Running regular integration tests and sending all requests to some
/test/ endpoint which forwards them to the real endpoints but also sets a
testing flag to be used only for internal use.

2. Use JerseyTest which works fine for the above use case, but is giving me
issues with bean/parameter validation(Question about this in separate email)




On Mon, Mar 24, 2014 at 2:34 PM, Robert DiFalco <robert.difalco_at_gmail.com>wrote:

> Erik,
>
> I'm not super clear on what you are trying to do here but would a
> ContainerRequestFilter work for you?
>
>
> On Mon, Mar 24, 2014 at 2:28 PM, Ted M. Young [@jitterted] <
> tedyoung_at_gmail.com> wrote:
>
>> Ah. Well then I'm not sure what to suggest, other than perhaps consuming
>> the logging output as that will have all of the requests in it.
>>
>> ;ted
>>
>>
>> On Mon, Mar 24, 2014 at 2:02 PM, Erik Holstad <erikholstad_at_gmail.com>wrote:
>>
>>> I'm planning to use this for testing purposes, so would be nice to
>>> capture all requests instead of having to add a new endpoint every time I
>>> add a new one to that actual code.
>>>
>>>
>>> On Thu, Mar 20, 2014 at 8:44 PM, Ted M. Young [@jitterted] <
>>> tedyoung_at_gmail.com> wrote:
>>>
>>>> Hi Erik,
>>>>
>>>> What would the benefit of this be? Why not just create two endpoints
>>>> that then call the same method internally? e.g.:
>>>>
>>>> @Path("/foo")
>>>> public class StocksResource {
>>>> @GET // just matches /foo
>>>> @Produces(MediaType.APPLICATION_JSON)
>>>> public Response getFoo() {
>>>> return foo(false);
>>>> }
>>>>
>>>> @GET
>>>> @Path("/bar") // matches /foo/bar
>>>> @Produces(MediaType.APPLICATION_JSON)
>>>> public Response getFooBar() {
>>>> return foo(true);
>>>> }
>>>>
>>>> private foo(boolean hasBar) {
>>>> // do stuff here
>>>> }
>>>> }
>>>>
>>>> ;ted
>>>>
>>>>
>>>>
>>>> On Thu, Mar 20, 2014 at 4:34 PM, Erik Holstad <erikholstad_at_gmail.com>wrote:
>>>>
>>>>> Hey!
>>>>>
>>>>> I wounder if there is a way to route all calls to any sub paths to a
>>>>> given parent path.
>>>>>
>>>>> Let's pretend we have 2 endpoints
>>>>>
>>>>> GET /foo and
>>>>> GET /foo/bar
>>>>>
>>>>> I would like to be able to catch them both in one method and then
>>>>> branch afterwards.
>>>>>
>>>>> I know I can do this using the regular HttpServletRequest but I just
>>>>> want this functionality for one specific path so don't want to change the
>>>>> structure of the other servlets.
>>>>>
>>>>> --
>>>>> Regards Erik
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Regards Erik
>>>
>>
>>
>


-- 
Regards Erik