ops4j / org.ops4j.pax.exam2

Pax Exam is a testing framework for OSGi
https://ops4j1.jira.com/wiki/spaces/PAXEXAM4/
Apache License 2.0
84 stars 100 forks source link

Add support to provisioning from an OnlineBundleRepository [PAXEXAM-491] #615

Open ops4j-issues opened 11 years ago

ops4j-issues commented 11 years ago

Christoph Läubrich created PAXEXAM-491

Instead of provisioning all bundles a testcase needs, it would be nice to just mention the BUTs (bundles under test) and let the rest be resolved from one or more OnlineBundleRepositorys (might be a local maven repro or any other source).

It could work like this:


Fixed in: unscheduled Votes: 0, Watches: 2

ops4j-issues commented 11 years ago

Christoph Läubrich commented

pushed code to the master, it could be used like this:

import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.osgi.RepositoryOptions.obr;
import static org.ops4j.pax.exam.osgi.RepositoryOptions.obrBundles;

import java.io.IOException;

import javax.inject.Inject;

import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.osgi.OBRRepositoryOption;
import org.ops4j.pax.exam.osgi.OBRValidation;
import org.ops4j.pax.exam.util.Filter;
import org.osgi.service.cm.ConfigurationAdmin;

@RunWith(PaxExam.class)
public class OBRFelixTest {

    @Filter(timeout = 60000)
    @Inject
    private ConfigurationAdmin configurationAdmin;

    @Inject
    private OBRValidation      validation;

    @Configuration
    public Option[] config() throws IOException {
        OBRRepositoryOption obr = obr("http://felix.apache.org/obr/releases.xml");
        obr.bundle("org.apache.felix.configadmin").version("1.2.4");
        return options(junitBundles(), obrBundles(), obr.toOption());
    }

    @Test
    public void test() {
        System.out.println("Hello OBR cfgAdmin is " + configurationAdmin.getClass().getName());
    }

    @After
    public void checkOBR() {
        validation.validate();
    }
}
ops4j-issues commented 11 years ago

Harald Wellmann commented

Is there any good reason for not simply using bundle("obr:...") with the Pax URL obr: protocol handler?

See https://ops4j1.jira.com/wiki/display/paxurl/Obr+Protocol.

ops4j-issues commented 11 years ago

Christoph Läubrich commented

Thanks again for your feedback Harald Wellmann the problem with the Pax URL handler (correct me if I'm wrong) is that it only works inside a running OSGi framework, so it is not useable in the Configuration-Phase, beside this, I'm not sure if it also installs dependent bundles or just the one specified.
Another problem is, that it must interact somehow with the framework to make sure installation has taken place before the text-probe starts.