DynamicWebAppBootstrap implements WebAppBootstrap { public void configure(ComponentRegistry registry) { for (String className : classNames) { logger.trace("Registering class {}", className); try { Class<?> clazz = Class.forName(className); registry.deepRegister(clazz); } catch (ClassNotFoundException e) { throw new ScannerException("Error while registering classes", e); } } } DynamicWebAppBootstrap(Collection<String> classNames); void configure(ComponentRegistry registry);  }
@Test public void shouldConfigureAllClasses() { Collection<String> classNames = asList(ResourceA.class.getName()); new DynamicWebAppBootstrap(classNames).configure(registry); verify(registry).deepRegister(ResourceA.class); }
@Test public void shouldNotDoAnythingIfHasNoClasses() { Collection<String> classNames = emptyList(); new DynamicWebAppBootstrap(classNames).configure(registry); verify(registry, never()).deepRegister(any(Class.class)); }
@Test(expected=ScannerException.class) public void shouldThrowScannerExceptionIfClassNotExists() { Collection<String> classNames = asList("a.resource.that.NotExists"); new DynamicWebAppBootstrap(classNames).configure(registry); }