Пример #1
0
  @Test
  public void constructorInjectionWithProviders() {
    Provider<Seat> p1 = getField(car, "constructorPlainSeatProvider");
    assertNotNull(p1.get());

    Provider<Tire> p2 = getField(car, "constructorPlainTireProvider");
    assertNotNull(p2.get());
  }
Пример #2
0
  @Test
  public void constructorInjectedProviderYieldsDistinctValues() {
    Provider<Seat> p1 = getField(car, "constructorDriversSeatProvider");
    assertNotSame(p1.get(), p1.get());

    Provider<Tire> p2 = getField(car, "constructorPlainTireProvider");
    assertNotSame(p2.get(), p2.get());

    Provider<Tire> p3 = getField(car, "constructorSpareTireProvider");
    assertNotSame(p3.get(), p3.get());
  }
Пример #3
0
 @Test
 public void fieldInjectedProviderYieldsSingleton() {
   Provider<Seat> p = car.fieldPlainSeatProvider;
   assertSame(p.get(), p.get());
 }
Пример #4
0
 @Test
 public void constructorInjectedProviderYieldsSingleton() {
   Provider<Seat> p = getField(car, "constructorPlainSeatProvider");
   assertSame(p.get(), p.get());
 }