Package com.google.inject.testing.guiceberry.junit3

Examples of com.google.inject.testing.guiceberry.junit3.BasicJunit3Module


  }

  public static final class Env implements Module {

    public void configure(Binder binder) {
      binder.install(new BasicJunit3Module());
      binder.bind(TestScopeListener.class)
        .to(NoOpTestScopeListener.class)
        .in(SINGLETON);
    }
View Full Code Here


  }

  public static final class Env implements Module {

    public void configure(Binder binder) {
      binder.install(new BasicJunit3Module());
      binder.bind(TestScopeListener.class)
        .to(NoOpTestScopeListener.class)
        .in(SINGLETON);
    }
View Full Code Here

      public void tearDown() throws Exception {
        currentUniverse = null;
      }
    });
    currentUniverse = new GuiceBerryUniverse();
    return new GuiceBerryJunit3(new GuiceBerry(currentUniverse));
  }
View Full Code Here

  }
 
  public void testThatTwoTestsWithSameGbeUseTheSameInjector()
      throws ClassNotFoundException {
    NonTdtcForGbeOne testOne = NonTdtcForGbeOne.createInstance();
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    guiceBerryJunit3.doSetUp(testOne);
   
    Injector injectorOne = currentUniverse.gbeClassToInjectorMap.get(Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE));
    GuiceBerryJunit3.tearDown(testOne);

    AnotherNonTdtcForGbeOne testTwo = AnotherNonTdtcForGbeOne.createInstance();
    guiceBerryJunit3.doSetUp(testTwo);
   
    Injector injectorTwo =
      currentUniverse.gbeClassToInjectorMap.get(Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE));

    // "number" is bound to a random, so this will only pass if the injector
View Full Code Here

    JUnitAsserts.assertNotEqual(testOne.number, testTwo.number);
  }

  public void testPutTwoInjectorsInMapForTestsThatDeclareDifferentGbes() {
    NonTdtcForGbeOne testOne = NonTdtcForGbeOne.createInstance();
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    guiceBerryJunit3.doSetUp(testOne);
    GuiceBerryJunit3.tearDown(testOne);
   
    TestWithGbeTwo testTwo = TestWithGbeTwo.createInstance();
    guiceBerryJunit3.doSetUp(testTwo);
  
    assertEquals(2, currentUniverse.gbeClassToInjectorMap.size());
  }
View Full Code Here

    } catch (RuntimeException expected) {}
  }
  public void testCallingTwoSetupWithNoTearDownBetween() {
    TestWithGbeOne test = TestWithGbeOne.createInstance();
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    guiceBerryJunit3.doSetUp(test);
    try {
      guiceBerryJunit3.doSetUp(test);
      fail();
    } catch (RuntimeException expected) {}  
  }
View Full Code Here

    test.run();
  }
 
  public void testMethodTearDownForTestCaseNotCalledAutomatically() {
    NonTdtcForGbeOne testOne = NonTdtcForGbeOne.createInstance();
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    guiceBerryJunit3.doSetUp(testOne);
    testOne.run();

    TestWithGbeOne testTwo = TestWithGbeOne.createInstance();
    try
      guiceBerryJunit3.doSetUp(testTwo);
      fail();
    } catch (RuntimeException expected) {}
  }
View Full Code Here

    assertTrue(baz < baz2);  
  }

  public void testTestScopeIsCreatedForModule()
      throws ClassNotFoundException {
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    TestWithGbeOne test = TestWithGbeOne.createInstance();
   
    assertNull(
      currentUniverse.gbeClassToInjectorMap.get(
        Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE)));
    guiceBerryJunit3.doSetUp(test);
    TestScope testScope =
      currentUniverse.gbeClassToInjectorMap.get(
        Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE))
        .getInstance(TestScope.class);
    assertNotNull(testScope);
View Full Code Here

    return injector.getInstance(TestScope.class);
  }
 
  public void testReUseTestScopeByTwoTestsWithSameGbe()
    throws ClassNotFoundException{
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    TestWithGbeOne testOne = TestWithGbeOne.createInstance();
    assertNull(
        getTestScopeForGbe(
            Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE)));
    guiceBerryJunit3.doSetUp(testOne);
    TestScope testScopeOne =
      getTestScopeForGbe(
          Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE));
    assertNotNull(testScopeOne);
   
    testOne.run();
  
    AnotherTestWithGbeOne testTwo =
      AnotherTestWithGbeOne.createInstance();
    guiceBerryJunit3.doSetUp(testTwo);
    assertNotNull(getTestScopeForGbe(
        Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE)));
   
    TestScope testScopeTwo =
      getTestScopeForGbe(
View Full Code Here

    assertEquals(1, currentUniverse.gbeClassToInjectorMap.size());
 

  public void testThatTestsWithDifferentGbesGetDifferentTestScopes()
      throws ClassNotFoundException {
    GuiceBerryJunit3 guiceBerryJunit3 = instance();
    TestWithGbeOne testOne = TestWithGbeOne.createInstance();
  
    assertNull(getTestScopeForGbe(
        Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE)));
    guiceBerryJunit3.doSetUp(testOne);
    TestScope testScopeOne =
      getTestScopeForGbe(
          Class.forName(GuiceBerryEnvOne.GUICE_BERRY_ENV_ONE));
    assertNotNull(testScopeOne);
 
    testOne.run();
   
    TestWithGbeTwo testTwo = TestWithGbeTwo.createInstance();
    guiceBerryJunit3.doSetUp(testTwo);
    assertNotNull(getTestScopeForGbe(
        Class.forName(GuiceBerryEnvTwo.GUICE_BERRY_ENV_TWO)));
    TestScope testScopeTwo =
      getTestScopeForGbe(
          Class.forName(GuiceBerryEnvTwo.GUICE_BERRY_ENV_TWO));
View Full Code Here

TOP

Related Classes of com.google.inject.testing.guiceberry.junit3.BasicJunit3Module

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.