This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch MNG-6856 in repository https://gitbox.apache.org/repos/asf/maven.git
commit 952b67f16152b5e078c01076d1d42299a01433ea Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Sun Jan 26 16:59:44 2020 +0100 [MNG-6856] Remove dependency to Powermock --- maven-model-builder/pom.xml | 5 --- .../StringSearchModelInterpolatorTest.java | 38 ++++++++-------------- pom.xml | 6 ---- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index a2145d2..81d2587 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -84,11 +84,6 @@ under the License. <artifactId>xmlunit-matchers</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-reflect</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java index cf38d30..4dff191 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java @@ -33,15 +33,18 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; +import static org.apache.commons.lang3.reflect.FieldUtils.readField; +import static org.apache.commons.lang3.reflect.FieldUtils.readStaticField; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.powermock.reflect.Whitebox.getField; -import static org.powermock.reflect.Whitebox.getInternalState; +import static org.hamcrest.MatcherAssert.assertThat; /** + * StringSearchModelInterpolator + * * @author jdcasey * @author Benjamin Bentmann + * @deprecated replaced by StringVisitorModelInterpolator (MNG-6697) */ public class StringSearchModelInterpolatorTest extends AbstractModelInterpolatorTest @@ -59,19 +62,16 @@ public class StringSearchModelInterpolatorTest protected ModelInterpolator createInterpolator( org.apache.maven.model.path.PathTranslator translator ) - throws Exception { return this.interpolator; } protected ModelInterpolator createInterpolator() - throws Exception { return this.interpolator; } public void testInterpolateStringArray() - throws Exception { Model model = new Model(); @@ -101,7 +101,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringArrayField() - throws Exception { Model model = new Model(); @@ -126,7 +125,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringListField() - throws Exception { Model model = new Model(); @@ -153,7 +151,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringListFieldAndOneLiteralValue() - throws Exception { Model model = new Model(); @@ -180,7 +177,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithUnmodifiableStringListField() - throws Exception { Model model = new Model(); @@ -204,7 +200,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringArrayListField() - throws Exception { Model model = new Model(); @@ -235,7 +230,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringToStringMapField() - throws Exception { Model model = new Model(); @@ -262,7 +256,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringToStringMapFieldAndOneLiteralValue() - throws Exception { Model model = new Model(); @@ -289,7 +282,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithUnmodifiableStringToStringMapField() - throws Exception { Model model = new Model(); @@ -313,7 +305,6 @@ public class StringSearchModelInterpolatorTest } public void testInterpolateObjectWithStringToStringArrayMapField() - throws Exception { Model model = new Model(); @@ -394,9 +385,8 @@ public class StringSearchModelInterpolatorTest assertProblemFree( collector ); //noinspection unchecked - Map<Class<?>, ?> cache = - (Map<Class<?>, ?>) getField( StringSearchModelInterpolator.class, "CACHED_ENTRIES" ) - .get( null ); + Map<Class<?>, ?> cache = (Map<Class<?>, ?>) readStaticField( StringSearchModelInterpolator.class, + "CACHED_ENTRIES", true ); Object objCacheItem = cache.get( Object.class ); Object fileCacheItem = cache.get( File.class ); @@ -404,8 +394,8 @@ public class StringSearchModelInterpolatorTest assertNotNull( objCacheItem ); assertNotNull( fileCacheItem ); - assertThat( ( (Object[]) getInternalState( objCacheItem, "fields" ) ).length, is( 0 ) ); - assertThat( ( (Object[]) getInternalState( fileCacheItem, "fields" ) ).length, is( 0 ) ); + assertThat( ( (Object[]) readField( objCacheItem, "fields", true ) ).length, is( 0 ) ); + assertThat( ( (Object[]) readField( fileCacheItem, "fields", true ) ).length, is( 0 ) ); } public void testNotInterpolateFile() @@ -426,15 +416,15 @@ public class StringSearchModelInterpolatorTest assertProblemFree( collector ); //noinspection unchecked - Map<Class<?>, ?> cache = - (Map<Class<?>, ?>) getField( StringSearchModelInterpolator.class, "CACHED_ENTRIES" ) - .get( null ); + Map<Class<?>, ?> cache = (Map<Class<?>, ?>) readStaticField( StringSearchModelInterpolator.class, + "CACHED_ENTRIES", true ); + Object fileCacheItem = cache.get( File.class ); assertNotNull( fileCacheItem ); - assertThat( ( (Object[]) getInternalState( fileCacheItem, "fields" ) ).length, is( 0 ) ); + assertThat( ( (Object[]) readField( fileCacheItem, "fields", true ) ).length, is( 0 ) ); } diff --git a/pom.xml b/pom.xml index 3148a97..cbb1e33 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,6 @@ under the License. <resolverVersion>1.4.1</resolverVersion> <slf4jVersion>1.7.29</slf4jVersion> <xmlunitVersion>2.2.1</xmlunitVersion> - <powermockVersion>1.7.4</powermockVersion> <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile> <!-- Control the name of the distribution and information output by mvn --> <distributionId>apache-maven</distributionId> @@ -420,11 +419,6 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-reflect</artifactId> - <version>${powermockVersion}</version> - </dependency> - <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <version>2.2</version>
