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

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

commit 4fcb7175941bf4bf7f227569da0aab0e1b01fb12
Author: Elliotte Rusty Harold <elh...@ibiblio.org>
AuthorDate: Thu Jul 16 07:20:16 2020 -0400

    replace deprecated methods
---
 ...ractInterpolatorFilterReaderLineEndingTest.java | 37 +++++++++++-----------
 .../filtering/DefaultMavenFileFilterTest.java      | 19 ++++++-----
 .../filtering/DefaultMavenReaderFilterTest.java    | 10 +++---
 .../DefaultMavenResourcesFilteringTest.java        |  6 ++--
 .../maven/shared/filtering/EscapeStringTest.java   |  5 +--
 5 files changed, 41 insertions(+), 36 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java
 
b/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java
index 82e7bba..1e25c78 100644
--- 
a/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java
+++ 
b/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java
@@ -24,12 +24,13 @@ import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.when;
 
+import java.io.IOException;
 import java.io.Reader;
 import java.io.StringReader;
 
+import org.apache.commons.io.IOUtils;
 import org.codehaus.plexus.interpolation.Interpolator;
 import org.codehaus.plexus.interpolation.RecursionInterceptor;
-import org.codehaus.plexus.util.IOUtil;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -55,39 +56,39 @@ public abstract class 
AbstractInterpolatorFilterReaderLineEndingTest
 
         Reader in = new StringReader( "text without expression" );
         Reader reader = getDollarBracesReader( in, interpolator, "\\" );
-        assertEquals( "text without expression", IOUtil.toString( reader ) );
+        assertEquals( "text without expression", IOUtils.toString( reader ) );
 
         in = new StringReader( "valid expression ${a}" );
         reader = getDollarBracesReader( in, interpolator, null );
-        assertEquals( "valid expression DONE_A", IOUtil.toString( reader ) );
+        assertEquals( "valid expression DONE_A", IOUtils.toString( reader ) );
 
         in = new StringReader( "empty expression ${}" );
         reader = getDollarBracesReader( in, interpolator, null );
-        assertEquals( "empty expression ${}", IOUtil.toString( reader ) );
+        assertEquals( "empty expression ${}", IOUtils.toString( reader ) );
 
         in = new StringReader( "dollar space expression $ {a}" );
         reader = getDollarBracesReader( in, interpolator, "\\" );
-        assertEquals( "dollar space expression $ {a}", IOUtil.toString( reader 
) );
+        assertEquals( "dollar space expression $ {a}", IOUtils.toString( 
reader ) );
 
         in = new StringReader( "space in expression ${ a}" );
         reader = getDollarBracesReader( in, interpolator, "\\" );
-        assertEquals( "space in expression ${ a}", IOUtil.toString( reader ) );
+        assertEquals( "space in expression ${ a}", IOUtils.toString( reader ) 
);
 
         in = new StringReader( "escape dollar with expression \\${a}" );
         reader = getDollarBracesReader( in, interpolator, "\\" );
-        assertEquals( "escape dollar with expression ${a}", IOUtil.toString( 
reader ) );
+        assertEquals( "escape dollar with expression ${a}", IOUtils.toString( 
reader ) );
 
 //        in = new StringReader( "escape escape string before expression 
\\\\${a}" );
 //        reader = getDollarBracesReader( in, interpolator, "\\" );
-//        assertEquals( "escape escape string before expression \\DONE_A", 
IOUtil.toString( reader ) );
+//        assertEquals( "escape escape string before expression \\DONE_A", 
IOUtils.toString( reader ) );
 //
 //        in = new StringReader( "escape escape string and expression 
\\\\\\${a}" );
 //        reader = getDollarBracesReader( in, interpolator, "\\" );
-//        assertEquals( "escape escape string before expression \\${a}", 
IOUtil.toString( reader ) );
+//        assertEquals( "escape escape string before expression \\${a}", 
IOUtils.toString( reader ) );
 
         in = new StringReader( "unknown expression ${unknown}" );
         reader = getDollarBracesReader( in, interpolator, "\\" );
-        assertEquals( "unknown expression ${unknown}", IOUtil.toString( reader 
) );
+        assertEquals( "unknown expression ${unknown}", IOUtils.toString( 
reader ) );
     }
 
     // MSHARED-198: custom delimiters doesn't work as expected
@@ -101,22 +102,22 @@ public abstract class 
AbstractInterpolatorFilterReaderLineEndingTest
         Reader in = new StringReader( "aaaFILTER.a.MEaaa" );
         Reader reader = getAaa_AaaReader( in, interpolator );
 
-        assertEquals( "DONE", IOUtil.toString( reader ) );
+        assertEquals( "DONE", IOUtils.toString( reader ) );
 
         in = new StringReader( "abcFILTER.a.MEabc" );
         reader = getAbc_AbcReader( in, interpolator );
-        assertEquals( "DONE", IOUtil.toString( reader ) );
+        assertEquals( "DONE", IOUtils.toString( reader ) );
     }
 
     // MSHARED-235: reader exceeds readAheadLimit
     @Test
-    public void testMarkInvalid()
-        throws Exception
+    public void testMarkInvalid() throws IOException
     {
-        Reader in = new StringReader( "@\").replace(p,\"]\").replace(q,\"" );
-        Reader reader = getAtReader( in, interpolator, "\\" );
-
-        assertEquals( "@\").replace(p,\"]\").replace(q,\"", IOUtil.toString( 
reader ) );
+        try ( Reader reader =
+            getAtReader( new StringReader( 
"@\").replace(p,\"]\").replace(q,\"" ), interpolator, "\\" ) )
+        {
+            assertEquals( "@\").replace(p,\"]\").replace(q,\"", 
IOUtils.toString( reader ) );
+        }
     }
 
     protected abstract Reader getAbc_AbcReader( Reader in, Interpolator 
interpolator );
diff --git 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
index 2eb0220..04f58f7 100644
--- 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
+++ 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
@@ -29,10 +29,10 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.utils.io.FileUtils;
 import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
-import org.apache.maven.shared.utils.io.IOUtil;
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -149,9 +149,10 @@ public class DefaultMavenFileFilterTest
 
         List<FilterWrapper> wrappers = 
mavenFileFilter.getDefaultFilterWrappers( req );
 
-        Reader reader = wrappers.get( 0 ).getReader( new StringReader( 
"${filefilter} ${buildfilter}" ) );
-
-        assertEquals( "true true", IOUtil.toString( reader ) );
+        try ( Reader reader = wrappers.get( 0 ).getReader( new StringReader( 
"${filefilter} ${buildfilter}" ) ) )
+        {
+            assertEquals( "true true", IOUtils.toString( reader ) );
+        }
     }
 
     // MSHARED-198: custom delimiters doesn't work as expected
@@ -169,10 +170,10 @@ public class DefaultMavenFileFilterTest
         List<FilterWrapper> wrappers = 
mavenFileFilter.getDefaultFilterWrappers( req );
 
         Reader reader = wrappers.get( 0 ).getReader( new StringReader( 
"aaaFILTER.a.MEaaa" ) );
-        assertEquals( "DONE", IOUtil.toString( reader ) );
+        assertEquals( "DONE", IOUtils.toString( reader ) );
 
         reader = wrappers.get( 0 ).getReader( new StringReader( 
"abcFILTER.a.MEabc" ) );
-        assertEquals( "DONE", IOUtil.toString( reader ) );
+        assertEquals( "DONE", IOUtils.toString( reader ) );
     }
 
     // MSHARED-199: Filtering doesn't work if 2 delimiters are used on the 
same line, the first one being left open
@@ -188,7 +189,9 @@ public class DefaultMavenFileFilterTest
 
         List<FilterWrapper> wrappers = 
mavenFileFilter.getDefaultFilterWrappers( req );
 
-        Reader reader = wrappers.get( 0 ).getReader( new StringReader( 
"t...@titi.com ${foo}" ) );
-        assertEquals( "t...@titi.com bar", IOUtil.toString( reader ) );
+        try ( Reader reader = wrappers.get( 0 ).getReader( new StringReader( 
"t...@titi.com ${foo}" ) ) )
+        {
+            assertEquals( "t...@titi.com bar", IOUtils.toString( reader ) );
+        }
     }
 }
diff --git 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java
 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java
index f440b25..49d6ec6 100644
--- 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java
+++ 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java
@@ -23,7 +23,7 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.util.Properties;
 
-import org.apache.maven.shared.utils.io.IOUtil;
+import org.apache.commons.io.IOUtils;
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -35,7 +35,6 @@ public class DefaultMavenReaderFilterTest
     public void testJustDoSomeFiltering()
         throws Exception
     {
-        assertNotNull( DefaultMavenReaderFilter.class );
         MavenReaderFilter readerFilter = lookup( MavenReaderFilter.class );
 
         StringReader src = new StringReader( "t...@titi.com ${foo}" );
@@ -46,8 +45,9 @@ public class DefaultMavenReaderFilterTest
         req.setFiltering( true );
         req.setAdditionalProperties( additionalProperties );
 
-        final Reader filter = readerFilter.filter( req );
-
-        assertEquals( "t...@titi.com bar", IOUtil.toString( filter ) );
+        try ( Reader filter = readerFilter.filter( req ) )
+        {
+            assertEquals( "t...@titi.com bar", IOUtils.toString( filter ) );
+        }
     }
 }
diff --git 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
index 253634a..a47fc01 100644
--- 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
+++ 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
@@ -28,11 +28,11 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Resource;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
 import org.codehaus.plexus.interpolation.ValueSource;
@@ -395,9 +395,9 @@ public class DefaultMavenResourcesFilteringTest
               FileInputStream currentIn = new FileInputStream( current ) )
         {
 
-            byte[] expectedBuffer = IOUtil.toByteArray( expectedIn );
+            byte[] expectedBuffer = IOUtils.toByteArray( expectedIn );
 
-            byte[] currentBuffer = IOUtil.toByteArray( currentIn );
+            byte[] currentBuffer = IOUtils.toByteArray( currentIn );
             if ( expectedBuffer.length != currentBuffer.length )
             {
                 return false;
diff --git 
a/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java 
b/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java
index 535d49c..d755f6c 100644
--- a/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java
@@ -21,14 +21,15 @@ package org.apache.maven.shared.filtering;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.maven.model.Resource;
 import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -91,7 +92,7 @@ public class EscapeStringTest
         
         try ( FileInputStream in = new FileInputStream( new File( 
outputDirectory, "content.xml" ) ) )
         { 
-            String content = IOUtil.toString( in );
+            String content = IOUtils.toString( in, StandardCharsets.UTF_8 );
             assertTrue( content.contains( "<broken-tag>Content with 
replacement: I am the replacement !</broken-tag>" ) );
             assertTrue( content.contains( "<broken-tag>Content with escaped 
replacement: Do not ${replaceThis} !</broken-tag>" ) );
         }

Reply via email to