コード例 #1
0
  @Test
  public void testAddService() {
    ServiceHolder tested = new ServiceHolder();
    Object service = new Object();

    tested.addService(service);

    Set<String> services = getField(tested, "services");

    assertEquals("Size of the \"services\" Set should be 1", 1, services.size());
    assertSame(
        "The services Set should didn't contain the expect service",
        service,
        services.iterator().next());
  }
コード例 #2
0
 @Test
 public void fieldInjectedProviderYieldsSingleton() {
   Provider<Seat> p = car.fieldPlainSeatProvider;
   assertSame(p.get(), p.get());
 }
コード例 #3
0
 @Test
 public void constructorInjectedProviderYieldsSingleton() {
   Provider<Seat> p = getField(car, "constructorPlainSeatProvider");
   assertSame(p.get(), p.get());
 }