Search in sources :

Example 36 with Injector

use of com.google.inject.Injector in project hadoop by apache.

the class TestAHSWebApp method testContainerPage.

@Test
public void testContainerPage() throws Exception {
    Injector injector = WebAppTests.createMockInjector(ApplicationBaseProtocol.class, mockApplicationHistoryClientService(1, 1, 1));
    ContainerPage containerPageInstance = injector.getInstance(ContainerPage.class);
    containerPageInstance.render();
    WebAppTests.flushOutput(injector);
    containerPageInstance.set(YarnWebParams.CONTAINER_ID, ContainerId.newContainerId(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1).toString());
    containerPageInstance.render();
    WebAppTests.flushOutput(injector);
}
Also used : Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 37 with Injector

use of com.google.inject.Injector in project hadoop by apache.

the class TestHSWebApp method testAppControllerIndex.

@Test
public void testAppControllerIndex() {
    MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
    Injector injector = WebAppTests.createMockInjector(AppContext.class, ctx);
    HsController controller = injector.getInstance(HsController.class);
    controller.index();
    assertEquals(ctx.getApplicationID().toString(), controller.get(APP_ID, ""));
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 38 with Injector

use of com.google.inject.Injector in project hadoop by apache.

the class TestHSWebApp method testTaskViewNaturalSortType.

@Test
public void testTaskViewNaturalSortType() {
    LOG.info("HsTaskPage");
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
    Injector testPage = WebAppTests.testPage(HsTaskPage.class, AppContext.class, appContext, params);
    View viewInstance = testPage.getInstance(HsTaskPage.class);
    Map<String, String> moreParams = viewInstance.context().requestContext().moreParams();
    String appTableColumnsMeta = moreParams.get("ui.dataTables.attempts.init");
    Assert.assertTrue(appTableColumnsMeta.indexOf("natural") != -1);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Injector(com.google.inject.Injector) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) View(org.apache.hadoop.yarn.webapp.View) Test(org.junit.Test)

Example 39 with Injector

use of com.google.inject.Injector in project hadoop by apache.

the class TestHSWebApp method testLogsViewBadStartEnd.

@Test
public void testLogsViewBadStartEnd() throws IOException {
    LOG.info("HsLogsPage with bad start/end params");
    MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = new HashMap<String, String>();
    params.put("start", "foo");
    params.put("end", "bar");
    params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1).toString());
    params.put(NM_NODENAME, NodeId.newInstance(MockJobs.NM_HOST, MockJobs.NM_PORT).toString());
    params.put(ENTITY_STRING, "container_10_0001_01_000001");
    params.put(APP_OWNER, "owner");
    Injector injector = WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, ctx, params);
    PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
    verify(spyPw).write("Invalid log start value: foo");
    verify(spyPw).write("Invalid log end value: bar");
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) HashMap(java.util.HashMap) Injector(com.google.inject.Injector) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 40 with Injector

use of com.google.inject.Injector in project hadoop by apache.

the class TestHSWebApp method testLogsView2.

@Test
public void testLogsView2() throws IOException {
    LOG.info("HsLogsPage with data");
    MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = new HashMap<String, String>();
    params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1).toString());
    params.put(NM_NODENAME, NodeId.newInstance(MockJobs.NM_HOST, MockJobs.NM_PORT).toString());
    params.put(ENTITY_STRING, "container_10_0001_01_000001");
    params.put(APP_OWNER, "owner");
    Injector injector = WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, ctx, params);
    PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
    verify(spyPw).write("Aggregation is not enabled. Try the nodemanager at " + MockJobs.NM_HOST + ":" + MockJobs.NM_PORT);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) HashMap(java.util.HashMap) Injector(com.google.inject.Injector) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

Injector (com.google.inject.Injector)2117 AbstractModule (com.google.inject.AbstractModule)624 Test (org.junit.Test)513 Module (com.google.inject.Module)386 Binder (com.google.inject.Binder)140 Before (org.junit.Before)116 Properties (java.util.Properties)110 Test (org.testng.annotations.Test)105 Key (com.google.inject.Key)91 HttpServletRequest (javax.servlet.http.HttpServletRequest)78 Map (java.util.Map)75 Provider (com.google.inject.Provider)74 TypeLiteral (com.google.inject.TypeLiteral)70 IOException (java.io.IOException)69 Set (java.util.Set)63 BeforeClass (org.junit.BeforeClass)61 File (java.io.File)59 ImmutableList (com.google.common.collect.ImmutableList)58 CConfiguration (co.cask.cdap.common.conf.CConfiguration)55 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)55