### Question:
ScriptEngineBundleScanner { protected void registerScriptEngines(Bundle bundle, List<BundleScriptEngineResolver> resolvers) { Enumeration<URL> scriptEnginesUrls = bundle.findEntries(META_INF_SERVICES_DIR, SCRIPT_ENGINE_SERVICE_FILE, false); if (scriptEnginesUrls == null) { return; } for (URL configURL : Collections.list(scriptEnginesUrls)) { LOGGER.info("Found ScriptEngineFactory in " + bundle.getSymbolicName()); resolvers.add(new BundleScriptEngineResolver(bundle, configURL)); } } ScriptEngineBundleScanner(); Bundle addBundle(Bundle bundle); @SuppressWarnings("unused") void modifiedBundle(Bundle bundle); void removedBundle(Bundle bundle); Map<Long, List<BundleScriptEngineResolver>> getResolvers();  }### Answer:
@Test public void registerNullScriptEngine() { Bundle bundle = mock(Bundle.class); when(bundle.findEntries(any(String.class), any(String.class), anyBoolean())).thenReturn(null); ScriptEngineBundleScanner customizer = new ScriptEngineBundleScanner(); ArrayList<BundleScriptEngineResolver> resolvers = new ArrayList<BundleScriptEngineResolver>(0); customizer.registerScriptEngines(bundle, resolvers); assertThat(resolvers.isEmpty(), is(true)); }
@Test public void registerScriptEngine() throws MalformedURLException { Bundle bundle = mockBundleWithScriptEngine(435L); ScriptEngineBundleScanner customizer = new ScriptEngineBundleScanner(); ArrayList<BundleScriptEngineResolver> resolvers = new ArrayList<BundleScriptEngineResolver>(1); customizer.registerScriptEngines(bundle, resolvers); assertThat(resolvers.size(), is(1)); BundleScriptEngineResolver resolver = resolvers.get(0); assertThat(resolver, is(instanceOf(BundleScriptEngineResolver.class))); }
@Test public void registerNonExistingScriptEngine() { Bundle bundle = mock(Bundle.class); when(bundle.findEntries(any(String.class), any(String.class), anyBoolean())).thenReturn(Collections.enumeration(Collections.<URL> emptyList())); ScriptEngineBundleScanner customizer = new ScriptEngineBundleScanner(); ArrayList<BundleScriptEngineResolver> resolvers = new ArrayList<BundleScriptEngineResolver>(0); customizer.registerScriptEngines(bundle, resolvers); assertThat(resolvers.isEmpty(), is(true)); }