From 919466bbd25449259800c25a41f19a2e5a27bb70 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 8 Apr 2008 07:28:46 +0000 Subject: [PATCH] additional tests and add classifier git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@645780 13f79535-47bb-0310-9956-ffa450edef68 --- .../DependencyTreeGeneratorConsumer.java | 6 +- .../DependencyTreeGeneratorConsumerTest.java | 45 +++++++++- .../test-data/surefire-testng-2.0-tree.xml | 59 +++++++++++++ .../jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom | 6 ++ .../2.0/surefire-testng-2.0.pom | 82 +++++++++++++++++++ 5 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-data/surefire-testng-2.0-tree.xml create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/openejb/jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java index 6102c333d..6d3bc514d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java @@ -89,7 +89,7 @@ public class DependencyTreeGeneratorConsumer /** @plexus.requirement */ private MavenProjectBuilder projectBuilder; - + /** @plexus.requirement */ private ArtifactRepositoryFactory artifactRepositoryFactory; @@ -300,6 +300,10 @@ public class DependencyTreeGeneratorConsumer { dependency.addElement( "scope" ).setText( artifact.getScope() ); } + if ( artifact.getClassifier() != null ) + { + dependency.addElement( "classifier" ).setText( artifact.getClassifier() ); + } xmlNode = dependency.addElement( "dependencies" ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java index 9b8bc8a1e..0c28f19e7 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java @@ -27,6 +27,8 @@ import org.apache.commons.io.IOUtils; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.consumers.ConsumerException; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; +import org.apache.maven.profiles.DefaultProfileManager; +import org.codehaus.plexus.spring.PlexusContainerAdapter; import org.codehaus.plexus.spring.PlexusInSpringTestCase; public class DependencyTreeGeneratorConsumerTest @@ -44,7 +46,7 @@ public class DependencyTreeGeneratorConsumerTest throws Exception { super.setUp(); - + consumer = (DependencyTreeGeneratorConsumer) lookup( KnownRepositoryContentConsumer.class, "dependency-tree-generator" ); @@ -76,4 +78,45 @@ public class DependencyTreeGeneratorConsumerTest consumer.completeScan(); } + + public void testInvalidCoordinate() + throws IOException, ConsumerException + { + consumer.beginScan( repository ); + + String path = "openejb/jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom"; + try + { + consumer.processFile( path ); + + fail( "Should not have successfully processed the file" ); + } + catch ( ConsumerException e ) + { + File generatedFile = new File( generatedRepositoryLocation, path + ".xml" ); + assertFalse( generatedFile.exists() ); + } + + consumer.completeScan(); + } + + public void testProfiles() + throws IOException, ConsumerException + { + PlexusContainerAdapter container = new PlexusContainerAdapter(); + container.setApplicationContext( getApplicationContext() ); + + DefaultProfileManager m = new DefaultProfileManager( container ); + + consumer.beginScan( repository ); + + String path = "org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom"; + consumer.processFile( path ); + + File generatedFile = new File( generatedRepositoryLocation, path + ".xml" ); + assertEquals( IOUtils.toString( getClass().getResourceAsStream( "/test-data/surefire-testng-2.0-tree.xml" ) ), + FileUtils.readFileToString( generatedFile ) ); + + consumer.completeScan(); + } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-data/surefire-testng-2.0-tree.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-data/surefire-testng-2.0-tree.xml new file mode 100644 index 000000000..287c45954 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-data/surefire-testng-2.0-tree.xml @@ -0,0 +1,59 @@ + + + + + org.apache.maven.surefire + surefire-testng + jar + 2.0 + + + org.apache.maven.surefire + surefire-api + jar + 2.0 + compile + + + org.codehaus.plexus + plexus-utils + jar + 1.1 + compile + + + + + org.testng + testng + jar + 4.7 + compile + jdk15 + + + junit + junit + jar + 3.8.1 + runtime + + + qdox + qdox + jar + 1.5 + runtime + + + bsh + bsh + jar + 2.0b1 + runtime + + + + + + diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/openejb/jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/openejb/jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom new file mode 100644 index 000000000..d56af580b --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/openejb/jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom @@ -0,0 +1,6 @@ + + 4.0.0 + openejb + jaxb-api + 2.0EA3 + diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom new file mode 100644 index 000000000..d8de3ad32 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-repo/org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom @@ -0,0 +1,82 @@ + + + surefire-providers + org.apache.maven.surefire + 2.0 + + 4.0.0 + surefire-testng + SureFire TestNG Runner + 2.0 + + + + maven-compiler-plugin + + 1.4 + 1.4 + + + + maven-surefire-plugin + + false + + + + + + + jdk14 + + 1.4 + + + + org.testng + testng + 4.7 + jdk14 + + + + + jdk15 + + !1.4 + + + + org.testng + testng + 4.7 + jdk15 + + + + + jdk1.3 + + + + maven-compiler-plugin + + false + 1.4 + + + + maven-surefire-plugin + + once + ${JAVA_1_3_HOME}/bin/java + + + + + + + + deployed + + \ No newline at end of file -- 2.39.5