You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/05/17 11:20:03 UTC
[maven-resolver-ant-tasks] 02/02: [MRESOLVER-181] Upgrade Ant to
1.9.15
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MRESOLVER-181
in repository https://gitbox.apache.org/repos/asf/maven-resolver-ant-tasks.git
commit e84eca1e1009b794e4634b31f6aeb4c0bd9192b2
Author: Nils Breunese <ni...@breun.nl>
AuthorDate: Sun May 16 20:36:44 2021 +0200
[MRESOLVER-181] Upgrade Ant to 1.9.15
Submitted by: Nils Breunese
o Updated to Ant 1.9.15
---
.../maven/resolver/internal/ant/AntBuildsTest.java | 64 ++++++++++++++--------
.../maven/resolver/internal/ant/ReactorTest.java | 13 +++--
2 files changed, 47 insertions(+), 30 deletions(-)
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
index 0c3c309..87102af 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.resolver.internal.ant;
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -22,15 +22,18 @@ package org.apache.maven.resolver.internal.ant;
import java.io.File;
import java.io.PrintStream;
-import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.eclipse.aether.internal.test.util.TestFileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+
+import static org.junit.Assert.assertTrue;
public abstract class AntBuildsTest
- extends BuildFileTest
{
private static final File BASE_DIR;
@@ -43,6 +46,9 @@ public abstract class AntBuildsTest
BUILD_DIR = new File( BASE_DIR, "target/ant" );
}
+ @Rule
+ public final BuildFileRule buildRule = new BuildFileRule();
+
protected File projectDir;
protected File localRepoDir;
@@ -65,12 +71,10 @@ public abstract class AntBuildsTest
// hook for subclasses to set further system properties for the project to pick up
}
- @Override
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
-
TestFileUtils.deleteFile( BUILD_DIR );
projectDir = new File( new File( BASE_DIR, "src/test/resources/ant" ), getProjectDirName() );
@@ -90,26 +94,38 @@ public abstract class AntBuildsTest
configureProject( new File( projectDir, "ant.xml" ).getAbsolutePath(), Project.MSG_VERBOSE );
}
- @Override
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
- try
- {
- ProjectWorkspaceReader.dropInstance();
- TestFileUtils.deleteFile( BUILD_DIR );
- }
- finally
- {
- super.tearDown();
- }
+ ProjectWorkspaceReader.dropInstance();
+ TestFileUtils.deleteFile( BUILD_DIR );
+ }
+
+ protected void assertLogContaining( String substring )
+ {
+ String realLog = getLog();
+ assertTrue( "expecting log to contain \"" + substring + "\" log was \"" + realLog + "\"", realLog.contains( substring ) );
+ }
+
+ protected void executeTarget( String targetName ) {
+ buildRule.executeTarget( targetName );
+ }
+
+ protected String getLog()
+ {
+ return buildRule.getLog();
+ }
+
+ protected Project getProject()
+ {
+ return buildRule.getProject();
}
- @Override
- public void configureProject( String filename, int logLevel )
+ private void configureProject( String filename, int logLevel )
throws BuildException
{
- super.configureProject( filename, logLevel );
+ buildRule.configureProject( filename, logLevel );
DefaultLogger logger = new DefaultLogger()
{
@Override
@@ -122,7 +138,7 @@ public abstract class AntBuildsTest
logger.setMessageOutputLevel( logLevel );
logger.setOutputPrintStream( System.out );
logger.setErrorPrintStream( System.err );
- getProject().addBuildListener( logger );
+ buildRule.getProject().addBuildListener( logger );
}
}
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
index 6b33710..3492ecc 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.resolver.internal.ant;
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -22,10 +22,11 @@ package org.apache.maven.resolver.internal.ant;
import java.io.File;
import java.io.IOException;
-import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
+import static org.junit.Assert.*;
+
public class ReactorTest
extends AntBuildsTest
{
@@ -76,7 +77,7 @@ public class ReactorTest
throws IOException
{
executeTarget( "testResolveArtifact" );
- String prop = project.getProperty( "resolve.test:test:jar" );
+ String prop = getProject().getProperty( "resolve.test:test:jar" );
assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
}
@@ -84,7 +85,7 @@ public class ReactorTest
throws IOException
{
executeTarget( "testResolveArtifactInMemoryPom" );
- String prop = project.getProperty( "resolve.test:test:jar" );
+ String prop = getProject().getProperty( "resolve.test:test:jar" );
assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
assertLogContaining( "The POM for test:test:jar:0.1-SNAPSHOT is missing, no dependency information available" );
}
@@ -93,7 +94,7 @@ public class ReactorTest
throws IOException
{
executeTarget( "testResolveVersionRange" );
- String prop = project.getProperty( "resolve.test:test:jar" );
+ String prop = getProject().getProperty( "resolve.test:test:jar" );
assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
}