Search in sources :

Example 1 with GuiceUtil

use of com.google.gwt.inject.rebind.util.GuiceUtil in project google-gin by gwtplus.

the class FactoryBindingTest method testTwoUnnamedStringAnnotations.

public void testTwoUnnamedStringAnnotations() {
    try {
        new FactoryBinding(Collections.<Key<?>, TypeLiteral<?>>emptyMap(), Key.get(TwoUnnamedStringsFactory.class), CONTEXT, new GuiceUtil(createInjectableCollector()), null);
        fail("Expected ConfigurationException.");
    } catch (ConfigurationException e) {
        assertTrue(e.getMessage().contains("has more than one parameter of type " + "java.lang.String annotated with @Assisted(\"\")."));
    }
}
Also used : GuiceUtil(com.google.gwt.inject.rebind.util.GuiceUtil) ConfigurationException(com.google.inject.ConfigurationException)

Example 2 with GuiceUtil

use of com.google.gwt.inject.rebind.util.GuiceUtil in project google-gin by gwtplus.

the class GinjectorBindingsTest method setUp.

@Override
public void setUp() {
    control = createControl();
    niceControl = createNiceControl();
    nameGenerator = control.createMock("nameGenerator", NameGenerator.class);
    logger = niceControl.createMock("logger", TreeLogger.class);
    guiceUtil = control.createMock("guiceUtil", GuiceUtil.class);
    {
        @SuppressWarnings("unchecked") Provider<GinjectorBindings> tmpProvider = control.createMock("ginjectorBindingsProvider", Provider.class);
        ginjectorBindingsProvider = tmpProvider;
    }
    collector = control.createMock("collector", MemberCollector.class);
    errorManager = control.createMock("errorManager", ErrorManager.class);
    bindingResolver = control.createMock("bindingResolver", BindingResolver.class);
    methodCallUtil = control.createMock("methodCallUtil", MethodCallUtil.class);
    bindingFactory = new BindingFactoryImpl(errorManager, guiceUtil, DummyInjectorInterface.class, methodCallUtil);
}
Also used : MethodCallUtil(com.google.gwt.inject.rebind.util.MethodCallUtil) TreeLogger(com.google.gwt.core.ext.TreeLogger) GuiceUtil(com.google.gwt.inject.rebind.util.GuiceUtil) BindingFactoryImpl(com.google.gwt.inject.rebind.binding.BindingFactoryImpl) NameGenerator(com.google.gwt.inject.rebind.util.NameGenerator) BindingResolver(com.google.gwt.inject.rebind.resolution.BindingResolver) MemberCollector(com.google.gwt.inject.rebind.util.MemberCollector) Provider(com.google.inject.Provider)

Example 3 with GuiceUtil

use of com.google.gwt.inject.rebind.util.GuiceUtil in project gwt-test-utils by gwt-test-utils.

the class GInjectorCreateHandler method readGuiceModules.

private Set<Module> readGuiceModules(Class<? extends GinModule>[] classLiterals, Class<? extends Ginjector> ginectorClass) throws Exception {
    Set<Module> modules = new HashSet<>();
    for (Class<? extends GinModule> literal : classLiterals) {
        LOGGER.debug("wrapping GinModule literal " + literal);
        MemberCollector memberCollector = new MemberCollector(GwtTreeLogger.get());
        GuiceUtil guiceUtil = new GuiceUtil(memberCollector);
        modules.add(new GinModuleAdapter(literal.newInstance(), new GinjectorBindings(null, GwtTreeLogger.get(), guiceUtil, ginectorClass, null, memberCollector, null, null)));
    }
    return modules;
}
Also used : GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings) GuiceUtil(com.google.gwt.inject.rebind.util.GuiceUtil) GinModuleAdapter(com.google.gwt.inject.rebind.adapter.GinModuleAdapter) Module(com.google.inject.Module) GinModule(com.google.gwt.inject.client.GinModule) MemberCollector(com.google.gwt.inject.rebind.util.MemberCollector) HashSet(java.util.HashSet)

Example 4 with GuiceUtil

use of com.google.gwt.inject.rebind.util.GuiceUtil in project google-gin by gwtplus.

the class FactoryBindingTest method testDuplicateNamedAssistedAnnotations.

public void testDuplicateNamedAssistedAnnotations() {
    try {
        new FactoryBinding(Collections.<Key<?>, TypeLiteral<?>>emptyMap(), Key.get(TwoAssistedFooStringsFactory.class), CONTEXT, new GuiceUtil(createInjectableCollector()), null);
        fail("Expected ConfigurationException.");
    } catch (ConfigurationException e) {
        assertTrue(e.getMessage().contains("has more than one parameter of type " + "java.lang.String annotated with @Assisted(\"foo\")."));
    }
}
Also used : GuiceUtil(com.google.gwt.inject.rebind.util.GuiceUtil) ConfigurationException(com.google.inject.ConfigurationException)

Example 5 with GuiceUtil

use of com.google.gwt.inject.rebind.util.GuiceUtil in project google-gin by gwtplus.

the class FactoryBindingTest method testMismatchedFactoryAndClassAnnotations.

public void testMismatchedFactoryAndClassAnnotations() {
    try {
        new FactoryBinding(Collections.<Key<?>, TypeLiteral<?>>emptyMap(), Key.get(MismatchedFactoryAndClassAssistedValuesFactory.class), CONTEXT, new GuiceUtil(createInjectableCollector()), null);
        fail("Expected ConfigurationException.");
    } catch (ConfigurationException e) {
        assertTrue(e.getMessage(), e.getMessage().contains("has no constructors matching " + "the parameters in method"));
    }
}
Also used : GuiceUtil(com.google.gwt.inject.rebind.util.GuiceUtil) ConfigurationException(com.google.inject.ConfigurationException)

Aggregations

GuiceUtil (com.google.gwt.inject.rebind.util.GuiceUtil)5 ConfigurationException (com.google.inject.ConfigurationException)3 MemberCollector (com.google.gwt.inject.rebind.util.MemberCollector)2 TreeLogger (com.google.gwt.core.ext.TreeLogger)1 GinModule (com.google.gwt.inject.client.GinModule)1 GinjectorBindings (com.google.gwt.inject.rebind.GinjectorBindings)1 GinModuleAdapter (com.google.gwt.inject.rebind.adapter.GinModuleAdapter)1 BindingFactoryImpl (com.google.gwt.inject.rebind.binding.BindingFactoryImpl)1 BindingResolver (com.google.gwt.inject.rebind.resolution.BindingResolver)1 MethodCallUtil (com.google.gwt.inject.rebind.util.MethodCallUtil)1 NameGenerator (com.google.gwt.inject.rebind.util.NameGenerator)1 Module (com.google.inject.Module)1 Provider (com.google.inject.Provider)1 HashSet (java.util.HashSet)1