use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.
the class BindingResolverTest method testResolveIndirectCycleThroughProvider.
public void testResolveIndirectCycleThroughProvider() throws Exception {
// Foo -> Baz -> Provider<Bar> -> Bar -> Foo
StandardTree tree = createExampleTree();
Binding fooBinding = expectCreateBinding(foo(), required(foo(), baz()));
Binding bazBinding = expectCreateBinding(baz(), required(baz(), providerBar()));
Binding providerBarBinding = expectCreateBinding(providerBar(), requiredLazy(providerBar(), bar()));
Binding barBinding = expectCreateBinding(bar(), required(bar(), foo()));
tree.root.addBinding(foo(), fooBinding);
tree.root.addBinding(providerBar(), providerBarBinding);
tree.root.addBinding(bar(), barBinding);
tree.root.addBinding(baz(), bazBinding);
expectParentBinding(foo(), tree.root, tree.childLL);
replayAndResolve(tree.childLL, required(Dependency.GINJECTOR, foo()));
}
use of com.google.gwt.inject.rebind.binding.Binding 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()));
}
use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.
the class BindingResolverTest method testResolveDependenciesResolveInOriginExposedToParent.
public void testResolveDependenciesResolveInOriginExposedToParent() throws Exception {
StandardTree tree = createExampleTree();
// Bar is bound in the child, but exposed to the root. Foo should still be in root
bindChild(bar(), tree.root, tree.childR);
bind(baz(), tree.root);
Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
Binding barBinding = expectCreateBinding(bar());
tree.root.addBinding(foo(), fooBinding);
tree.childR.addBinding(bar(), barBinding);
expectParentBinding(foo(), tree.root, tree.childR);
replayAndResolve(tree.childR, required(Dependency.GINJECTOR, foo()));
}
use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.
the class BindingResolverTest method testResolveMultipleCycles.
public void testResolveMultipleCycles() throws Exception {
// Foo -> Bar -> Provider<Baz> -> Baz -> {Provider<Foo>, Provider<Bar>, Provider<Baz>}
// Resolves multiple cycles, including a cycle that starts with a Provider
StandardTree tree = createExampleTree();
Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()));
Binding barBinding = expectCreateBinding(bar(), required(bar(), providerBaz()));
Binding providerBazBinding = expectCreateBinding(providerBaz(), requiredLazy(providerBaz(), baz()));
Binding bazBinding = expectCreateBinding(baz(), required(baz(), providerFoo()), required(baz(), providerFoo()), required(baz(), providerBar()));
Binding providerFooBinding = expectCreateBinding(providerFoo(), requiredLazy(providerFoo(), foo()));
Binding providerBarBinding = expectCreateBinding(providerBar(), requiredLazy(providerBar(), bar()));
tree.root.addBinding(foo(), fooBinding);
tree.root.addBinding(providerBar(), providerBarBinding);
tree.root.addBinding(providerFoo(), providerFooBinding);
tree.root.addBinding(providerBaz(), providerBazBinding);
tree.root.addBinding(bar(), barBinding);
tree.root.addBinding(baz(), bazBinding);
expectParentBinding(foo(), tree.root, tree.childLL);
replayAndResolve(tree.childLL, required(Dependency.GINJECTOR, foo()));
}
use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.
the class BindingResolverTest method bind.
private void bind(Key<?> key, GinjectorBindings in) {
Binding binding = control.createMock(Binding.class);
expect(binding.getContext()).andReturn(Context.forText("")).anyTimes();
expect(in.isBound(key)).andReturn(true).anyTimes();
expect(in.getBinding(key)).andReturn(binding).anyTimes();
bindings.add(binding);
}
Aggregations