use of org.osgi.service.cm.ConfigurationAdmin in project sling by apache.
the class BasicTeleportedIT method testConfigAdmin.
@Test
public void testConfigAdmin() throws IOException {
final String pid = "TEST_" + getClass().getName() + UUID.randomUUID();
// demonstrate that we can access OSGi services from teleported tests
final ConfigurationAdmin ca = teleporter.getService(ConfigurationAdmin.class);
assertNotNull("Teleporter should provide a ConfigurationAdmin", ca);
final Configuration cfg = ca.getConfiguration(pid);
assertNotNull("Expecting to get a Configuration", cfg);
assertEquals("Expecting the correct pid", pid, cfg.getPid());
}
use of org.osgi.service.cm.ConfigurationAdmin in project sling by apache.
the class JobHandlingDistributionQueueProviderTest method testDisableQueueProcessing.
@Test
public void testDisableQueueProcessing() throws Exception {
JobManager jobManager = mock(JobManager.class);
ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
Configuration config = mock(Configuration.class);
when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
BundleContext context = mock(BundleContext.class);
JobHandlingDistributionQueueProvider jobHandlingdistributionQueueProvider = new JobHandlingDistributionQueueProvider("dummy-agent", jobManager, context);
jobHandlingdistributionQueueProvider.disableQueueProcessing();
}
use of org.osgi.service.cm.ConfigurationAdmin in project ddf by codice.
the class ApplicationServiceImplTest method testServiceChanged.
/**
* Tests the {@link ApplicationServiceImpl#setConfigFileName(String)} method
*
* @throws Exception
*/
@Test
public void testServiceChanged() throws Exception {
Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationServiceImpl appService = new ApplicationServiceImpl(bundleStateServices) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
};
appService.setConfigFileName("foo");
ServiceReference<ConfigurationAdmin> testConfigAdminRef = mock(ServiceReference.class);
ConfigurationAdmin testConfigAdmin = mock(ConfigurationAdmin.class);
Configuration testConfig = mock(Configuration.class);
when(bundleContext.getServiceReference(ConfigurationAdmin.class)).thenReturn(testConfigAdminRef);
when(bundleContext.getService(testConfigAdminRef)).thenReturn(testConfigAdmin);
when(testConfigAdmin.getConfiguration(ApplicationServiceImpl.class.getName())).thenReturn(testConfig);
Dictionary<String, Object> testProperties = new Hashtable<>();
testProperties.put("test1", "foo");
testProperties.put("test2", "bar");
when(testConfig.getProperties()).thenReturn(testProperties);
ServiceEvent serviceEvent = mock(ServiceEvent.class);
when(serviceEvent.getType()).thenReturn(ServiceEvent.REGISTERED);
appService.serviceChanged(serviceEvent);
assertThat(testConfig.getProperties().size(), is(testProperties.size()));
assertThat(testConfig.getProperties().get("test1"), is("foo"));
}
use of org.osgi.service.cm.ConfigurationAdmin in project ddf by codice.
the class SecurityTest method configureMocksForBundleContext.
private void configureMocksForBundleContext(String systemHostname) throws Exception {
System.setProperty("org.codice.ddf.system.hostname", systemHostname);
Bundle bundle = mock(Bundle.class);
when(FrameworkUtil.getBundle(any(Class.class))).thenReturn(bundle);
BundleContext bundleContext = mock(BundleContext.class);
when(bundle.getBundleContext()).thenReturn(bundleContext);
ServiceReference adminRef = mock(ServiceReference.class);
ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
Configuration config = mock(Configuration.class);
when(configAdmin.getConfiguration(anyString(), anyString())).thenReturn(config);
when(bundleContext.getService(adminRef)).thenReturn(configAdmin);
ServiceReference securityRef = mock(ServiceReference.class);
SecurityManager securityManager = mock(SecurityManager.class);
when(securityManager.getSubject(any())).thenReturn(systemSubject);
when(bundleContext.getService(securityRef)).thenReturn(securityManager);
when(bundleContext.getServiceReference(ConfigurationAdmin.class)).thenReturn(adminRef);
when(bundleContext.getServiceReference(SecurityManager.class)).thenReturn(securityRef);
}
use of org.osgi.service.cm.ConfigurationAdmin in project ddf by codice.
the class TestRegistryReportActionProvider method setup.
@Before
public void setup() {
metacard = new MetacardImpl();
source = mock(Source.class);
configurationAdmin = mock(ConfigurationAdmin.class);
configuration = mock(Configuration.class);
actionProvider = new RegistryReportActionProvider(ACTION_PROVIDER_ID);
metacard.setId(SAMPLE_ID);
metacard.setTags(SAMPLE_REGISTRY_TAGS);
metacard.setSourceId(SAMPLE_SOURCE_ID);
metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, SAMPLE_REGISTRY_ID);
}
Aggregations