コード例 #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());
 }