Package org.ops4j.pax.exam

Examples of org.ops4j.pax.exam.ExamSystem


    @Before
    public void setUp() throws IOException {
        // Had to use a @Before instead of @BeforeClass as that requires a
        // static method
        if (testContainer == null) {
            ExamSystem system = DefaultExamSystem.create(config());
            testContainer = PaxExamRuntime.createContainer(system);
            testContainer.start();
        }
    }
View Full Code Here


    @Before
    public void startContainer() throws Exception {
        if (testContainer == null) {
            ServerConfiguration sc = new ServerConfiguration();
            ExamSystem system = DefaultExamSystem.create(sc.config());
            testContainer = PaxExamRuntime.createContainer(system);
            testContainer.start();
            new RetryLoop(new RetryLoop.Condition() {
                public String getDescription() {
                    return "Check if MDCTestServlet is up";
View Full Code Here

            if (internalConfigurationOptions != null && internalConfigurationOptions.length != 0) {
                invokerConfiguration =
                    systemProperty(EXAM_INVOKER_PROPERTY).value(internalConfigurationOptions[0].getInvoker());
            }

            ExamSystem subsystem = system.fork(
                options(
                    systemProperty(RMI_HOST_PROPERTY).value(registry.getHost()),
                    systemProperty(RMI_PORT_PROPERTY).value("" + registry.getPort()),
                    systemProperty(RMI_NAME_PROPERTY).value(name),
                    invokerConfiguration,
                    systemProperty(EXAM_INJECT_PROPERTY).value("true"),
                    editConfigurationFileExtend("etc/system.properties", "jline.shutdownhook", "true")
                ));
            target = new RBCRemoteTarget(name, registry.getPort(), subsystem.getTimeout());

            System.setProperty("java.protocol.handler.pkgs", "org.ops4j.pax.url");

            URL sourceDistribution = new URL(framework.getFrameworkURL());

            KeepRuntimeFolderOption[] keepRuntimeFolder = subsystem.getOptions(KeepRuntimeFolderOption.class);
            if (keepRuntimeFolder != null && keepRuntimeFolder.length != 0) {
                deleteRuntime = false;
            }

            targetFolder = retrieveFinalTargetFolder(subsystem);
            extractKarafDistribution(sourceDistribution, targetFolder);

            File javaHome = new File(System.getProperty("java.home"));
            File karafBase = searchKarafBase(targetFolder);
            File distributionInfo = new File(karafBase + "/etc/distribution.info");
            File karafBin = new File(karafBase + "/bin");
            File featuresXmlFile = new File(targetFolder + "/examfeatures.xml");
            File karafHome = karafBase;
            File deploy = new File(karafBase + "/deploy");
            String karafData = karafHome + "/data";

            framework = new InternalKarafDistributionConfigurationOption(framework, distributionInfo);
            versionAdaptions = KarafManipulatorFactory.createManipulator(framework.getKarafVersion());

            ArrayList<String> javaOpts = Lists.newArrayList();
            appendVmSettingsFromSystem(javaOpts, subsystem);
            String[] javaEndorsedDirs =
                new String[]{ javaHome + "/jre/lib/endorsed", javaHome + "/lib/endorsed", karafHome + "/lib/endorsed" };
            String[] javaExtDirs =
                new String[]{ javaHome + "/jre/lib/ext", javaHome + "/lib/ext", javaHome + "/lib/ext" };
            String[] karafOpts = new String[]{};
            ArrayList<String> opts =
                Lists.newArrayList("-Dkaraf.startLocalConsole=" + shouldLocalConsoleBeStarted(subsystem),
                    "-Dkaraf.startRemoteShell=" + shouldRemoteShellBeStarted(subsystem));

            String[] classPath = buildKarafClasspath(karafHome);
            String main = "org.apache.karaf.main.Main";
            String options = "";
            String[] environment = new String[]{};
            String[] fileEndings = new String[]{ "jar", "war", "zip", "kar", "xml" };

            updateLogProperties(karafHome, subsystem);
            updateUserSetProperties(karafHome, subsystem);
            copyBootClasspathLibraries(karafHome, subsystem);
            setupExamProperties(karafHome, subsystem);
            makeScriptsInBinExec(karafBin);

            int startLevel = Constants.DEFAULT_START_LEVEL;
            ExamBundlesStartLevel examBundlesStartLevel = system.getSingleOption(ExamBundlesStartLevel.class);
            if (examBundlesStartLevel != null) {
                startLevel = examBundlesStartLevel.getStartLevel();
            }

            ExamFeaturesFile examFeaturesFile;
            if (framework.isUseDeployFolder()) {
                copyReferencedArtifactsToDeployFolder(deploy, subsystem, fileEndings);
                examFeaturesFile = ExamFeaturesFileFactory.createExamFeaturesFile("", startLevel);
            } else {
                StringBuilder extension = extractExtensionString(subsystem);
                examFeaturesFile = ExamFeaturesFileFactory.createExamFeaturesFile(extension.toString(), startLevel);
            }
            examFeaturesFile.writeToFile(featuresXmlFile);
            examFeaturesFile.adaptDistributionToStartExam(karafHome, featuresXmlFile);

            long startedAt = System.currentTimeMillis();

            runner.exec(environment, karafBase, javaHome.toString(), javaOpts.toArray(new String[]{}),
                javaEndorsedDirs, javaExtDirs, karafHome.toString(), karafData, karafOpts,
                opts.toArray(new String[]{}), classPath, main, options);

            LOGGER.debug("Test Container started in " + (System.currentTimeMillis() - startedAt) + " millis");
            LOGGER.info("Wait for test container to finish its initialization " + subsystem.getTimeout());

            if (subsystem.getOptions(ServerModeOption.class).length == 0) {
                waitForState(org.openengsb.labs.paxexam.karaf.container.internal.Constants.SYSTEM_BUNDLE,
                    Bundle.ACTIVE, subsystem.getTimeout());
            }
            else {
                LOGGER
                    .info("System runs in Server Mode. Which means, no Test facility bundles available on target system.");
            }
View Full Code Here

      ReactorManager reactorManager = ReactorManager.getInstance();
      try {
        
         Field fieldSystem = ReactorManager.class.getDeclaredField("system");
         fieldSystem.setAccessible(true);
         ExamSystem system = (ExamSystem) fieldSystem.get(reactorManager);
         return system.createProbe();
      } catch (Exception e) {
         e.printStackTrace();
      }
      return probeBuilder;
   }
View Full Code Here

            if (internalConfigurationOptions != null && internalConfigurationOptions.length != 0) {
                invokerConfiguration =
                        systemProperty("pax.exam.invoker").value(internalConfigurationOptions[0].getInvoker());
            }

            ExamSystem subsystem = system.fork(
                    options(
                            systemProperty(RMI_HOST_PROPERTY).value(registry.getHost()),
                            systemProperty(RMI_PORT_PROPERTY).value("" + registry.getPort()),
                            systemProperty(RMI_NAME_PROPERTY).value(name),
                            invokerConfiguration,
                            systemProperty(EXAM_INJECT_PROPERTY).value("true"),
                            editConfigurationFileExtend("etc/system.properties", "jline.shutdownhook", "true")
                    ));
            target = new RBCRemoteTarget(name, registry.getPort(), subsystem.getTimeout());

            System.setProperty("java.protocol.handler.pkgs", "org.ops4j.pax.url");

            URL sourceDistribution = new URL(framework.getFrameworkURL());

            KeepRuntimeFolderOption[] keepRuntimeFolder = subsystem.getOptions(KeepRuntimeFolderOption.class);
            if (keepRuntimeFolder != null && keepRuntimeFolder.length != 0) {
                deleteRuntime = false;
            }

            targetFolder = retrieveFinalTargetFolder(subsystem);
            extractKarafDistribution(sourceDistribution, targetFolder);

            File javaHome = new File(System.getProperty("java.home"));
            File karafBase = searchKarafBase(targetFolder);
            File distributionInfo = new File(karafBase + "/etc/distribution.info");
            File karafBin = new File(karafBase + "/bin");
            File featuresXmlFile = new File(targetFolder + "/examfeatures.xml");
            File karafHome = karafBase;
            File deploy = new File(karafBase + "/deploy");
            String karafData = karafHome + "/data";

            framework = new InternalKarafDistributionConfigurationOption(framework, distributionInfo);
            versionAdaptions = KarafManipulatorFactory.createManipulator(framework.getKarafVersion());

            ArrayList<String> javaOpts = Lists.newArrayList();
            appendVmSettingsFromSystem(javaOpts, subsystem);
            String[] javaEndorsedDirs =
                    new String[]{javaHome + "/jre/lib/endorsed", javaHome + "/lib/endorsed", karafHome + "/lib/endorsed"};
            String[] javaExtDirs =
                    new String[]{javaHome + "/jre/lib/ext", javaHome + "/lib/ext", javaHome + "/lib/ext"};
            String[] karafOpts = new String[]{};
            ArrayList<String> opts =
                    Lists.newArrayList("-Dkaraf.startLocalConsole=" + shouldLocalConsoleBeStarted(subsystem),
                            "-Dkaraf.startRemoteShell=" + shouldRemoteShellBeStarted(subsystem));

            String[] classPath = buildKarafClasspath(karafHome);
            String main = "org.apache.karaf.main.Main";
            String options = "";
            String[] environment = new String[]{};
            String[] fileEndings = new String[]{"jar", "war", "zip", "kar", "xml"};

            updateLogProperties(karafHome, subsystem);
            updateUserSetProperties(karafHome, subsystem);
            copyBootClasspathLibraries(karafHome, subsystem);
            setupExamProperties(karafHome, subsystem);
            makeScriptsInBinExec(karafBin);

            int startLevel = Constants.DEFAULT_START_LEVEL;
            ExamBundlesStartLevel examBundlesStartLevel = system.getSingleOption(ExamBundlesStartLevel.class);
            if (examBundlesStartLevel != null) {
                startLevel = examBundlesStartLevel.getStartLevel();
            }

            ExamFeaturesFile examFeaturesFile;
            if (framework.isUseDeployFolder()) {
                copyReferencedArtifactsToDeployFolder(deploy, subsystem, fileEndings);
                examFeaturesFile = new ExamFeaturesFile("", startLevel);
            } else {
                StringBuilder extension = extractExtensionString(subsystem);
                examFeaturesFile = new ExamFeaturesFile(extension.toString(), startLevel);
            }
            examFeaturesFile.writeToFile(featuresXmlFile);

            examFeaturesFile.adaptDistributionToStartExam(karafHome, featuresXmlFile);

            long startedAt = System.currentTimeMillis();

            runner.exec(environment, karafBase, javaHome.toString(), javaOpts.toArray(new String[]{}),
                    javaEndorsedDirs, javaExtDirs, karafHome.toString(), karafData, karafOpts,
                    opts.toArray(new String[]{}), classPath, main, options);

            LOGGER.debug("Test Container started in " + (System.currentTimeMillis() - startedAt) + " millis");
            LOGGER.info("Wait for test container to finish its initialization " + subsystem.getTimeout());

            if (subsystem.getOptions(ServerModeOption.class).length == 0) {
                waitForState(org.apache.karaf.tooling.exam.container.internal.Constants.SYSTEM_BUNDLE,
                        Bundle.ACTIVE, subsystem.getTimeout());
            } else {
                LOGGER
                        .info("System runs in Server Mode. Which means, no Test facility bundles available on target system.");
            }
View Full Code Here

public class OSGiTest {
    @Test
    public void test() throws Throwable {
        int httpPort = PortAllocator.allocatePort();
        ExamSystem system = DefaultExamSystem.create(options(
                url("link:classpath:META-INF/links/org.ops4j.pax.logging.api.link"),
                url("link:classpath:META-INF/links/org.osgi.compendium.link"),
                url("link:classpath:org.apache.felix.configadmin.link"),
                url("link:classpath:org.apache.servicemix.bundles.wsdl4j.link"),
                url("link:classpath:org.apache.geronimo.specs.geronimo-activation_1.1_spec.link"), // TODO: should not be necessary on Java 6
View Full Code Here

public class SimpleMultiTest {

    @Test
    public void bareRunTest() throws Exception {
        Option[] options = new Option[] {};
        ExamSystem system = createTestSystem(options);
        TestProbeProvider p = makeProbe(system);

        // the parse will split all single containers
        for (TestContainer testContainer : getTestContainerFactory().create(system)) {
            try {
                testContainer.start();
                testContainer.install(p.getStream());
                for (TestAddress test : p.getTests()) {
                    testContainer.call(test);
                }
            }
            finally {
                testContainer.stop();
            }
        }
        system.clear();
    }
View Full Code Here

    public void reactorRun(StagedExamReactorFactory strategy) throws Exception {
        TestContainerFactory factory = getFactory();
        Option[] options = new Option[] { regressionDefaults() };

        ExamSystem system = PaxExamRuntime.createTestSystem(options);
        ExamReactor reactor = new DefaultExamReactor(system, factory);
        TestProbeBuilder probe = makeProbe(system);

        reactor.addProbe(probe);
        reactor.addConfiguration(options);

        StagedExamReactor stagedReactor = reactor.stage(strategy);
        stagedReactor.beforeClass();
        try {
            for (TestAddress call : stagedReactor.getTargets()) {
                stagedReactor.invoke(call);
            }

        }
        finally {
            stagedReactor.afterClass();
            system.clear();
        }

    }
View Full Code Here

            regressionDefaults(),
            mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.junit",
                "4.9_2"),
            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"), };

        ExamSystem system = createTestSystem(options);
        TestProbeProvider p = makeProbe(system);

        // the parse will split all single containers
        for (TestContainer testContainer : getTestContainerFactory().create(system)) {
            try {
                testContainer.start();
                testContainer.install(p.getStream());
                for (TestAddress test : p.getTests()) {
                    testContainer.call(test);
                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            finally {
                testContainer.stop();
            }
        }
        system.clear();
    }
View Full Code Here

    public void singleStepTest() throws Exception {
        Option[] options = new Option[] {
            mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.junit",
                "4.9_2"),
            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG") };
        ExamSystem system = createTestSystem(options);
        TestProbeProvider p = makeProbe(system);

        TestContainer[] containers = PaxExamRuntime.getTestContainerFactory().create(system);

        for (TestContainer testContainer : containers) {
View Full Code Here

TOP

Related Classes of org.ops4j.pax.exam.ExamSystem

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.