Examples of XWikiExecutor


Examples of org.xwiki.test.integration.XWikiExecutor

        final Map<Profile, XWikiExecutor> executorByProfile = new HashMap<Profile, XWikiExecutor>();
        for (int i = 0; i < profiles.size(); i++) {
            try {
                // All executors are #0 because they will not be run in parallel.
                executorByProfile.put(((Class<Profile>)profiles.get(i)).newInstance(),
                                      new XWikiExecutor(0));
            } catch (Exception e) {
                throw new RuntimeException("Failed to instanciate configuration profile.", e);
            }
        }

        // Callback to setup executors in the suite class.
        try {
            for (Profile profile : executorByProfile.keySet()) {
                profile.apply(executorByProfile.get(profile));
            }
        } catch (Exception e) {
            throw new RuntimeException("Failed to initialize XWiki Executors", e);
        }


        for (final Profile profile : executorByProfile.keySet()) {
            final XWikiExecutor executor = executorByProfile.get(profile);
            try {

                try {
                    executor.start();
                } catch (Exception e) {
                    throw new RuntimeException("Failed to start XWiki", e);
                }

                try {
                    Object instance = this.getTestClass().getJavaClass().newInstance();

                    // If there is a field which is an XWikiExecutor type
                    // and has an @Requirement annotation, inject the current executor.
                    for (Field field : this.getTestClass().getJavaClass().getDeclaredFields()) {
                        if (field.getType() == XWikiExecutor.class
                            && field.getAnnotation(Requirement.class) != null)
                        {
                            field.setAccessible(true);
                            field.set(instance, executor);
                        }
                    }

                    // If the class is initializable then call initialize.
                    final Class[] interfaces = this.getTestClass().getJavaClass().getInterfaces();
                    for (int i = 0; i < interfaces.length; i++) {
                        if (interfaces[i] == Initializable.class) {
                            this.getTestClass().getJavaClass().getMethod("initialize").invoke(instance);
                        }
                    }

                } catch (Exception e) {
                    throw new RuntimeException("Failed to prepare tests to run in config profile.", e);
                }

                super.run(notifier);
            } finally {
                try {
                    executor.stop();
                } catch (Exception e) {
                    // Squash this and let the original exception be thrown.
                }
            }
        }
View Full Code Here

Examples of org.xwiki.test.integration.XWikiExecutor

    /** Utility methods which should be available to tests and to pages. */
    private final TestUtils util = new TestUtils();

    public PersistentTestContext() throws Exception
    {
        this.executor = new XWikiExecutor(0);
        executor.start();

        // Use a wrapping driver to display more information when there are failures.
        this.driver = new XWikiWrappingDriver(new FirefoxDriver(), getUtil());

View Full Code Here

Examples of org.xwiki.test.integration.XWikiExecutor

        final Map<Profile, XWikiExecutor> executorByProfile = new HashMap<Profile, XWikiExecutor>();
        for (int i = 0; i < profiles.size(); i++) {
            try {
                // All executors are #0 because they will not be run in parallel.
                executorByProfile.put(((Class<Profile>) profiles.get(i)).newInstance(), new XWikiExecutor(0));
            } catch (Exception e) {
                throw new RuntimeException("Failed to instanciate configuration profile.", e);
            }
        }

        // Callback to setup executors in the suite class.
        try {
            for (Profile profile : executorByProfile.keySet()) {
                profile.apply(executorByProfile.get(profile));
            }
        } catch (Exception e) {
            throw new RuntimeException("Failed to initialize XWiki Executors", e);
        }

        for (final Profile profile : executorByProfile.keySet()) {
            final XWikiExecutor executor = executorByProfile.get(profile);
            try {

                try {
                    executor.start();
                } catch (Exception e) {
                    throw new RuntimeException("Failed to start XWiki", e);
                }

                try {
                    Object instance = this.getTestClass().getJavaClass().newInstance();

                    // If there is a field which is an XWikiExecutor type
                    // and has an @Inject annotation, inject the current executor.
                    for (Field field : this.getTestClass().getJavaClass().getDeclaredFields()) {
                        if (field.getType() == XWikiExecutor.class && field.getAnnotation(Inject.class) != null) {
                            field.setAccessible(true);
                            field.set(instance, executor);
                        }
                    }

                    // If the class is initializable then call initialize.
                    final Class< ? >[] interfaces = this.getTestClass().getJavaClass().getInterfaces();
                    for (int i = 0; i < interfaces.length; i++) {
                        if (interfaces[i] == Initializable.class) {
                            this.getTestClass().getJavaClass().getMethod("initialize").invoke(instance);
                        }
                    }

                } catch (Exception e) {
                    throw new RuntimeException("Failed to prepare tests to run in config profile.", e);
                }

                super.run(notifier);
            } finally {
                try {
                    executor.stop();
                } catch (Exception e) {
                    // Squash this and let the original exception be thrown.
                }
            }
        }
View Full Code Here

Examples of org.xwiki.test.integration.XWikiExecutor

    private static RepositoryUtils repositoryUtil;

    @XWikiExecutorSuite.PreStart
    public void preStart(List<XWikiExecutor> executors) throws Exception
    {
        XWikiExecutor executor = executors.get(0);

        repositoryUtil = new RepositoryUtils();

        PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
        // Put self as extensions repository
        properties.setProperty(
            "extension.repositories",
            Arrays.asList("self:xwiki:http://localhost:8080/xwiki/rest", "maven-test:maven:"
                + repositoryUtil.getMavenRepository().toURI()));
        executor.saveXWikiProperties(properties);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.