maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r687538 - in /maven/sandbox/trunk/mercury: mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/ mercury-md/mercury-md-shared/src/main/java/org/apache/mav...
Date Thu, 21 Aug 2008 02:20:51 GMT
Author: ogusakov
Date: Wed Aug 20 19:20:51 2008
New Revision: 687538

URL: http://svn.apache.org/viewvc?rev=687538&view=rev
Log:
local repo fully functioning, both reader and writer. LATEST, RELEASE, SNAPSHOT, SNAPSHOT_TS
implemented by http://docs.codehaus.org/display/MAVEN/Mercury+Repository+Abstraction#MercuryRepositoryAbstraction-Artifactversionsspecialtreatment

Added:
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/4/a-4.jar
  (with props)
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-20080807.234713-11.jar
  (with props)
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-SNAPSHOT.jar
  (with props)
Modified:
    maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java
    maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
    maven/sandbox/trunk/mercury/mercury-md/mercury-md-shared/src/main/java/org/apache/maven/mercury/repository/metadata/MetadataBuilder.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2Test.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2Test.java

Modified: maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ArtifactBasicMetadata.java
Wed Aug 20 19:20:51 2008
@@ -199,20 +199,23 @@
   {
     return version;
   }
-  public void setVersion(
-      String version )
+
+  public void setVersion( String version )
   {
     this.version = version;
   }
+  
   public String getClassifier()
   {
     return classifier;
   }
+  
   public void setClassifier(
       String classifier )
   {
     this.classifier = classifier;
   }
+  
   public String getType()
   {
     return type;

Modified: maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/DefaultArtifactVersion.java
Wed Aug 20 19:20:51 2008
@@ -207,7 +207,13 @@
         if( qualifier == null )
           base = version;
         else
-          base = version.substring( 0, version.indexOf( qualifier )-1 );
+        {
+          int ind = version.indexOf( qualifier );
+          if( ind == 0 )
+            base = qualifier;
+          else
+            base = version.substring( 0, version.indexOf( qualifier )-1 );
+        }
       }
   }
 

Modified: maven/sandbox/trunk/mercury/mercury-md/mercury-md-shared/src/main/java/org/apache/maven/mercury/repository/metadata/MetadataBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-md/mercury-md-shared/src/main/java/org/apache/maven/mercury/repository/metadata/MetadataBuilder.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-md/mercury-md-shared/src/main/java/org/apache/maven/mercury/repository/metadata/MetadataBuilder.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-md/mercury-md-shared/src/main/java/org/apache/maven/mercury/repository/metadata/MetadataBuilder.java
Wed Aug 20 19:20:51 2008
@@ -9,6 +9,7 @@
 import java.util.Date;
 import java.util.List;
 
+import org.apache.maven.mercury.artifact.Artifact;
 import org.apache.maven.mercury.repository.metadata.io.xpp3.MetadataXpp3Reader;
 import org.apache.maven.mercury.repository.metadata.io.xpp3.MetadataXpp3Writer;
 
@@ -196,4 +197,24 @@
       return fmt.format( date );
   }
   
+  public static Snapshot createSnapshot( String version )
+  {
+    Snapshot sn = new Snapshot();
+    
+    if( version == null || version.length() < 3 )
+      return sn;
+    
+    String utc = MetadataBuilder.getUTCTimestamp();
+    sn.setTimestamp( utc );
+    
+    if( version.endsWith( Artifact.SNAPSHOT_VERSION ))
+      return sn;
+    
+    String sbn = version.substring( version.lastIndexOf( '-' )+1 );
+    int    bn = Integer.parseInt( sbn ); 
+    sn.setBuildNumber( bn );
+    
+    return sn;
+  }
+  
 }

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
Wed Aug 20 19:20:51 2008
@@ -7,10 +7,12 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.maven.mercury.artifact.Artifact;
 import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
 import org.apache.maven.mercury.artifact.ArtifactMetadata;
 import org.apache.maven.mercury.artifact.DefaultArtifact;
 import org.apache.maven.mercury.artifact.Quality;
+import org.apache.maven.mercury.artifact.version.DefaultArtifactVersion;
 import org.apache.maven.mercury.artifact.version.VersionException;
 import org.apache.maven.mercury.artifact.version.VersionRange;
 import org.apache.maven.mercury.builder.api.MetadataProcessingException;
@@ -76,8 +78,117 @@
     for( ArtifactBasicMetadata bmd : query )
     {
       DefaultArtifact da = bmd instanceof DefaultArtifact ? (DefaultArtifact)bmd : new DefaultArtifact(
bmd );
+      
+      String version = bmd.getVersion();
+      DefaultArtifactVersion dav = new DefaultArtifactVersion( version );
+      Quality vq = dav.getQuality();
+      
+      String relGaPath = bmd.getGroupId().replace( '.', '/' ) + '/' + bmd.getArtifactId();
+      File   gaDir = new File( _repoDir, relGaPath );
+      
+      if( !gaDir.exists() )
+      {
+        res.add( new RepositoryException( _lang.getMessage( "ga.not.found", bmd.toString(),
relGaPath ) ) );
+        continue;
+      }
+      
+
+      File binary = null;
+      
+      // merge RELEASE and LATEST, should be no difference
+      if( Artifact.RELEASE_VERSION.equals( version )
+          ||
+          Artifact.LATEST_VERSION.equals( version ) 
+        )
+      {
+        boolean noSnapshots = Artifact.RELEASE_VERSION.equals( version );
+        version = null;
+        DefaultArtifactVersion tempDav = null;
+        DefaultArtifactVersion tempDav2 = null;
 
-      File binary = new File( _repoDir, relPathOf( bmd, null, null) );
+        File [] files = gaDir.listFiles();
+
+        // find latest
+        for( File vf : files )
+        {
+          if( vf.isFile() )
+            continue;
+          
+          String vn = vf.getName();
+          
+          // RELEASE?
+          if( noSnapshots && vn.endsWith( Artifact.SNAPSHOT_VERSION ))
+            continue;
+          
+          if( version == null )
+          {
+            version = vn;
+            tempDav = new DefaultArtifactVersion( vn );
+            continue;
+          }
+          
+          tempDav2 = new DefaultArtifactVersion( vn );
+          if( tempDav2.compareTo( tempDav ) > 0 )
+          {
+            version = vn;
+            tempDav = tempDav2;
+          }
+          
+        }
+
+        if( version == null )
+        {
+          res.add( new RepositoryException( _lang.getMessage( "gav.not.found", bmd.toString(),
relGaPath ) ) );
+          continue;
+        }
+        
+        // LATEST is a SNAPSHOT :(
+        if( version.endsWith( Artifact.SNAPSHOT_VERSION ) )
+        {
+          binary = findLatestSnapshot( new File( gaDir, version ), da, res );
+
+          if( binary == null )
+            continue;
+        }
+        else
+        {
+          binary = new File( gaDir, version+'/'+bmd.getArtifactId()+'-'+version+( bmd.hasClassifier()
? '-'+bmd.getClassifier() : "" )+'.'+bmd.getType() );
+          da.setVersion( version );
+        }
+      }
+      // regular snapshot requested
+      else if( version.endsWith( Artifact.SNAPSHOT_VERSION ) )
+      {
+        File gavDir = new File( gaDir, version );
+        if( !gavDir.exists() )
+        {
+          res.add( new RepositoryException( _lang.getMessage( "gavdir.not.found", bmd.toString(),
gavDir.getAbsolutePath() ) ) );
+          continue;
+        }
+        
+        binary = findLatestSnapshot( gavDir, da, res );
+        
+        if( binary == null )
+          continue;
+          
+      }
+      // time stamped snapshot requested
+      else if( vq.equals( Quality.SNAPSHOT_TS_QUALITY ))
+      {
+        binary = new File( gaDir,  dav.getBase()+'-'+Artifact.SNAPSHOT_VERSION 
+            + '/' + bmd.getArtifactId() + '-' + bmd.getVersion() + ( bmd.hasClassifier()
? '-'+bmd.getClassifier() : "" ) 
+            + '.' + bmd.getType()
+                          );
+      }
+      else
+      {
+        binary = new File( gaDir,  version 
+            + '/' + bmd.getArtifactId() + '-' + bmd.getVersion() + ( bmd.hasClassifier()
? '-'+bmd.getClassifier() : "" ) 
+            + '.' + bmd.getType()
+                          );
+      }
+      
+      // binary calculated 
       if( ! binary.exists() )
       {
         res.add( new RepositoryException( _lang.getMessage( "binary.not.found", bmd.toString(),
binary.getAbsolutePath() ) ) );
@@ -86,24 +197,27 @@
 
       da.setFile( binary );
       
-      File pomFile = new File( _repoDir, relPathOf( bmd, null, "pom") );
-      if( pomFile.exists() )
+      try // reading pom if one exists
       {
-        try
+        if( "pom".equals( bmd.getType() ) ) 
         {
-          da.setPomBlob( FileUtil.readRawData( pomFile ) );
+            da.setPomBlob( FileUtil.readRawData( binary ) );
         }
-        catch( Exception e )
+        else
         {
-          throw new RepositoryException( e );
+          File pomFile = new File( _repoDir, relPathOf( da, null, "pom", dav) );
+          if( pomFile.exists() )
+              da.setPomBlob( FileUtil.readRawData( pomFile ) );
+          else
+            _log.warn( _lang.getMessage( "pom.not.found", bmd.toString()) );
         }
+
+        res.add( da );
       }
-      else
+      catch( IOException e )
       {
-        _log.warn( _lang.getMessage( "pom.not.found", bmd.toString()) );
+        throw new RepositoryException( e );
       }
-
-      res.add( da );
     }
     return res;
   }
@@ -158,6 +272,75 @@
     return ror;
   }
   //---------------------------------------------------------------------------------------------------------------
+  private static File findLatestSnapshot( File gavDir, DefaultArtifact da, RepositoryOperationResult<DefaultArtifact>
res )
+  {
+      
+    String version = gavDir.getName();
+    DefaultArtifactVersion dav = new DefaultArtifactVersion( version );
+    
+    File binary = new File( gavDir, da.getArtifactId()+'-'+dav.getBase()+'-'+Artifact.SNAPSHOT_VERSION
+            +( da.hasClassifier() ? '-'+da.getClassifier() : "" )
+            +'.'+da.getType()
+    );
+    
+    // no real SNAPSHOT file, let's look for one
+    if( binary.exists() )
+    {
+      da.setVersion( dav.getBase()+'-'+Artifact.SNAPSHOT_VERSION );
+      return binary;
+    }
+
+    
+    File [] files = gavDir.listFiles();
+    version = null;
+    DefaultArtifactVersion tempDav = null;
+    DefaultArtifactVersion tempDav2 = null;
+    
+    int aLen = da.getArtifactId().length();
+    
+    // find latest
+    for( File vf : files )
+    {
+      if( vf.isFile() )
+        continue;
+      
+      String vn = vf.getName().substring( aLen+1 );
+      
+      // no snapshots
+      if( vn.endsWith( Artifact.SNAPSHOT_VERSION ))
+        continue;
+
+      if( version == null )
+      {
+        version = vn;
+        tempDav = new DefaultArtifactVersion( vn );
+        continue;
+      }
+      
+      tempDav2 = new DefaultArtifactVersion( vn );
+      if( tempDav2.compareTo( tempDav ) > 0 )
+      {
+        version = vn;
+        tempDav = tempDav2;
+      }
+    
+    }
+
+    if( version == null )
+    {
+      res.add( new RepositoryException( _lang.getMessage( "snapshot.not.found", da.toString(),
gavDir.getAbsolutePath() ) ) );
+      return null;
+    }
+    
+    binary = new File( gavDir, da.getArtifactId()+'-'+dav.getBase()+'-'+version
+                            + ( da.hasClassifier() ? '-'+da.getClassifier() : "" )
+                            + '.'+da.getType()
+                      );
+    da.setVersion( version );
+    
+    return binary;
+  }
+  //---------------------------------------------------------------------------------------------------------------
   /**
    * direct disk search, no redirects, first attempt
    */
@@ -224,14 +407,21 @@
   public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, String type )
   throws MetadataProcessingException
   {
-    return readRawData( relPathOf(bmd, classifier, type) );
+    return readRawData( relPathOf(bmd, classifier, type, null ) );
   }
   //---------------------------------------------------------------------------------------------------------------
-  private static String relPathOf( ArtifactBasicMetadata bmd, String classifier, String type
)
+  private static String relPathOf( ArtifactBasicMetadata bmd, String classifier, String type,
DefaultArtifactVersion inDav )
   {
-    String bmdPath = bmd.getGroupId().replace( '.', '/' )+"/"+bmd.getArtifactId()+"/"+bmd.getVersion();
+    DefaultArtifactVersion dav = inDav;
+    if( inDav == null )
+      dav = new DefaultArtifactVersion( bmd.getVersion() );
+    Quality aq = dav.getQuality();
+    boolean isSnapshot = aq.equals( Quality.SNAPSHOT_QUALITY ) || aq.equals( Quality.SNAPSHOT_TS_QUALITY
);
+    
+    String bmdPath = bmd.getGroupId().replace( '.', '/' )+'/'+bmd.getArtifactId()
+                +'/' + ( isSnapshot ? dav.getBase()+'-'+Artifact.SNAPSHOT_VERSION : bmd.getVersion()
);
     
-    String path = bmdPath+"/"+bmd.getBaseName(classifier)+'.' + (type == null ? bmd.getType()
: type );
+    String path = bmdPath+'/'+bmd.getBaseName(classifier)+'.' + (type == null ? bmd.getType()
: type );
     
     return path ;
   }

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
Wed Aug 20 19:20:51 2008
@@ -12,6 +12,9 @@
 import java.util.Set;
 
 import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.Quality;
+import org.apache.maven.mercury.artifact.version.DefaultArtifactVersion;
+import org.apache.maven.mercury.artifact.version.VersionQuery;
 import org.apache.maven.mercury.crypto.api.StreamObserver;
 import org.apache.maven.mercury.crypto.api.StreamObserverException;
 import org.apache.maven.mercury.crypto.api.StreamVerifier;
@@ -26,6 +29,10 @@
 import org.apache.maven.mercury.repository.metadata.Metadata;
 import org.apache.maven.mercury.repository.metadata.MetadataBuilder;
 import org.apache.maven.mercury.repository.metadata.MetadataException;
+import org.apache.maven.mercury.repository.metadata.MetadataOperation;
+import org.apache.maven.mercury.repository.metadata.SetSnapshotOperation;
+import org.apache.maven.mercury.repository.metadata.Snapshot;
+import org.apache.maven.mercury.repository.metadata.SnapshotOperand;
 import org.apache.maven.mercury.repository.metadata.StringOperand;
 import org.apache.maven.mercury.transport.api.Server;
 import org.apache.maven.mercury.util.FileUtil;
@@ -128,10 +135,12 @@
           throw new RepositoryException( e );
       }
     }
-
+    DefaultArtifactVersion dav = new DefaultArtifactVersion( artifact.getVersion() );
+    Quality aq = dav.getQuality();
+    boolean isSnapshot = aq.equals( Quality.SNAPSHOT_QUALITY ) || aq.equals( Quality.SNAPSHOT_TS_QUALITY
);
 
     String relGroupPath = artifact.getGroupId().replace( '.', '/' )+"/"+artifact.getArtifactId();
-    String relVersionPath = relGroupPath + '/' + artifact.getVersion();
+    String relVersionPath = relGroupPath + '/' + (isSnapshot ? (dav.getBase()+'-'+Artifact.SNAPSHOT_VERSION)
: artifact.getVersion() );
 
     try
     {
@@ -149,7 +158,11 @@
         }
           
       }
-      
+
+      // create folders
+      File gav = new File( _repoDir, relVersionPath );
+      gav.mkdirs();
+
       String fName = _repoDir.getAbsolutePath()+'/'+relVersionPath+'/'+artifact.getBaseName()+'.'+artifact.getType();
       
       if( !isPom )
@@ -160,26 +173,52 @@
         // if classier - nothing else to do :)
         if( artifact.hasClassifier() )
           return;
+        
+        // GA metadata
+        File mdFile = new File( _repoDir, relGroupPath+'/'+"maven-metadata-local.xml");
+        Metadata localMd = null;
+        
+        if( mdFile.exists() )
+          localMd = MetadataBuilder.read( new FileInputStream(mdFile) );
+        else
+        {
+          localMd = new Metadata();
+          localMd.setGroupId( artifact.getGroupId() );
+          localMd.setArtifactId( artifact.getArtifactId() );
+        }
+        
+        MetadataOperation mdOp = null;
+        
+        if( isSnapshot )
+        {
+          Snapshot sn = MetadataBuilder.createSnapshot( artifact.getVersion() );
+          sn.setLocalCopy( true );
+          mdOp = new SetSnapshotOperation( new SnapshotOperand(sn) );
+        }
+        else
+          mdOp = new AddVersionOperation( new StringOperand(artifact.getVersion()) ); 
+        
+        byte [] resBytes = MetadataBuilder.changeMetadata( localMd, mdOp );
+
+        FileUtil.writeRawData( mdFile, resBytes );
 
-        File groupMd = new File( _repoDir, relGroupPath+'/'+"maven-metadata.xml");
-        Metadata gmd = null;
+        // now - GAV metadata
+        mdFile = new File( _repoDir, relVersionPath+'/'+"maven-metadata-local.xml");
+        localMd = null;
         
-        if( groupMd.exists() )
-          gmd = MetadataBuilder.read( new FileInputStream(groupMd) );
+        if( mdFile.exists() )
+          localMd = MetadataBuilder.read( new FileInputStream(mdFile) );
         else
         {
-          gmd = new Metadata();
-          gmd.setGroupId( artifact.getGroupId() );
-          gmd.setArtifactId( artifact.getArtifactId() );
-          gmd.setVersion( artifact.getVersion() );
+          localMd = new Metadata();
+          localMd.setGroupId( artifact.getGroupId() );
+          localMd.setArtifactId( artifact.getArtifactId() );
+          localMd.setVersion( artifact.getVersion() );
         }
         
-        byte [] resBytes = MetadataBuilder.changeMetadata( 
-                        gmd
-                      , new AddVersionOperation( new StringOperand(artifact.getVersion())
) 
-                                                          );
+        resBytes = MetadataBuilder.changeMetadata( localMd, mdOp );
 
-        FileUtil.writeRawData( groupMd, resBytes );
+        FileUtil.writeRawData( mdFile, resBytes );
       }
       
       if( hasPomBlob )

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
Wed Aug 20 19:20:51 2008
@@ -1,6 +1,10 @@
 bad.repository.type=repository should implement LocalRepository, instead got {0}
 empty.query=received empty query - {0}
-binary.not.found=Artifact {0} binary at {1} not found 
+binary.not.found=Artifact {0} binary at not found {1} 
+ga.not.found=Artifact {0} version group not found at {1} 
+gav.not.found=No artifact version for {0} found in {1}
+snapshot.not.found=No snapshot version for {0} found in {1}
+gavdir.not.found=No directory {1} for artifact {0} 
 pom.not.found=Artifact {0} - binary exists, but POM not found in the repository 
 artifact.no.stream=Cannot find either input stream or file, associated with artifact {0}
 pom.artifact.no.stream=Cannot find either pom blob, input stream or file, associated with
artifact {0}
\ No newline at end of file

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2Test.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2Test.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2Test.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2Test.java
Wed Aug 20 19:20:51 2008
@@ -139,23 +139,121 @@
     assertNotNull( da.getFile() );
     assertTrue( da.getFile().exists() );
     assertNotNull( da.getPomBlob() );
+  }
+  //------------------------------------------------------------------------------
+  public void testReadSnapshot()
+  throws IllegalArgumentException, RepositoryException
+  {
+    bmd = new ArtifactBasicMetadata("a:a:5-SNAPSHOT");
+    query.add( bmd );
+
+    RepositoryOperationResult<DefaultArtifact> ror = reader.readArtifacts( query );
+    
+    assertNotNull( ror );
+    assertFalse( ror.hasExceptions() );
+    assertTrue( ror.hasResults() );
+    
+    List<DefaultArtifact> res = ror.getResults();
+    
+    assertNotNull( res );
+    assertEquals( 1, res.size() );
+    
+    DefaultArtifact da = res.get( 0 );
+    
+    assertNotNull( da );
+    assertNotNull( da.getFile() );
+    assertTrue( da.getFile().exists() );
+    assertEquals( 159630, da.getFile().length() );
+    assertNotNull( da.getPomBlob() );
     
-System.out.println(da.getPomBlob());
+System.out.println( new String(da.getPomBlob()) );
   }
   //------------------------------------------------------------------------------
-  public void testReadLatest()
+  public void testReadSnapshotTS()
+  throws IllegalArgumentException, RepositoryException
   {
-    // TODO
+    bmd = new ArtifactBasicMetadata("a:a:5-20080807.234713-11");
+    query.add( bmd );
+
+    RepositoryOperationResult<DefaultArtifact> ror = reader.readArtifacts( query );
+    
+    assertNotNull( ror );
+    assertFalse( ror.hasExceptions() );
+    assertTrue( ror.hasResults() );
+    
+    List<DefaultArtifact> res = ror.getResults();
+    
+    assertNotNull( res );
+    assertEquals( 1, res.size() );
+    
+    DefaultArtifact da = res.get( 0 );
+    
+    assertNotNull( da );
+    assertNotNull( da.getFile() );
+    assertTrue( da.getFile().exists() );
+    assertEquals( 14800, da.getFile().length() );
+    assertNotNull( da.getPomBlob() );
+    
+System.out.println( new String(da.getPomBlob()) );
   }
   //------------------------------------------------------------------------------
-  public void testReadSnapshot()
+  public void testReadLatest()
+  throws IllegalArgumentException, RepositoryException
   {
-    // TODO
+    bmd = new ArtifactBasicMetadata("a:a:LATEST");
+    query.add( bmd );
+
+    RepositoryOperationResult<DefaultArtifact> ror = reader.readArtifacts( query );
+    
+    assertNotNull( ror );
+    assertFalse( ror.hasExceptions() );
+    assertTrue( ror.hasResults() );
+    
+    List<DefaultArtifact> res = ror.getResults();
+    
+    assertNotNull( res );
+    assertEquals( 1, res.size() );
+    
+    DefaultArtifact da = res.get( 0 );
+    
+    assertNotNull( da );
+    assertEquals( "5-SNAPSHOT", da.getVersion() );
+    
+    assertNotNull( da.getFile() );
+    assertTrue( da.getFile().exists() );
+    assertEquals( 159630, da.getFile().length() );
+    assertNotNull( da.getPomBlob() );
+    
   }
   //------------------------------------------------------------------------------
-  public void testReadSnapshotTimeStamp()
+  public void testReadRelease()
+  throws IllegalArgumentException, RepositoryException
   {
-    // TODO
+    bmd = new ArtifactBasicMetadata("a:a:RELEASE");
+    query.add( bmd );
+
+    RepositoryOperationResult<DefaultArtifact> ror = reader.readArtifacts( query );
+    
+    assertNotNull( ror );
+    assertFalse( ror.hasExceptions() );
+    assertTrue( ror.hasResults() );
+    
+    List<DefaultArtifact> res = ror.getResults();
+    
+    assertNotNull( res );
+    assertEquals( 1, res.size() );
+    
+    DefaultArtifact da = res.get( 0 );
+    
+    assertNotNull( da );
+    assertEquals( "4", da.getVersion() );
+    
+    assertNotNull( da.getFile() );
+    assertTrue( da.getFile().exists() );
+    assertEquals( 14800, da.getFile().length() );
+    assertNotNull( da.getPomBlob() );
+    
+System.out.println( new String(da.getPomBlob()) );
   }
   //------------------------------------------------------------------------------
   //------------------------------------------------------------------------------

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2Test.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2Test.java?rev=687538&r1=687537&r2=687538&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2Test.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2Test.java
Wed Aug 20 19:20:51 2008
@@ -64,6 +64,7 @@
     query = new ArrayList<ArtifactBasicMetadata>();
     
     server = new Server( "test", repoFile.toURL() );
+    // verifiers
     factories = new HashSet<StreamVerifierFactory>();       
     factories.add( 
         new PgpStreamVerifierFactory(
@@ -79,10 +80,8 @@
     repo = new LocalRepositoryM2( server );
     reader = repo.getReader( mdProcessor );
     writer = repo.getWriter();
-    
-      
   }
-    
+  
   public void testWriteArtifact()
   throws Exception
   {
@@ -100,10 +99,47 @@
     
     File ap = new File( repo.getDirectory(), "/org/apache/maven/maven-core/2.0.9/maven-core-2.0.9.pom");
     assertTrue( ap.exists() );
-    assertEquals( 7785, ap.length() );
+    assertEquals( 7785, ap.length() );  
+  }
+  
+  public void testWriteSnapshotAsTS()
+  throws Exception
+  {
+    Set<Artifact> set = new HashSet<Artifact>(3);
+    DefaultArtifact da = new DefaultArtifact( new ArtifactBasicMetadata("org.apache.maven:maven-core:2.0.9-20080805.215925-8")
);
+    da.setPomBlob( FileUtil.readRawData( getClass().getResourceAsStream( "/maven-core-2.0.9.pom"
) ) );
+    da.setStream( getClass().getResourceAsStream( "/maven-core-2.0.9.jar" ) );
+    set.add( da );
+    
+    writer.writeArtifact( set );
+    
+    File af = new File( repo.getDirectory(), "/org/apache/maven/maven-core/2.0.9-SNAPSHOT/maven-core-2.0.9-20080805.215925-8.jar");
+    assertTrue( af.exists() );
+    assertEquals( 159630, af.length() );
+    
+    File ap = new File( repo.getDirectory(), "/org/apache/maven/maven-core/2.0.9-SNAPSHOT/maven-core-2.0.9-20080805.215925-8.pom");
+    assertTrue( ap.exists() );
+    assertEquals( 7785, ap.length() );  
+  }
+  
+  public void testWriteSnapshot()
+  throws Exception
+  {
+    Set<Artifact> set = new HashSet<Artifact>(3);
+    DefaultArtifact da = new DefaultArtifact( new ArtifactBasicMetadata("org.apache.maven:maven-core:2.0.9-SNAPSHOT")
);
+    da.setPomBlob( FileUtil.readRawData( getClass().getResourceAsStream( "/maven-core-2.0.9.pom"
) ) );
+    da.setStream( getClass().getResourceAsStream( "/maven-core-2.0.9.jar" ) );
+    set.add( da );
+    
+    writer.writeArtifact( set );
     
+    File af = new File( repo.getDirectory(), "/org/apache/maven/maven-core/2.0.9-SNAPSHOT/maven-core-2.0.9-SNAPSHOT.jar");
+    assertTrue( af.exists() );
+    assertEquals( 159630, af.length() );
     
+    File ap = new File( repo.getDirectory(), "/org/apache/maven/maven-core/2.0.9-SNAPSHOT/maven-core-2.0.9-SNAPSHOT.pom");
+    assertTrue( ap.exists() );
+    assertEquals( 7785, ap.length() );  
   }
-
   
 }

Added: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/4/a-4.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/4/a-4.jar?rev=687538&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/4/a-4.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-20080807.234713-11.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-20080807.234713-11.jar?rev=687538&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-20080807.234713-11.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-SNAPSHOT.jar?rev=687538&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/test/resources/repo/a/a/5-SNAPSHOT/a-5-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message