@Test public void testDatasourcesResourcesFilteringAccess() { setUpMockExpectations(requestPath, true, requestMethod); EasyMock.replay(req, request, authorizationInfo); Assert.assertTrue( ((AbstractResourceFilter) resourceFilter.getRequestFilter()).isApplicable(requestPath)); resourceFilter.getRequestFilter().filter(request); EasyMock.verify(req, request, authorizationInfo); }
@Test public void testDatasourcesResourcesFilteringBadPath() { EasyMock.replay(req, request, authorizationInfo); final String badRequestPath = requestPath.replaceAll("\\w+", "droid"); Assert.assertFalse( ((AbstractResourceFilter) resourceFilter.getRequestFilter()).isApplicable(badRequestPath)); EasyMock.verify(req, request, authorizationInfo); }
@Test(expected = WebApplicationException.class) public void testDatasourcesResourcesFilteringNoAccess() { setUpMockExpectations(requestPath, false, requestMethod); EasyMock.replay(req, request, authorizationInfo); // Assert.assertTrue(((AbstractResourceFilter) // resourceFilter.getRequestFilter()).isApplicable(requestPath)); try { resourceFilter.getRequestFilter().filter(request); } catch (WebApplicationException e) { Assert.assertEquals(Response.Status.FORBIDDEN.getStatusCode(), e.getResponse().getStatus()); throw e; } EasyMock.verify(req, request, authorizationInfo); }