You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/10/04 11:55:18 UTC

[maven-stage-plugin] branch test created (now e6db4f0)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a change to branch test
in repository https://gitbox.apache.org/repos/asf/maven-stage-plugin.git.


      at e6db4f0  use Java 7 file handling in test

This branch includes the following new commits:

     new e6db4f0  use Java 7 file handling in test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-stage-plugin] 01/01: use Java 7 file handling in test

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/maven-stage-plugin.git

commit e6db4f046246fd46b0ed66ff3756305f861c580e
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sun Oct 4 07:55:05 2020 -0400

    use Java 7 file handling in test
---
 .../maven/plugins/stage/RepositoryCopierTest.java  | 56 +++++++++++-----------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java b/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java
index 61a4ec7..410c477 100644
--- a/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java
+++ b/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java
@@ -20,14 +20,16 @@ package org.apache.maven.plugins.stage;
  */
 
 import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.apache.commons.io.FileUtils;
 import org.apache.maven.artifact.repository.metadata.Metadata;
 import org.apache.maven.wagon.repository.Repository;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.Reader;
-import java.io.FileReader;
+import java.nio.charset.StandardCharsets;
+import java.io.InputStreamReader;
 import java.util.List;
 
 /** @author Jason van Zyl */
@@ -47,9 +49,7 @@ public class RepositoryCopierTest
 
         File targetRepo = new File( getBasedir(), "target/target-repository" );
 
-        System.out.println( "Copying target stage for tests ..." );
-
-        FileUtils.copyDirectoryStructure( targetRepoSource, targetRepo );
+        FileUtils.copyDirectory( targetRepoSource, targetRepo );
 
         File stagingRepo = new File( getBasedir(), "src/test/staging-repository" );
 
@@ -103,28 +103,28 @@ public class RepositoryCopierTest
 
         assertTrue( versionDir.exists() );
 
-        Reader r = new FileReader( new File( basedir, RepositoryCopier.MAVEN_METADATA) );
-
-        Metadata metadata = reader.read( r );
-
-        // Make sure our new versions has been setup as the release.
-        assertEquals( version, metadata.getVersioning().getRelease() );
-
-        assertEquals( "20070327020553", metadata.getVersioning().getLastUpdated() );
-
-        // Make sure we didn't whack old versions.
-        List versions = metadata.getVersioning().getVersions();
-
-        assertTrue( versions.contains( "2.0.1" ) );
-
-        assertTrue( versions.contains( "2.0.2" ) );
-
-        assertTrue( versions.contains( "2.0.3" ) );
-        
-        assertTrue( versions.contains( "2.0.4" ) );
-
-        assertTrue( versions.contains( "2.0.5" ) );
-
-        r.close();
+        File file = new File( basedir, RepositoryCopier.MAVEN_METADATA);
+        try ( Reader r = new InputStreamReader ( new FileInputStream( file ), StandardCharsets.UTF_8 ) )
+        {
+            Metadata metadata = reader.read( r );
+    
+            // Make sure our new version has been setup as the release.
+            assertEquals( version, metadata.getVersioning().getRelease() );
+    
+            assertEquals( "20070327020553", metadata.getVersioning().getLastUpdated() );
+    
+            // Make sure we didn't whack old versions.
+            List<String> versions = metadata.getVersioning().getVersions();
+    
+            assertTrue( versions.contains( "2.0.1" ) );
+    
+            assertTrue( versions.contains( "2.0.2" ) );
+    
+            assertTrue( versions.contains( "2.0.3" ) );
+            
+            assertTrue( versions.contains( "2.0.4" ) );
+    
+            assertTrue( versions.contains( "2.0.5" ) );
+        }
     }
 }