use of com.google.inject.Injector 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 com.google.inject.Injector in project hadoop by apache.
the class TestWebAppTests method testRequestScope.
@Test
public void testRequestScope() {
Injector injector = WebAppTests.createMockInjector(this);
assertSame(injector.getInstance(ScopeTest.class), injector.getInstance(ScopeTest.class));
}
use of com.google.inject.Injector in project hadoop by apache.
the class TestAHSWebApp method testAppPageNaturalSortType.
@Test
public void testAppPageNaturalSortType() throws Exception {
Injector injector = WebAppTests.createMockInjector(ApplicationBaseProtocol.class, mockApplicationHistoryClientService(1, 5, 1));
AppPage appPageInstance = injector.getInstance(AppPage.class);
appPageInstance.render();
WebAppTests.flushOutput(injector);
Map<String, String> moreParams = appPageInstance.context().requestContext().moreParams();
String attemptsTableColumnsMeta = moreParams.get("ui.dataTables.attempts.init");
Assert.assertTrue(attemptsTableColumnsMeta.indexOf("natural") != -1);
}
use of com.google.inject.Injector in project hadoop by apache.
the class TestAHSWebApp method testAppControllerIndex.
@Test
public void testAppControllerIndex() throws Exception {
ApplicationHistoryManager ahManager = mock(ApplicationHistoryManager.class);
Injector injector = WebAppTests.createMockInjector(ApplicationHistoryManager.class, ahManager);
AHSController controller = injector.getInstance(AHSController.class);
controller.index();
Assert.assertEquals("Application History", controller.get(TITLE, "unknown"));
}
use of com.google.inject.Injector in project hadoop by apache.
the class TestAHSWebApp method testAppAttemptPage.
@Test
public void testAppAttemptPage() throws Exception {
Injector injector = WebAppTests.createMockInjector(ApplicationBaseProtocol.class, mockApplicationHistoryClientService(1, 1, 5));
AppAttemptPage appAttemptPageInstance = injector.getInstance(AppAttemptPage.class);
appAttemptPageInstance.render();
WebAppTests.flushOutput(injector);
appAttemptPageInstance.set(YarnWebParams.APPLICATION_ATTEMPT_ID, ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1).toString());
appAttemptPageInstance.render();
WebAppTests.flushOutput(injector);
}
Aggregations