### Question:
BundleScriptEngineResolver implements ScriptEngineResolver { public void unregister() { if (reg != null) { reg.unregister(); } } BundleScriptEngineResolver(Bundle bundle, URL configFile); void register(); void unregister(); @Override ScriptEngine resolveScriptEngine(String name); @Override String toString();  }### Answer:
@SuppressWarnings("unchecked") @Test public void unregister() { Bundle bundle = mock(Bundle.class); BundleContext bundleContext = mock(BundleContext.class); when(bundle.getBundleContext()).thenReturn(bundleContext); BundleScriptEngineResolver scriptEngineResolver = new BundleScriptEngineResolver(bundle, null); ServiceRegistration<ScriptEngineResolver> serviceReg = mock(ServiceRegistration.class); when(bundleContext.registerService(eq(ScriptEngineResolver.class), eq(scriptEngineResolver), isNull(Dictionary.class))).thenReturn(serviceReg); scriptEngineResolver.register(); scriptEngineResolver.unregister(); verify(serviceReg).unregister(); }