Skip to content

Commit

Permalink
Adding (failing) tests for Commonjava#96
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcasey committed Mar 14, 2016
1 parent 06fd4bd commit ac83e7f
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef;
import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef;
import org.commonjava.maven.galley.maven.parse.GalleyMavenXMLException;
import org.junit.Ignore;
import org.junit.Test;

public class MavenPomViewTest
Expand Down Expand Up @@ -165,6 +166,47 @@ public void dependencyManagedBySingleBOMWithExpressionToProjectGroupId()
assertThat( dv.getScope(), equalTo( DependencyScope.test ) );
}

@Test
public void directDepsInParentAndMainPOM()
throws Exception
{
MavenPomView pomView = loadPoms( "pom-with-parent-and-direct-dep.xml", "simple-parent-with-direct-dep.xml" );

List<DependencyView> deps = pomView.getAllDirectDependencies();
assertThat( deps.size(), equalTo( 2 ) );
}

@Test
@Ignore( "https://github.com/Commonjava/galley/issues/96" )
public void managedDepOverlapMergedFromParentToMainPOM()
throws Exception
{
MavenPomView pomView = loadPoms( "pom-with-parent-and-incomplete-managed-dep.xml", "simple-parent-with-managed-dep.xml" );

List<DependencyView> deps = pomView.getAllManagedDependencies();


assertThat( deps.size(), equalTo( 1 ) );
DependencyView dep = deps.get( 0 );
assertThat( dep.getScope(), equalTo( DependencyScope.test ) );
assertThat( dep.getVersion(), equalTo( "2.5" ) );
}

@Test
@Ignore( "https://github.com/Commonjava/galley/issues/96" )
public void dependencyOverrideInMainPOM()
throws Exception
{
MavenPomView pomView = loadPoms( "pom-with-parent-and-redeclared-direct-dep.xml", "simple-parent-with-direct-dep.xml" );

List<DependencyView> deps = pomView.getAllDirectDependencies();


assertThat( deps.size(), equalTo( 1 ) );
DependencyView dep = deps.get( 0 );
assertThat( dep.getScope(), equalTo( DependencyScope.compile ) );
}

@Test
public void projectWithBOMContainingBOMs()
throws Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Copyright (c) 2014 Red Hat, Inc..
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v3.0
which accompanies this distribution, and is available at
http://www.gnu.org/licenses/gpl.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.foo</groupId>
<artifactId>bar-parent</artifactId>
<version>1.0.0.0</version>
</parent>

<groupId>org.foo</groupId>
<artifactId>bar-project</artifactId>
<version>0.0.0.1</version>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
Copyright (c) 2014 Red Hat, Inc..
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v3.0
which accompanies this distribution, and is available at
http://www.gnu.org/licenses/gpl.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.foo</groupId>
<artifactId>bar-parent</artifactId>
<version>1.0.0.0</version>
</parent>

<groupId>org.foo</groupId>
<artifactId>bar-project</artifactId>
<version>0.0.0.1</version>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
Copyright (c) 2014 Red Hat, Inc..
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v3.0
which accompanies this distribution, and is available at
http://www.gnu.org/licenses/gpl.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.foo</groupId>
<artifactId>bar-parent</artifactId>
<version>1.0.0.0</version>
</parent>

<groupId>org.foo</groupId>
<artifactId>bar-project</artifactId>
<version>0.0.0.1</version>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
Copyright (c) 2014 Red Hat, Inc..
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v3.0
which accompanies this distribution, and is available at
http://www.gnu.org/licenses/gpl.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>bar-parent</artifactId>
<version>1.0.0.0</version>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Copyright (c) 2014 Red Hat, Inc..
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v3.0
which accompanies this distribution, and is available at
http://www.gnu.org/licenses/gpl.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>bar-parent</artifactId>
<version>1.0.0.0</version>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

0 comments on commit ac83e7f

Please sign in to comment.