Class TicketsWebServiceScratchpadRoutingTest
GET /tickets/scratchpad โ the one thing the mocked
TicketsWebServiceTest cannot see, since it calls the handler methods directly and a literal
route swallowed by @Path("/{id}") would still pass there.
JAX-RS sorts candidate methods by literal character count ahead of template count (JSR-370 ยง3.7.2),
so /scratchpad outranks /{id}. If that stopped holding, the request would reach
TicketsWebService.getTicket(Long) with "scratchpad" to convert to a Long and Jersey
would answer 404 โ hence the 200 assertion, paired with a numeric id that must still reach
/{id} so the first assertion means the literal segment won a real contest.
Deliberately NOT a BaseJerseyIntegrationTest5: no database and no application context are
needed, only the in-memory container and a mocked service, so this stays in the fast suite. Spring
method security is absent, so @PreAuthorize does not fire here โ the auth contract is
asserted by reflection in TicketsWebServiceTest instead.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.glassfish.jersey.test.JerseyTest
client, close, closeIfNotNull, configureClient, configureDeployment, disable, enable, forceDisable, forceEnable, forceSet, getAsyncTimeoutMultiplier, getBaseUri, getClient, getLastLoggedRecord, getLoggedRecords, getPort, getSslContext, getSslParameters, isEnabled, set, set, setClient, target, target
-
Constructor Details
-
TicketsWebServiceScratchpadRoutingTest
public TicketsWebServiceScratchpadRoutingTest()
-
-
Method Details
-
getTestContainerFactory
protected org.glassfish.jersey.test.spi.TestContainerFactory getTestContainerFactory()- Overrides:
getTestContainerFactoryin classorg.glassfish.jersey.test.JerseyTest
-
configure
protected jakarta.ws.rs.core.Application configure()- Overrides:
configurein classorg.glassfish.jersey.test.JerseyTest
-
setUp
-
tearDown
-
scratchpadRoute_isNotSwallowedByTheIdTemplate
@Test public void scratchpadRoute_isNotSwallowedByTheIdTemplate() -
numericIdStillRoutesToTheSingleTicketHandler
@Test public void numericIdStillRoutesToTheSingleTicketHandler()The numeric-id route is still live, so the 200 above is a contest won, not a template gone.
-