Examples of FeaturesServiceImpl


Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(bundleContext, installedBundle1, installedBundle2);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        svc.addRepository(uri);

        try {
            List<Feature> features = Arrays.asList(svc.listFeatures());
            Collections.reverse(features);
            svc.installFeatures(new CopyOnWriteArraySet<Feature>(features),
                                EnumSet.noneOf(FeaturesService.Option.class));
            fail("Call should have thrown an exception");
        } catch (MalformedURLException e) {
        }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(frameworkWiring, sysBundle, bundleContext, installedBundle1, installedBundle2);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        svc.addRepository(uri);

        List<Feature> features = Arrays.asList(svc.listFeatures());
        Collections.reverse(features);
        svc.installFeatures(new CopyOnWriteArraySet<Feature>(features),
                            EnumSet.noneOf(FeaturesService.Option.class));

//        verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle1, installedBundle2);
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        try {
            svc.addRepository(uri);
            fail("exception expected");
        } catch (Exception e) {
            assertTrue(e.getMessage().contains("Unable to validate"));
        }
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();
        replay(bundleContext);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        svc.addRepository(uri);
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

                configuration.load(new FileReader(configFile));
            } catch (IOException e) {
                LOGGER.warn("Error reading configuration file " + configFile.toString(), e);
            }
        }
        featuresService = new FeaturesServiceImpl();
        featuresService.setUrls(getString(configuration, "featuresRepositories", ""));
        featuresService.setBoot(getString(configuration, "featuresBoot", ""));
        featuresService.setBootFeaturesAsynchronous(getBool(configuration, "bootFeaturesAsynchronous", false));
        featuresService.setRespectStartLvlDuringFeatureStartup(getBool(configuration, "respectStartLvlDuringFeatureStartup", false));
        featuresService.setResolverTimeout(getLong(configuration, "resolverTimeout", 5000));
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(bundleContext, installedBundle);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        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).getLocation());
        assertTrue(features[0].getBundles().get(0).isStart());

        verify(bundleContext, installedBundle);

        reset(bundleContext, installedBundle);

        // required since the sorted set uses it
        expect(installedBundle.compareTo(EasyMock.<Bundle>anyObject())).andReturn(0).anyTimes();

        expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
        expect(bundleContext.installBundle(isA(String.class),
                                           isA(InputStream.class))).andReturn(installedBundle);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
        expect(installedBundle.getHeaders()).andReturn(new Hashtable());
        installedBundle.start();

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(bundleContext, installedBundle);

        svc.installFeature("f1", FeatureImpl.DEFAULT_VERSION, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
       
        Feature[] installed = svc.listInstalledFeatures();
        assertEquals(1, installed.length);
        assertEquals("f1", installed[0].getName());
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(bundleContext, installedBundle);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        svc.addRepository(uri);
       
        verify(bundleContext, installedBundle);

        reset(bundleContext, installedBundle);

        // required since the sorted set uses it
        expect(installedBundle.compareTo(EasyMock.<Bundle>anyObject())).andReturn(0).anyTimes();

        // Installs f1 and 0.1
        expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
        expect(bundleContext.installBundle(isA(String.class),
                                           isA(InputStream.class))).andReturn(installedBundle);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
        expect(installedBundle.getHeaders()).andReturn(new Hashtable());
        installedBundle.start();

        // Installs f1 and 0.2
        expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
        expect(bundleContext.installBundle(isA(String.class),
                                           isA(InputStream.class))).andReturn(installedBundle);
        expect(installedBundle.getBundleId()).andReturn(123456L);
        expect(installedBundle.getBundleId()).andReturn(123456L);
        expect(installedBundle.getBundleId()).andReturn(123456L);
        expect(bundleContext.getBundle(123456L)).andReturn(installedBundle);
        expect(installedBundle.getHeaders()).andReturn(new Hashtable());
        installedBundle.start();

        // UnInstalls f1 and 0.1
        expect(bundleContext.getBundle(12345)).andReturn(installedBundle);
        installedBundle.uninstall();

        // UnInstalls f1 and 0.2
        expect(bundleContext.getBundle(123456)).andReturn(installedBundle);
        installedBundle.uninstall();

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        // refresh
        expect(bundleContext.getBundle(0)).andStubReturn(sysBundle);
        expect(sysBundle.adapt(FrameworkWiring.class)).andStubReturn(frameworkWiring);
        final Capture<FrameworkListener> listeners =  new Capture<FrameworkListener>();
        frameworkWiring.refreshBundles(EasyMock.<Collection<Bundle>>eq(null), capture(listeners));
        expectLastCall().andStubAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                for (FrameworkListener listener : listeners.getValues()) {
                    listener.frameworkEvent(new FrameworkEvent(FrameworkEvent.PACKAGES_REFRESHED, sysBundle, null));
                }
                return null;
            }
        });

        replay(bundleContext, installedBundle, sysBundle, frameworkWiring);

        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");
    }   
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        replay(bundleContext);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);

        // Adds Repository
        svc.addRepository(uri);                                                    
       
        // Removes Repository
        svc.removeRepository(uri);       
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

            }
        });

        replay(bundleContext, installedBundle, sysBundle, frameworkWiring);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        svc.addRepository(uri);

        svc.installFeature("f1", "0.1");

        // Uninstall repository
        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f2", "0.1");

    }
View Full Code Here

Examples of org.apache.karaf.features.internal.FeaturesServiceImpl

        URI uri = tmp.toURI();

        BundleContext bundleContext = prepareBundleContextForInstallUninstall();

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setBundleContext(bundleContext);
        svc.addRepository(uri);

        svc.installFeature("f1", "0.1");

        // Uninstall repository
        svc.uninstallFeature("f1", "0.1");
        svc.uninstallFeature("f2", "0.1");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.