Package com.google.gwt.inject.rebind.binding

Examples of com.google.gwt.inject.rebind.binding.Binding


  // Tries to create Foo, which has an optional dependency on Bar, which requires Baz.
  // Baz can't be created, so it should create Foo, without the Bar.
  public void testResolveBindingWithOptionalDependencyThatFails() throws Exception {   
    StandardTree tree = createExampleTree();
   
    Binding fooBinding = expectCreateBinding(foo(), optional(foo(), bar()));
    expectCreateBinding(bar(), required(bar(), baz()));
    expect(bindingCreator.create(baz())).andThrow(new BindingCreationException("Unable to create"));
    tree.root.addBinding(foo(), fooBinding);
    expectParentBinding(foo(), tree.root, tree.childLL);
       
View Full Code Here


    replayAndResolve(tree.childLL, required(Dependency.GINJECTOR, foo()));
  }
 
  public void testResolveBindingWithOptionalThatDoesntBlockPosition() throws Exception {
    StandardTree tree = createExampleTree();
    Binding fooBinding = expectCreateBinding(foo(), optional(foo(), bar()));
    expectCreateBinding(bar(), required(bar(), baz()));
    expectCreateBinding(baz());
   
    // Can't bar() because baz() is already bound in childLL.  Therefore, bar() should not constrain
    // the position of foo(), and we should place it in the root.
View Full Code Here

    replayAndResolve(root, required(foo(), fooImpl()));
  }
 
  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()));
View Full Code Here

   
    bind(baz(), root);
    bind(bar(), childL);
    expect(root.isBoundLocallyInChild(bar())).andReturn(true).anyTimes();
   
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
    Binding barBinding = expectCreateBinding(bar());
   
    childR.addBinding(bar(), barBinding);
    expectParentBinding(baz(), root, childR);
    childR.addBinding(foo(), fooBinding);
       
View Full Code Here

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

    bind(bar(), child1);
    bindChild(bar(), root, child1);
    bind(baz(), child2);
    bindChild(baz(), root, child2);
   
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()), required(foo(), baz()));
    root.addBinding(foo(), fooBinding);
    expectParentBinding(foo(), root, child3);
       
    replayAndResolve(child3, required(Dependency.GINJECTOR, foo()));
  }
View Full Code Here

  public void testResolveCycleThroughProvider() throws Exception {
    // Foo -> Bar ->Provider<Foo> -> Foo, cycle is OK because of Provider. 
    // Provider<Foo> is in the "unpositioned pending Foo" set.
    StandardTree tree = createExampleTree();
   
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), bar()));
    Binding barBinding = expectCreateBinding(bar(), required(bar(), providerFoo()));
    Binding providerFooBinding = expectCreateBinding(providerFoo(),
        requiredLazy(providerFoo(), foo()));
   
    tree.root.addBinding(foo(), fooBinding);
    tree.root.addBinding(bar(), barBinding);
    tree.root.addBinding(providerFoo(), providerFooBinding);
View Full Code Here

    // Foo -> AsyncProvider<Foo> -> Foo, cycle is OK because of AsyncProvider. 
    // AsyncProvider<Foo> is in the "unpositioned pending Foo" set.  Identical to
    // testResolveCycleThroughProvider, but verifies that AsyncProvider is also acceptable.
    StandardTree tree = createExampleTree();
   
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), asyncProviderFoo()));
    Binding providerFooBinding = expectCreateBinding(
        asyncProviderFoo(), requiredLazy(asyncProviderFoo(), foo()));
   
    tree.root.addBinding(foo(), fooBinding);
    tree.root.addBinding(asyncProviderFoo(), providerFooBinding);
    expectParentBinding(foo(), tree.root, tree.childLL);
View Full Code Here

    // Foo -> Provider<Bar> -> Bar -> {Foo, Baz}, Baz is bound at childL
    // This test makes sure that we at least ensure that Bar doesn't move higher than
    // *any* of it's dependencies, even after detecting a cycle.
    StandardTree tree = createExampleTree();
   
    Binding fooBinding = expectCreateBinding(foo(), required(foo(), providerBar()));
    Binding providerBarBinding = expectCreateBinding(providerBar(),
        requiredLazy(providerBar(), bar()));
    Binding barBinding = expectCreateBinding(bar(), required(bar(), foo()), required(bar(), baz()));
    bind(baz(), tree.childL);
   
    tree.childL.addBinding(foo(), fooBinding);
    tree.childL.addBinding(providerBar(), providerBarBinding);
    tree.childL.addBinding(bar(), barBinding);
View Full Code Here

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

TOP

Related Classes of com.google.gwt.inject.rebind.binding.Binding

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.