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();
}
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()));
}
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;
}
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()));
}
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()));
}
Aggregations