assertTrue(System.getProperty("FOO").equals("BAR"));
CustomAvalonService customAvalonService;
CustomSpringService customSpringService;
SystemPropertyService systemPropertyService;
ServiceManager serviceManager = (ServiceManager) ctx.getBean("avalonContainerBean");
// lookup and use the Spring bean using Spring's context
systemPropertyService = (SystemPropertyService) ctx.getBean("systemPropertyService");
assertNotNull(systemPropertyService);
// lookup and use the Spring bean using Spring's context
customSpringService = (CustomSpringService) ctx.getBean("customSpringService");
customSpringService.sayGretting();
assertEquals(customSpringService.getGreeting(), GREETING);
// lookup and use the Spring bean using Avalon's Service Manager
customSpringService = (CustomSpringService) serviceManager.lookup("customSpringService");
customSpringService.sayGretting();
assertEquals(customSpringService.getGreeting(), GREETING);
// lookup and use the Avalon service using Spring's context
customAvalonService = (CustomAvalonService) ctx.getBean("customAvalonService");
customAvalonService.sayGretting();
assertEquals(customAvalonService.getGreeting(), GREETING);
// lookup and use the Avalon service using Avalon's Service Manager
customAvalonService = (CustomAvalonService) serviceManager.lookup("customAvalonService");
customAvalonService.sayGretting();
assertEquals(customAvalonService.getGreeting(), GREETING);
// try to find a non-existing service using Avalon's Service Manager
try
{
serviceManager.lookup("foo");
fail("Looking up a non-existing service must throw a ServiceException");
}
catch(ServiceException e)
{
// nothing to do