Package se.jbee.inject.bind

Source Code of se.jbee.inject.bind.TestLinker$LinkerBundle

package se.jbee.inject.bind;

import static org.junit.Assert.assertEquals;
import static se.jbee.inject.Dependency.dependency;

import org.junit.Test;

import se.jbee.inject.Injector;
import se.jbee.inject.bootstrap.Bootstrap;
import se.jbee.inject.bootstrap.BootstrapperBundle;

public class TestLinker {

  static class TwiceInstalledModule
      extends BinderModule {

    @Override
    protected void declare() {
      bind( Integer.class ).to( 42 );
    }

  }

  private static class LinkerBundle
      extends BootstrapperBundle {

    @Override
    protected void bootstrap() {
      install( new TwiceInstalledModule() );
      install( new TwiceInstalledModule() );
    }

  }

  /**
   * A monomodal module has just one initial state (or no state). Therefore it can be determined
   * that installing it twice or more does not make sense.
   */
  @Test
  public void thatMonomodalModulesCanBeInstalledTwice() {
    Injector injector = Bootstrap.injector( LinkerBundle.class );
    assertEquals( 42, injector.resolve( dependency( Integer.class ) ).intValue() );
  }
}
TOP

Related Classes of se.jbee.inject.bind.TestLinker$LinkerBundle

TOP
Copyright © 2018 www.massapi.com. 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.