Search in sources :

Example 1 with GinjectorBindings

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

the class DependencyExplorerTest method testSourcePositioned.

/**
 * Tests that when we have a dependency that installs multiple steps (eg, GINJECTOR -> foo -> bar)
 * we will treat foo as previously positioned.
 */
public void testSourcePositioned() throws Exception {
    GinjectorBindings parent = control.createMock("parent", GinjectorBindings.class);
    expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE), new Dependency(foo(), bar(), SOURCE)));
    expect(origin.isBound(foo())).andReturn(true).anyTimes();
    expect(origin.isBound(bar())).andReturn(false).anyTimes();
    expect(origin.isPinned(foo())).andReturn(true).anyTimes();
    expect(origin.isPinned(bar())).andReturn(false).anyTimes();
    expect(origin.getParent()).andReturn(parent).anyTimes();
    expect(parent.getParent()).andReturn(null).times(2);
    expect(parent.isBound(foo())).andReturn(false);
    expect(parent.isPinned(foo())).andReturn(false);
    expect(parent.isBound(bar())).andReturn(true);
    control.replay();
    DependencyExplorerOutput output = dependencyExplorer.explore(origin);
    assertSame(origin, output.getPreExistingLocations().get(foo()));
    assertSame(parent, output.getPreExistingLocations().get(bar()));
    control.verify();
}
Also used : GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings) DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 2 with GinjectorBindings

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

the class BindingResolverTest method testDepHiddenInChildBlocksResolvingInRoot_NoErrorIfOptional.

public void testDepHiddenInChildBlocksResolvingInRoot_NoErrorIfOptional() throws Exception {
    GinjectorBindings root = createInjectorNode("root");
    GinjectorBindings child = createInjectorNode("child");
    setChildren(root, child);
    bind(baz(), root);
    bind(bar(), child);
    expect(root.isBoundLocallyInChild(bar())).andReturn(true).anyTimes();
    expect(root.getChildWhichBindsLocally(bar())).andReturn(child);
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), baz()), optional(foo(), bar()));
    expectCreateBinding(bar());
    root.addBinding(foo(), fooBinding);
    replayAndResolve(root, required(Dependency.GINJECTOR, foo()));
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings)

Example 3 with GinjectorBindings

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

the class BindingResolverTest method createInjectorNode.

private GinjectorBindings createInjectorNode(String name) {
    GinjectorBindings node = control.createMock(name, GinjectorBindings.class);
    nodes.add(node);
    expect(node.getParent()).andStubReturn(null);
    expect(node.getChildren()).andStubReturn(new ArrayList<GinjectorBindings>());
    expect(node.isBound(isA(Key.class))).andStubReturn(false);
    expect(node.isBoundLocallyInChild(isA(Key.class))).andStubReturn(false);
    expect(node.getBinding(isA(Key.class))).andStubReturn(null);
    expect(node.getModuleName()).andStubReturn(name);
    expect(node.isPinned(isA(Key.class))).andStubReturn(false);
    return node;
}
Also used : GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings) Key(com.google.inject.Key)

Example 4 with GinjectorBindings

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

the class BindingResolverTest method testCycleDetectionForBindFooToFooImpl.

public void testCycleDetectionForBindFooToFooImpl() throws Exception {
    GinjectorBindings root = createInjectorNode("root");
    bind(foo(), root);
    expectCreateBinding(fooImpl(), required(fooImpl(), bar()));
    expectCreateBinding(bar(), required(bar(), foo()));
    errorManager.logError(isA(String.class), isA(String.class), EasyMock.anyObject());
    // Intentionally use a different key, so that == won't work
    replayAndResolve(root, required(foo(), fooImpl()));
}
Also used : GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings)

Example 5 with GinjectorBindings

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

the class BindingResolverTest method testOneNode.

public void testOneNode() throws Exception {
    GinjectorBindings root = createInjectorNode("root");
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
    bind(bar(), root);
    bind(baz(), root);
    root.addBinding(foo(), fooBinding);
    replayAndResolve(root, required(Dependency.GINJECTOR, foo()));
}
Also used : ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings)

Aggregations

GinjectorBindings (com.google.gwt.inject.rebind.GinjectorBindings)27 Binding (com.google.gwt.inject.rebind.binding.Binding)10 Dependency (com.google.gwt.inject.rebind.binding.Dependency)8 ParentBinding (com.google.gwt.inject.rebind.binding.ParentBinding)7 ExposedChildBinding (com.google.gwt.inject.rebind.binding.ExposedChildBinding)6 DependencyExplorerOutput (com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput)6 Key (com.google.inject.Key)5 NameGenerator (com.google.gwt.inject.rebind.util.NameGenerator)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Capture (org.easymock.Capture)3 GinjectorNameGenerator (com.google.gwt.inject.rebind.GinjectorNameGenerator)2 InjectorMethod (com.google.gwt.inject.rebind.util.InjectorMethod)2 SourceWriteUtil (com.google.gwt.inject.rebind.util.SourceWriteUtil)2 GeneratorContext (com.google.gwt.core.ext.GeneratorContext)1 GinModule (com.google.gwt.inject.client.GinModule)1 GinScope (com.google.gwt.inject.rebind.GinScope)1 GinModuleAdapter (com.google.gwt.inject.rebind.adapter.GinModuleAdapter)1 GinjectorBinding (com.google.gwt.inject.rebind.binding.GinjectorBinding)1 SubPackageClass (com.google.gwt.inject.rebind.output.subpackage.SubPackageClass)1