use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testSourcePositioned_Exposed.
/**
* Tests that when we have a dependency that installs multiple steps (eg, GINJECTOR -> foo -> bar)
* we will use the highest foo available.
*/
public void testSourcePositioned_Exposed() 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(true);
expect(parent.isBound(bar())).andReturn(true);
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(parent, output.getPreExistingLocations().get(foo()));
assertSame(parent, output.getPreExistingLocations().get(bar()));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testUsesExposedBinding.
/**
* Tests that we don't skip an exposed binding from a different injector.
*/
public void testUsesExposedBinding() throws Exception {
GinjectorBindings parent = control.createMock("parent", GinjectorBindings.class);
GinjectorBindings otherGinjector = control.createMock("other", GinjectorBindings.class);
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.isBound(foo())).andReturn(false).anyTimes();
expect(origin.isPinned(foo())).andReturn(false).anyTimes();
expect(origin.getParent()).andReturn(parent).anyTimes();
expect(parent.getParent()).andReturn(null);
expect(parent.isBound(foo())).andReturn(true);
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(parent, output.getPreExistingLocations().get(foo()));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testWillBeBoundBoundInParent.
public void testWillBeBoundBoundInParent() throws Exception {
GinjectorBindings parent = control.createMock("parent", GinjectorBindings.class);
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.isPinned(foo())).andReturn(false).anyTimes();
expect(origin.isBound(foo())).andReturn(false).anyTimes();
expect(origin.getParent()).andReturn(parent).anyTimes();
expect(parent.getParent()).andReturn(null);
expect(parent.isBound(foo())).andReturn(false);
expect(parent.isPinned(foo())).andReturn(true);
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(parent, output.getPreExistingLocations().get(foo()));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testSkipsExposedBindingFromOrigin.
/**
* Tests that we don't try to use an exposed binding from the "origin" to satisfy a dependency
* from the origin.
*/
public void testSkipsExposedBindingFromOrigin() throws Exception {
GinjectorBindings parent = control.createMock("parent", GinjectorBindings.class);
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.isBound(foo())).andReturn(false).anyTimes();
expect(origin.isPinned(foo())).andReturn(true).anyTimes();
expect(origin.getParent()).andReturn(parent).anyTimes();
expect(bindingCreator.create(foo())).andReturn(binding);
expect(binding.getDependencies()).andReturn(TestUtils.dependencyList());
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertTrue(output.getPreExistingLocations().isEmpty());
assertTrue(output.getImplicitlyBoundKeys().contains(foo()));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testAlreadyBoundInParent.
public void testAlreadyBoundInParent() throws Exception {
GinjectorBindings parent = control.createMock("parent", GinjectorBindings.class);
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.isPinned(foo())).andReturn(false).anyTimes();
expect(origin.isBound(foo())).andReturn(false).anyTimes();
expect(origin.getParent()).andReturn(parent).anyTimes();
expect(parent.getParent()).andReturn(null);
expect(parent.isBound(foo())).andReturn(true);
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(parent, output.getPreExistingLocations().get(foo()));
control.verify();
}
Aggregations