]> source.dussan.org Git - archiva.git/commitdiff
additional tests and add classifier
authorBrett Porter <brett@apache.org>
Tue, 8 Apr 2008 07:28:46 +0000 (07:28 +0000)
committerBrett Porter <brett@apache.org>
Tue, 8 Apr 2008 07:28:46 +0000 (07:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@645780 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/resources/test-data/surefire-testng-2.0-tree.xml [new file with mode: 0644]
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 with mode: 0644]
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 with mode: 0644]

index 6102c333d0f60f38039d38f0182c3a26e90cb1de..6d3bc514da9527f3fc52bfbde6bf6655aff61cb7 100644 (file)
@@ -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" );
 
index 9b8bc8a1e2c1d41c551a33b9563f64dc66a8c414..0c28f19e78cb651d87ef407c3c42ee21f1f073a1 100644 (file)
@@ -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 (file)
index 0000000..287c459
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<tree>
+  <dependency>
+    <groupId>org.apache.maven.surefire</groupId>
+    <artifactId>surefire-testng</artifactId>
+    <type>jar</type>
+    <version>2.0</version>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.maven.surefire</groupId>
+        <artifactId>surefire-api</artifactId>
+        <type>jar</type>
+        <version>2.0</version>
+        <scope>compile</scope>
+        <dependencies>
+          <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+            <type>jar</type>
+            <version>1.1</version>
+            <scope>compile</scope>
+          </dependency>
+        </dependencies>
+      </dependency>
+      <dependency>
+        <groupId>org.testng</groupId>
+        <artifactId>testng</artifactId>
+        <type>jar</type>
+        <version>4.7</version>
+        <scope>compile</scope>
+        <classifier>jdk15</classifier>
+        <dependencies>
+          <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <type>jar</type>
+            <version>3.8.1</version>
+            <scope>runtime</scope>
+          </dependency>
+          <dependency>
+            <groupId>qdox</groupId>
+            <artifactId>qdox</artifactId>
+            <type>jar</type>
+            <version>1.5</version>
+            <scope>runtime</scope>
+          </dependency>
+          <dependency>
+            <groupId>bsh</groupId>
+            <artifactId>bsh</artifactId>
+            <type>jar</type>
+            <version>2.0b1</version>
+            <scope>runtime</scope>
+          </dependency>
+        </dependencies>
+      </dependency>
+    </dependencies>
+  </dependency>
+</tree>
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 (file)
index 0000000..d56af58
--- /dev/null
@@ -0,0 +1,6 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>openejb</groupId>
+  <artifactId>jaxb-api</artifactId>
+  <version>2.0EA3</version>
+</project>
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 (file)
index 0000000..d8de3ad
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>surefire-providers</artifactId>
+    <groupId>org.apache.maven.surefire</groupId>
+    <version>2.0</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>surefire-testng</artifactId>
+  <name>SureFire TestNG Runner</name>
+  <version>2.0</version>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.4</source>
+          <target>1.4</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <fork>false</fork>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <profiles>
+    <profile>
+      <id>jdk14</id>
+      <activation>
+        <jdk>1.4</jdk>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.testng</groupId>
+          <artifactId>testng</artifactId>
+          <version>4.7</version>
+          <classifier>jdk14</classifier>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>jdk15</id>
+      <activation>
+        <jdk>!1.4</jdk>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.testng</groupId>
+          <artifactId>testng</artifactId>
+          <version>4.7</version>
+          <classifier>jdk15</classifier>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>jdk1.3</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <configuration>
+              <fork>false</fork>
+              <compilerVersion>1.4</compilerVersion>
+            </configuration>
+          </plugin>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <forkMode>once</forkMode>
+              <jvm>${JAVA_1_3_HOME}/bin/java</jvm>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+  <distributionManagement>
+    <status>deployed</status>
+  </distributionManagement>
+</project>
\ No newline at end of file