/** @throws ClassNotFoundException */
  @Test
  public void testResolveServiceC() throws ClassNotFoundException {

    final BaseSummoner summoner = new BaseSummoner();
    summoner.setSummonResolver(
        new CompositeSummonResolver(
            new Vector<IServiceSummoner>() {
              {
                add(summoner);
              }
            }));

    ServiceA a = new ServiceA();
    ServiceB b = new ServiceB();
    ServiceC c = new ServiceC();
    summoner.registerServiceFor(a.getClass().getCanonicalName(), a);
    summoner.registerServiceFor(b.getClass().getCanonicalName(), b);
    summoner.registerServiceFor(c.getClass().getCanonicalName(), c);

    SummonableService resolved = summoner.get(c.getClass().getCanonicalName(), c);
    summoner.resolveSummons();

    assertEquals(c.getClass(), resolved.getClass());
    assertTrue(b.equals(c.b));
    assertTrue(a.equals(c.a));
  }
示例#2
0
  @Test
  public void serviceBCalledAtLeastOnceAndAtMostThreeTimes() {
    new MockServiceBForOneToThreeInvocations();
    new MockServiceBHelper();

    ServiceA serviceA = new ServiceA();
    serviceA.doSomethingElseUsingServiceB(2);
    String config = serviceA.getConfig();

    assertEquals("test", config);
  }
  /** @throws ClassNotFoundException */
  @Test
  public void testResolveServiceA() throws ClassNotFoundException {
    final BaseSummoner summoner = new BaseSummoner();
    summoner.setSummonResolver(
        new CompositeSummonResolver(
            new Vector<IServiceSummoner>() {
              {
                add(summoner);
              }
            }));

    ServiceA a = new ServiceA();
    summoner.registerServiceFor(a.getClass().getCanonicalName(), a);

    SummonableService resolved = summoner.get(a.getClass().getCanonicalName(), a);
    summoner.interSummonResolve(true);
    assertEquals(a.getClass(), resolved.getClass());
  }
示例#4
0
 public void methodC() {
   sc.methodC();
   sa.methodA();
 }
示例#5
0
 public void methodA() {
   sa.methodA();
   sb.methodB();
 }