You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/02/29 20:05:25 UTC

[maven] 02/02: Revert tests with unneeded changes

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

rfscholte pushed a commit to branch MNG-6656
in repository https://gitbox.apache.org/repos/asf/maven.git

commit a94e2d15c6e590cc008c8551d1e9ee4e44a250c9
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Feb 29 21:05:12 2020 +0100

    Revert tests with unneeded changes
---
 .../apache/maven/project/ProjectBuilderTest.java   | 24 ++++++++++++----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
index 4833b00..6c7fbf9 100644
--- a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
@@ -26,6 +26,8 @@ import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
 import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -39,7 +41,6 @@ import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.model.building.ModelSource;
 import org.apache.maven.shared.utils.io.FileUtils;
 
-import com.google.common.io.Files;
 
 public class ProjectBuilderTest
     extends AbstractCoreMavenComponentTestCase
@@ -142,22 +143,23 @@ public class ProjectBuilderTest
         String initialValue = System.setProperty( DefaultProjectBuilder.DISABLE_GLOBAL_MODEL_CACHE_SYSTEM_PROPERTY, Boolean.toString( true ) );
         // TODO a similar test should be created to test the dependency management (basically all usages
         // of DefaultModelBuilder.getCache() are affected by MNG-6530
-        File tempDir = Files.createTempDir();
-        FileUtils.copyDirectoryStructure (new File( "src/test/resources/projects/grandchild-check"), tempDir );
+
+        Path tempDir = Files.createTempDirectory( null );
+        FileUtils.copyDirectoryStructure ( new File( "src/test/resources/projects/grandchild-check" ), tempDir.toFile() );
         try
         {
             MavenSession mavenSession = createMavenSession( null );
             ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
             configuration.setRepositorySession( mavenSession.getRepositorySession() );
             org.apache.maven.project.ProjectBuilder projectBuilder = lookup( org.apache.maven.project.ProjectBuilder.class );
-            File child = new File( tempDir, "child/pom.xml" );
+            File child = new File( tempDir.toFile(), "child/pom.xml" );
             // build project once
             projectBuilder.build( child, configuration );
             // modify parent
-            File parent = new File( tempDir, "pom.xml" );
+            File parent = new File( tempDir.toFile(), "pom.xml" );
             String parentContent = FileUtils.fileRead( parent );
             parentContent = parentContent.replaceAll( "<packaging>pom</packaging>",
-            		"<packaging>pom</packaging><properties><addedProperty>addedValue</addedProperty></properties>" );
+                    "<packaging>pom</packaging><properties><addedProperty>addedValue</addedProperty></properties>" );
             FileUtils.fileWrite( parent, "UTF-8", parentContent );
             // re-build pom with modified parent
             ProjectBuildingResult result = projectBuilder.build( child, configuration );
@@ -173,7 +175,7 @@ public class ProjectBuilderTest
             {
                 System.setProperty( DefaultProjectBuilder.DISABLE_GLOBAL_MODEL_CACHE_SYSTEM_PROPERTY, initialValue );
             }
-            FileUtils.deleteDirectory( tempDir );
+            FileUtils.deleteDirectory( tempDir.toFile() );
         }
     }
 
@@ -303,7 +305,7 @@ public class ProjectBuilderTest
         return null;
     }
 
-    private void assertResultShowNoError(List<ProjectBuildingResult> results)
+    private void assertResultShowNoError( List<ProjectBuildingResult> results )
     {
         for ( ProjectBuildingResult result : results )
         {
@@ -320,12 +322,12 @@ public class ProjectBuilderTest
         ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
         configuration.setRepositorySession( mavenSession.getRepositorySession() );
         configuration.setResolveDependencies( true );
-        List<ProjectBuildingResult> result = projectBuilder.build( Collections.singletonList(file), true, configuration );
-        MavenProject project = result.get(0).getProject();
+        List<ProjectBuildingResult> result = projectBuilder.build( Collections.singletonList( file ), true, configuration );
+        MavenProject project = result.get( 0 ).getProject();
         // verify a few typical parameters are not duplicated
         assertEquals( 1, project.getTestCompileSourceRoots().size() );
         assertEquals( 1, project.getCompileSourceRoots().size() );
         assertEquals( 1, project.getMailingLists().size() );
         assertEquals( 1, project.getResources().size() );
     }
-}
+}
\ No newline at end of file