use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.
the class BindingResolverTest method expectCreateBinding.
private Binding expectCreateBinding(Key<?> key, Dependency... keys) throws Exception {
Binding binding = control.createMock(Binding.class);
expect(bindingCreator.create(key)).andReturn(binding);
Set<Dependency> requiredKeys = new HashSet<Dependency>(keys.length);
Collections.addAll(requiredKeys, keys);
expect(binding.getDependencies()).andReturn(requiredKeys).atLeastOnce();
bindings.add(binding);
return binding;
}
use of com.google.gwt.inject.rebind.binding.Binding in project google-gin by gwtplus.
the class BindingResolverTest method testResolveDependenciesInRoot_InheritedByChild.
public void testResolveDependenciesInRoot_InheritedByChild() throws Exception {
StandardTree tree = createExampleTree();
// Bar already in root, inherited in childL. Baz already in root. Foo can still be in root.
Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
bind(bar(), tree.root);
bindParent(bar(), tree.root, tree.childL);
bind(baz(), tree.root);
tree.root.addBinding(foo(), fooBinding);
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 testResolveCycleDepBeforeProviderBound.
public void testResolveCycleDepBeforeProviderBound() throws Exception {
// Foo -> {Baz, Provider<Bar>}; Provider<Bar> -> Bar -> Foo. Baz is bound at childL
// Similar to the last one, although this time the already bound dependency comes before
// earlier in the cycle (Before the provider). We should still make sure that Foo is
// in the correct position.
StandardTree tree = createExampleTree();
Binding fooBinding = expectCreateBinding(foo(), required(foo(), baz()), required(foo(), providerBar()));
Binding providerBarBinding = expectCreateBinding(providerBar(), requiredLazy(providerBar(), bar()));
Binding barBinding = expectCreateBinding(bar(), required(bar(), foo()));
bind(baz(), tree.childL);
tree.childL.addBinding(foo(), fooBinding);
tree.childL.addBinding(providerBar(), providerBarBinding);
tree.childL.addBinding(bar(), barBinding);
expectParentBinding(foo(), tree.childL, 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 testResolveBindingWithOptionalDependency_DepFails.
public void testResolveBindingWithOptionalDependency_DepFails() throws Exception {
StandardTree tree = createExampleTree();
// Baz is optional and fails to resolve
Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), optional(foo(), baz()));
expect(bindingCreator.create(baz())).andThrow(new BindingCreationException("Unable to create"));
bind(bar(), tree.root);
tree.root.addBinding(foo(), fooBinding);
// childLL gets foo from childL
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 testResolveDependenciesInOriginExposedToParent.
public void testResolveDependenciesInOriginExposedToParent() throws Exception {
StandardTree tree = createExampleTree();
// Bar is bound in the child, but exposed to the root. Foo should still be in root
bind(bar(), tree.childR);
bindChild(bar(), tree.root, tree.childR);
bind(baz(), tree.root);
Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
tree.root.addBinding(foo(), fooBinding);
expectParentBinding(foo(), tree.root, tree.childR);
replayAndResolve(tree.childR, required(Dependency.GINJECTOR, foo()));
}
Aggregations