]> source.dussan.org Git - archiva.git/commitdiff
[MRM-145] index skins
authorBrett Porter <brett@apache.org>
Sat, 26 Aug 2006 11:25:57 +0000 (11:25 +0000)
committerBrett Porter <brett@apache.org>
Sat, 26 Aug 2006 11:25:57 +0000 (11:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@437144 13f79535-47bb-0310-9956-ffa450edef68

archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactory.java
archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/MinimalArtifactIndexRecordFactoryTest.java
archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactoryTest.java
archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar [new file with mode: 0644]
archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.pom [new file with mode: 0644]

index d97a1d6cfd9f28f348a8363a9c92dde99877ec85..d4f67b3e426c24ed9aac8e2eca69d8cbf673f335 100644 (file)
@@ -81,6 +81,10 @@ public class StandardArtifactIndexRecordFactory
      */
     protected Digester md5Digester;
 
+    private static final String SITE_TEMPLATE_NAME = "META-INF/maven/site.vm";
+
+    private static final String SITE_CSS_NAME = "css/maven-theme.css";
+
     private static final String PLUGIN_METADATA_NAME = "META-INF/maven/plugin.xml";
 
     private static final String ARCHETYPE_METADATA_NAME = "META-INF/maven/archetype.xml";
@@ -236,6 +240,10 @@ public class StandardArtifactIndexRecordFactory
                 {
                     populateArchetypeEntries( record );
                 }
+                else if ( SITE_TEMPLATE_NAME.equals( name ) || SITE_CSS_NAME.equals( name ) )
+                {
+                    populateSkinEntries( record );
+                }
             }
         }
 
@@ -255,6 +263,12 @@ public class StandardArtifactIndexRecordFactory
         record.setType( "maven-archetype" );
     }
 
+    private void populateSkinEntries( StandardArtifactIndexRecord record )
+    {
+        // Typically discovered as a JAR
+        record.setType( "maven-skin" );
+    }
+
     private Xpp3Dom readXmlMetadataFileInJar( File file, String name )
         throws RepositoryIndexException
     {
index a2aeba0b39774d650dec420eeca57d3268d06123..f40700f116f3f1767f743dfbb3504aaf24db1749 100644 (file)
@@ -168,6 +168,12 @@ public class MinimalArtifactIndexRecordFactoryTest
         record = factory.createRecord( artifact );
 
         assertNull( "Check no record", record );
+
+        artifact = createArtifact( "test-skin", "1.0", "pom" );
+
+        record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
     }
 
     public void testIndexedPlugin()
index 42ea5756ac004c40334471d4f4c93a822407fd00..3a425ca61d8ae8e58c4d964c7c2197517a49edc5 100644 (file)
@@ -254,6 +254,12 @@ public class StandardArtifactIndexRecordFactoryTest
         record = factory.createRecord( artifact );
 
         assertNull( "Check no record", record );
+
+        artifact = createArtifact( "test-skin", "1.0", "pom" );
+
+        record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
     }
 
     public void testIndexedPlugin()
@@ -316,6 +322,34 @@ public class StandardArtifactIndexRecordFactoryTest
         assertEquals( "check record", expectedRecord, record );
     }
 
+    public void testIndexedSkin()
+        throws RepositoryIndexException, IOException, XmlPullParserException
+    {
+        Artifact artifact = createArtifact( "test-skin" );
+
+        RepositoryIndexRecord record = factory.createRecord( artifact );
+
+        StandardArtifactIndexRecord expectedRecord = new StandardArtifactIndexRecord();
+        expectedRecord.setMd5Checksum( "ba2d8a722f763db2950ad63119585f45" );
+        expectedRecord.setFilename( repository.pathOf( artifact ) );
+        expectedRecord.setLastModified( artifact.getFile().lastModified() );
+        expectedRecord.setSize( artifact.getFile().length() );
+        expectedRecord.setArtifactId( "test-skin" );
+        expectedRecord.setGroupId( TEST_GROUP_ID );
+        expectedRecord.setBaseVersion( "1.0" );
+        expectedRecord.setVersion( "1.0" );
+        expectedRecord.setSha1Checksum( "44855e3e56c18ce766db315a2d4c114d7a8c8ab0" );
+        expectedRecord.setType( "maven-skin" );
+        expectedRecord.setRepository( "test" );
+        expectedRecord.setFiles( Arrays.asList( new String[]{"META-INF/MANIFEST.MF", "css/maven-theme.css",
+            "META-INF/maven/org.apache.maven.skins/test-skin/pom.xml",
+            "META-INF/maven/org.apache.maven.skins/test-skin/pom.properties"} ) );
+        expectedRecord.setPackaging( "jar" );
+        expectedRecord.setProjectName( "Skin - test-skin" );
+
+        assertEquals( "check record", expectedRecord, record );
+    }
+
     public void testCorruptJar()
         throws RepositoryIndexException
     {
diff --git a/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar
new file mode 100644 (file)
index 0000000..99bd1e7
Binary files /dev/null and b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar differ
diff --git a/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.pom b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.pom
new file mode 100644 (file)
index 0000000..2055446
--- /dev/null
@@ -0,0 +1,8 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.archiva.record</groupId>
+  <artifactId>test-skin</artifactId>
+  <version>1.0</version>
+  <name>Skin - test-skin</name>
+</project>