Search in sources :

Example 81 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ConfigurationAdminTest method testGetBundleLocation.

/**
     * Tests the {@link ConfigurationAdmin#getBundleLocation(String)} method
     *
     * @throws Exception
     */
@Test
public void testGetBundleLocation() throws Exception {
    org.osgi.service.cm.ConfigurationAdmin testConfigAdmin = mock(org.osgi.service.cm.ConfigurationAdmin.class);
    ConfigurationAdmin configAdmin = new ConfigurationAdmin(testConfigAdmin);
    Configuration testConfig = mock(Configuration.class);
    when(testConfig.getBundleLocation()).thenReturn(TEST_LOCATION);
    when(testConfigAdmin.getConfiguration(TEST_PID, null)).thenReturn(testConfig);
    assertEquals(TEST_LOCATION, configAdmin.getBundleLocation(TEST_PID));
    verify(testConfig, atLeastOnce()).getBundleLocation();
}
Also used : Configuration(org.osgi.service.cm.Configuration) Test(org.junit.Test)

Example 82 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ConfigureTestCommons method configureFilterInvalidMetacards.

public static void configureFilterInvalidMetacards(String filterErrors, String filterWarnings, AdminConfig configAdmin) throws IOException {
    Configuration config = configAdmin.getConfiguration(METACARD_VALIDATITY_FILTER_PLUGIN_SERVICE_PID, null);
    Dictionary properties = new Hashtable<>();
    properties.put("filterErrors", filterErrors);
    properties.put("filterWarnings", filterWarnings);
    config.update(properties);
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable)

Example 83 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ConfigureTestCommons method configureEnforceValidityErrorsAndWarnings.

public static void configureEnforceValidityErrorsAndWarnings(String enforceErrors, String enforceWarnings, AdminConfig configAdmin) throws IOException {
    Configuration config = configAdmin.getConfiguration(METACARD_VALIDATITY_MARKER_PLUGIN_SERVICE_PID, null);
    Dictionary properties = new Hashtable<>();
    properties.put("enforceErrors", enforceErrors);
    properties.put("enforceWarnings", enforceWarnings);
    config.update(properties);
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable)

Example 84 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ConfigureTestCommons method configureEnforcedMetacardValidators.

public static void configureEnforcedMetacardValidators(List<String> enforcedValidators, AdminConfig configAdmin) throws IOException {
    // Update metacardMarkerPlugin config with no enforcedMetacardValidators
    Configuration config = configAdmin.getConfiguration(METACARD_VALIDATITY_MARKER_PLUGIN_SERVICE_PID, null);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("enforcedMetacardValidators", enforcedValidators);
    config.update(properties);
}
Also used : Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable)

Example 85 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ConfigureTestCommons method configureMetacardValidityFilterPlugin.

public static void configureMetacardValidityFilterPlugin(List<String> securityAttributeMappings, AdminConfig configAdmin) throws IOException {
    Configuration config = configAdmin.getConfiguration(METACARD_VALIDATITY_FILTER_PLUGIN_SERVICE_PID, null);
    Dictionary properties = new Hashtable<>();
    properties.put("attributeMap", securityAttributeMappings);
    config.update(properties);
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable)

Aggregations

Configuration (org.osgi.service.cm.Configuration)226 Test (org.junit.Test)85 Hashtable (java.util.Hashtable)75 IOException (java.io.IOException)55 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)49 Dictionary (java.util.Dictionary)36 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)19 ServiceReference (org.osgi.framework.ServiceReference)19 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)18 Matchers.anyString (org.mockito.Matchers.anyString)16 BundleContext (org.osgi.framework.BundleContext)15 RegistrySourceConfiguration (org.codice.ddf.registry.federationadmin.service.internal.RegistrySourceConfiguration)11 Map (java.util.Map)10 Bundle (org.osgi.framework.Bundle)10 File (java.io.File)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 Mockito.anyString (org.mockito.Mockito.anyString)9 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)8 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)7