use of org.apache.felix.utils.log.Logger in project felix by apache.
the class StaxParserTest method createRepositoryAdmin.
private RepositoryAdminImpl createRepositoryAdmin(Class repositoryParser) throws Exception {
BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
Bundle systemBundle = EasyMock.createMock(Bundle.class);
BundleRevision systemBundleRevision = EasyMock.createMock(BundleRevision.class);
Activator.setContext(bundleContext);
EasyMock.expect(bundleContext.getProperty(RepositoryAdminImpl.REPOSITORY_URL_PROP)).andReturn(getClass().getResource("/referral1_repository.xml").toExternalForm());
EasyMock.expect(bundleContext.getProperty(RepositoryParser.OBR_PARSER_CLASS)).andReturn(repositoryParser.getName());
EasyMock.expect(bundleContext.getProperty((String) EasyMock.anyObject())).andReturn(null).anyTimes();
EasyMock.expect(bundleContext.getBundle(0)).andReturn(systemBundle);
EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
final Capture c = new Capture();
EasyMock.expect(bundleContext.createFilter((String) capture(c))).andAnswer(new IAnswer() {
public Object answer() throws Throwable {
return FilterImpl.newInstance((String) c.getValue());
}
}).anyTimes();
EasyMock.replay(new Object[] { bundleContext, systemBundle, systemBundleRevision });
RepositoryAdminImpl repoAdmin = new RepositoryAdminImpl(bundleContext, new Logger(bundleContext));
// force initialization && remove all initial repositories
Repository[] repos = repoAdmin.listRepositories();
for (int i = 0; repos != null && i < repos.length; i++) {
repoAdmin.removeRepository(repos[i].getURI());
}
return repoAdmin;
}
use of org.apache.felix.utils.log.Logger in project feature-flags-for-osgi by amitjoy.
the class FeatureManagerProvider method activate.
@Activate
protected void activate(final BundleContext bundleContext) throws Exception {
logger = new Logger(bundleContext);
extender = new MetaTypeExtender(metaTypeService, logger, bundlePids, allFeatures);
extender.start(bundleContext);
}
use of org.apache.felix.utils.log.Logger in project felix by apache.
the class OSGiRepositoryImplTest method createRepositoryAdmin.
private RepositoryAdminImpl createRepositoryAdmin() throws Exception {
Bundle sysBundle = Mockito.mock(Bundle.class);
Mockito.when(sysBundle.getHeaders()).thenReturn(new Hashtable<String, String>());
BundleRevision br = Mockito.mock(BundleRevision.class);
Mockito.when(sysBundle.adapt(BundleRevision.class)).thenReturn(br);
Capability cap1 = new OSGiCapabilityImpl("some.system.cap", Collections.<String, Object>singletonMap("sys.cap", "something"), Collections.singletonMap("x", "y"));
Capability cap2 = new OSGiCapabilityImpl("some.system.cap", Collections.<String, Object>singletonMap("sys.cap", "somethingelse"), Collections.<String, String>emptyMap());
Mockito.when(br.getCapabilities(null)).thenReturn(Arrays.asList(cap1, cap2));
BundleContext bc = Mockito.mock(BundleContext.class);
Mockito.when(bc.getBundle(0)).thenReturn(sysBundle);
Mockito.when(sysBundle.getBundleContext()).thenReturn(bc);
return new RepositoryAdminImpl(bc, new Logger(bc));
}
use of org.apache.felix.utils.log.Logger in project felix by apache.
the class OSGiRepositoryXMLTest method createRepositoryAdmin.
private RepositoryAdminImpl createRepositoryAdmin() throws Exception {
Bundle sysBundle = Mockito.mock(Bundle.class);
Mockito.when(sysBundle.getHeaders()).thenReturn(new Hashtable<String, String>());
BundleRevision br = Mockito.mock(BundleRevision.class);
Mockito.when(sysBundle.adapt(BundleRevision.class)).thenReturn(br);
BundleContext bc = Mockito.mock(BundleContext.class);
Mockito.when(bc.getBundle(0)).thenReturn(sysBundle);
Mockito.when(sysBundle.getBundleContext()).thenReturn(bc);
return new RepositoryAdminImpl(bc, new Logger(bc));
}
use of org.apache.felix.utils.log.Logger in project felix by apache.
the class RepositoryAdminTest method createRepositoryAdmin.
private RepositoryAdminImpl createRepositoryAdmin() throws Exception {
BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
Bundle systemBundle = EasyMock.createMock(Bundle.class);
BundleRevision systemBundleRevision = EasyMock.createMock(BundleRevision.class);
Activator.setContext(bundleContext);
EasyMock.expect(bundleContext.getProperty((String) EasyMock.anyObject())).andReturn(null).anyTimes();
EasyMock.expect(bundleContext.getBundle(0)).andReturn(systemBundle);
EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
final Capture c = new Capture();
EasyMock.expect(bundleContext.createFilter((String) capture(c))).andAnswer(new IAnswer() {
public Object answer() throws Throwable {
return FilterImpl.newInstance((String) c.getValue());
}
}).anyTimes();
EasyMock.replay(new Object[] { bundleContext, systemBundle, systemBundleRevision });
RepositoryAdminImpl repoAdmin = new RepositoryAdminImpl(bundleContext, new Logger(bundleContext));
// force initialization && remove all initial repositories
org.apache.felix.bundlerepository.Repository[] repos = repoAdmin.listRepositories();
for (int i = 0; repos != null && i < repos.length; i++) {
repoAdmin.removeRepository(repos[i].getURI());
}
return repoAdmin;
}
Aggregations