use of org.sonar.maven.model.maven2.MavenProject in project sonar-java by SonarSource.
the class MavenDependencyCollectorTest method parse.
private static MavenProject parse(String testCase) {
File file = new File("src/test/files/checks/xml/maven/dependencyCollector/" + testCase + "-pom.xml");
MavenProject project = PomParser.parseXML(file);
if (project == null) {
Fail.fail("unable to parse test case: " + file.getAbsolutePath());
}
return project;
}
use of org.sonar.maven.model.maven2.MavenProject in project sonar-java by SonarSource.
the class PomParserTest method should_retrieve_attributes.
@Test
public void should_retrieve_attributes() throws Exception {
MavenProject project = PomParser.parseXML(SIMPLE_POM_FILE);
checkAttribute(project.getModelVersion(), "4.0.0", 3, 17, 3, 22);
checkAttribute(project.getGroupId(), "org.sonarsource.java", 5, 12, 5, 32);
checkAttribute(project.getArtifactId(), "simple-project", 6, 15, 6, 29);
checkAttribute(project.getPackaging(), "jar", 10, 14, 10, 17);
checkAttribute(project.getName(), "simple-project", 12, 9, 12, 23);
checkAttribute(project.getUrl(), "http://maven.apache.org", 13, 8, 13, 31);
// starting column is unknown
checkAttribute(project.getVersion(), "1.0-SNAPSHOT", 7, -1, 9, 10);
// empty property
checkAttribute(project.getDescription(), "", 14, 16, 14, 16);
}
use of org.sonar.maven.model.maven2.MavenProject in project sonar-java by SonarSource.
the class PomParserTest method should_not_parse.
@Test
public void should_not_parse() {
MavenProject project = PomParser.parseXML(new File("."));
assertThat(project).isNull();
}
use of org.sonar.maven.model.maven2.MavenProject in project sonar-java by SonarSource.
the class PomParserTest method should_parse_incompletly_pom_with_complex_elements.
@Test
public void should_parse_incompletly_pom_with_complex_elements() throws Exception {
MavenProject project = PomParser.parseXML(COMPLEX_ELEMENT_POM_FILE);
Configuration config = project.getBuild().getPlugins().getPlugins().get(0).getExecutions().getExecutions().get(0).getConfiguration();
checkPosition(config, 16, 13, 24, 13);
assertThat(config).isNotNull();
List<Element> values = config.getElements();
assertThat(values).hasSize(2);
}
use of org.sonar.maven.model.maven2.MavenProject in project sonar-java by SonarSource.
the class PomParserTest method should_fail_parsing.
@Test
public void should_fail_parsing() {
MavenProject project = PomParser.parseXML(PARSE_ISSUE_POM_FILE);
assertThat(project).isNull();
}
Aggregations