Package org.ops4j.pax.exam

Examples of org.ops4j.pax.exam.TestContainerException


     *            the file extension to scan for (eg .cfg)
     * @return an option containing all the read configurations
     */
    public static Option configurationFolder(File folder, String extension) {
        if (!folder.exists()) {
            throw new TestContainerException("folder " + folder + " does not exits");
        }
        List<Option> options = new ArrayList<Option>();
        File[] files = folder.listFiles();

        for (File file : files) {
            if (file.isDirectory()) {
                continue;
            }
            String name = file.getName();
            if (!name.endsWith(extension)) {
                continue;
            }
            else {
                name = name.substring(0, name.length() - extension.length());
            }
            String[] split = name.split("-");
            ConfigurationProvisionOption cfg = new ConfigurationProvisionOption(split[0],
                new HashMap<String, Object>());
            cfg.factory(split.length > 1);
            Properties properties = new Properties();
            try {
                FileInputStream stream = new FileInputStream(file);
                try {
                    properties.load(stream);
                }
                finally {
                    stream.close();
                }
            }
            catch (IOException e) {
                throw new TestContainerException("can't read configuration file " + file, e);
            }
            Set<String> names = properties.stringPropertyNames();
            for (String key : names) {
                cfg.put(key, properties.getProperty(key));
            }
View Full Code Here


            instance = new SingletonStagedReactor(containers, mProbes);
        }
        else {
            if ( /* ! instance.testContainers.equals( containers ) || */
            !instance.probes.equals(mProbes)) {
                throw new TestContainerException(
                    "using the PerSuite reactor strategy, all test classes must share the same probes");
            }
        }
        return instance;
    }
View Full Code Here

                try {
                    container.installProbe(builder.build().getStream());
                }
                catch (IOException e) {
                    throw new TestContainerException("Unable to build the probe.", e);
                }
            }
        }
    }
View Full Code Here

                return null;
            }
        }
        // CHECKSTYLE:SKIP : catch all wanted
        catch (Throwable e) {
            throw new TestContainerException("Problem delegating to test.", e);
        }
    }
View Full Code Here

        try {
            URL applUrl = new URL(option.getURL());
            deployModule(option.getName(), applUrl.openStream());
        }
        catch (MalformedURLException exc) {
            throw new TestContainerException("Problem deploying " + option, exc);
        }
        catch (IOException exc) {
            throw new TestContainerException("Problem deploying " + option, exc);
        }
    }
View Full Code Here

            ServerDeploymentPlanResult result = deploymentManager.execute(plan).get();
            UUID actionId = plan.getDeploymentActions().get(0).getId();
            ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(actionId);

            if (actionResult.getResult() != Result.EXECUTED) {
                throw new TestContainerException("problem deploying " + applicationName);
            }
            deployed.push(warName);
        }
        catch (ExecutionException exc) {
            throw new TestContainerException("Problem deploying " + applicationName, exc);
        }
        catch (InterruptedException exc) {
            throw new TestContainerException("Problem deploying " + applicationName, exc);
        }
    }
View Full Code Here

        ServerDeploymentPlanResult result;
        try {
            result = deploymentManager.execute(plan).get();
        }
        catch (InterruptedException exc) {
            throw new TestContainerException("problem undeploying " + applName, exc);
        }
        catch (ExecutionException exc) {
            throw new TestContainerException("problem undeploying " + applName, exc);
        }
        UUID actionId = plan.getDeploymentActions().get(0).getId();
        ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(actionId);

        if (actionResult.getResult() != Result.EXECUTED) {
            throw new TestContainerException("problem undeploying " + applName);
        }
    }
View Full Code Here

        File dataDir = new File(tempDir, "data");
        dataDir.mkdir();

        File configFile = new File(configTargetDir, "standalone.xml");
        if (!configFile.exists()) {
            throw new TestContainerException(configFile + " does not exist");
        }
        parseServerConfiguration(configFile);
        System.setProperty("jboss.server.data.dir", dataDir.getAbsolutePath());
        server = EmbeddedServerFactory.create(wildFlyHome, null, null,
            getSystemPackages());
        try {
            server.start();
            deploymentManager = ServerDeploymentManager.Factory.create(
                InetAddress.getByName("localhost"), mgmtPort);
            testDirectory.setAccessPoint(new URI("http://localhost:" + httpPort
                + "/Pax-Exam-Probe/"));
            deployModules();
        }
        catch (ServerStartException | URISyntaxException | UnknownHostException exc) {
            throw new TestContainerException("Problem starting test container.", exc);
        }
        return this;
    }
View Full Code Here

        System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
        System.setProperty("org.jboss.logging.provider", "slf4j");

        wildFlyHome = cm.getProperty("pax.exam.wildfly80.home");
        if (wildFlyHome == null) {
            throw new TestContainerException(
                "System property pax.exam.wildfly80.home must be set to WildFly 8.0 install root");
        }

        String configDirName = cm.getProperty(WILDFLY80_CONFIG_DIR_KEY,
            "src/test/resources/wildfly80-config");
        configSourceDir = new File(configDirName);
        boolean overwriteConfig = Boolean.parseBoolean(cm.getProperty(WILDFLY80_CONFIG_OVERWRITE_KEY,
            "false"));

        if (isValidInstallation()) {
            if (overwriteConfig) {
                installConfiguration();
            }
        }
        else {
            LOG.info("installing WildFly 8.0 in {}", wildFlyHome);
            String distUrl = cm.getProperty(WILDFLY80_DIST_URL_KEY, WILDFLY80_DIST_URL_DEFAULT);
            LOG.info("installing WildFly 8.0 from {} in {}", distUrl, wildFlyHome);
            try {
                URL url = new URL(distUrl);
                File installDir = new File(wildFlyHome);
                File installParent = installDir.getParentFile();
                File tempInstall = new File(installParent, UUID.randomUUID().toString());
                ZipInstaller installer = new ZipInstaller(url, tempInstall.getAbsolutePath());
                installer.downloadAndInstall();
                File unpackedRoot = tempInstall.listFiles()[0];
                unpackedRoot.renameTo(installDir);
                installWildFlyModules();
                installConfiguration();
            }
            catch (IOException exc) {
                throw new TestContainerException("error during WildFly 8.0 installation", exc);
            }
        }
    }
View Full Code Here

            LOG.info("installing add-on module {}", module);
            ZipInstaller installer = new ZipInstaller(moduleUrl, moduleDir.getAbsolutePath());
            installer.downloadAndInstall();
        }
        catch (MalformedURLException exc) {
            throw new TestContainerException("invalid module URL: " + module, exc);
        }
        catch (IOException exc) {
            throw new TestContainerException(exc);
        }
    }
View Full Code Here

TOP

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

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.