Package org.ops4j.pax.exam.options

Examples of org.ops4j.pax.exam.options.MavenArtifactProvisionOption


    protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
        return getOsgiService(null, type, filter, timeout);
    }

    protected Bundle installBundle(String groupId, String artifactId) throws Exception {
        MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
        return bundleContext.installBundle(mvnUrl.getURL());
    }
View Full Code Here


           
            CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);

            BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
            // install the blueprint sample onto the framework associated with the composite bundle
            MavenArtifactProvisionOption mapo = mavenBundleInTest("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample");
            // let's use input stream to avoid invoking mvn url handler which isn't avail in the child framework.
            InputStream is = new URL(mapo.getURL()).openStream();
            Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
            assertNotNull(bundle);
           
            // start the composite bundle then the blueprint sample
            cb.start();
            bundle.start();
View Full Code Here

    public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
        return mavenBundle(groupId, artifactId, null, null, null);
    }

    public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId, String version, String classifier, String type) {
        MavenArtifactProvisionOption m = CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId);
        if (version != null) {
            m.version(version);
        } else {
            try {
                m.versionAsInProject();
            } catch (RuntimeException t) {
                //in eclipse, the dependencies.properties may not be avail since it's not
                //generated into a source directory (directly into classes).
                //thus, try and load it manually

                try {
                    File file = new File("META-INF/maven/dependencies.properties");
                    if (!file.exists()) {
                        file = new File("target/classes/META-INF/maven/dependencies.properties");
                    }
                    if (file.exists()) {
                        Properties dependencies = new Properties();
                        InputStream is = new FileInputStream(file);
                        try {
                            dependencies.load(is);
                        } finally {
                            is.close();
                        }
                        version = dependencies.getProperty( groupId + "/" + artifactId + "/version" );
                        m.version(version);
                    } else {
                        throw t;
                    }
                } catch (Throwable t2) {
                    throw t;
                }
            }
        }
        if (classifier != null) {
            m.classifier(classifier);
        }
        if (type != null) {
            m.type(type);
        }
        return m;
    }
View Full Code Here

        options.add(bootClasspathLibrary(mavenBundle("org.apache.karaf.jaas", "org.apache.karaf.jaas.boot")).afterFramework());
        options.add(bootClasspathLibrary(mavenBundle("org.apache.karaf", "org.apache.karaf.main")).afterFramework());
        for (Enumeration e = startupProps.propertyNames(); e.hasMoreElements();) {
            String name = (String) e.nextElement();
            String value = startupProps.getProperty(name);
            MavenArtifactProvisionOption opt = convertToMaven(name);
            if (opt.getURL().contains("org.apache.karaf.features")) {
                opt.noStart();
            }
            opt.startLevel(Integer.parseInt(value));
            options.add(opt);
        }
        options.add(mavenBundle("org.apache.karaf.tooling", "org.apache.karaf.tooling.testing"));
        options.add(wrappedBundle(mavenBundle("org.ops4j.pax.exam", "pax-exam-container-default")));
        // We need to add pax-exam-junit here when running with the ibm
View Full Code Here

     * @return the pax-exam provisioning option for the bundle or <code>null</code> if not found
     */
    public static MavenArtifactProvisionOption findMaven(Option[] options, String groupId, String artifactId) {
        for (Option option : options) {
            if (option instanceof MavenArtifactProvisionOption) {
                MavenArtifactProvisionOption mvn = (MavenArtifactProvisionOption) option;
                if (mvn.getURL().startsWith("mvn:" + groupId + "/" + artifactId + "/")) {
                    return mvn;
                }
            }
        }
        return null;
View Full Code Here

    }

    private static MavenArtifactProvisionOption convertToMaven(String location) {
        String[] p = location.split("/");
        if (p.length >= 4 && p[p.length-1].startsWith(p[p.length-3] + "-" + p[p.length-2])) {
            MavenArtifactProvisionOption opt = new MavenArtifactProvisionOption();
            int artifactIdVersionLength = p[p.length-3].length() + 1 + p[p.length-2].length(); // (artifactId + "-" + version).length
            if (p[p.length-1].charAt(artifactIdVersionLength) == '-') {
                opt.classifier((p[p.length-1].substring(artifactIdVersionLength + 1, p[p.length-1].lastIndexOf('.'))));
            }
            StringBuffer sb = new StringBuffer();
            for (int j = 0; j < p.length - 3; j++) {
                if (j > 0) {
                    sb.append('.');
                }
                sb.append(p[j]);
            }
            opt.groupId(sb.toString());
            opt.artifactId(p[p.length-3]);
            opt.version(p[p.length-2]);
            opt.type(p[p.length-1].substring(p[p.length-1].lastIndexOf('.') + 1));
            return opt;
        } else {
            throw new IllegalArgumentException("Unable to extract maven information from " + location);
        }
    }
View Full Code Here

    @Configuration
    public static Option[] configure() {
        Option[] activeMQOptions = configure("activemq");

        MavenArtifactProvisionOption qpidClient = CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-client").versionAsInProject();
        MavenArtifactProvisionOption qpidClientJms = CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-client-jms").versionAsInProject();
        MavenArtifactProvisionOption qpidCommon = CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-common").versionAsInProject();
        MavenArtifactProvisionOption geronimoJms = CoreOptions.mavenBundle("org.apache.geronimo.specs", "geronimo-jms_1.1_spec").versionAsInProject();
        MavenArtifactProvisionOption geronimoJta = CoreOptions.mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec","1.1.1");

        Option[] options = append(qpidClient, activeMQOptions);
        options = append(qpidClientJms, options);
        options = append(qpidCommon, options);
        options = append(geronimoJms, options);
View Full Code Here

            throw new RuntimeException(e);
        }
    }

    protected Bundle installBundle(String groupId, String artifactId) throws Exception {
        MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
        return bundleContext.installBundle(mvnUrl.getURL());
    }
View Full Code Here

        MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
        return bundleContext.installBundle(mvnUrl.getURL());
    }

    protected Bundle installBundle(String groupId, String artifactId, String classifier, String type) throws Exception {
        MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
        return bundleContext.installBundle(mvnUrl.getURL());
    }
View Full Code Here

    public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
        return mavenBundle(groupId, artifactId, null, null, null);
    }

    public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId, String version, String classifier, String type) {
        MavenArtifactProvisionOption m = CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId);
        if (version != null) {
            m.version(version);
        } else {
            try {
                m.versionAsInProject();
            } catch (RuntimeException t) {
                //in eclipse, the dependencies.properties may not be avail since it's not
                //generated into a source directory (directly into classes).
                //thus, try and load it manually
               
                try {
                    File file = new File("META-INF/maven/dependencies.properties");
                    if (!file.exists()) {
                        file = new File("target/classes/META-INF/maven/dependencies.properties");
                    }
                    if (file.exists()) {
                        Properties dependencies = new Properties();
                        dependencies.load(new FileInputStream(file));
                        version = dependencies.getProperty( groupId + "/" + artifactId + "/version" );
                        m.version(version);
                    } else {
                        throw t;
                    }
                } catch (Throwable t2) {
                    throw t;
                }
            }
        }
        if (classifier != null) {
            m.classifier(classifier);
        }
        if (type != null) {
            m.type(type);
        }
        return m;
    }
View Full Code Here

TOP

Related Classes of org.ops4j.pax.exam.options.MavenArtifactProvisionOption

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.