Search in sources :

Example 21 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingGroupInTargetDefinition.

@Test
public void testAddTargetWithMissingGroupInTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration(null, "myArtifactId", "myVersion");
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    try {
        configurationReader.addTargetArtifact(configuration, session, null, dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 22 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingArtifactIdInTargetDefinition.

@Test
public void testAddTargetWithMissingArtifactIdInTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration("myGroupId", null, "myVersion");
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    try {
        configurationReader.addTargetArtifact(configuration, session, null, dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 23 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.

the class TargetPlatformFilterConfigurationReaderTest method getTargetFilters.

private Xpp3Dom getTargetFilters(String pomFile) throws IOException, Exception, ProjectBuildingException {
    File pom = ResourceUtil.resourceFile(pomFile);
    Xpp3Dom config = getTargetPlatformConfiguration(pom);
    return config.getChild("filters");
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) File(java.io.File)

Example 24 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.

the class TargetPlatformFilterConfigurationReaderTest method testValidRemoveAllFilters.

public void testValidRemoveAllFilters() throws Exception {
    Xpp3Dom filterConfig = getTargetFilters("targetfilter/valid_removeAll/pom.xml");
    List<TargetPlatformFilter> filters = subject.parseFilterConfiguration(filterConfig);
    for (TargetPlatformFilter filter : filters) {
        assertThat(filter.getAction(), is(FilterAction.REMOVE_ALL));
    }
    assertThat(filters.get(0).getScopePattern(), is(patternWithoutVersion(CapabilityType.OSGI_BUNDLE, "org.eclipse.equinox.servletbridge.extensionbundle")));
    assertThat(filters.get(1).getScopePattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "org.eclipse.equinox.app", "[3.6.0,3.6.1)")));
    assertThat(filters.get(2).getScopePattern(), is(patternWithVersion(CapabilityType.P2_INSTALLABLE_UNIT, "a.jre.javase", "1.7.0")));
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 25 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.

the class TargetPlatformFilterConfigurationReaderTest method testValidRestrictToFilters.

public void testValidRestrictToFilters() throws Exception {
    Xpp3Dom filterConfig = getTargetFilters("targetfilter/valid_restrictTo/pom.xml");
    List<TargetPlatformFilter> filters = subject.parseFilterConfiguration(filterConfig);
    for (TargetPlatformFilter filter : filters) {
        assertThat(filter.getAction(), is(FilterAction.RESTRICT));
    }
    assertThat(filters.get(0).getScopePattern(), is(patternWithoutVersion(CapabilityType.OSGI_BUNDLE, "org.eclipse.osgi")));
    assertThat(filters.get(0).getActionPattern(), is(patternWithVersionRange(null, null, "[3.6,3.7)")));
    assertThat(filters.get(1).getScopePattern(), is(patternWithoutVersion(CapabilityType.OSGI_BUNDLE, "org.eclipse.osgi")));
    assertThat(filters.get(1).getActionPattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "org.eclipse.osgi", "[3.6,3.7)")));
    assertThat(filters.get(2).getScopePattern(), is(patternWithoutVersion(CapabilityType.JAVA_PACKAGE, "javax.persistence")));
    assertThat(filters.get(2).getActionPattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "javax.persistence", "2.0")));
    assertThat(filters.get(3).getScopePattern(), is(patternWithVersionRange(CapabilityType.OSGI_BUNDLE, "org.eclipse.equinox.app", "[3.6.0,3.7.0)")));
    assertThat(filters.get(3).getActionPattern(), is(patternWithVersion(null, null, "3.6.2.v00000000")));
    assertThat(filters.get(4).getScopePattern(), is(patternWithoutVersion(CapabilityType.P2_INSTALLABLE_UNIT, "a.jre.javase")));
    assertThat(filters.get(4).getActionPattern(), is(patternWithVersion(null, null, "1.5.0")));
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Aggregations

Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)156 Plugin (org.apache.maven.model.Plugin)39 File (java.io.File)26 ArrayList (java.util.ArrayList)18 PluginExecution (org.apache.maven.model.PluginExecution)18 IOException (java.io.IOException)13 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 MavenSession (org.apache.maven.execution.MavenSession)10 MavenProject (org.apache.maven.project.MavenProject)10 Model (org.apache.maven.model.Model)9 Reader (java.io.Reader)8 Build (org.apache.maven.model.Build)8 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)8 BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)8 MojoExecution (org.apache.maven.plugin.MojoExecution)7 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)7 Map (java.util.Map)6 Dependency (org.apache.maven.model.Dependency)6 StringReader (java.io.StringReader)5