]> source.dussan.org Git - archiva.git/commitdiff
[MRM-872]
authorMaria Odea B. Ching <oching@apache.org>
Thu, 10 Jul 2008 14:50:18 +0000 (14:50 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Thu, 10 Jul 2008 14:50:18 +0000 (14:50 +0000)
-added test case for repo group merged metadata request

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@675602 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java

index 0d52a68a02de35f23438487a920c7468e6d85df4..544f62b3c2c56854cfb3e2c051fc778883227275 100644 (file)
@@ -261,6 +261,9 @@ public class ArchivaDavResourceFactory
         if ( request.getRequestURI().endsWith( "metadata.xml" ) )
         {
             // TODO MRM-872 : must merge all available metadatas
+            // use RepositoryMetadataMerge for the merging of the versions 
+            // 
+            // Deng: I'll continue this tomorrow, everything is getting blurry now
         }
 
         DavResource resource = availableResources.get( 0 );
index 57453ea81633638202303f7f4152c517affacdfa..f06c73cd18c8cbe9befa0f2e86618682b8cd41f2 100644 (file)
@@ -217,6 +217,45 @@ public class RepositoryServletRepositoryGroupTest
         assertNotNull( "Should have received a response", response );
         assertEquals( "Should have been an 401 response code.", HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode() );
     }
+    
+    // MRM-872
+    public void testGetMergedMetadata()
+        throws Exception
+    {
+        // first metadata file
+        String resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";
+        
+        File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
+        dummyInternalResourceFile.getParentFile().mkdirs();
+        FileUtils.writeStringToFile( dummyInternalResourceFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                       "<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>" +
+                       "<versioning><latest>1.0</latest><release>1.0</release><versions><version>1.0</version>" +
+                       "<version>2.5</version><lastUpdated>20080708095554</lastUpdated></versioning></metadata>", null );
+        
+        //second metadata file
+        resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";        
+        dummyInternalResourceFile = new File( repoRootLast, resourceName );
+        dummyInternalResourceFile.getParentFile().mkdirs();
+        FileUtils.writeStringToFile( dummyInternalResourceFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>" +
+                "<versioning><latest>2.0</latest><release>2.0</release><versions><version>1.0</version>" +
+                "<version>1.5</version><version>2.0</version><lastUpdated>20080709095554</lastUpdated>" +
+                "</versioning></metadata>", null );
+        
+        WebRequest request =
+            new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" +
+                "dummy-merged-metadata-resource/maven-metadata.xml" );
+        WebResponse response = sc.getResource( request );
+        
+        String expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+            "<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>" +
+            "<versioning><latest>2.5</latest><versions><version>1.0</version>" +
+            "<version>1.5</version><version>2.0</version><version>2.5</version><lastUpdated>20080709095554</lastUpdated>" +
+            "</versioning></metadata>"; 
+                
+        //assertResponseOK( response );
+        //assertEquals( "Expected file contents", expectedString, response.getText() );
+    }
         
     protected void assertResponseMethodNotAllowed( WebResponse response )
     {