Exemplo n.º 1
0
  public void testHasServiceAnotationsStrategy() throws Exception {

    ServiceStrategy test = new ServiceStrategies.HasServiceAnnotationsStrategy();

    MyService2 service = new MyService2();

    ServiceAdaptor adaptor = test.serviceFor(service, session);

    assertNotNull(adaptor);

    assertEquals(service, adaptor.getComponent());

    adaptor.start();

    assertEquals(true, service.started);

    adaptor.stop();

    assertEquals(false, service.started);

    ExceptionListener el =
        new ExceptionListener() {
          @Override
          public void exceptionThrown(Exception e) {}
        };

    adaptor.acceptExceptionListener(el);

    assertSame(el, service.el);

    assertNull(test.serviceFor(new Object(), session));
  }
Exemplo n.º 2
0
  public void testHasServiceMethodsStrategy() throws Exception {

    ServiceStrategy test = new ServiceStrategies.HasServiceMethodsStrategy();

    MyService3 service = new MyService3();

    ServiceAdaptor adaptor = test.serviceFor(service, session);

    assertNotNull(adaptor);

    assertEquals(service, adaptor.getComponent());

    adaptor.start();

    assertEquals(true, service.started);

    adaptor.stop();

    assertEquals(false, service.started);

    assertNull(test.serviceFor(new Object(), session));
  }