prefs.flush();
featuresRegistry.register(isA(Repository.class));
replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle, featuresRegistry);
FeaturesServiceImpl svc = new FeaturesServiceImpl();
svc.setPreferences(preferencesService);
svc.setBundleContext(bundleContext);
svc.setFeaturesServiceRegistry(featuresRegistry);
svc.addRepository(uri);
Repository[] repositories = svc.listRepositories();
assertNotNull(repositories);
assertEquals(1, repositories.length);
assertNotNull(repositories[0]);
Feature[] features = repositories[0].getFeatures();
assertNotNull(features);
assertEquals(1, features.length);
assertNotNull(features[0]);
assertEquals("f1", features[0].getName());
assertNotNull(features[0].getDependencies());
assertEquals(0, features[0].getDependencies().size());
assertNotNull(features[0].getBundles());
assertEquals(1, features[0].getBundles().size());
assertEquals(name, features[0].getBundles().get(0));
verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle, featuresRegistry);
reset(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle, featuresRegistry);
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
installedBundle.start();
expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
expect(prefs.node("repositories")).andReturn(repositoriesNode);
repositoriesNode.clear();
repositoriesNode.putInt("count", 1);
repositoriesNode.put("item.0", uri.toString());
expect(prefs.node("features")).andReturn(featuresNode);
featuresNode.clear();
featuresNode.put("f1" + FeatureImpl.SPLIT_FOR_NAME_AND_VERSION + FeatureImpl.DEFAULT_VERSION, "12345");
prefs.putBoolean("bootFeaturesInstalled", false);
prefs.flush();
replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle);
svc.installFeature("f1");
}