Package com.google.gwt.inject.rebind

Examples of com.google.gwt.inject.rebind.GinjectorBindings


    FragmentPackageName parentKeyPackageName = fragmentPackageNameFactory.create(
        parentKeyBinding.getGetterMethodPackage());

    StringBuilder result = new StringBuilder().append("injector");
    // Walk up the injector hierarchy until we hit the requested parent.
    GinjectorBindings current = bindings;
    while (current != null && current != parentBindings) {
      result.append(".getParent()");
      current = current.getParent();
    }
    if (current == null) {
      // This should never happen; it indicates that the given parent injector
      // isn't actually a parent of the current bindings object.
      errorManager.logError(
View Full Code Here


     * in the parent by an {@link ExposedChildBinding}.
     */
    private void expectExposedBindingsExist() {
      for (Map.Entry<GinjectorBindings, Map<Key<?>, GinjectorBindings>> entry :
          exposedTo.entrySet()) {
        GinjectorBindings parent = entry.getKey();
        Map<Key<?>, GinjectorBindings> keyToChildMap = entry.getValue();

        for (Map.Entry<Key<?>, GinjectorBindings> keyAndChild : keyToChildMap.entrySet()) {
          Key<?> key = keyAndChild.getKey();
          GinjectorBindings child = keyAndChild.getValue();

          expect(parent.getBinding(key))
              .andReturn(new ExposedChildBinding(errorManager, Key.get(Long.class), child,
                  Context.forText("")))
              .anyTimes();
View Full Code Here

     * For each non-exposed binding, expect it to return an arbitrary binding
     * implementation that is never accessed.
     */
    private void expectNotExposedBindingsExist() {
      for (Map.Entry<GinjectorBindings, Set<Key<?>>> entry : notExposedBinding.entrySet()) {
        GinjectorBindings bindings = entry.getKey();
        Set<Key<?>> keys = entry.getValue();

        for(Key<?> key : keys) {
          expect(bindings.getBinding(key))
              .andReturn(createMock(Binding.class))
              .anyTimes();
        }
      }
    }
View Full Code Here

        new Dependency(Dependency.GINJECTOR, foo(), SOURCE));
    control.verify();
  }

  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();
  }
View Full Code Here

    assertSame(parent, output.getPreExistingLocations().get(foo()));
    control.verify();
  }

  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();
  }
View Full Code Here

  /**
   * 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();
View Full Code Here

  /**
   * 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();
View Full Code Here

  /**
   * 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();
View Full Code Here

  /**
   * 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();
View Full Code Here

    MethodCallUtil methodCallUtil = createMock(MethodCallUtil.class, "methodCallUtil");
    expect(methodCallUtil.createMethodCallWithInjection(capture(methodCapture),
        (String) anyObject(), (NameGenerator) anyObject(), (List<InjectorMethod>) anyObject()))
        .andReturn(SourceSnippets.forText(""));

    GinjectorBindings bindings = createMock(GinjectorBindings.class, "bindings");
    expect(bindings.getNameGenerator())
        .andStubReturn(nameGenerator);
    expect(bindings.getStaticInjectionRequests()).andStubReturn(
        Arrays.<Class<?>>asList(SubClass.class, SubPackageClass.class));

    String ginjectorPackageName = "com.google.gwt.inject.rebind.output";
    String ginjectorClassName = "GinjectorFragmentOutputterTest$FakeGinjector";
View Full Code Here

TOP

Related Classes of com.google.gwt.inject.rebind.GinjectorBindings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.