maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r372763 - in /maven/repository-manager/trunk/maven-repository-converter/src: main/java/org/apache/maven/repository/converter/ test/java/org/apache/maven/repository/converter/ test/resources/org/apache/maven/repository/converter/
Date Fri, 27 Jan 2006 05:58:03 GMT
Author: brett
Date: Thu Jan 26 21:57:54 2006
New Revision: 372763

URL: http://svn.apache.org/viewcvs?rev=372763&view=rev
Log:
[MRM-9] dry run tests

Modified:
    maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
    maven/repository-manager/trunk/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
    maven/repository-manager/trunk/maven-repository-converter/src/test/resources/org/apache/maven/repository/converter/RepositoryConverterTest.xml

Modified: maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java?rev=372763&r1=372762&r2=372763&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
(original)
+++ maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
Thu Jan 26 21:57:54 2006
@@ -167,7 +167,7 @@
             metadata = newMetadata;
         }
 
-        if ( changed )
+        if ( changed && !dryrun )
         {
             Writer writer = null;
             try

Modified: maven/repository-manager/trunk/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java?rev=372763&r1=372762&r2=372763&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
(original)
+++ maven/repository-manager/trunk/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
Thu Jan 26 21:57:54 2006
@@ -583,13 +583,52 @@
 
         assertFalse( "Check target file doesn't exist", targetFile.exists() );
         assertFalse( "Check target POM doesn't exist", targetPomFile.exists() );
+
+        ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
+        File metadataFile =
+            new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata(
metadata ) );
+        assertFalse( "Check metadata not created", metadataFile.exists() );
     }
 
     public void testDryRunFailure()
+        throws Exception
     {
         // test dry run does nothing on a run that will fail, and returns failure
 
-        // TODO
+        repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "dryrun-repository-converter"
);
+
+        Artifact artifact = createArtifact( "test", "modified-artifact", "1.0.0" );
+        Artifact pomArtifact = createPomArtifact( artifact );
+
+        File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf(
artifact ) );
+        File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf(
pomArtifact ) );
+        File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf(
artifact ) );
+        File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf(
pomArtifact ) );
+
+        assertTrue( "Check target file exists", targetFile.exists() );
+        assertTrue( "Check target POM exists", targetPomFile.exists() );
+
+        sourceFile.setLastModified( System.currentTimeMillis() );
+        sourcePomFile.setLastModified( System.currentTimeMillis() );
+
+        long origTime = targetFile.lastModified();
+        long origPomTime = targetPomFile.lastModified();
+
+        // Need to guarantee last modified is not equal
+        Thread.sleep( SLEEP_MILLIS );
+
+        repositoryConverter.convert( artifact, targetRepository, reporter );
+        checkFailure();
+        assertEquals( "Check failure message", getI18nString( "failure.target.already.exists"
),
+                      getFailure().getReason() );
+
+        assertEquals( "Check unmodified", origTime, targetFile.lastModified() );
+        assertEquals( "Check unmodified", origPomTime, targetPomFile.lastModified() );
+
+        ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
+        File metadataFile =
+            new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata(
metadata ) );
+        assertFalse( "Check metadata not created", metadataFile.exists() );
     }
 
     public void testRollbackArtifactCreated()

Modified: maven/repository-manager/trunk/maven-repository-converter/src/test/resources/org/apache/maven/repository/converter/RepositoryConverterTest.xml
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-converter/src/test/resources/org/apache/maven/repository/converter/RepositoryConverterTest.xml?rev=372763&r1=372762&r2=372763&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-converter/src/test/resources/org/apache/maven/repository/converter/RepositoryConverterTest.xml
(original)
+++ maven/repository-manager/trunk/maven-repository-converter/src/test/resources/org/apache/maven/repository/converter/RepositoryConverterTest.xml
Thu Jan 26 21:57:54 2006
@@ -25,6 +25,10 @@
       </configuration>
       <requirements>
         <requirement>
+          <role>org.apache.maven.repository.digest.Digester</role>
+          <field-name>digester</field-name>
+        </requirement>
+        <requirement>
           <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
           <field-name>artifactFactory</field-name>
         </requirement>
@@ -32,6 +36,10 @@
           <role>org.apache.maven.model.converter.ArtifactPomRewriter</role>
           <field-name>rewriter</field-name>
         </requirement>
+        <requirement>
+          <role>org.codehaus.plexus.i18n.I18N</role>
+          <field-name>i18n</field-name>
+        </requirement>
       </requirements>
     </component>
     <component>
@@ -43,12 +51,20 @@
       </configuration>
       <requirements>
         <requirement>
+          <role>org.apache.maven.repository.digest.Digester</role>
+          <field-name>digester</field-name>
+        </requirement>
+        <requirement>
           <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
           <field-name>artifactFactory</field-name>
         </requirement>
         <requirement>
           <role>org.apache.maven.model.converter.ArtifactPomRewriter</role>
           <field-name>rewriter</field-name>
+        </requirement>
+        <requirement>
+          <role>org.codehaus.plexus.i18n.I18N</role>
+          <field-name>i18n</field-name>
         </requirement>
       </requirements>
     </component>



Mime
View raw message