Package org.ops4j.pax.tinybundles.core

Examples of org.ops4j.pax.tinybundles.core.TinyBundle


            }
        }

        File metadata = new File("src/main/resources/blueprint", "HelloProvider.xml");

        TinyBundle bundle = TinyBundles.bundle();
        bundle.add(org.apache.felix.ipojo.test.compatibility.scr.HelloServiceProvider.class);
        try {
            bundle.add("blueprint/provider.xml", new FileInputStream(metadata));
        } catch (FileNotFoundException e) {
            throw new IllegalArgumentException("Cannot find XML metadata : " + metadata.getAbsolutePath());
        }

        InputStream inputStream = bundle
                .set(Constants.BUNDLE_SYMBOLICNAME, "hello-provider-blueprint")
               // .set(Constants.IMPORT_PACKAGE, "*")
                .set("Bundle-Blueprint", "blueprint/provider.xml")
                .build(withBnd());

View Full Code Here


            }
        }

        File metadata = new File("src/main/resources/blueprint", "HelloConsumer.xml");

        TinyBundle bundle = TinyBundles.bundle();
        bundle.add(org.apache.felix.ipojo.test.compatibility.scr.HelloServiceConsumer.class);
        try {
            bundle.add("blueprint/consumer.xml", new FileInputStream(metadata));
        } catch (FileNotFoundException e) {
            throw new IllegalArgumentException("Cannot find XML metadata : " + metadata.getAbsolutePath());
        }

        InputStream inputStream = bundle
                .set(Constants.BUNDLE_SYMBOLICNAME, "hello-consumer-blueprint")
               // .set(Constants.IMPORT_PACKAGE, "*")
                .set("Bundle-Blueprint", "blueprint/consumer.xml")
                .build(withBnd());

View Full Code Here

    }

    public Option testedBundle() throws MalformedURLException {
        File out = new File("target/tested/bundle.jar");

        TinyBundle tested = TinyBundles.bundle();

        // We look inside target/classes to find the class and resources
        File classes = new File("target/classes");
        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
        List<File> services = new ArrayList<File>();
        for (File file : files) {
            if (file.isDirectory()) {
                // By convention we export of .services and .service package
                if (file.getName().endsWith("services"|| file.getName().endsWith("service")) {
                    services.add(file);
                }
            } else {
                // We need to compute the path
                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
                tested.add(path, file.toURI().toURL());
                System.out.println(file.getName() + " added to " + path);
            }
        }

        String export = "";
        for (File file : services) {
            if (export.length() > 0) { export += ", "; }
            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
            String packageName = path.replace('/', '.');
            export += packageName;
        }

        System.out.println("Exported packages : " + export);

        InputStream inputStream = tested
                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
                //.set(Constants.IMPORT_PACKAGE, "*")
                .set(Constants.EXPORT_PACKAGE, export)
                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));

View Full Code Here

            return;
        }
        String delegationHeader =
            String.format("%s-%s", org.openengsb.labs.delegation.service.Constants.PROVIDED_CLASSES_HEADER,
                org.openengsb.core.api.Constants.DELEGATION_CONTEXT_MODELS);
        TinyBundle providerTinyBundle = bundle()
            .add(TestModel.class)
            .add(SubModel.class)
            .add(PrimitivePropertyModel.class)
            .add(TestModelProvider.class)
            .set(Constants.BUNDLE_ACTIVATOR, TestModelProvider.class.getName())
            .set(Constants.BUNDLE_SYMBOLICNAME, "test.model.provider")
            .set(Constants.BUNDLE_VERSION, providerVersion)
            .set(Constants.EXPORT_PACKAGE, "org.openengsb.itests.exam.models")
            .set(Constants.IMPORT_PACKAGE,
                "org.openengsb.core.api.model, org.osgi.framework, org.slf4j, "
                        + "org.openengsb.labs.delegation.service")
            .set(delegationHeader, "org.openengsb.itests.exam.models.*")
            .set(org.openengsb.core.api.Constants.PROVIDE_MODELS_HEADER, "true");
        Bundle providerBundle = getBundleContext().installBundle("test://testlocation/test.provider.jar",
            providerTinyBundle.build());
        providerBundle.start();
        providerInstalled = true;
    }
View Full Code Here

            streamBundle(createFragmentBundle()).noStart(), junitBundles(), cleanCaches());
    }

    private InputStream createFragmentBundle() {
        try {
            TinyBundle bundle = TinyBundles.bundle(StoreFactory.anonymousStore())
                .set(Constants.FRAGMENT_HOST, "org.ops4j.pax.exam.sample9.pde")
                .set(Constants.BUNDLE_MANIFESTVERSION, "2")
                .set(Constants.BUNDLE_SYMBOLICNAME, "org.ops4j.pax.exam.sample9.fragment")
                .add("messages.properties", getClass().getResource("/messages.properties"));
            return bundle.build();
        }
        catch (IOException e) {
            throw new TestContainerException(e);
        }
View Full Code Here

            mavenBundle("org.ops4j.pax.exam.samples", "pax-exam-sample9-pde", Info.getPaxExamVersion()),
            url(createFragmentBundle().toExternalForm()).noStart(), junitBundles(), cleanCaches());
    }

    private URL createFragmentBundle() {
        TinyBundle bundle = TinyBundles.bundle()
            .set(Constants.FRAGMENT_HOST, "org.ops4j.pax.exam.sample9.pde")
            .set(Constants.BUNDLE_MANIFESTVERSION, "2")
            .set(Constants.BUNDLE_SYMBOLICNAME, "org.ops4j.pax.exam.sample9.fragment")
            .add("messages.properties", getClass().getResource("/messages.properties"));

        try {
            Store<InputStream> store = StoreFactory.anonymousStore();
            Handle handle = store.store(bundle.build());
            return store.getLocation(handle).toURL();
        }
        catch (IOException e) {
            throw new TestContainerException(e);
        }
View Full Code Here

        }
        catch (IOException e) {
            throw new TestContainerException("Writing object data failed", e);
        }
        ByteArrayInputStream stream = new ByteArrayInputStream(outputStream.toByteArray());
        TinyBundle bundle = TinyBundles.bundle();
        bundle.add(ConfigurationOptionConfigurationListener.class);
        bundle.add(ConfigurationOptionActivator.class).add("override.obj", stream);
        bundle
            .set(Constants.BUNDLE_SYMBOLICNAME, "PAXExamConfigurationOption-" + UUID.randomUUID());
        bundle.set(Constants.IMPORT_PACKAGE,
            "org.osgi.framework,org.osgi.service.cm,org.osgi.util.tracker,org.slf4j");
        bundle.set(Constants.BUNDLE_ACTIVATOR, ConfigurationOptionActivator.class.getName());
        bundle.set(Constants.BUNDLE_MANIFESTVERSION, "2");
        return CoreOptions.streamBundle(bundle.build()).startLevel(1).start(true).update(false);
    }
View Full Code Here

            throw new TestContainerException("No tests added to setup!");
        }

        constructProbeTag(extraProperties);
        try {
            TinyBundle bundle = prepareProbeBundle(createExtraIgnores());
            return new DefaultTestProbeProvider(getTests(), store, store.store(bundle
                .build(withClassicBuilder())));

        }
        catch (IOException e) {
            throw new TestContainerException(e);
View Full Code Here

            throw new TestContainerException(e);
        }
    }

    private TinyBundle prepareProbeBundle(Properties p) throws IOException {
        TinyBundle bundle = bundle(store).set(Constants.DYNAMICIMPORT_PACKAGE, "*");

        bundle.set(Constants.BUNDLE_SYMBOLICNAME, "");
        bundle.set(Constants.BUNDLE_MANIFESTVERSION, "2");
        for (Object key : extraProperties.keySet()) {
            bundle.set((String) key, (String) extraProperties.get(key));
        }
        for (Object key : p.keySet()) {
            bundle.set((String) key, (String) p.get(key));
        }

        Map<String, URL> map = collectResources();
        for (String item : map.keySet()) {
            bundle.add(item, map.get(item));
        }
        return bundle;
    }
View Full Code Here

TOP

Related Classes of org.ops4j.pax.tinybundles.core.TinyBundle

Copyright © 2018 www.massapicom. 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.