Search in sources :

Example 1 with MavenArtifact

use of org.motechproject.testing.osgi.mvn.MavenArtifact in project motech by motech.

the class BasePaxIT method dependencies.

/**
 * Returns the Pax Exam options describing the dependencies for the test (modules other than the tested one).
 * This method will take all dependencies of the tested module (using Maven) and remove dependencies outside of scopes not
 * being used during the test and dependencies that are marked as ignored. More specific methods than this one should be
 * easier to override in order to control the dependency management for the test. Only the osgi-platform module will be marked for being
 * started by this method, since it is responsible for starting other bundles.
 * @return the Pax Exam options describing the dependencies to use during the test.
 * @see #getAdditionalTestDependencies()
 * @see #getIgnoredDependencies()
 * @see #getRequiredDependencyScopes()
 */
protected Option dependencies() {
    List<MavenArtifact> mavenDependencies = getMavenArtifacts();
    List<MavenArtifactProvisionOption> options = new ArrayList<>();
    Set<String> ignoredDependencies = getIgnoredDependencies();
    Set<String> testDependencies = getTestDependencies();
    Set<String> includedScopes = getRequiredDependencyScopes();
    for (MavenArtifact artifact : mavenDependencies) {
        String groupId = artifact.getGroupId();
        String artifactId = artifact.getArtifactId();
        String version = artifact.getVersion();
        MavenArtifactProvisionOption mavenOption = mavenBundle(groupId, artifactId, version);
        String artifactStr = artifact.toGroupArtifactString();
        boolean shouldInclude = includedScopes.contains(artifact.getScope()) || testDependencies.contains(artifactStr);
        if (shouldInclude && !ignoredDependencies.contains(artifactStr)) {
            // we only start the platform bundle
            if (!MOTECH_PLATFORM_BUNDLE.equals(artifactStr)) {
                mavenOption = mavenOption.noStart();
            }
            options.add(mavenOption);
        }
    }
    return composite(options.toArray(new Option[options.size()]));
}
Also used : ArrayList(java.util.ArrayList) MavenArtifactProvisionOption(org.ops4j.pax.exam.options.MavenArtifactProvisionOption) Option(org.ops4j.pax.exam.Option) MavenArtifactProvisionOption(org.ops4j.pax.exam.options.MavenArtifactProvisionOption) MavenArtifact(org.motechproject.testing.osgi.mvn.MavenArtifact)

Aggregations

ArrayList (java.util.ArrayList)1 MavenArtifact (org.motechproject.testing.osgi.mvn.MavenArtifact)1 Option (org.ops4j.pax.exam.Option)1 MavenArtifactProvisionOption (org.ops4j.pax.exam.options.MavenArtifactProvisionOption)1