Search in sources :

Example 1 with FeaturesServiceImpl

use of org.apache.karaf.features.internal.service.FeaturesServiceImpl in project karaf by apache.

the class FeaturesServiceTest method testInstallBatchFeatureWithFailure.

@Test
@Ignore("Currently takes too long")
public void testInstallBatchFeatureWithFailure() throws Exception {
    String bundle1Uri = "file:bundle1";
    String bundle2Uri = "file:bundle2";
    URI uri = createTempRepo(FEATURE_WITH_INVALID_BUNDLE, bundle1Uri, bundle2Uri);
    BundleInstallSupport installSupport = EasyMock.niceMock(BundleInstallSupport.class);
    expect(installSupport.getInfo()).andReturn(dummyInfo());
    EasyMock.replay(installSupport);
    FeaturesServiceConfig cfg = new FeaturesServiceConfig();
    FeaturesServiceImpl svc = new FeaturesServiceImpl(new Storage(), null, null, resolver, installSupport, null, cfg);
    svc.addRepository(uri);
    try {
        List<String> features = new ArrayList<>();
        for (Feature feature : svc.listFeatures()) {
            features.add(feature.getId());
        }
        Collections.reverse(features);
        svc.installFeatures(new CopyOnWriteArraySet<>(features), EnumSet.noneOf(FeaturesService.Option.class));
        fail("Call should have thrown an exception");
    } catch (MultiException e) {
        Throwable suppressed = e.getSuppressed()[0];
        Assert.assertEquals("Error downloading zfs:unknown", suppressed.getMessage());
    }
}
Also used : FeaturesServiceImpl(org.apache.karaf.features.internal.service.FeaturesServiceImpl) BundleInstallSupport(org.apache.karaf.features.internal.service.BundleInstallSupport) ArrayList(java.util.ArrayList) URI(java.net.URI) StateStorage(org.apache.karaf.features.internal.service.StateStorage) FeaturesServiceConfig(org.apache.karaf.features.internal.service.FeaturesServiceConfig) MultiException(org.apache.karaf.features.internal.util.MultiException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with FeaturesServiceImpl

use of org.apache.karaf.features.internal.service.FeaturesServiceImpl in project karaf by apache.

the class FeaturesServiceTest method testLoadOldFeatureFile.

/**
 * This test checks feature service behavior with old, non namespaced descriptor.
 */
@Test
public void testLoadOldFeatureFile() throws Exception {
    URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>" + "  <feature name='f1'><bundle>file:bundle1</bundle><bundle>file:bundle2</bundle></feature>" + "</features>");
    BundleInstallSupport installSupport = EasyMock.niceMock(BundleInstallSupport.class);
    EasyMock.replay(installSupport);
    FeaturesServiceConfig cfg = new FeaturesServiceConfig();
    FeaturesServiceImpl svc = new FeaturesServiceImpl(new Storage(), null, null, resolver, installSupport, null, cfg);
    svc.addRepository(uri);
    Feature[] features = svc.getFeatures("f1");
    Assert.assertEquals(1, features.length);
    Feature feature = features[0];
    Assert.assertNotNull("No feature named fi found", feature);
    List<BundleInfo> bundles = feature.getBundles();
    Assert.assertEquals(2, bundles.size());
}
Also used : FeaturesServiceImpl(org.apache.karaf.features.internal.service.FeaturesServiceImpl) StateStorage(org.apache.karaf.features.internal.service.StateStorage) BundleInstallSupport(org.apache.karaf.features.internal.service.BundleInstallSupport) FeaturesServiceConfig(org.apache.karaf.features.internal.service.FeaturesServiceConfig) URI(java.net.URI) Test(org.junit.Test)

Example 3 with FeaturesServiceImpl

use of org.apache.karaf.features.internal.service.FeaturesServiceImpl in project karaf by apache.

the class FeaturesServiceTest method testGetFeaturesShouldHandleDifferentVersionPatterns.

/*
       TODO: migrate those tests

    @Test
    public void testInstallFeature() throws Exception {
        URI uri = createTempRepo(
                "<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>" 
                + "  <feature name='f1'><bundle start='true'>bundle-f1</bundle></feature>"
                + "</features>");

        BundleManager bundleManager = EasyMock.createMock(BundleManager.class);
        Bundle installedBundle = createDummyBundle(12345L, "bundle-f1", headers());
        FeaturesServiceImpl svc = testAddRepository("bundle-f1", uri, bundleManager, installedBundle);
        
        reset(bundleManager);
        
        expect(bundleManager.installBundleIfNeeded(eq("bundle-f1"), eq(0), eq((String)null))).andReturn(new BundleInstallerResult(installedBundle, true));
        expect(bundleManager.getDataFile(EasyMock.anyObject(String.class))).andReturn(dataFile);
        ignoreRefreshes(bundleManager);
        replay(bundleManager);
        svc.installFeature("f1", org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
        verify(bundleManager);
        
        Feature[] installed = svc.listInstalledFeatures();
        assertEquals(1, installed.length);
        assertEquals("f1", installed[0].getName());
    }

    private FeaturesServiceImpl testAddRepository(String name, URI uri, BundleManager bundleManager,
            Bundle installedBundle) throws IOException, BundleException, Exception {
        expect(bundleManager.getDataFile(EasyMock.anyObject(String.class))).andReturn(dataFile);
        expect(bundleManager.installBundleIfNeeded(eq(name), eq(0), eq((String)null))).andReturn(new BundleInstallerResult(installedBundle, true)).anyTimes();

        replay(bundleManager);
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        svc.addRepository(uri);
        Repository[] repositories = svc.listRepositories();
        verify(bundleManager);

        assertNotNull(repositories);
        assertEquals(1, repositories.length);
        assertNotNull(repositories[0]);
        Feature[] features = repositories[0].getFeatureCache();
        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).getLocation());
        assertTrue(features[0].getBundles().get(0).isStart());
        return svc;
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testUninstallFeatureWithTwoVersions() throws Exception {
        URI uri  = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                + "  <feature name='f1' version='0.1'><bundle>bundle-0.1</bundle></feature>"
                + "  <feature name='f1' version='0.2'><bundle>bundle-0.1</bundle></feature>" 
                + "</features>");

        Bundle bundlef101 = createDummyBundle(12345L, "bundle-0.1", headers());

        BundleManager bundleManager = EasyMock.createMock(BundleManager.class);
        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        expect(bundleManager.getDataFile(EasyMock.anyObject(String.class))).andReturn(dataFile).anyTimes();
        expect(bundleManager.installBundleIfNeeded("bundle-0.1", 0, null)).andReturn(new BundleInstallerResult(bundlef101, true));
        expect(bundleManager.installBundleIfNeeded("bundle-0.1", 0, null)).andReturn(new BundleInstallerResult(bundlef101, false));
        expect(bundleManager.getBundleContext()).andReturn(bundleContext);
        ignoreRefreshes(bundleManager);
        bundleManager.uninstall(Collections.EMPTY_LIST, true);
        EasyMock.expectLastCall().times(2);
        
        
        replay(bundleManager);
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        svc.addRepository(uri);

        try {
            svc.uninstallFeature("f1");
            fail("Uninstall should have failed as feature is not installed");
        } catch (Exception e) {
            // ok
        }

        svc.installFeature("f1", "0.1", EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
        svc.installFeature("f1", "0.2", EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));

        try {
            svc.uninstallFeature("f1");
            fail("Uninstall should have failed as feature is installed in multiple versions");
        } catch (Exception e) {
            // ok
        }

        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f1");
        verify(bundleManager);
    }    
    
    @Test
    public void testAddAndRemoveRepository() throws Exception {
        URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                + "  <feature name='f1' version='0.1'><bundle>bundle-f1-0.1</bundle></feature>"
                + "</features>");

        BundleManager bundleManager = EasyMock.createMock(BundleManager.class);
        expect(bundleManager.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(bundleManager);
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        EasyMock.verify(bundleManager);

        svc.addRepository(uri);                                                     
        svc.removeRepository(uri);
        verify(bundleManager);
    }

    // Tests install of a Repository that includes a feature
    // with a feature dependency
    // The dependant feature is in the same repository
    // Tests uninstall of features
    @SuppressWarnings("unchecked")
    @Test
    public void testInstallFeatureWithDependantFeatures() throws Exception {
        URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                                 + "  <feature name='f1' version='0.1'><feature version='0.1'>f2</feature><bundle>bundle-f1-0.1</bundle></feature>"
                                 + "  <feature name='f2' version='0.1'><bundle>bundle-f2-0.1</bundle></feature>"
                                 + "</features>");

        BundleManager bundleManager = EasyMock.createMock(BundleManager.class);
        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        Bundle bundlef101 = createDummyBundle(12345L, "bundle-f1-0.1", headers());
        Bundle bundlef201 = createDummyBundle(54321L, "bundle-f2-0.1", headers());
        expect(bundleManager.getDataFile(EasyMock.<String> anyObject())).andReturn(dataFile).anyTimes();
        expect(bundleManager.installBundleIfNeeded("bundle-f1-0.1", 0, null))
            .andReturn(new BundleInstallerResult(bundlef101, true));
        expect(bundleManager.installBundleIfNeeded("bundle-f2-0.1", 0, null))
            .andReturn(new BundleInstallerResult(bundlef201, true));
        expect(bundleManager.getBundleContext()).andReturn(bundleContext).anyTimes();
        expect(bundleContext.getBundle(12345)).andReturn(bundlef101).anyTimes();
        ignoreRefreshes(bundleManager);
        bundleManager.uninstall(Collections.EMPTY_LIST, true);
       
        EasyMock.expectLastCall().anyTimes();
        replay(bundleManager);
        
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        svc.addRepository(uri);
        svc.installFeature("f1", "0.1");
        svc.uninstallFeature("f1", "0.1");
        verify(bundleManager);

    }

    @SuppressWarnings("unchecked")
    private BundleManager prepareBundleManagerForInstallUninstall(String bundleUri, String bundlename) throws Exception {
        BundleManager bundleManager = EasyMock.createMock(BundleManager.class);
        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        Bundle installedBundle = createDummyBundle(12345L, bundlename, headers());
        expect(bundleManager.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();
        expect(bundleManager.installBundleIfNeeded(bundleUri, 0, null)).andReturn(new BundleInstallerResult(installedBundle, true));
        expect(bundleManager.getBundleContext()).andReturn(bundleContext);
        ignoreRefreshes(bundleManager);
        bundleManager.uninstall(Collections.EMPTY_LIST, true);
        EasyMock.expectLastCall().times(2);
        return bundleManager;
    }

    @Test
    public void testInstallFeatureWithDependantFeaturesAndVersionWithoutPreinstall() throws Exception {
        URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                + "  <feature name='f1' version='0.1'><feature version='0.1'>f2</feature></feature>"
                + "  <feature name='f2' version='0.1'><bundle>bundle-0.1</bundle></feature>"
                + "  <feature name='f2' version='0.2'><bundle>bundle-0.2</bundle></feature>"
                + "</features>");

        BundleManager bundleManager = prepareBundleManagerForInstallUninstall("bundle-0.1", "bundle-0.1");

        replay(bundleManager);
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        svc.addRepository(uri);
        svc.installFeature("f1", "0.1");
        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f2", "0.1");
        verify(bundleManager);
    }

    @Test
    public void testInstallFeatureWithDependantFeaturesAndNoVersionWithoutPreinstall() throws Exception {
        URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                + "  <feature name='f1' version='0.1'><feature>f2</feature></feature>"
                + "  <feature name='f2' version='0.1'><bundle>bundle-0.1</bundle></feature>"
                + "  <feature name='f2' version='0.2'><bundle>bundle-0.2</bundle></feature>"
                + "</features>");

        BundleManager bundleManager = prepareBundleManagerForInstallUninstall("bundle-0.2", "bundle-0.2");

        replay(bundleManager);
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        svc.addRepository(uri);
        svc.installFeature("f1", "0.1");
        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f2", "0.2");
        verify(bundleManager);
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testInstallFeatureWithDependantFeaturesAndRangeWithoutPreinstall() throws Exception {
        URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                + "  <feature name='f1' version='0.1'><feature version='[0.1,0.3)'>f2</feature></feature>"
                + "  <feature name='f2' version='0.1'><bundle>bundle-0.1</bundle></feature>"
                + "  <feature name='f2' version='0.2'><bundle>bundle-0.2</bundle></feature>"
                + "</features>");

        BundleManager bundleManager = EasyMock.createMock(BundleManager.class);
        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        Bundle bundleVer02 = createDummyBundle(54321L, "bundleVer02", headers());
        expect(bundleManager.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();
        expect(bundleManager.installBundleIfNeeded("bundle-0.2", 0, null)).andReturn(new BundleInstallerResult(bundleVer02, true));
        expect(bundleManager.getBundleContext()).andReturn(bundleContext);
        ignoreRefreshes(bundleManager);
        bundleManager.uninstall(Collections.EMPTY_LIST, true);

        EasyMock.expectLastCall().times(2);

        replay(bundleManager);
        FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
        svc.addRepository(uri);
        svc.installFeature("f1", "0.1");
        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f2", "0.2");
        verify(bundleManager);
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testInstallFeatureWithDependantFeaturesAndRangeWithPreinstall() throws Exception {
        String bundleVer01Uri = "bundle-0.1";
        String bundleVer02Uri = "bundle-0.2";

        URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>"
                + "<feature name='f1' version='0.1'><feature version='[0.1,0.3)'>f2</feature></feature>"
                + "  <feature name='f2' version='0.1'><bundle>%s</bundle></feature>"
                + "  <feature name='f2' version='0.2'><bundle>%s</bundle></feature>"
                + "</features>", bundleVer01Uri, bundleVer02Uri);
        
        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
        replay(bundleContext);

        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, bundleContext, new Storage(), null, null, null, null);
        svc.addRepository(uri);
        svc.installFeature("f2", "0.1");
        svc.installFeature("f1", "0.1");
        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f2", "0.1");

        verify(bundleContext);
    }
    */
@Test
public void testGetFeaturesShouldHandleDifferentVersionPatterns() throws Exception {
    URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>" + "  <feature name='f1' version='0.1'><feature version='[0.1,0.3)'>f2</feature></feature>" + "  <feature name='f2' version='0.1'><bundle>bundle1</bundle></feature>" + "  <feature name='f2' version='0.2'><bundle>bundle2</bundle></feature>" + "</features>");
    FeaturesServiceConfig cfg = new FeaturesServiceConfig();
    BundleInstallSupport installSupport = EasyMock.niceMock(BundleInstallSupport.class);
    EasyMock.replay(installSupport);
    FeaturesServiceImpl svc = new FeaturesServiceImpl(new Storage(), null, null, resolver, installSupport, null, cfg);
    svc.addRepository(uri);
    assertEquals(feature("f2", "0.2"), svc.getFeatures("f2", "[0.1,0.3)")[0]);
    assertEquals(feature("f2", "0.2"), svc.getFeatures("f2", "0.0.0")[0]);
    assertEquals(feature("f2", "0.2"), svc.getFeatures("f2", "0.2")[0]);
    assertEquals(0, svc.getFeatures("f2", "0.3").length);
}
Also used : FeaturesServiceImpl(org.apache.karaf.features.internal.service.FeaturesServiceImpl) StateStorage(org.apache.karaf.features.internal.service.StateStorage) BundleInstallSupport(org.apache.karaf.features.internal.service.BundleInstallSupport) FeaturesServiceConfig(org.apache.karaf.features.internal.service.FeaturesServiceConfig) URI(java.net.URI) Test(org.junit.Test)

Example 4 with FeaturesServiceImpl

use of org.apache.karaf.features.internal.service.FeaturesServiceImpl in project karaf by apache.

the class Activator method doStart.

protected void doStart() throws Exception {
    BundleContext systemBundleContext = bundleContext.getBundle(0).getBundleContext();
    ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
    int resolverThreads = getInt("resolverThreads", Runtime.getRuntime().availableProcessors());
    executorService = new ThreadPoolExecutor(0, resolverThreads, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), ThreadUtils.namedThreadFactory("resolver"));
    Resolver resolver = new ResolverImpl(new Slf4jResolverLog(LoggerFactory.getLogger(ResolverImpl.class)), executorService);
    URLStreamHandlerService mvnUrlHandler = getTrackedService(URLStreamHandlerService.class);
    if (configurationAdmin == null || mvnUrlHandler == null) {
        return;
    }
    StandardRegionDigraph dg = DigraphHelper.loadDigraph(bundleContext);
    DigraphHelper.verifyUnmanagedBundles(bundleContext, dg);
    registerRegionDiGraph(dg);
    boolean configCfgStore = getBoolean("configCfgStore", FeaturesService.DEFAULT_CONFIG_CFG_STORE);
    FeatureConfigInstaller configInstaller = new FeatureConfigInstaller(configurationAdmin, configCfgStore);
    installSupport = new BundleInstallSupportImpl(bundleContext.getBundle(), bundleContext, systemBundleContext, getTrackedServiceRef(ConfigurationAdmin.class).getBundle(), configInstaller, dg);
    register(RegionDigraphPersistence.class, () -> installSupport.saveDigraph());
    FeatureRepoFinder featureFinder = new FeatureRepoFinder();
    register(ManagedService.class, featureFinder, FeatureRepoFinder.getServiceProperties());
    Repository globalRepository = getGlobalRepository();
    FeaturesServiceConfig cfg = getConfig();
    StateStorage stateStorage = createStateStorage();
    featuresService = new FeaturesServiceImpl(stateStorage, featureFinder, configurationAdmin, resolver, installSupport, globalRepository, cfg);
    try {
        EventAdminListener eventAdminListener = new EventAdminListener(bundleContext);
        featuresService.registerListener(eventAdminListener);
    } catch (Throwable t) {
    // No EventAdmin support in this case
    }
    register(FeaturesService.class, featuresService);
    featuresListenerTracker = createFeatureListenerTracker();
    featuresListenerTracker.open();
    FeaturesServiceMBeanImpl featuresServiceMBean = new FeaturesServiceMBeanImpl();
    featuresServiceMBean.setBundleContext(bundleContext);
    featuresServiceMBean.setFeaturesService(featuresService);
    registerMBean(featuresServiceMBean, "type=feature");
    String[] featuresRepositories = getStringArray("featuresRepositories", "");
    String featuresBoot = getString("featuresBoot", "");
    boolean featuresBootAsynchronous = getBoolean("featuresBootAsynchronous", false);
    BootFeaturesInstaller bootFeaturesInstaller = new BootFeaturesInstaller(bundleContext, featuresService, featuresRepositories, featuresBoot, featuresBootAsynchronous);
    bootFeaturesInstaller.start();
}
Also used : FeaturesServiceImpl(org.apache.karaf.features.internal.service.FeaturesServiceImpl) BootFeaturesInstaller(org.apache.karaf.features.internal.service.BootFeaturesInstaller) Resolver(org.osgi.service.resolver.Resolver) URLStreamHandlerService(org.osgi.service.url.URLStreamHandlerService) StateStorage(org.apache.karaf.features.internal.service.StateStorage) BundleInstallSupportImpl(org.apache.karaf.features.internal.service.BundleInstallSupportImpl) ResolverImpl(org.apache.felix.resolver.ResolverImpl) FeatureRepoFinder(org.apache.karaf.features.internal.service.FeatureRepoFinder) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) FeaturesServiceMBeanImpl(org.apache.karaf.features.internal.management.FeaturesServiceMBeanImpl) StandardRegionDigraph(org.eclipse.equinox.internal.region.StandardRegionDigraph) EventAdminListener(org.apache.karaf.features.internal.service.EventAdminListener) FeatureConfigInstaller(org.apache.karaf.features.internal.service.FeatureConfigInstaller) XmlRepository(org.apache.karaf.features.internal.repository.XmlRepository) Repository(org.osgi.service.repository.Repository) AggregateRepository(org.apache.karaf.features.internal.repository.AggregateRepository) JsonRepository(org.apache.karaf.features.internal.repository.JsonRepository) FeaturesServiceConfig(org.apache.karaf.features.internal.service.FeaturesServiceConfig) Slf4jResolverLog(org.apache.karaf.features.internal.resolver.Slf4jResolverLog) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) BundleContext(org.osgi.framework.BundleContext)

Example 5 with FeaturesServiceImpl

use of org.apache.karaf.features.internal.service.FeaturesServiceImpl in project karaf by apache.

the class FeaturesServiceTest method testSchemaValidation.

/**
 * This test checks schema validation of submited uri.
 */
@Test
public void testSchemaValidation() throws Exception {
    URI uri = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'>" + "  <featur><bundle>somebundle</bundle></featur></features>");
    BundleInstallSupport installSupport = EasyMock.niceMock(BundleInstallSupport.class);
    EasyMock.replay(installSupport);
    FeaturesServiceConfig cfg = new FeaturesServiceConfig();
    FeaturesServiceImpl svc = new FeaturesServiceImpl(new Storage(), null, null, resolver, installSupport, null, cfg);
    try {
        svc.addRepository(uri);
        fail("exception expected");
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("Unable to validate"));
    }
}
Also used : FeaturesServiceImpl(org.apache.karaf.features.internal.service.FeaturesServiceImpl) StateStorage(org.apache.karaf.features.internal.service.StateStorage) BundleInstallSupport(org.apache.karaf.features.internal.service.BundleInstallSupport) FeaturesServiceConfig(org.apache.karaf.features.internal.service.FeaturesServiceConfig) URI(java.net.URI) MultiException(org.apache.karaf.features.internal.util.MultiException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

FeaturesServiceConfig (org.apache.karaf.features.internal.service.FeaturesServiceConfig)5 FeaturesServiceImpl (org.apache.karaf.features.internal.service.FeaturesServiceImpl)5 StateStorage (org.apache.karaf.features.internal.service.StateStorage)5 URI (java.net.URI)4 BundleInstallSupport (org.apache.karaf.features.internal.service.BundleInstallSupport)4 Test (org.junit.Test)4 MultiException (org.apache.karaf.features.internal.util.MultiException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ResolverImpl (org.apache.felix.resolver.ResolverImpl)1 FeaturesServiceMBeanImpl (org.apache.karaf.features.internal.management.FeaturesServiceMBeanImpl)1 AggregateRepository (org.apache.karaf.features.internal.repository.AggregateRepository)1 JsonRepository (org.apache.karaf.features.internal.repository.JsonRepository)1 XmlRepository (org.apache.karaf.features.internal.repository.XmlRepository)1 Slf4jResolverLog (org.apache.karaf.features.internal.resolver.Slf4jResolverLog)1 BootFeaturesInstaller (org.apache.karaf.features.internal.service.BootFeaturesInstaller)1 BundleInstallSupportImpl (org.apache.karaf.features.internal.service.BundleInstallSupportImpl)1 EventAdminListener (org.apache.karaf.features.internal.service.EventAdminListener)1