Home | History | Annotate | Download | only in guice
      1 package test.guice;
      2 
      3 import com.google.inject.Module;
      4 
      5 import org.testng.IModuleFactory;
      6 import org.testng.ITestContext;
      7 
      8 public class ModuleFactory implements IModuleFactory {
      9 
     10   @Override
     11   public Module createModule(ITestContext context, Class<?> testClass) {
     12     String parameter = context.getCurrentXmlTest().getParameter("inject");
     13     String expected = "guice";
     14     if (! expected.equals(parameter)) {
     15       throw new RuntimeException("Excepted parameter to be " + expected + ", got " + parameter);
     16     }
     17     if (GuiceModuleFactoryTest.class == testClass) {
     18       return new GuiceExampleModule();
     19     } else {
     20       throw new RuntimeException("Don't know how to create a module for class " + testClass);
     21     }
     22   }
     23 
     24 }
     25