use of javax.servlet.http.HttpServletRequest in project hadoop by apache.
the class TestWebAppTests method testInstances.
@Test
public void testInstances() throws Exception {
Injector injector = WebAppTests.createMockInjector(this);
HttpServletRequest req = injector.getInstance(HttpServletRequest.class);
HttpServletResponse res = injector.getInstance(HttpServletResponse.class);
String val = req.getParameter("foo");
PrintWriter out = res.getWriter();
out.println("Hello world!");
logInstances(req, res, out);
assertSame(req, injector.getInstance(HttpServletRequest.class));
assertSame(res, injector.getInstance(HttpServletResponse.class));
assertSame(this, injector.getInstance(TestWebAppTests.class));
verify(req).getParameter("foo");
verify(res).getWriter();
verify(out).println("Hello world!");
}
use of javax.servlet.http.HttpServletRequest in project hadoop by apache.
the class DefaultWrapperServlet method doGet.
@Private
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
RequestDispatcher rd = getServletContext().getNamedDispatcher("default");
HttpServletRequest wrapped = new HttpServletRequestWrapper(req) {
public String getServletPath() {
return "";
}
};
rd.forward(wrapped, resp);
}
use of javax.servlet.http.HttpServletRequest in project hadoop by apache.
the class TestAggregatedLogsBlock method getAggregatedLogsBlockForTest.
private AggregatedLogsBlockForTest getAggregatedLogsBlockForTest(Configuration configuration, String user, String containerId, String nodeName) {
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getRemoteUser()).thenReturn(user);
AggregatedLogsBlockForTest aggregatedBlock = new AggregatedLogsBlockForTest(configuration);
aggregatedBlock.setRequest(request);
aggregatedBlock.moreParams().put(YarnWebParams.CONTAINER_ID, containerId);
aggregatedBlock.moreParams().put(YarnWebParams.NM_NODENAME, nodeName);
aggregatedBlock.moreParams().put(YarnWebParams.APP_OWNER, user);
aggregatedBlock.moreParams().put("start", "");
aggregatedBlock.moreParams().put("end", "");
aggregatedBlock.moreParams().put(YarnWebParams.ENTITY_STRING, "entity");
return aggregatedBlock;
}
use of javax.servlet.http.HttpServletRequest in project hadoop by apache.
the class TestHsWebServicesAcls method testGetJobTaskAcls.
@Test
public void testGetJobTaskAcls() {
HttpServletRequest hsr = mock(HttpServletRequest.class);
when(hsr.getRemoteUser()).thenReturn(ENEMY_USER);
try {
hsWebServices.getJobTask(hsr, jobIdStr, this.taskIdStr);
fail("enemy can access job");
} catch (WebApplicationException e) {
assertEquals(Status.UNAUTHORIZED, Status.fromStatusCode(e.getResponse().getStatus()));
}
when(hsr.getRemoteUser()).thenReturn(FRIENDLY_USER);
hsWebServices.getJobTask(hsr, this.jobIdStr, this.taskIdStr);
}
use of javax.servlet.http.HttpServletRequest in project hadoop by apache.
the class TestHsWebServicesAcls method testGetJobTaskAttemptsAcls.
@Test
public void testGetJobTaskAttemptsAcls() {
HttpServletRequest hsr = mock(HttpServletRequest.class);
when(hsr.getRemoteUser()).thenReturn(ENEMY_USER);
try {
hsWebServices.getJobTaskAttempts(hsr, this.jobIdStr, this.taskIdStr);
fail("enemy can access job");
} catch (WebApplicationException e) {
assertEquals(Status.UNAUTHORIZED, Status.fromStatusCode(e.getResponse().getStatus()));
}
when(hsr.getRemoteUser()).thenReturn(FRIENDLY_USER);
hsWebServices.getJobTaskAttempts(hsr, this.jobIdStr, this.taskIdStr);
}
Aggregations