@Test public void backendDisabledWithDefaultLocation() { BundleContext context = mock(BundleContext.class); ServiceRegistration<PersistenceManager> registration = mock(ServiceRegistration.class); when(context.registerService(any(Class.class), any(PersistenceManager.class), any(Dictionary.class))).thenReturn(registration); ApplicationConfiguration configuration = mock(ApplicationConfiguration.class); when(configuration.getBaseDir()).thenReturn(new File("target/junk")); when(configuration.getBooleanWithDefault("configadmin.persistence", true)).thenReturn(false); when(configuration.getWithDefault("configadmin.storage", ConfigurationAdminBackend.LOCATION)).thenReturn (ConfigurationAdminBackend.LOCATION); ConfigurationAdminBackend backend = new ConfigurationAdminBackend(context, configuration); assertThat(backend.reg).isNull(); backend.unregisterQuietly(); }
@Invalidate public void unregisterQuietly() { if (reg == null) { return; } try { reg.unregister(); } catch (IllegalStateException e) { } reg = null; }
ConfigurationAdminBackend { @Invalidate public void unregisterQuietly() { if (reg == null) { return; } try { reg.unregister(); } catch (IllegalStateException e) { } reg = null; } }
ConfigurationAdminBackend { @Invalidate public void unregisterQuietly() { if (reg == null) { return; } try { reg.unregister(); } catch (IllegalStateException e) { } reg = null; } ConfigurationAdminBackend(@Context BundleContext context,
                                     @Requires ApplicationConfiguration configuration); }
ConfigurationAdminBackend { @Invalidate public void unregisterQuietly() { if (reg == null) { return; } try { reg.unregister(); } catch (IllegalStateException e) { } reg = null; } ConfigurationAdminBackend(@Context BundleContext context,
                                     @Requires ApplicationConfiguration configuration); @Invalidate void unregisterQuietly(); }
ConfigurationAdminBackend { @Invalidate public void unregisterQuietly() { if (reg == null) { return; } try { reg.unregister(); } catch (IllegalStateException e) { } reg = null; } ConfigurationAdminBackend(@Context BundleContext context,
                                     @Requires ApplicationConfiguration configuration); @Invalidate void unregisterQuietly(); static final String LOCATION; }