Cleaned up test fixture to use dedicated local repository

Project: http://git-wip-us.apache.org/repos/asf/maven-aether/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-aether/commit/21f9e1be
Tree: http://git-wip-us.apache.org/repos/asf/maven-aether/tree/21f9e1be
Diff: http://git-wip-us.apache.org/repos/asf/maven-aether/diff/21f9e1be

Branch: refs/heads/ant-tasks
Commit: 21f9e1be20e9d4966bc16f2f869d72aa910d665a
Parents: b25ac6c
Author: Benjamin Bentmann <bentm...@sonatype.com>
Authored: Thu Jan 2 16:38:00 2014 +0100
Committer: Benjamin Bentmann <bentm...@sonatype.com>
Committed: Thu Jan 2 16:38:00 2014 +0100

----------------------------------------------------------------------
 build.xml                                       |  4 +-
 src/test/ant/Resolve.xml                        |  4 +-
 .../org/eclipse/aether/ant/AntBuildsTest.java   | 78 ++++----------------
 .../java/org/eclipse/aether/ant/DeployTest.java | 30 +++-----
 .../org/eclipse/aether/ant/InstallTest.java     | 28 ++-----
 .../org/eclipse/aether/ant/ReactorTest.java     | 10 +--
 .../org/eclipse/aether/ant/ResolveTest.java     | 14 +---
 7 files changed, 38 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index f9f08ea..d90fc93 100644
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
- ~ Copyright (c) 2010, 2011 Sonatype, Inc.
+ ~ Copyright (c) 2010, 2014 Sonatype, Inc.
  ~ All rights reserved. This program and the accompanying materials
  ~ are made available under the terms of the Eclipse Public License v1.0
  ~ which accompanies this distribution, and is available at
@@ -25,7 +25,7 @@
     </classpath>
   </taskdef>
 
-  <property name="build.dir" location="target/ant"/>
+  <property name="build.dir" location="target/its"/>
 
   <aether:localrepo dir="${build.dir}/local-repo"/>
 

http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/src/test/ant/Resolve.xml
----------------------------------------------------------------------
diff --git a/src/test/ant/Resolve.xml b/src/test/ant/Resolve.xml
index 2b4d05a..177b1f1 100644
--- a/src/test/ant/Resolve.xml
+++ b/src/test/ant/Resolve.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
- ~ Copyright (c) 2010, 2011 Sonatype, Inc.
+ ~ Copyright (c) 2010, 2014 Sonatype, Inc.
  ~ All rights reserved. This program and the accompanying materials
  ~ are made available under the terms of the Eclipse Public License v1.0
  ~ which accompanies this distribution, and is available at
@@ -46,7 +46,7 @@
   </target>
 
   <target name="testResolveGlobalPomIntoOtherLocalRepo">
-    <repo:localrepo dir="${build.dir}/resolvetest-local-repo"/>
+    <repo:localrepo dir="${build.dir}/local-repo-custom"/>
     <repo:pom file="${project.dir}/pom.xml"/>
     <repo:resolve>
       <properties prefix="test.resolve.path" classpath="compile"/>

http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/src/test/java/org/eclipse/aether/ant/AntBuildsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/eclipse/aether/ant/AntBuildsTest.java 
b/src/test/java/org/eclipse/aether/ant/AntBuildsTest.java
index f7fa766..6de1e26 100644
--- a/src/test/java/org/eclipse/aether/ant/AntBuildsTest.java
+++ b/src/test/java/org/eclipse/aether/ant/AntBuildsTest.java
@@ -1,5 +1,5 @@
 
/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -13,66 +13,41 @@ package org.eclipse.aether.ant;
 import java.io.File;
 import java.io.PrintStream;
 
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.DefaultSettingsBuilderFactory;
-import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
-import org.apache.maven.settings.building.SettingsBuilder;
-import org.apache.maven.settings.building.SettingsBuildingException;
-import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
-import org.apache.maven.settings.crypto.SettingsDecrypter;
-import org.apache.maven.settings.crypto.SettingsDecryptionResult;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildFileTest;
 import org.apache.tools.ant.DefaultLogger;
-import org.eclipse.aether.ant.AntSettingsDecryptorFactory;
-import org.eclipse.aether.internal.test.util.TestFileProcessor;
+import org.eclipse.aether.internal.test.util.TestFileUtils;
 
 public abstract class AntBuildsTest
     extends BuildFileTest
 {
-    private static final SettingsBuilder settingsBuilder = new 
DefaultSettingsBuilderFactory().newInstance();
 
-    private static final SettingsDecrypter settingsDecrypter = new 
AntSettingsDecryptorFactory().newInstance();
-
-    private static final String SETTINGS_XML = "settings.xml";
+    private static final File BASE_DIR;
 
     protected static final File BUILD_DIR;
 
     static
     {
-        File baseDir = new File( "." ).getAbsoluteFile();
-        File projectDir = new File( baseDir, "src/test/ant" );
-        BUILD_DIR = new File( baseDir, "target/surefire" );
-        System.setProperty( "project.dir", projectDir.getAbsolutePath() );
-        System.setProperty( "build.dir", BUILD_DIR.getAbsolutePath() );
+        BASE_DIR = new File( "." ).getAbsoluteFile();
+        BUILD_DIR = new File( BASE_DIR, "target/ant" );
     }
 
-    protected TestFileProcessor fp;
-
-    protected File defaultLocalRepository;
+    protected File localRepoDir;
 
     @Override
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        this.fp = new TestFileProcessor();
 
+        TestFileUtils.deleteFile( BUILD_DIR );
 
-        Settings settings = getSettings();
-        String mavenRepoProperty = System.getProperty( "maven.repo.local" );
-        if ( mavenRepoProperty != null )
-        {
-            defaultLocalRepository = new File( mavenRepoProperty );
-        }
-        else if ( settings.getLocalRepository() != null )
-        {
-            defaultLocalRepository = new File( settings.getLocalRepository() );
-        }
-        else
-        {
-            defaultLocalRepository = new File( System.getProperty( "user.home" 
), ".m2/repository" );
-        }
+        File projectDir = new File( BASE_DIR, "src/test/ant" );
+        localRepoDir = new File( BUILD_DIR, "local-repo" );
+
+        System.setProperty( "project.dir", projectDir.getAbsolutePath() );
+        System.setProperty( "build.dir", BUILD_DIR.getAbsolutePath() );
+        System.setProperty( "maven.repo.local", localRepoDir.getAbsolutePath() 
);
     }
 
     @Override
@@ -82,6 +57,7 @@ public abstract class AntBuildsTest
         try
         {
             ProjectWorkspaceReader.dropInstance();
+            TestFileUtils.deleteFile( BUILD_DIR );
         }
         finally
         {
@@ -109,30 +85,4 @@ public abstract class AntBuildsTest
         getProject().addBuildListener( logger );
     }
 
-    protected synchronized Settings getSettings()
-        throws SettingsBuildingException
-    {
-        DefaultSettingsBuildingRequest request = new 
DefaultSettingsBuildingRequest();
-        request.setUserSettingsFile( getUserSettings() );
-
-        Settings settings = settingsBuilder.build( request 
).getEffectiveSettings();
-        SettingsDecryptionResult result = settingsDecrypter.decrypt( new 
DefaultSettingsDecryptionRequest( settings ) );
-        settings.setServers( result.getServers() );
-        settings.setProxies( result.getProxies() );
-        return settings;
-    }
-
-    protected File getUserSettings()
-    {
-        File userHome = new File( System.getProperty( "user.home" ) );
-        File file = new File( new File( userHome, ".ant" ), SETTINGS_XML );
-        if ( file.isFile() )
-        {
-            return file;
-        }
-        else
-        {
-            return new File( new File( userHome, ".m2" ), SETTINGS_XML );
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/src/test/java/org/eclipse/aether/ant/DeployTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/eclipse/aether/ant/DeployTest.java 
b/src/test/java/org/eclipse/aether/ant/DeployTest.java
index 5a57dc4..e404a1f 100644
--- a/src/test/java/org/eclipse/aether/ant/DeployTest.java
+++ b/src/test/java/org/eclipse/aether/ant/DeployTest.java
@@ -1,5 +1,5 @@
 
/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,8 +16,6 @@ import static org.hamcrest.Matchers.*;
 import java.io.File;
 import java.util.Arrays;
 
-import org.eclipse.aether.internal.test.util.TestFileUtils;
-
 /*
  * still missing:
  * - deploy snapshots/releases into correct repos
@@ -26,28 +24,18 @@ public class DeployTest
     extends AntBuildsTest
 {
 
-    private File distRepoPath;
+    private File distRepoDir;
 
     @Override
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        distRepoPath = new File( "target/dist-repo" );
-        System.setProperty( "project.distrepo.url", 
distRepoPath.toURI().toString() );
-        TestFileUtils.deleteFile( distRepoPath );
-
+        distRepoDir = new File( BUILD_DIR, "dist-repo" );
+        System.setProperty( "project.distrepo.url", 
distRepoDir.toURI().toString() );
         configureProject( "src/test/ant/Deploy.xml" );
     }
 
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        TestFileUtils.deleteFile( distRepoPath );
-    }
-
     public void testDeployGlobalPom()
     {
         executeTarget( "testDeployGlobalPom" );
@@ -55,7 +43,7 @@ public class DeployTest
 
         assertLogContaining( "Uploading" );
         
-        assertUpdatedFile( tstamp, distRepoPath, 
"test/test/0.1-SNAPSHOT/maven-metadata.xml" );
+        assertUpdatedFile( tstamp, distRepoDir, 
"test/test/0.1-SNAPSHOT/maven-metadata.xml" );
     }
 
     public void testDeployOverrideGlobalPom()
@@ -65,7 +53,7 @@ public class DeployTest
 
         assertLogContaining( "Uploading" );
 
-        assertUpdatedFile( tstamp, distRepoPath, 
"test/other/0.1-SNAPSHOT/maven-metadata.xml" );
+        assertUpdatedFile( tstamp, distRepoDir, 
"test/other/0.1-SNAPSHOT/maven-metadata.xml" );
     }
 
     public void testDeployOverrideGlobalPomByRef()
@@ -75,8 +63,8 @@ public class DeployTest
 
         assertLogContaining( "Uploading" );
 
-        assertUpdatedFile( tstamp, distRepoPath, 
"test/test/0.1-SNAPSHOT/maven-metadata.xml" );
-        assertUpdatedFile( tstamp, distRepoPath, 
"test/other/0.1-SNAPSHOT/maven-metadata.xml" );
+        assertUpdatedFile( tstamp, distRepoDir, 
"test/test/0.1-SNAPSHOT/maven-metadata.xml" );
+        assertUpdatedFile( tstamp, distRepoDir, 
"test/other/0.1-SNAPSHOT/maven-metadata.xml" );
     }
 
     public void testDeployAttachedArtifact()
@@ -85,7 +73,7 @@ public class DeployTest
 
         assertLogContaining( "Uploading" );
 
-        File dir = new File(distRepoPath, "test/test/0.1-SNAPSHOT/" );
+        File dir = new File(distRepoDir, "test/test/0.1-SNAPSHOT/" );
         String[] files = dir.list();
         assertThat( "attached artifact not found: " + Arrays.toString( files 
), files,
                     hasItemInArray( endsWith( "-ant.xml" ) ) );

http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/src/test/java/org/eclipse/aether/ant/InstallTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/eclipse/aether/ant/InstallTest.java 
b/src/test/java/org/eclipse/aether/ant/InstallTest.java
index 18dda11..c375c54 100644
--- a/src/test/java/org/eclipse/aether/ant/InstallTest.java
+++ b/src/test/java/org/eclipse/aether/ant/InstallTest.java
@@ -1,5 +1,5 @@
 
/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,8 +16,6 @@ import static org.hamcrest.Matchers.*;
 import java.io.File;
 import java.io.IOException;
 
-import org.eclipse.aether.internal.test.util.TestFileUtils;
-
 public class InstallTest
     extends AntBuildsTest
 {
@@ -27,19 +25,9 @@ public class InstallTest
         throws Exception
     {
         super.setUp();
-        TestFileUtils.deleteFile( new File( defaultLocalRepository, "test" ) );
-
         configureProject( "src/test/ant/Install.xml" );
     }
 
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        TestFileUtils.deleteFile( new File( defaultLocalRepository, "test" ) );
-    }
-
     public void testInstallGlobalPom()
     {
         executeTarget( "testInstallGlobalPom" );
@@ -47,7 +35,7 @@ public class InstallTest
 
         assertLogContaining( "Installing" );
         
-        assertUpdatedFile( tstamp, defaultLocalRepository, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
+        assertUpdatedFile( tstamp, localRepoDir, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
     }
 
     public void testInstallOverrideGlobalPom()
@@ -57,7 +45,7 @@ public class InstallTest
 
         assertLogContaining( "Installing" );
 
-        assertUpdatedFile( tstamp, defaultLocalRepository, 
"test/other/0.1-SNAPSHOT/other-0.1-SNAPSHOT.pom" );
+        assertUpdatedFile( tstamp, localRepoDir, 
"test/other/0.1-SNAPSHOT/other-0.1-SNAPSHOT.pom" );
     }
 
     public void testInstallOverrideGlobalPomByRef()
@@ -67,8 +55,8 @@ public class InstallTest
 
         assertLogContaining( "Installing" );
 
-        assertUpdatedFile( tstamp, defaultLocalRepository, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
-        assertUpdatedFile( tstamp, defaultLocalRepository, 
"test/other/0.1-SNAPSHOT/other-0.1-SNAPSHOT.pom" );
+        assertUpdatedFile( tstamp, localRepoDir, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
+        assertUpdatedFile( tstamp, localRepoDir, 
"test/other/0.1-SNAPSHOT/other-0.1-SNAPSHOT.pom" );
     }
 
     public void testDefaultRepo()
@@ -78,15 +66,14 @@ public class InstallTest
 
         assertLogContaining( "Installing" );
 
-        assertUpdatedFile( tstamp, defaultLocalRepository, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
-        assertUpdatedFile( tstamp, defaultLocalRepository, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-ant.xml" );
+        assertUpdatedFile( tstamp, localRepoDir, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
+        assertUpdatedFile( tstamp, localRepoDir, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-ant.xml" );
     }
 
     public void testCustomRepo()
         throws IOException
     {
         File repoPath = new File( BUILD_DIR, "local-repo-custom" );
-        TestFileUtils.deleteFile( repoPath );
 
         executeTarget( "testCustomRepo" );
         long tstamp = System.currentTimeMillis();
@@ -96,7 +83,6 @@ public class InstallTest
 
         assertUpdatedFile( tstamp, repoPath, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.pom" );
         assertUpdatedFile( tstamp, repoPath, 
"test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-ant.xml" );
-        TestFileUtils.deleteFile( repoPath );
     }
 
     private void assertUpdatedFile( long tstamp, File repoPath, String path )

http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/src/test/java/org/eclipse/aether/ant/ReactorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/eclipse/aether/ant/ReactorTest.java 
b/src/test/java/org/eclipse/aether/ant/ReactorTest.java
index e95adf9..f8483af 100644
--- a/src/test/java/org/eclipse/aether/ant/ReactorTest.java
+++ b/src/test/java/org/eclipse/aether/ant/ReactorTest.java
@@ -1,5 +1,5 @@
 
/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -33,14 +33,6 @@ public class ReactorTest
         configureProject( "src/test/ant/Reactor.xml", Project.MSG_VERBOSE );
     }
 
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        ProjectWorkspaceReader.dropInstance();
-    }
-
     private Artifact artifact( String coords )
     {
         return new DefaultArtifact( coords );

http://git-wip-us.apache.org/repos/asf/maven-aether/blob/21f9e1be/src/test/java/org/eclipse/aether/ant/ResolveTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/eclipse/aether/ant/ResolveTest.java 
b/src/test/java/org/eclipse/aether/ant/ResolveTest.java
index 406abd7..2946f4c 100644
--- a/src/test/java/org/eclipse/aether/ant/ResolveTest.java
+++ b/src/test/java/org/eclipse/aether/ant/ResolveTest.java
@@ -1,5 +1,5 @@
 
/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -20,7 +20,6 @@ import java.util.Map;
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
-import org.eclipse.aether.internal.test.util.TestFileUtils;
 
 public class ResolveTest
     extends AntBuildsTest
@@ -60,28 +59,24 @@ public class ResolveTest
 
         String prop = getProject().getProperty( 
"test.resolve.path.org.sonatype.aether:aether-api:jar" );
         assertThat( "aether-api was not resolved as a property", prop, 
notNullValue() );
-        assertThat( "aether-api was not resolved to default local repository", 
prop,
-                    containsString( "resolvetest-local-repo" ) );
+        assertThat( "aether-api was not resolved to default local repository", 
prop.replace( '\\', '/' ),
+                    endsWith( 
"local-repo-custom/org/sonatype/aether/aether-api/1.11/aether-api-1.11.jar" ) );
     }
 
     public void testResolveCustomFileLayout()
         throws IOException
     {
         File dir = new File( BUILD_DIR, "resolve-custom-layout" );
-        TestFileUtils.deleteFile( dir );
         executeTarget( "testResolveCustomFileLayout" );
 
         assertThat( "aether-api was not saved with custom file layout",
                     new File( dir, 
"org.sonatype.aether/aether-api/org/sonatype/aether/jar" ).exists() );
-
-        TestFileUtils.deleteFile( dir );
     }
 
     public void testResolveAttachments()
         throws IOException
     {
         File dir = new File( BUILD_DIR, "resolve-attachments" );
-        TestFileUtils.deleteFile( dir );
         executeTarget( "testResolveAttachments" );
         
         File jdocDir = new File(dir, "javadoc");
@@ -96,9 +91,6 @@ public class ResolveTest
                     new File( sourcesDir, 
"org.sonatype.aether-aether-api-sources.jar" ).exists() );
         assertThat( "found non-sources files", Arrays.asList( 
sourcesDir.list() ),
                     everyItem( endsWith( "sources.jar" ) ) );
-
-
-        TestFileUtils.deleteFile( dir );
     }
 
     public void testResolvePath()

Reply via email to