public Injector getParentInjector() { ISuite suite = m_testContext.getSuite(); // Reuse the previous parent injector, if any Injector injector = suite.getParentInjector(); if (injector == null) { String stageString = suite.getGuiceStage(); Stage stage; if (isStringNotEmpty(stageString)) { stage = Stage.valueOf(stageString); } else { stage = Stage.DEVELOPMENT; } if (m_hasParentModule) { Class<Module> parentModule = (Class<Module>) ClassHelper.forName(suite.getParentModule()); if (parentModule == null) { throw new TestNGException("Cannot load parent Guice module class: " + suite.getParentModule()); } Module module = newModule(parentModule); injector = com.google.inject.Guice.createInjector(stage, module); } else { injector = com.google.inject.Guice.createInjector(stage); } suite.setParentInjector(injector); } return injector; }
@SuppressWarnings("unchecked") public Injector getParentInjector() { ISuite suite = m_testContext.getSuite(); // Reuse the previous parent injector, if any Injector injector = suite.getParentInjector(); if (injector == null) { String stageString = suite.getGuiceStage(); Stage stage; if (isStringNotEmpty(stageString)) { stage = Stage.valueOf(stageString); } else { stage = Stage.DEVELOPMENT; } if (m_hasParentModule) { Class<Module> parentModule = (Class<Module>) ClassHelper.forName(suite.getParentModule()); if (parentModule == null) { throw new TestNGException( "Cannot load parent Guice module class: " + suite.getParentModule()); } Module module = newModule(parentModule); injector = com.google.inject.Guice.createInjector(stage, module); } else { injector = com.google.inject.Guice.createInjector(stage); } suite.setParentInjector(injector); } return injector; }